Repository: nipy/nipype

Issue:
Additional parameters for FSL Eddy
### Summary
nipype's interface for FSL eddy currently does not support the  parameters "--cnr_maps" and "--residuals".

### Actual behavior
You can use the parameters through the args string, but then you can not connect the resulting output to other nodes!

### Expected behavior
Make them proper optional parameters that produce proper output specified in the OutputSpec 

### Platform details:
{'commit_hash': '3ec8065',
 'commit_source': 'repository',
 'networkx_version': '2.1',
 'nibabel_version': '2.1.0',
 'nipype_version': '1.1.4-dev+g3ec8065',
 'numpy_version': '1.15.0',
 'pkg_path': 'private/nipype/nipype',
 'scipy_version': '1.1.0',
 'sys_executable': '/usr/bin/python',
 'sys_platform': 'linux2',
 'sys_version': '2.7.9 (default, Jun 29 2016, 13:08:31) \n[GCC 4.9.2]',
 'traits_version': '4.6.0'}

FSL version: 5.0.10

These eddy parameters are kind of hidden since they do not appear in the usage page, they do however appear in the eddy user guide: https://fsl.fmrib.ox.ac.uk/fsl/fslwiki/eddy/UsersGuide

    my_eddy_output.eddy_cnr_maps
        Written iff --cnr_maps is set
    my_eddy_output.eddy_residuals
         Written iff --residuals is set.

I have already written the code because someone at our chair needed it, so if you want i can make a pull request.
Kind regards,
Niklas Förster


Discussion:
Hi Niklas - that would be great!

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
@@ -659,6 +659,10 @@ class EddyInputSpec(FSLCommandInputSpec):
         "the field specified by --field and first volume "
         "in file --imain")
     use_cuda = traits.Bool(False, desc="Run eddy using cuda gpu")
+    cnr_maps = traits.Bool(
+        False, desc='Output CNR-Maps', argstr='--cnr_maps', min_ver='5.0.10')
+    residuals = traits.Bool(
+        False, desc='Output Residuals', argstr='--residuals', min_ver='5.0.10')
 
 
 class EddyOutputSpec(TraitedSpec):
@@ -685,6 +689,10 @@ class EddyOutputSpec(TraitedSpec):
         exists=True,
         desc=('Text-file with a plain language report on what '
               'outlier slices eddy has found'))
+    out_cnr_maps = File(
+        exists=True, desc='path/name of file with the cnr_maps')
+    out_residuals = File(
+        exists=True, desc='path/name of file with the residuals')
 
 
 class Eddy(FSLCommand):
@@ -787,6 +795,16 @@ def _list_outputs(self):
             self.inputs.out_base)
         out_outlier_report = os.path.abspath(
             '%s.eddy_outlier_report' % self.inputs.out_base)
+        if isdefined(self.inputs.cnr_maps) and self.inputs.cnr_maps:
+            out_cnr_maps = os.path.abspath(
+                '%s.eddy_cnr_maps.nii.gz' % self.inputs.out_base)
+            if os.path.exists(out_cnr_maps):
+                outputs['out_cnr_maps'] = out_cnr_maps
+        if isdefined(self.inputs.residuals) and self.inputs.residuals:
+            out_residuals = os.path.abspath(
+                '%s.eddy_residuals.nii.gz' % self.inputs.out_base)
+            if os.path.exists(out_residuals):
+                outputs['out_residuals'] = out_residuals
 
         if os.path.exists(out_rotated_bvecs):
             outputs['out_rotated_bvecs'] = out_rotated_bvecs


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
@@ -74,6 +74,8 @@ def test_Eddy_inputs():
         session=dict(argstr='--session=%s', ),
         slm=dict(argstr='--slm=%s', ),
         use_cuda=dict(),
+        cnr_maps=dict(argstr='--cnr_maps', min_ver='5.0.10', ),
+        residuals=dict(argstr='--residuals', min_ver='5.0.10', ),
     )
     inputs = Eddy.input_spec()
 
@@ -89,6 +91,8 @@ def test_Eddy_outputs():
         out_restricted_movement_rms=dict(),
         out_rotated_bvecs=dict(),
         out_shell_alignment_parameters=dict(),
+        out_cnr_maps=dict(),
+        out_residuals=dict(),
     )
     outputs = Eddy.output_spec()