Repository: nipy/nipype

Issue:
Mrtrix3's dwibiascorrect interface crashes due to "-"
Interface crashes because of "-" before algorithm specification.

```python
RuntimeError: Command:
```
```bash
dwibiascorrect -mask <mask_file> -ants <in_file> <out_file>

Standard output:

Standard error:

Error: argument algorithm: invalid choice: <in_file> (choose from 'ants', 'fsl')
Usage: dwibiascorrect algorithm [ options ] ...
       (Run dwibiascorrect -help for more information)

Return code: 1
```
The expected behavior would be to execute the following command:
```bash
dwibiascorrect ants [options] <in_file> <out_file>
```
To replicate the behavior, simply execute:
```python
import nipype.interface.mrtrix3 as mrt
bc = mrt.DWIBiasCorrect()
bc.inputs.in_file = <in_file>
bc.inputs.out_file = <out_file>
bc.inputs.use_ants = True
bc.run()
```
Running on a 64 bit Linux machine (Ubuntu)

```
{'commit_hash': '72945ef34',
 'commit_source': 'installation',
 'networkx_version': '2.4',
 'nibabel_version': '3.0.0',
 'nipype_version': '1.5.0',
 'numpy_version': '1.19.0',
 'pkg_path': '/home/groot/Projects/labbing/venv/lib/python3.7/site-packages/nipype',
 'scipy_version': '1.5.0',
 'sys_executable': '/home/groot/Projects/labbing/venv/bin/python',
 'sys_platform': 'linux',
 'sys_version': '3.7.8 (default, Jun 29 2020, 04:26:04) \n[GCC 9.3.0]',
 'traits_version': '6.1.1'}
```
- 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
@@ -181,15 +181,17 @@ class DWIBiasCorrectInputSpec(MRTrix3BaseInputSpec):
     )
     in_mask = File(argstr="-mask %s", desc="input mask image for bias field estimation")
     use_ants = traits.Bool(
-        argstr="-ants",
+        argstr="ants",
         mandatory=True,
         desc="use ANTS N4 to estimate the inhomogeneity field",
+        position=0,
         xor=["use_fsl"],
     )
     use_fsl = traits.Bool(
-        argstr="-fsl",
+        argstr="fsl",
         mandatory=True,
         desc="use FSL FAST to estimate the inhomogeneity field",
+        position=0,
         xor=["use_ants"],
     )
     bias = File(argstr="-bias %s", desc="bias field")
@@ -224,14 +226,20 @@ class DWIBiasCorrect(MRTrix3Base):
     >>> bias_correct.inputs.in_file = 'dwi.mif'
     >>> bias_correct.inputs.use_ants = True
     >>> bias_correct.cmdline
-    'dwibiascorrect -ants dwi.mif dwi_biascorr.mif'
+    'dwibiascorrect ants dwi.mif dwi_biascorr.mif'
     >>> bias_correct.run()                             # doctest: +SKIP
     """
 
     _cmd = "dwibiascorrect"
     input_spec = DWIBiasCorrectInputSpec
     output_spec = DWIBiasCorrectOutputSpec
-
+    def _format_arg(self, name, trait_spec, value):
+        if name in ("use_ants", "use_fsl"):
+            ver = self.version
+            # Changed in version 3.0, after release candidates
+            if ver is not None and (ver[0] < "3" or ver.startswith("3.0_RC")):
+                return f"-{trait_spec.argstr}"
+        return super()._format_arg(name, trait_spec, value)
 
 class ResponseSDInputSpec(MRTrix3BaseInputSpec):
     algorithm = traits.Enum(


Test patch:
diff --git a/nipype/interfaces/mrtrix3/tests/test_auto_DWIBiasCorrect.py b/nipype/interfaces/mrtrix3/tests/test_auto_DWIBiasCorrect.py
--- a/nipype/interfaces/mrtrix3/tests/test_auto_DWIBiasCorrect.py
+++ b/nipype/interfaces/mrtrix3/tests/test_auto_DWIBiasCorrect.py
@@ -58,13 +58,15 @@ def test_DWIBiasCorrect_inputs():
             position=-1,
         ),
         use_ants=dict(
-            argstr="-ants",
+            argstr="ants",
             mandatory=True,
+            position=0,
             xor=["use_fsl"],
         ),
         use_fsl=dict(
-            argstr="-fsl",
+            argstr="fsl",
             mandatory=True,
+            position=0,
             xor=["use_ants"],
         ),
     )