Repository: nipy/nipype

Issue:
Eddy-Wrapper does not work properly 
Hi,

thanks for the great Framework.

I think there are two bugs in the FSL Eddy wrapper.

[319] in_topup =  File(exists=True, desc='Base name for output files from topup', argstr='--topup=%s' )

does not work correctly, because eddy just expects a base name which it uses for two files (basename_fieldcoef.nii.gz and basename_movpar.txt). A quick fix is to set  exists=False.

The second bug is in the output check.
[368] outputs['out_parameter'] = '%s..eddy_parameters' % self.inputs.out_base

it should read:
[368] outputs['out_parameter'] = '%s.eddy_parameters' % self.inputs.out_base
(Just one dot between %s and eddy_parameters.

Eddy-Wrapper does not work properly 
Hi,

thanks for the great Framework.

I think there are two bugs in the FSL Eddy wrapper.

[319] in_topup =  File(exists=True, desc='Base name for output files from topup', argstr='--topup=%s' )

does not work correctly, because eddy just expects a base name which it uses for two files (basename_fieldcoef.nii.gz and basename_movpar.txt). A quick fix is to set  exists=False.

The second bug is in the output check.
[368] outputs['out_parameter'] = '%s..eddy_parameters' % self.inputs.out_base

it should read:
[368] outputs['out_parameter'] = '%s.eddy_parameters' % self.inputs.out_base
(Just one dot between %s and eddy_parameters.



Discussion:
thanks for this. could you please send a PR with the fixes?

also a question regarding the first bug. doesn't in_topup refer to two files that are output from topup? if so, i think the interface will need to take those files separately from a workflow perspective and use the basename only.

@oesteban - fyi

Thanks, I am currently finishing things in a project, so I will look at it very soon :).

Yes,  "in_topup" refers to the two files that are output from topup. 

I am  not sure how to modify the interface, so it takes just the basename as an input and then checks for the presence of both files. Can you point me to an example interface, where this has been implemented. Then I can change it and send a PR.

I think the most flexible way to do this is to remove in_topup and replace
it with "fieldcoef" and "movpar" inputs. Then overload _run_interface to
copy/rename the input fieldcoef and movpar files to whatever pattern eddy
expects. This way we enable straighforward connection between topup and
eddy as well as enable users to easily intercept and modify fieldcoef and
movpar files. Similar scheme has been used for bedpostx and probtractx.

On Thu, Jan 23, 2014 at 11:40 PM, JensNRAD notifications@github.com wrote:

> Yes, "in_topup" refers to the two files that are output from topup.
> 
> I am not sure how to modify the interface, so it takes just the basename
> as an input and then checks for the presence of both files. Can you point
> me to an example interface, where this has been implemented. Then I can
> change it and send a PR.
> 
> —
> Reply to this email directly or view it on GitHubhttps://github.com/nipy/nipype/issues/769#issuecomment-33177550
> .

thanks for this. could you please send a PR with the fixes?

also a question regarding the first bug. doesn't in_topup refer to two files that are output from topup? if so, i think the interface will need to take those files separately from a workflow perspective and use the basename only.

@oesteban - fyi

Thanks, I am currently finishing things in a project, so I will look at it very soon :).

Yes,  "in_topup" refers to the two files that are output from topup. 

I am  not sure how to modify the interface, so it takes just the basename as an input and then checks for the presence of both files. Can you point me to an example interface, where this has been implemented. Then I can change it and send a PR.

I think the most flexible way to do this is to remove in_topup and replace
it with "fieldcoef" and "movpar" inputs. Then overload _run_interface to
copy/rename the input fieldcoef and movpar files to whatever pattern eddy
expects. This way we enable straighforward connection between topup and
eddy as well as enable users to easily intercept and modify fieldcoef and
movpar files. Similar scheme has been used for bedpostx and probtractx.

On Thu, Jan 23, 2014 at 11:40 PM, JensNRAD notifications@github.com wrote:

> Yes, "in_topup" refers to the two files that are output from topup.
> 
> I am not sure how to modify the interface, so it takes just the basename
> as an input and then checks for the presence of both files. Can you point
> me to an example interface, where this has been implemented. Then I can
> change it and send a PR.
> 
> —
> Reply to this email directly or view it on GitHubhttps://github.com/nipy/nipype/issues/769#issuecomment-33177550
> .


Resolving patch:
diff --git a/nipype/interfaces/fsl/epi.py b/nipype/interfaces/fsl/epi.py
--- a/nipype/interfaces/fsl/epi.py
+++ b/nipype/interfaces/fsl/epi.py
@@ -6,8 +6,9 @@
 
     Change directory to provide relative paths for doctests
     >>> import os
