Skip to content

Fix for Eddy-Wrapper does not work properly #769 #785

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

Merged
merged 5 commits into from
Feb 5, 2014
Merged
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
79 changes: 56 additions & 23 deletions nipype/interfaces/fsl/epi.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,32 +305,60 @@ def _list_outputs(self):


class EddyInputSpec( FSLCommandInputSpec ):
in_file = File(exists=True, mandatory=True, desc='File containing all the images to estimate distortions for', argstr='--imain=%s' )
in_mask = File(exists=True, mandatory=True, desc='Mask to indicate brain', argstr='--mask=%s' )
in_index = File(exists=True, mandatory=True, desc='File containing indices for all volumes in --imain into --acqp and --topup', argstr='--index=%s' )
in_acqp = File(exists=True, mandatory=True, desc='File containing acquisition parameters', argstr='--acqp=%s' )
in_bvec = File(exists=True, mandatory=True, desc='File containing the b-vectors for all volumes in --imain', argstr='--bvecs=%s' )
in_bval = File(exists=True, mandatory=True, desc='File containing the b-values for all volumes in --imain', argstr='--bvals=%s' )
in_file = File(exists=True, mandatory=True,
desc=('File containing all the images to estimate '
'distortions for'), argstr='--imain=%s')
in_mask = File(exists=True, mandatory=True,
desc='Mask to indicate brain', argstr='--mask=%s')
in_index = File(exists=True, mandatory=True,
desc=('File containing indices for all volumes in --imain '
'into --acqp and --topup'), argstr='--index=%s')
in_acqp = File(exists=True, mandatory=True,
desc='File containing acquisition parameters',
argstr='--acqp=%s' )
in_bvec = File(exists=True, mandatory=True,
desc=('File containing the b-vectors for all volumes in '
'--imain'), argstr='--bvecs=%s')
in_bval = File(exists=True, mandatory=True,
desc=('File containing the b-values for all volumes in '
'--imain'), argstr='--bvals=%s')
out_base = File( desc='basename for output (warped) image',
argstr='--out=%s' )
session = File(exists=True,
desc=('File containing session indices for all volumes in '
'--imain'), argstr='--session=%s')
in_topup_fieldcoef = File(exists=True, argstr="--topup=%s", copyfile=False,
requires=['in_topup_movpar'],
desc=('topup file containing the field '
'coefficients'))
in_topup_movpar = File(exists=True, requires=['in_topup_fieldcoef'],
copyfile=False, desc='topup movpar.txt file')
flm = traits.Enum(('linear','quadratic','cubic'),
desc='First level EC model', argstr='--flm=%s' )
fwhm = traits.Float(desc=('FWHM for conditioning filter when estimating '
'the parameters'), argstr='--fwhm=%s')
niter = traits.Int( 5, desc='Number of iterations', argstr='--niter=%s')
method = traits.Enum(('jac','lsr'), argstr='--resamp=%s',
desc=('Final resampling method (jacobian/least '
'squeares)'))
repol = traits.Bool( False, desc='Detect and replace outlier slices',
argstr='--repol' )

out_base = File( desc='basename for output (warped) image', argstr='--out=%s' )


session = File(exists=True, desc='File containing session indices for all volumes in --imain', argstr='--session=%s' )
in_topup = File(exists=True, desc='Base name for output files from topup', argstr='--topup=%s' )
flm = traits.Enum( ('linear','quadratic','cubic'), desc='First level EC model', argstr='--flm=%s' )
fwhm = traits.Float( desc='FWHM for conditioning filter when estimating the parameters', argstr='--fwhm=%s' )
niter = traits.Int( 5, desc='Number of iterations', argstr='--niter=%s' )
method = traits.Enum( ('jac','lsr'), argstr='--resamp=%s', desc='Final resampling method (jacobian/least squeares)' )
repol = traits.Bool( False, desc='Detect and replace outlier slices', argstr='--repol' )

class EddyOutputSpec( TraitedSpec ):
out_corrected = File( exists=True, desc='4D image file containing all the corrected volumes' )
out_parameter = File( exists=True, desc='text file with parameters definining the field and movement for each scan')
out_corrected = File(exists=True,
desc=('4D image file containing all the corrected '
'volumes'))
out_parameter = File(exists=True,
desc=('text file with parameters definining the field '
'and movement for each scan'))

class Eddy( FSLCommand ):
""" Interface for FSL eddy, a tool for estimating and correcting eddy currents induced distortions.
`User guide <http://fsl.fmrib.ox.ac.uk/fsl/fslwiki/Eddy/UsersGuide>`_ and
`more info regarding acqp file <http://fsl.fmrib.ox.ac.uk/fsl/fslwiki/eddy/Faq#How_do_I_know_what_to_put_into_my_--acqp_file>`_.
""" Interface for FSL eddy, a tool for estimating and correcting eddy
currents induced distortions. `User guide
<http://fsl.fmrib.ox.ac.uk/fsl/fslwiki/Eddy/UsersGuide>`_ and
`more info regarding acqp file
<http://fsl.fmrib.ox.ac.uk/fsl/fslwiki/eddy/Faq#How_do_I_know_what_to_put_into_my_--acqp_file>`_.

Examples
--------
Expand All @@ -353,10 +381,15 @@ class Eddy( FSLCommand ):
input_spec = EddyInputSpec
output_spec = EddyOutputSpec

