Repository: nipy/nipype

Issue:
mrtrix3.ResponseSD - Handling of multiple b-values
### Summary
When running ResponseSD() (and assuming EstimateFOD(), which has a similar input), current interface does not seem to handle multiple b-values (possibly due to the input `max_sh` defaulting to a single integer value).

### Actual behavior
Get an error specifying the number of manually-defined lmax's does not match number of b-values (see last line).

```Command:  mrconvert /home/tkai/Desktop/tmp2/genACTTractography/act_preproc_wf/MRConvert/dwi.mif /home/tkai/Desktop/tmp2/genACTTractography/act_preproc_wf/dwi2response/dwi2response-tmp-U774DL/dwi.mif -strides 0,0,0,1 -fslgrad /home/tkai/graham/scratch/WholeBrain/derivatives/prepdwi_0.0.6a/prepdwi/sub-5082/dwi/sub-5082_dwi_space-T1w_preproc.bvec /home/tkai/graham/scratch/WholeBrain/derivatives/prepdwi_0.0.6a/prepdwi/sub-5082/dwi/sub-5082_dwi_space-T1w_preproc.bval
Command:  dwi2mask /home/tkai/Desktop/tmp2/genACTTractography/act_preproc_wf/MRConvert/dwi.mif /home/tkai/Desktop/tmp2/genACTTractography/act_preproc_wf/dwi2response/dwi2response-tmp-U774DL/mask.mif
Command:  mrconvert /home/tkai/Desktop/tmp2/genACTTractography/act_preproc_wf/Generate5tt/5tt.mif /home/tkai/Desktop/tmp2/genACTTractography/act_preproc_wf/dwi2response/dwi2response-tmp-U774DL/5tt.mif
dwi2response: Changing to temporary directory (/home/tkai/Desktop/tmp2/genACTTractography/act_preproc_wf/dwi2response/dwi2response-tmp-U774DL/)
Command:  5ttcheck 5tt.mif
dwi2response: [ERROR] Number of manually-defined lmax's (1) does not match number of b-values (3)
```

### Expected behavior
The lmax, if manually defined should allow for more than a single integer to match the number of b-values (e.g. -lmax 0,8,8 in this case), otherwise no default from the Nipype interface.

At the moment, I've forked a copy of nipype and made a temporary solution with the input `max_sh` passing the expected input as a string, removing the default to run without error.

### How to replicate the behavior
Use of multi-shell dwi data with mrt.ResponseSD and algorithm 'msmt_5tt'.

### Script/Workflow details

Current pipeline code is stored at [https://github.com/kaitj/mrtpipelines](https://github.com/kaitj/mrtpipelines)

### Platform details:

```
python3 -c "import nipype; print(nipype.get_info()); print(nipype.__version__)"
{'nibabel_version': '2.2.1', 'numpy_version': '1.14.3', 'nipype_version': '1.0.4-dev+g5a96ea5', 'commit_source': 'repository', 'sys_version': '3.5.2 (default, Nov 23 2017, 16:37:01) \n[GCC 5.4.0 20160609]', 'traits_version': '4.6.0', 'scipy_version': '1.1.0', 'pkg_path': '/home/tkai/git/nipype/nipype', 'sys_platform': 'linux', 'commit_hash': '5a96ea5', 'networkx_version': '2.1', 'sys_executable': '/usr/bin/python3'}
1.0.4-dev+g5a96ea5
```

### Execution environment

Choose one
- Container [Tag: ???]
- My python environment inside container [Base Tag: ???]
- My python environment outside container



Discussion:

Resolving patch:
diff --git a/nipype/interfaces/mrtrix3/preprocess.py b/nipype/interfaces/mrtrix3/preprocess.py
--- a/nipype/interfaces/mrtrix3/preprocess.py
+++ b/nipype/interfaces/mrtrix3/preprocess.py
@@ -7,7 +7,7 @@
 import os.path as op
 
 from ..base import (CommandLineInputSpec, CommandLine, traits, TraitedSpec,
-                    File, isdefined, Undefined)
+                    File, isdefined, Undefined, InputMultiObject)
 from .base import MRTrix3BaseInputSpec, MRTrix3Base
 
 
@@ -40,10 +40,14 @@ class ResponseSDInputSpec(MRTrix3BaseInputSpec):
         argstr='%s', position=-1, desc='output CSF response text file')
     in_mask = File(
         exists=True, argstr='-mask %s', desc='provide initial mask image')
-    max_sh = traits.Int(
-        8, usedefault=True,
-        argstr='-lmax %d',
-        desc='maximum harmonic degree of response function')
+    max_sh = InputMultiObject(
+        traits.Int,
+        value=[8],
+        usedefault=True,
+        argstr='-lmax %s',
+        sep=',',
+        desc=('maximum harmonic degree of response function - single value for '
+              'single-shell response, list for multi-shell response'))
 
 
 class ResponseSDOutputSpec(TraitedSpec):
@@ -67,6 +71,11 @@ class ResponseSD(MRTrix3Base):
     >>> resp.cmdline                               # doctest: +ELLIPSIS
     'dwi2response tournier -fslgrad bvecs bvals -lmax 8 dwi.mif wm.txt'
     >>> resp.run()                                 # doctest: +SKIP
+
+    # We can also pass in multiple harmonic degrees in the case of multi-shell
+    >>> resp.inputs.max_sh = [6,8,10]
+    >>> resp.cmdline
+    'dwi2response tournier -fslgrad bvecs bvals -lmax 6,8,10 dwi.mif wm.txt'
     """
 
     _cmd = 'dwi2response'


Test patch:
diff --git a/nipype/interfaces/mrtrix3/tests/test_auto_ResponseSD.py b/nipype/interfaces/mrtrix3/tests/test_auto_ResponseSD.py
--- a/nipype/interfaces/mrtrix3/tests/test_auto_ResponseSD.py
+++ b/nipype/interfaces/mrtrix3/tests/test_auto_ResponseSD.py
@@ -40,7 +40,8 @@ def test_ResponseSD_inputs():
         ),
         in_mask=dict(argstr='-mask %s', ),
         max_sh=dict(
-            argstr='-lmax %d',
+            argstr='-lmax %s',
+            sep=',',
             usedefault=True,
         ),
         mtt_file=dict(