-    >>> filepath = os.path.dirname( os.path.realpath( __file__ ) )
-    >>> datadir = os.path.realpath(os.path.join(filepath, '../../testing/data'))
+    >>> filepath = os.path.dirname(os.path.realpath(__file__))
+    >>> datadir = os.path.realpath(os.path.join(filepath,
+    ...                            '../../testing/data'))
     >>> os.chdir(datadir)
 """
 
@@ -20,37 +21,46 @@
 
 from nipype.interfaces.fsl.base import FSLCommand, FSLCommandInputSpec, Info
 from nipype.interfaces.base import (traits, TraitedSpec, InputMultiPath, File,
-                                    isdefined, Undefined )
-
-
-from nipype.utils.filemanip import load_json, save_json, split_filename, fname_presuffix
+                                    isdefined, Undefined)
+from nipype.utils.filemanip import (load_json, save_json, split_filename,
+                                    fname_presuffix)
 
 warn = warnings.warn
 warnings.filterwarnings('always', category=UserWarning)
 
 
 class PrepareFieldmapInputSpec(FSLCommandInputSpec):
-    scanner = traits.String('SIEMENS', argstr='%s', position=1, desc='must be SIEMENS', usedefault=True)
-    in_phase = File( exists=True, argstr='%s', position=2, mandatory=True,
-                     desc='Phase difference map, in SIEMENS format range from 0-4096 or 0-8192 )' )
+    scanner = traits.String('SIEMENS', argstr='%s', position=1,
+                            desc='must be SIEMENS', usedefault=True)
+    in_phase = File(exists=True, argstr='%s', position=2, mandatory=True,
+                    desc=('Phase difference map, in SIEMENS format range from '
+                          '0-4096 or 0-8192)'))
     in_magnitude = File(exists=True, argstr='%s', position=3, mandatory=True,
                         desc='Magnitude difference map, brain extracted')
-    delta_TE = traits.Float(2.46, usedefault=True, mandatory=True, argstr='%f', position=-2,
-                            desc='echo time difference of the fielmap sequence in ms. (usually 2.46ms in Siemens)')
+    delta_TE = traits.Float(2.46, usedefault=True, mandatory=True, argstr='%f',
+                            position=-2,
+                            desc=('echo time difference of the '
+                                  'fieldmap sequence in ms. (usually 2.46ms in'
+                                  ' Siemens)'))
+    nocheck = traits.Bool(False, position=-1, argstr='--nocheck',
+                          usedefault=True,
+                          desc=('do not perform sanity checks for image '
+                                'size/range/dimensions'))
+    out_fieldmap = File(argstr='%s', position=5,
+                        desc='output name for prepared fieldmap')
 
-    nocheck = traits.Bool(False, position=-1, argstr='--nocheck',usedefault=True,
-                          desc='do not perform sanity checks for image size/range/dimensions')
-    out_fieldmap = File( argstr='%s', position=5, desc='output name for prepared fieldmap' )
 
+class PrepareFieldmapOutputSpec(TraitedSpec):
+    out_fieldmap = File(exists=True, desc='output name for prepared fieldmap')
 
-class PrepareFieldmapOutputSpec( TraitedSpec ):
-    out_fieldmap = File( exists=True, desc='output name for prepared fieldmap' )
 
 class PrepareFieldmap(FSLCommand):
-    """ Interface for the fsl_prepare_fieldmap script (FSL 5.0)
+    """
+    Interface for the fsl_prepare_fieldmap script (FSL 5.0)
 
-    Prepares a fieldmap suitable for FEAT from SIEMENS data - saves output in rad/s format
-    e.g. fsl_prepare_fieldmap SIEMENS images_3_gre_field_mapping images_4_gre_field_mapping fmap_rads 2.65
+    Prepares a fieldmap suitable for FEAT from SIEMENS data - saves output in
+    rad/s format (e.g. ```fsl_prepare_fieldmap SIEMENS
+    images_3_gre_field_mapping images_4_gre_field_mapping fmap_rads 2.65```).
 
 
     Examples
@@ -62,7 +72,8 @@ class PrepareFieldmap(FSLCommand):
     >>> prepare.inputs.in_magnitude = "magnitude.nii"
     >>> prepare.inputs.output_type = "NIFTI_GZ"
     >>> prepare.cmdline #doctest: +ELLIPSIS
-    'fsl_prepare_fieldmap SIEMENS phase.nii magnitude.nii .../phase_fslprepared.nii.gz 2.460000'
+    'fsl_prepare_fieldmap SIEMENS phase.nii magnitude.nii \
+.../phase_fslprepared.nii.gz 2.460000'
     >>> res = prepare.run() # doctest: +SKIP
 
 
@@ -71,15 +82,15 @@ class PrepareFieldmap(FSLCommand):
     input_spec = PrepareFieldmapInputSpec
     output_spec = PrepareFieldmapOutputSpec
 
-    def _parse_inputs( self, skip=None ):
+    def _parse_inputs(self, skip=None):
         if skip is None:
             skip = []
 
-        if not isdefined(self.inputs.out_fieldmap ):
+        if not isdefined(self.inputs.out_fieldmap):
             self.inputs.out_fieldmap = self._gen_fname(
-                self.inputs.in_phase, suffix='_fslprepared' )
+                self.inputs.in_phase, suffix='_fslprepared')
 
-        if not isdefined(self.inputs.nocheck ) or not self.inputs.nocheck:
+        if not isdefined(self.inputs.nocheck) or not self.inputs.nocheck:
             skip += ['nocheck']
 
         return super(PrepareFieldmap, self)._parse_inputs(skip=skip)
@@ -89,16 +100,16 @@ def _list_outputs(self):
         outputs['out_fieldmap'] = self.inputs.out_fieldmap
         return outputs
 
-    def _run_interface( self, runtime ):
-        runtime = super( PrepareFieldmap, self )._run_interface(runtime)
+    def _run_interface(self, runtime):
+        runtime = super(PrepareFieldmap, self)._run_interface(runtime)
 
         if runtime.returncode == 0:
             out_file = self.inputs.out_fieldmap
-            im = nib.load( out_file )
-            dumb_img = nib.Nifti1Image(np.zeros(
-                      im.get_shape()), im.get_affine(), im.get_header())
+            im = nib.load(out_file)
+            dumb_img = nib.Nifti1Image(np.zeros(im.get_shape()),
+                                       im.get_affine(), im.get_header())
             out_nii = nib.funcs.concat_images((im, dumb_img))
-            nib.save( out_nii, out_file )
+            nib.save(out_nii, out_file)
 
         return runtime
 
@@ -110,19 +121,20 @@ class TOPUPInputSpec(FSLCommandInputSpec):
                          xor=['encoding_direction'],
                          desc='name of text file with PE directions/times',
                          argstr='--datain=%s')
-    encoding_direction = traits.List(traits.Enum('y','x','z','x-','y-','z-'),
-                                     mandatory=True, xor=['encoding_file'],
+    encoding_direction = traits.List(traits.Enum('y', 'x', 'z', 'x-', 'y-',
+                                     'z-'), mandatory=True,
+                                     xor=['encoding_file'],
                                      requires=['readout_times'],
                                      argstr='--datain=%s',
                                      desc=('encoding direction for automatic '
-                                           'generation of encoding_file'))
+                                     'generation of encoding_file'))
     readout_times = InputMultiPath(traits.Float,
                                    requires=['encoding_direction'],
                                    xor=['encoding_file'], mandatory=True,
                                    desc=('readout times (dwell times by # '
                                          'phase-encode steps minus 1)'))
     out_base = File(desc=('base-name of output files (spline '
-                          'coefficients (Hz) and movement parameters)'),
+                    'coefficients (Hz) and movement parameters)'),
                     name_source=['in_file'], name_template='%s_base',
                     argstr='--out=%s', hash_files=False)
     out_field = File(argstr='--fout=%s', hash_files=False,
@@ -134,9 +146,13 @@ class TOPUPInputSpec(FSLCommandInputSpec):
     out_logfile = File(argstr='--logout=%s', desc='name of log-file',
                        name_source=['in_file'], name_template='%s_topup.log',
                        keep_extension=True, hash_files=False)
+
+    # TODO: the following traits admit values separated by commas, one value
+    # per registration level inside topup.
     warp_res = traits.Float(10.0, argstr='--warpres=%f',
                             desc=('(approximate) resolution (in mm) of warp '
-                                  'basis for the different sub-sampling levels'))
+                                  'basis for the different sub-sampling levels'
+                                  '.'))
     subsamp = traits.Int(1, argstr='--subsamp=%d',
                          desc='sub-sampling scheme')
     fwhm = traits.Float(8.0, argstr='--fwhm=%f',
@@ -146,13 +162,31 @@ class TOPUPInputSpec(FSLCommandInputSpec):
                                  'arguments'))
     max_iter = traits.Int(5, argstr='--miter=%d',
                           desc='max # of non-linear iterations')
-    # @oesteban: I don't know how to implement these 3 parameters, AFAIK there's
-    # no documentation.
-    #lambda	Weight of regularisation, default depending on --ssqlambda and --regmod switches. See user documetation.
-    #ssqlambda	If set (=1), lambda is weighted by current ssq, default 1
-    #regmod	Model for regularisation of warp-field [membrane_energy bending_energy], default bending_energy
-    estmov = traits.Enum(1, 0,
-                         desc='estimate movements if set', argstr='--estmov=%d')
+    reg_lambda = traits.Float(1.0, argstr='--miter=%0.f',
+                              desc=('lambda weighting value of the '
+                                    'regularisation term'))
+    ssqlambda = traits.Enum(1, 0, argstr='--ssqlambda=%d',
+                            desc=('Weight lambda by the current value of the '
+                                  'ssd. If used (=1), the effective weight of '
+                                  'regularisation term becomes higher for the '
+                                  'initial iterations, therefore initial steps'
+                                  ' are a little smoother than they would '
+                                  'without weighting. This reduces the '
+                                  'risk of finding a local minimum.'))
+    regmod = traits.Enum('bending_energy', 'membrane_energy',
+                         argstr='--regmod=%s',
+                         desc=('Regularisation term implementation. Defaults '
+                               'to bending_energy. Note that the two functions'
+                               ' have vastly different scales. The membrane '
+                               'energy is based on the first derivatives and '
+                               'the bending energy on the second derivatives. '
+                               'The second derivatives will typically be much '
+                               'smaller than the first derivatives, so input '
+                               'lambda will have to be larger for '
+                               'bending_energy to yield approximately the same'
+                               ' level of regularisation.'))
+    estmov = traits.Enum(1, 0, argstr='--estmov=%d',
+                         desc='estimate movements if set')
     minmet = traits.Enum(0, 1, argstr='--minmet=%d',
                          desc=('Minimisation method 0=Levenberg-Marquardt, '
                                '1=Scaled Conjugate Gradient'))
@@ -165,8 +199,8 @@ class TOPUPInputSpec(FSLCommandInputSpec):
     interp = traits.Enum('spline', 'linear', argstr='--interp=%s',
                          desc='Image interpolation model, linear or spline.')
     scale = traits.Enum(0, 1, argstr='--scale=%d',
-                        desc=('If set (=1), the images are individually scaled '
-                              'to a common mean'))
+                        desc=('If set (=1), the images are individually scaled'
+                              ' to a common mean'))
     regrid = traits.Enum(1, 0, argstr='--regrid=%d',
                          desc=('If set (=1), the calculations are done in a '
                                'different grid'))
@@ -183,24 +217,27 @@ class TOPUPOutputSpec(TraitedSpec):
 
 
 class TOPUP(FSLCommand):
-    """ Interface for FSL topup, a tool for estimating and correcting
-        susceptibility induced distortions
-        Reference: http://fsl.fmrib.ox.ac.uk/fsl/fslwiki/TOPUP
-        Example: http://fsl.fmrib.ox.ac.uk/fsl/fslwiki/topup/ExampleTopupFollowedByApplytopup
-
-        topup --imain=<some 4D image> --datain=<text file> --config=<text file with parameters> --coutname=my_field
-
+    """
+    Interface for FSL topup, a tool for estimating and correcting
+    susceptibility induced distortions. See FSL documentation for
+    `reference <http://fsl.fmrib.ox.ac.uk/fsl/fslwiki/TOPUP>`_,
+    `usage examples
+    <http://fsl.fmrib.ox.ac.uk/fsl/fslwiki/topup/ExampleTopupFollowedByApplytopup>`_,
+    and `exemplary config files
+    <https://github.com/ahheckel/FSL-scripts/blob/master/rsc/fsl/fsl4/topup/b02b0.cnf`_.
 
-        Examples
-        --------
+    Examples
+    --------
 
-        >>> from nipype.interfaces.fsl import TOPUP
-        >>> topup = TOPUP()
-        >>> topup.inputs.in_file = "b0_b0rev.nii"
-        >>> topup.inputs.encoding_file = "topup_encoding.txt"
-        >>> topup.cmdline #doctest: +ELLIPSIS
-        'topup --config=b02b0.cnf --datain=topup_encoding.txt --imain=b0_b0rev.nii --out=b0_b0rev_base --iout=b0_b0rev_corrected.nii.gz --fout=b0_b0rev_field.nii.gz --logout=b0_b0rev_topup.log'
-        >>> res = topup.run() # doctest: +SKIP
+    >>> from nipype.interfaces.fsl import TOPUP
+    >>> topup = TOPUP()
+    >>> topup.inputs.in_file = "b0_b0rev.nii"
+    >>> topup.inputs.encoding_file = "topup_encoding.txt"
+    >>> topup.cmdline #doctest: +ELLIPSIS
+    'topup --config=b02b0.cnf --datain=topup_encoding.txt \
+--imain=b0_b0rev.nii --out=b0_b0rev_base --iout=b0_b0rev_corrected.nii.gz \
+--fout=b0_b0rev_field.nii.gz --logout=b0_b0rev_topup.log'
+    >>> res = topup.run() # doctest: +SKIP
 
     """
     _cmd = 'topup'
