Skip to content

Commit

Permalink
Merge pull request #3248 from GalBenZvi/patch-1
Browse files Browse the repository at this point in the history
FIX: Handle changes in CLI structure of mrtrix3.DWIBiasCorrect
  • Loading branch information
effigies authored Nov 8, 2020
2 parents 3976524 + 68b3003 commit b356ad1
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
4 changes: 4 additions & 0 deletions .zenodo.json
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,10 @@
"affiliation": "Sagol School of Neuroscience, Tel Aviv University",
"name": "Baratz, Zvi"
},
{
"affiliation": "Sagol School of Neuroscience, Tel Aviv University",
"name": "Ben-Zvi, Gal"
},
{
"name": "Matsubara, K"
},
Expand Down
16 changes: 12 additions & 4 deletions nipype/interfaces/mrtrix3/preprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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(
Expand Down
6 changes: 4 additions & 2 deletions nipype/interfaces/mrtrix3/tests/test_auto_DWIBiasCorrect.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
),
)
Expand Down

0 comments on commit b356ad1

Please sign in to comment.