Skip to content

Commit b356ad1

Browse files
authored
Merge pull request #3248 from GalBenZvi/patch-1
FIX: Handle changes in CLI structure of mrtrix3.DWIBiasCorrect
2 parents 3976524 + 68b3003 commit b356ad1

File tree

3 files changed

+20
-6
lines changed

3 files changed

+20
-6
lines changed

.zenodo.json

+4
Original file line numberDiff line numberDiff line change
@@ -697,6 +697,10 @@
697697
"affiliation": "Sagol School of Neuroscience, Tel Aviv University",
698698
"name": "Baratz, Zvi"
699699
},
700+
{
701+
"affiliation": "Sagol School of Neuroscience, Tel Aviv University",
702+
"name": "Ben-Zvi, Gal"
703+
},
700704
{
701705
"name": "Matsubara, K"
702706
},

nipype/interfaces/mrtrix3/preprocess.py

+12-4
Original file line numberDiff line numberDiff line change
@@ -181,15 +181,17 @@ class DWIBiasCorrectInputSpec(MRTrix3BaseInputSpec):
181181
)
182182
in_mask = File(argstr="-mask %s", desc="input mask image for bias field estimation")
183183
use_ants = traits.Bool(
184-
argstr="-ants",
184+
argstr="ants",
185185
mandatory=True,
186186
desc="use ANTS N4 to estimate the inhomogeneity field",
187+
position=0,
187188
xor=["use_fsl"],
188189
)
189190
use_fsl = traits.Bool(
190-
argstr="-fsl",
191+
argstr="fsl",
191192
mandatory=True,
192193
desc="use FSL FAST to estimate the inhomogeneity field",
194+
position=0,
193195
xor=["use_ants"],
194196
)
195197
bias = File(argstr="-bias %s", desc="bias field")
@@ -224,14 +226,20 @@ class DWIBiasCorrect(MRTrix3Base):
224226
>>> bias_correct.inputs.in_file = 'dwi.mif'
225227
>>> bias_correct.inputs.use_ants = True
226228
>>> bias_correct.cmdline
227-
'dwibiascorrect -ants dwi.mif dwi_biascorr.mif'
229+
'dwibiascorrect ants dwi.mif dwi_biascorr.mif'
228230
>>> bias_correct.run() # doctest: +SKIP
229231
"""
230232

231233
_cmd = "dwibiascorrect"
232234
input_spec = DWIBiasCorrectInputSpec
233235
output_spec = DWIBiasCorrectOutputSpec
234-
236+
def _format_arg(self, name, trait_spec, value):
237+
if name in ("use_ants", "use_fsl"):
238+
ver = self.version
239+
# Changed in version 3.0, after release candidates
240+
if ver is not None and (ver[0] < "3" or ver.startswith("3.0_RC")):
241+
return f"-{trait_spec.argstr}"
242+
return super()._format_arg(name, trait_spec, value)
235243

236244
class ResponseSDInputSpec(MRTrix3BaseInputSpec):
237245
algorithm = traits.Enum(

nipype/interfaces/mrtrix3/tests/test_auto_DWIBiasCorrect.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,15 @@ def test_DWIBiasCorrect_inputs():
5858
position=-1,
5959
),
6060
use_ants=dict(
61-
argstr="-ants",
61+
argstr="ants",
6262
mandatory=True,
63+
position=0,
6364
xor=["use_fsl"],
6465
),
6566
use_fsl=dict(
66-
argstr="-fsl",
67+
argstr="fsl",
6768
mandatory=True,
69+
position=0,
6870
xor=["use_ants"],
6971
),
7072
)

0 commit comments

Comments
 (0)