@@ -240,8 +277,8 @@ def _generate_encfile(self):
         durations = self.inputs.readout_times
         if len(self.inputs.encoding_direction) != len(durations):
             if len(self.inputs.readout_times) != 1:
-                raise ValueError(('Readout time must be a float or match length'
-                                  ' of encoding directions'))
+                raise ValueError(('Readout time must be a float or match the'
+                                  'length of encoding directions'))
             durations = durations * len(self.inputs.encoding_direction)
 
         lines = []
@@ -280,41 +317,47 @@ class ApplyTOPUPInputSpec(FSLCommandInputSpec):
     in_topup_movpar = File(exists=True, requires=['in_topup_fieldcoef'],
                            copyfile=False, desc='topup movpar.txt file')
     out_corrected = File(desc='output (warped) image',
-                         name_source=['in_files'], name_template='%s_corrected',
-                         argstr='--out=%s' )
-    method = traits.Enum(('jac','lsr'), argstr='--method=%s',
-                         desc=('use jacobian modulation (jac) or least-squares '
-                               'resampling (lsr)'))
-    interp = traits.Enum(('trilinear','spline'), argstr='--interp=%s',
+                         name_source=['in_files'],
+                         name_template='%s_corrected',
+                         argstr='--out=%s')
+    method = traits.Enum('jac', 'lsr', argstr='--method=%s',
+                         desc=('use jacobian modulation (jac) or least-squares'
+                               ' resampling (lsr)'))
+    interp = traits.Enum('trilinear', 'spline', argstr='--interp=%s',
                          desc='interpolation method')
