Skip to content

ENH: Allow input weight for afni's volreg. #2155

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 25 additions & 13 deletions nipype/interfaces/afni/preprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ class AlignEpiAnatPyOutputSpec(TraitedSpec):
desc="matrix to volume register and align epi"
"to anatomy and put into standard space")
epi_vr_motion = File(
desc="motion parameters from EPI time-series"
desc="motion parameters from EPI time-series"
"registration (tsh included in name if slice"
"timing correction is also included).")
skullstrip = File(
Expand All @@ -131,20 +131,20 @@ class AlignEpiAnatPy(AFNIPythonCommand):
an EPI and an anatomical structural dataset, and applies the resulting
transformation to one or the other to bring them into alignment.

This script computes the transforms needed to align EPI and
anatomical datasets using a cost function designed for this purpose. The
script combines multiple transformations, thereby minimizing the amount of
This script computes the transforms needed to align EPI and
anatomical datasets using a cost function designed for this purpose. The
script combines multiple transformations, thereby minimizing the amount of
interpolation applied to the data.

Basic Usage:
align_epi_anat.py -anat anat+orig -epi epi+orig -epi_base 5

The user must provide EPI and anatomical datasets and specify the EPI
sub-brick to use as a base in the alignment.
sub-brick to use as a base in the alignment.

Internally, the script always aligns the anatomical to the EPI dataset,
and the resulting transformation is saved to a 1D file.
As a user option, the inverse of this transformation may be applied to the
and the resulting transformation is saved to a 1D file.
As a user option, the inverse of this transformation may be applied to the
EPI dataset in order to align it to the anatomical data instead.

This program generates several kinds of output in the form of datasets
Expand Down Expand Up @@ -182,7 +182,7 @@ def _list_outputs(self):
epi_prefix = ''.join(self._gen_fname(self.inputs.in_file).split('+')[:-1])
outputtype = self.inputs.outputtype
if outputtype == 'AFNI':
ext = '.HEAD'
ext = '.HEAD'
else:
Info.output_type_to_ext(outputtype)
matext = '.1D'
Expand Down Expand Up @@ -620,7 +620,7 @@ class AutoTLRCInputSpec(CommandLineInputSpec):
mandatory=True,
exists=True,
copyfile=False)
base = traits.Str(
base = traits.Str(
desc = ' Reference anatomical volume'
' Usually this volume is in some standard space like'
' TLRC or MNI space and with afni dataset view of'
Expand Down Expand Up @@ -706,7 +706,7 @@ def _list_outputs(self):
ext = '.HEAD'
outputs['out_file'] = os.path.abspath(self._gen_fname(self.inputs.in_file, suffix='+tlrc')+ext)
return outputs

class BandpassInputSpec(AFNICommandInputSpec):
in_file = File(
desc='input file to 3dBandpass',
Expand Down Expand Up @@ -2547,6 +2547,13 @@ class VolregInputSpec(AFNICommandInputSpec):
argstr='-base %s',
position=-6,
exists=True)
in_weight_volume = traits.Either(
traits.Tuple(File(exists=True), traits.Int),
File(exists=True),
desc='weights for each voxel. a file with an optional volume number'
' (defaults to 0)',
argstr="-weight '%s[%d]'")

zpad = traits.Int(
desc='Zeropad around the edges by \'n\' voxels during rotations',
argstr='-zpad %d',
Expand Down Expand Up @@ -2580,10 +2587,15 @@ class VolregInputSpec(AFNICommandInputSpec):
keep_extension=True,
name_source='in_file')
interp = traits.Enum(
('Fourier', 'cubic', 'heptic', 'quintic','linear'),
('Fourier', 'cubic', 'heptic', 'quintic', 'linear'),
desc='spatial interpolation methods [default = heptic]',
argstr='-%s')

def _format_arg(self, name, trait_spec, value):
if name == 'in_weight_volume' and not isinstance(value, traits.Tuple):
value = (value, 0)
return super(Volreg, self)._format_arg(name, trait_spec, value)


class VolregOutputSpec(TraitedSpec):
out_file = File(
Expand Down
2 changes: 2 additions & 0 deletions nipype/interfaces/afni/tests/test_auto_Volreg.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ def test_Volreg_inputs():
mandatory=True,
position=-1,
),
in_weight_volume=dict(argstr="-weight '%s[%d]'",
),
interp=dict(argstr='-%s',
),
md1d_file=dict(argstr='-maxdisp1D %s',
Expand Down