def _format_arg(self, name, spec, value):
if name == 'in_topup_fieldcoef':
return spec.argstr % value.split('_fieldcoef')[0]
return super(Eddy, self)._format_arg(name, spec, value)

def _parse_inputs( self, skip=None ):
if skip is None:
skip = []

if not isdefined(self.inputs.out_base ):
self.inputs.out_base = os.path.abspath( './eddy_corrected' )
return super(Eddy, self)._parse_inputs(skip=skip)
Expand All @@ -365,7 +398,7 @@ def _parse_inputs( self, skip=None ):
def _list_outputs(self):
outputs = self.output_spec().get()
outputs['out_corrected'] = '%s.nii.gz' % self.inputs.out_base
outputs['out_parameter'] = '%s..eddy_parameters' % self.inputs.out_base
outputs['out_parameter'] = '%s.eddy_parameters' % self.inputs.out_base
return outputs


Expand Down
7 changes: 6 additions & 1 deletion nipype/interfaces/fsl/tests/test_auto_Eddy.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,12 @@ def test_Eddy_inputs():
in_mask=dict(argstr='--mask=%s',
mandatory=True,
),
in_topup=dict(argstr='--topup=%s',
in_topup_fieldcoef=dict(argstr='--topup=%s',
copyfile=False,
requires=['in_topup_movpar'],
),
in_topup_movpar=dict(copyfile=False,
requires=['in_topup_fieldcoef'],
),
method=dict(argstr='--resamp=%s',
),
Expand Down
39 changes: 21 additions & 18 deletions nipype/interfaces/vista/tests/test_auto_Vnifti2Image.py
Original file line number Diff line number Diff line change
@@ -1,39 +1,41 @@
# AUTO-GENERATED by tools/checkspecs.py - DO NOT EDIT
from nipype.testing import assert_equal
from nipype.interfaces.vista.vista import Vnifti2Image

def test_Vnifti2Image_inputs():
input_map = dict(ignore_exception=dict(nohash=True,
usedefault=True,
),
out_file=dict(hash_files=False,
name_template='%s.v',
name_source=['in_file'],
keep_extension=False,
position=-1,
argstr='-out %s',
),
args=dict(argstr='%s',
input_map = dict(args=dict(argstr='%s',
),
terminal_output=dict(nohash=True,
mandatory=True,
attributes=dict(argstr='-attr %s',
mandatory=False,
position=2,
),
environ=dict(nohash=True,
usedefault=True,
),
in_file=dict(position=1,
ignore_exception=dict(nohash=True,
usedefault=True,
),
in_file=dict(argstr='-in %s',
mandatory=True,
argstr='-in %s',
position=1,
),
attributes=dict(position=2,
mandatory=False,
argstr='-attr %s',
out_file=dict(argstr='-out %s',
hash_files=False,
keep_extension=False,
name_source=['in_file'],
name_template='%s.v',
position=-1,
),
terminal_output=dict(mandatory=True,
nohash=True,
),
)
inputs = Vnifti2Image.input_spec()

for key, metadata in input_map.items():
for metakey, value in metadata.items():
yield assert_equal, getattr(inputs.traits()[key], metakey), value

def test_Vnifti2Image_outputs():
output_map = dict(out_file=dict(),
)
Expand All @@ -42,3 +44,4 @@ def test_Vnifti2Image_outputs():
for key, metadata in output_map.items():
for metakey, value in metadata.items():
yield assert_equal, getattr(outputs.traits()[key], metakey), value

33 changes: 18 additions & 15 deletions nipype/interfaces/vista/tests/test_auto_VtoMat.py
Original file line number Diff line number Diff line change
@@ -1,35 +1,37 @@
# AUTO-GENERATED by tools/checkspecs.py - DO NOT EDIT
from nipype.testing import assert_equal
from nipype.interfaces.vista.vista import VtoMat

def test_VtoMat_inputs():
input_map = dict(ignore_exception=dict(nohash=True,
usedefault=True,
input_map = dict(args=dict(argstr='%s',
),
out_file=dict(hash_files=False,
name_template='%s.mat',
name_source=['in_file'],
keep_extension=False,
position=-1,
argstr='-out %s',
environ=dict(nohash=True,
usedefault=True,
),
args=dict(argstr='%s',
ignore_exception=dict(nohash=True,
usedefault=True,
),
terminal_output=dict(nohash=True,
in_file=dict(argstr='-in %s',
mandatory=True,
position=1,
),
environ=dict(nohash=True,
usedefault=True,
out_file=dict(argstr='-out %s',
hash_files=False,
keep_extension=False,
name_source=['in_file'],
name_template='%s.mat',
position=-1,
),
in_file=dict(position=1,
mandatory=True,
argstr='-in %s',
terminal_output=dict(mandatory=True,
nohash=True,
),
)
inputs = VtoMat.input_spec()

for key, metadata in input_map.items():
for metakey, value in metadata.items():
yield assert_equal, getattr(inputs.traits()[key], metakey), value

def test_VtoMat_outputs():
output_map = dict(out_file=dict(),
)
Expand All @@ -38,3 +40,4 @@ def test_VtoMat_outputs():
for key, metadata in output_map.items():
for metakey, value in metadata.items():
yield assert_equal, getattr(outputs.traits()[key], metakey), value