-    datatype = traits.Enum(('char', 'short', 'int', 'float', 'double'),
+    datatype = traits.Enum('char', 'short', 'int', 'float', 'double',
                            argstr='-d=%s', desc='force output data type')
 
 
-class ApplyTOPUPOutputSpec( TraitedSpec ):
-    out_corrected = File( exists=True, desc=('name of 4D image file with '
-                                             'unwarped images'))
+class ApplyTOPUPOutputSpec(TraitedSpec):
+    out_corrected = File(exists=True, desc=('name of 4D image file with '
+                                            'unwarped images'))
 
 
-class ApplyTOPUP( FSLCommand ):
-    """ Interface for FSL topup, a tool for estimating and correcting susceptibility induced distortions.
-        `General reference <http://fsl.fmrib.ox.ac.uk/fsl/fslwiki/topup/ApplytopupUsersGuide>`_
-        and `use example <http://fsl.fmrib.ox.ac.uk/fsl/fslwiki/topup/ExampleTopupFollowedByApplytopup>`_.
+class ApplyTOPUP(FSLCommand):
+    """
+    Interface for FSL topup, a tool for estimating and correcting
+    susceptibility induced distortions.
+    `General reference
+    <http://fsl.fmrib.ox.ac.uk/fsl/fslwiki/topup/ApplytopupUsersGuide>`_
+    and `use example
+    <http://fsl.fmrib.ox.ac.uk/fsl/fslwiki/topup/ExampleTopupFollowedByApplytopup>`_.
 
 
-        Examples
-        --------
+    Examples
+    --------
 
-        >>> from nipype.interfaces.fsl import ApplyTOPUP
-        >>> applytopup = ApplyTOPUP()
-        >>> applytopup.inputs.in_files = [ "epi.nii", "epi_rev.nii" ]
-        >>> applytopup.inputs.encoding_file = "topup_encoding.txt"
-        >>> applytopup.inputs.in_index = [ 1,2 ]
-        >>> applytopup.inputs.in_topup_fieldcoef = "topup_fieldcoef.nii.gz"
-        >>> applytopup.inputs.in_topup_movpar = "topup_movpar.txt"
-        >>> applytopup.cmdline #doctest: +ELLIPSIS
-        'applytopup --datain=topup_encoding.txt --imain=epi.nii,epi_rev.nii --inindex=1,2 --topup=topup --out=epi_corrected.nii.gz'
-        >>> res = applytopup.run() # doctest: +SKIP
+    >>> from nipype.interfaces.fsl import ApplyTOPUP
+    >>> applytopup = ApplyTOPUP()
+    >>> applytopup.inputs.in_files = ["epi.nii", "epi_rev.nii"]
+    >>> applytopup.inputs.encoding_file = "topup_encoding.txt"
+    >>> applytopup.inputs.in_index = [1,2]
+    >>> applytopup.inputs.in_topup_fieldcoef = "topup_fieldcoef.nii.gz"
+    >>> applytopup.inputs.in_topup_movpar = "topup_movpar.txt"
+    >>> applytopup.cmdline #doctest: +ELLIPSIS
+    'applytopup --datain=topup_encoding.txt --imain=epi.nii,epi_rev.nii \
+--inindex=1,2 --topup=topup --out=epi_corrected.nii.gz'
+    >>> res = applytopup.run() # doctest: +SKIP
 
     """
     _cmd = 'applytopup'
@@ -327,78 +370,85 @@ def _format_arg(self, name, spec, value):
         return super(ApplyTOPUP, self)._format_arg(name, spec, value)
 
 
-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,
+class EddyInputSpec(FSLCommandInputSpec):
+    in_file = File(exists=True, mandatory=True, argstr='--imain=%s',
+                   desc=('File containing all the images to estimate '
+                         'distortions for'))
+    in_mask = File(exists=True, mandatory=True, argstr='--mask=%s',
+                   desc='Mask to indicate brain')
+    in_index = File(exists=True, mandatory=True, argstr='--index=%s',
                     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,
+                          'into --acqp and --topup'))
+    in_acqp = File(exists=True, mandatory=True, argstr='--acqp=%s',
+                   desc='File containing acquisition parameters')
+    in_bvec = File(exists=True, mandatory=True, argstr='--bvecs=%s',
+                   desc=('File containing the b-vectors for all volumes in '
+                         '--imain'))
+    in_bval = File(exists=True, mandatory=True, argstr='--bvals=%s',
+                   desc=('File containing the b-values for all volumes in '
+                         '--imain'))
+    out_base = File(argstr='--out=%s',
+                    desc=('basename for output (warped) image'))
+
+    session = File(exists=True, argstr='--session=%s',
+                   desc=('File containing session indices for all volumes in '
+                         '--imain'))
+    in_topup_fieldcoef = File(exists=True, argstr="--topup=%s",
                               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' )
+                           desc='topup movpar.txt file')
+
+    flm = traits.Enum('linear', 'quadratic', 'cubic', argstr='--flm=%s',
+                      desc='First level EC model')
+
     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',
+
+    niter = traits.Int(5, argstr='--niter=%s', desc='Number of iterations')
+
+    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' )
+                               'squares)'))
+    repol = traits.Bool(False, argstr='--repol',
+                        desc='Detect and replace outlier slices')
 
 
-class EddyOutputSpec( TraitedSpec ):
+class EddyOutputSpec(TraitedSpec):
     out_corrected = File(exists=True,
-                        desc=('4D image file containing all the corrected '
-                              'volumes'))
+                         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>`_.
-
-        Examples
-        --------
-
-        >>> from nipype.interfaces.fsl import Eddy
-        >>> eddy = Eddy()
-        >>> eddy.inputs.in_file = 'epi.nii'
-        >>> eddy.inputs.in_mask  = 'epi_mask.nii'
-        >>> eddy.inputs.in_index = 'epi_index.txt'
-        >>> eddy.inputs.in_acqp  = 'epi_acqp.txt'
-        >>> eddy.inputs.in_bvec  = 'bvecs.scheme'
-        >>> eddy.inputs.in_bval  = 'bvals.scheme'
-        >>> eddy.cmdline #doctest: +ELLIPSIS
-        'eddy --acqp=epi_acqp.txt --bvals=bvals.scheme --bvecs=bvecs.scheme --imain=epi.nii --index=epi_index.txt --mask=epi_mask.nii --out=.../eddy_corrected'
-        >>> res = eddy.run() # doctest: +SKIP
+                         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>`_.
+
+    Examples
+    --------
+
+    >>> from nipype.interfaces.fsl import Eddy
+    >>> eddy = Eddy()
+    >>> eddy.inputs.in_file = 'epi.nii'
+    >>> eddy.inputs.in_mask  = 'epi_mask.nii'
+    >>> eddy.inputs.in_index = 'epi_index.txt'
+    >>> eddy.inputs.in_acqp  = 'epi_acqp.txt'
+    >>> eddy.inputs.in_bvec  = 'bvecs.scheme'
+    >>> eddy.inputs.in_bval  = 'bvals.scheme'
+    >>> eddy.cmdline #doctest: +ELLIPSIS
+    'eddy --acqp=epi_acqp.txt --bvals=bvals.scheme --bvecs=bvecs.scheme \
+--imain=epi.nii --index=epi_index.txt --mask=epi_mask.nii \
+--out=.../eddy_corrected'
+    >>> res = eddy.run() # doctest: +SKIP
+
     """
     _cmd = 'eddy'
     input_spec = EddyInputSpec
@@ -409,15 +459,14 @@ def _format_arg(self, name, spec, value):
             return spec.argstr % value.split('_fieldcoef')[0]
         return super(Eddy, self)._format_arg(name, spec, value)
 
-    def _parse_inputs( self, skip=None ):
+    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' )
+        if not isdefined(self.inputs.out_base):
+            self.inputs.out_base = os.path.abspath('eddy_corrected')
         return super(Eddy, self)._parse_inputs(skip=skip)
 
-
     def _list_outputs(self):
         outputs = self.output_spec().get()
         outputs['out_corrected'] = '%s.nii.gz' % self.inputs.out_base
@@ -425,6 +474,71 @@ def _list_outputs(self):
         return outputs
 
 
+class SigLossInputSpec(FSLCommandInputSpec):
+    in_file = File(mandatory=True,
+                   exists=True,
+                   argstr='-i %s',
+                   desc='b0 fieldmap file')
+    out_file = File(argstr='-s %s',
+                    desc='output signal loss estimate file',
+                    genfile=True)
+
+    mask_file = File(exists=True,
+                     argstr='-m %s',
+                     desc='brain mask file')
+    echo_time = traits.Float(argstr='--te=%f',
+                             desc='echo time in seconds')
+    slice_direction = traits.Enum('x', 'y', 'z',
+                                  argstr='-d %s',
+                                  desc='slicing direction')
+
+
+class SigLossOuputSpec(TraitedSpec):
+    out_file = File(exists=True,
+                    desc='signal loss estimate file')
+
+
+class SigLoss(FSLCommand):
+    """
+    Estimates signal loss from a field map (in rad/s)
+
+    Examples
+    --------
+
+    >>> from nipype.interfaces.fsl import SigLoss
+    >>> sigloss = SigLoss()
+    >>> sigloss.inputs.in_file = "phase.nii"
+    >>> sigloss.inputs.echo_time = 0.03
+    >>> sigloss.inputs.output_type = "NIFTI_GZ"
+    >>> sigloss.cmdline #doctest: +ELLIPSIS
+    'sigloss --te=0.030000 -i phase.nii -s .../phase_sigloss.nii.gz'
+    >>> res = sigloss.run() # doctest: +SKIP
+
+
+    """
+    input_spec = SigLossInputSpec
+    output_spec = SigLossOuputSpec
+    _cmd = 'sigloss'
+
+    def _list_outputs(self):
+        outputs = self.output_spec().get()
+        outputs['out_file'] = self.inputs.out_file
+        if ((not isdefined(outputs['out_file'])) and
+                (isdefined(self.inputs.in_file))):
+            outputs['out_file'] = self._gen_fname(self.inputs.in_file,
+                                                  suffix='_sigloss')
+        return outputs
+
+    def _gen_filename(self, name):
+        if name == 'out_file':
+            return self._list_outputs()['out_file']
+        return None
+
+#######################################
+# deprecated interfaces
+#######################################
+
+
 class EPIDeWarpInputSpec(FSLCommandInputSpec):
     mag_file = File(exists=True,
                     desc='Magnitude file',
@@ -460,7 +574,6 @@ class EPIDeWarpInputSpec(FSLCommandInputSpec):
                           argstr='--cleanup')
 
 
-
 class EPIDeWarpOutputSpec(TraitedSpec):
     unwarped_file = File(desc="unwarped epi file")
     vsm_file = File(desc="voxel shift map")
@@ -469,7 +582,12 @@ class EPIDeWarpOutputSpec(TraitedSpec):
 
 
 class EPIDeWarp(FSLCommand):
-    """Wraps fieldmap unwarping script from Freesurfer's epidewarp.fsl_
+    """
+    Wraps the unwarping script `epidewarp.fsl
+    <http://surfer.nmr.mgh.harvard.edu/fswiki/epidewarp.fsl>`_.
+
+    .. warning:: deprecated in FSL, please use
+      :func:`nipype.workflows.dmri.preprocess.epi.sdc_fmb` instead.
 
     Examples
     --------
@@ -481,19 +599,29 @@ class EPIDeWarp(FSLCommand):
     >>> dewarp.inputs.dph_file = "phase.nii"
     >>> dewarp.inputs.output_type = "NIFTI_GZ"
     >>> dewarp.cmdline #doctest: +ELLIPSIS
-    'epidewarp.fsl --mag magnitude.nii --dph phase.nii --epi functional.nii --esp 0.58 --exfdw .../exfdw.nii.gz --nocleanup --sigma 2 --tediff 2.46 --tmpdir .../temp --vsm .../vsm.nii.gz'
+    'epidewarp.fsl --mag magnitude.nii --dph phase.nii --epi functional.nii \
+--esp 0.58 --exfdw .../exfdw.nii.gz --nocleanup --sigma 2 --tediff 2.46 \
+--tmpdir .../temp --vsm .../vsm.nii.gz'
     >>> res = dewarp.run() # doctest: +SKIP
 
-    References
-    ----------
-    _epidewarp.fsl: http://surfer.nmr.mgh.harvard.edu/fswiki/epidewarp.fsl
 
     """
-
     _cmd = 'epidewarp.fsl'
     input_spec = EPIDeWarpInputSpec
     output_spec = EPIDeWarpOutputSpec
 
+    def __init__(self, **inputs):
+        warnings.warn(("Deprecated: Please use "
+                      "nipype.workflows.dmri.preprocess.epi.sdc_fmb instead"),
+                      DeprecationWarning)
+        return super(EPIDeWarp, self).__init__(**inputs)
+
+    def _run_interface(self, runtime):
+        runtime = super(EPIDeWarp, self)._run_interface(runtime)
+        if runtime.stderr:
+            self.raise_exception(runtime)
+        return runtime
+
     def _gen_filename(self, name):
         if name == 'exfdw':
             if isdefined(self.inputs.exf_file):
@@ -536,77 +664,33 @@ def _list_outputs(self):
         return outputs
 
 
-class SigLossInputSpec(FSLCommandInputSpec):
-    in_file = File(mandatory=True,
-                   exists=True,
-                   argstr='-i %s',
-                   desc='b0 fieldmap file')
-    out_file = File(argstr='-s %s',
-                    desc='output signal loss estimate file',
-                    genfile=True)
-
-    mask_file = File(exists=True,
-                     argstr='-m %s',
-                     desc='brain mask file')
-    echo_time = traits.Float(argstr='--te=%f',
-                             desc='echo time in seconds')
-    slice_direction = traits.Enum('x','y','z',
-                                  argstr='-d %s',
-                                  desc='slicing direction')
-class SigLossOuputSpec(TraitedSpec):
-    out_file = File(exists=True,
-                    desc='signal loss estimate file')
-
-class SigLoss(FSLCommand):
-    """Estimates signal loss from a field map (in rad/s)
-
-    Examples
-    --------
-
-    >>> from nipype.interfaces.fsl import SigLoss
-    >>> sigloss = SigLoss()
-    >>> sigloss.inputs.in_file = "phase.nii"
-    >>> sigloss.inputs.echo_time = 0.03
-    >>> sigloss.inputs.output_type = "NIFTI_GZ"
-    >>> sigloss.cmdline #doctest: +ELLIPSIS
-    'sigloss --te=0.030000 -i phase.nii -s .../phase_sigloss.nii.gz'
-    >>> res = sigloss.run() # doctest: +SKIP
-    """
-    input_spec = SigLossInputSpec
-    output_spec = SigLossOuputSpec
-    _cmd = 'sigloss'
-
-    def _list_outputs(self):
-        outputs = self.output_spec().get()
-        outputs['out_file'] = self.inputs.out_file
-        if not isdefined(outputs['out_file']) and isdefined(self.inputs.in_file):
-            outputs['out_file']=self._gen_fname(self.inputs.in_file,
-                                                suffix='_sigloss')
-        return outputs
-
-    def _gen_filename(self, name):
-        if name=='out_file':
-            return self._list_outputs()['out_file']
-        return None
-
 class EddyCorrectInputSpec(FSLCommandInputSpec):
-    in_file = File(exists=True, desc='4D input file', argstr='%s', position=0, mandatory=True)
-    out_file = File(desc='4D output file', argstr='%s', position=1, genfile=True, hash_files=False)
-    ref_num = traits.Int(argstr='%d', position=2, desc='reference number', mandatory=True)
+    in_file = File(exists=True, desc='4D input file', argstr='%s', position=0,
+                   mandatory=True)
+    out_file = File(desc='4D output file', argstr='%s', position=1,
+                    name_source=['in_file'], name_template='%s_edc',
+                    output_name='eddy_corrected')
+    ref_num = traits.Int(0, argstr='%d', position=2, desc='reference number',
+                         mandatory=True, usedefault=True)
 
 
 class EddyCorrectOutputSpec(TraitedSpec):
-    eddy_corrected = File(exists=True, desc='path/name of 4D eddy corrected output file')
+    eddy_corrected = File(exists=True,
+                          desc='path/name of 4D eddy corrected output file')
 
 
 class EddyCorrect(FSLCommand):
-    """  Deprecated! Please use create_eddy_correct_pipeline instead
+    """
+
+    .. warning:: Deprecated in FSL. Please use
+      :class:`nipype.interfaces.fsl.epi.Eddy` instead
 
     Example
     -------
 
     >>> from nipype.interfaces.fsl import EddyCorrect
-    >>> eddyc = EddyCorrect(in_file='diffusion.nii', out_file="diffusion_edc.nii", ref_num=0)
+    >>> eddyc = EddyCorrect(in_file='diffusion.nii',
+    ...                     out_file="diffusion_edc.nii", ref_num=0)
     >>> eddyc.cmdline
     'eddy_correct diffusion.nii diffusion_edc.nii 0'
 
@@ -616,30 +700,12 @@ class EddyCorrect(FSLCommand):
     output_spec = EddyCorrectOutputSpec
 
     def __init__(self, **inputs):
-        warnings.warn("Deprecated: Please use create_eddy_correct_pipeline instead", DeprecationWarning)
+        warnings.warn(("Deprecated: Please use nipype.interfaces.fsl.epi.Eddy "
+                      "instead"), DeprecationWarning)
         return super(EddyCorrect, self).__init__(**inputs)
 
     def _run_interface(self, runtime):
-        if not isdefined(self.inputs.out_file):
-            self.inputs.out_file = self._gen_fname(self.inputs.in_file, suffix='_edc')
         runtime = super(EddyCorrect, self)._run_interface(runtime)
         if runtime.stderr:
             self.raise_exception(runtime)
         return runtime
-
-    def _list_outputs(self):
-        outputs = self.output_spec().get()
-        outputs['eddy_corrected'] = self.inputs.out_file
-        if not isdefined(outputs['eddy_corrected']):
-            outputs['eddy_corrected'] = self._gen_fname(self.inputs.in_file, suffix='_edc')
-        outputs['eddy_corrected'] = os.path.abspath(outputs['eddy_corrected'])
-        return outputs
-
-    def _gen_filename(self, name):
-        if name is 'out_file':
-            return self._list_outputs()['eddy_corrected']
-        else:
-            return None
-
-
-


Test patch:
diff --git a/nipype/interfaces/fsl/tests/test_auto_Eddy.py b/nipype/interfaces/fsl/tests/test_auto_Eddy.py
--- a/nipype/interfaces/fsl/tests/test_auto_Eddy.py
+++ b/nipype/interfaces/fsl/tests/test_auto_Eddy.py
@@ -34,11 +34,9 @@ def test_Eddy_inputs():
     mandatory=True,
     ),
     in_topup_fieldcoef=dict(argstr='--topup=%s',
-    copyfile=False,
     requires=['in_topup_movpar'],
     ),
-    in_topup_movpar=dict(copyfile=False,
-    requires=['in_topup_fieldcoef'],
+    in_topup_movpar=dict(requires=['in_topup_fieldcoef'],
     ),
     method=dict(argstr='--resamp=%s',
     ),
diff --git a/nipype/interfaces/fsl/tests/test_auto_EddyCorrect.py b/nipype/interfaces/fsl/tests/test_auto_EddyCorrect.py
--- a/nipype/interfaces/fsl/tests/test_auto_EddyCorrect.py
+++ b/nipype/interfaces/fsl/tests/test_auto_EddyCorrect.py
@@ -16,14 +16,16 @@ def test_EddyCorrect_inputs():
     position=0,
     ),
     out_file=dict(argstr='%s',
-    genfile=True,
-    hash_files=False,
+    name_source=['in_file'],
+    name_template='%s_edc',
+    output_name='eddy_corrected',
     position=1,
     ),
     output_type=dict(),
     ref_num=dict(argstr='%d',
     mandatory=True,
     position=2,
+    usedefault=True,
     ),
     terminal_output=dict(mandatory=True,
     nohash=True,
diff --git a/nipype/interfaces/fsl/tests/test_auto_TOPUP.py b/nipype/interfaces/fsl/tests/test_auto_TOPUP.py
--- a/nipype/interfaces/fsl/tests/test_auto_TOPUP.py
+++ b/nipype/interfaces/fsl/tests/test_auto_TOPUP.py
@@ -64,12 +64,18 @@ def test_TOPUP_inputs():
     requires=['encoding_direction'],
     xor=['encoding_file'],
     ),
+    reg_lambda=dict(argstr='--miter=%0.f',
+    ),
+    regmod=dict(argstr='--regmod=%s',
+    ),
     regrid=dict(argstr='--regrid=%d',
     ),
     scale=dict(argstr='--scale=%d',
     ),
     splineorder=dict(argstr='--splineorder=%d',
     ),
+    ssqlambda=dict(argstr='--ssqlambda=%d',
+    ),
     subsamp=dict(argstr='--subsamp=%d',
     ),
     terminal_output=dict(mandatory=True,