Skip to content

Commit 3ec8065

Browse files
authored
Merge pull request #2731 from ihnorton/rmv_dwi2tensor_reg_term
FIX: Remove 'reg_term'/'regularisation' from dwi2tensor interface
2 parents 4f2933e + 98faffa commit 3ec8065

File tree

3 files changed

+37
-6
lines changed

3 files changed

+37
-6
lines changed

nipype/interfaces/mrtrix3/base.py

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,39 @@
44
from __future__ import (print_function, division, unicode_literals,
55
absolute_import)
66

7-
from ... import logging
8-
from ..base import (CommandLineInputSpec, CommandLine, traits, File, isdefined)
7+
from ... import logging, LooseVersion
8+
from ...utils.filemanip import which
9+
from ..base import (CommandLineInputSpec, CommandLine, traits, File, isdefined, PackageInfo)
910
iflogger = logging.getLogger('nipype.interface')
1011

1112

13+
class Info(PackageInfo):
14+
version_cmd = 'mrconvert --version'
15+
16+
@staticmethod
17+
def parse_version(raw_info):
18+
# info is like: "== mrconvert 0.3.15-githash"
19+
for line in raw_info.splitlines():
20+
if line.startswith('== mrconvert '):
21+
v_string = line.split()[2]
22+
break
23+
else:
24+
return None
25+
26+
# -githash may or may not be appended
27+
v_string = v_string.split('-')[0]
28+
29+
return '.'.join(v_string.split('.')[:3])
30+
31+
@classmethod
32+
def looseversion(cls):
33+
""" Return a comparable version object
34+
35+
If no version found, use LooseVersion('0.0.0')
36+
"""
37+
return LooseVersion(cls.version() or '0.0.0')
38+
39+
1240
class MRTrix3BaseInputSpec(CommandLineInputSpec):
1341
nthreads = traits.Int(
1442
argstr='-nthreads %d',
@@ -78,3 +106,7 @@ def _parse_inputs(self, skip=None):
78106
pass
79107

80108
return super(MRTrix3Base, self)._parse_inputs(skip=skip)
109+
110+
@property
111+
def version(self):
112+
return Info.version()

nipype/interfaces/mrtrix3/reconst.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ class FitTensorInputSpec(MRTrix3BaseInputSpec):
3939
argstr='-method %s',
4040
desc=('select method used to perform the fitting'))
4141
reg_term = traits.Float(
42-
5.e3, usedefault=True,
4342
argstr='-regularisation %f',
43+
max_ver='0.3.13',
4444
desc=('specify the strength of the regularisation term on the '
4545
'magnitude of the tensor elements (default = 5000). This '
4646
'only applies to the non-linear methods'))
@@ -64,8 +64,7 @@ class FitTensor(MRTrix3Base):
6464
>>> tsr.inputs.in_mask = 'mask.nii.gz'
6565
>>> tsr.inputs.grad_fsl = ('bvecs', 'bvals')
6666
>>> tsr.cmdline # doctest: +ELLIPSIS
67-
'dwi2tensor -fslgrad bvecs bvals -mask mask.nii.gz \
68-
-regularisation 5000.000000 dwi.mif dti.mif'
67+
'dwi2tensor -fslgrad bvecs bvals -mask mask.nii.gz dwi.mif dti.mif'
6968
>>> tsr.run() # doctest: +SKIP
7069
"""
7170

nipype/interfaces/mrtrix3/tests/test_auto_FitTensor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def test_FitTensor_inputs():
3434
),
3535
reg_term=dict(
3636
argstr='-regularisation %f',
37-
usedefault=True,
37+
max_ver='0.3.13',
3838
),
3939
)
4040
inputs = FitTensor.input_spec()

0 commit comments

Comments
 (0)