Skip to content

Commit 26ad945

Browse files
committed
Add version support to MRTrix3Base
1 parent 17d4f98 commit 26ad945

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

nipype/interfaces/mrtrix3/base.py

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,32 @@
55
absolute_import)
66

77
from ... import logging
8-
from ..base import (CommandLineInputSpec, CommandLine, traits, File, isdefined)
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 = which('mrconvert')
15+
if version_cmd:
16+
version_cmd = version_cmd + ' --version'
17+
18+
@staticmethod
19+
def parse_version(raw_info):
20+
# info is like: "== mrconvert 0.3.15-githash"
21+
for line in raw_info.splitlines():
22+
if line.startswith('== mrconvert '):
23+
v_string = line.split()[2]
24+
break
25+
else:
26+
return None
27+
28+
# -githash may or may not be appended
29+
v_string = v_string.split('-')[0]
30+
31+
return '.'.join(v_string.split('.')[:3])
32+
33+
1234
class MRTrix3BaseInputSpec(CommandLineInputSpec):
1335
nthreads = traits.Int(
1436
argstr='-nthreads %d',
@@ -78,3 +100,7 @@ def _parse_inputs(self, skip=None):
78100
pass
79101

80102
return super(MRTrix3Base, self)._parse_inputs(skip=skip)
103+
104+
@property
105+
def version(self):
106+
return Info.version()

nipype/interfaces/mrtrix3/reconst.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ class FitTensorInputSpec(MRTrix3BaseInputSpec):
4141
reg_term = traits.Float(
4242
5.e3, usedefault=True,
4343
argstr='-regularisation %f',
44+
max_ver='0.3.13',
4445
desc=('specify the strength of the regularisation term on the '
4546
'magnitude of the tensor elements (default = 5000). This '
4647
'only applies to the non-linear methods'))

0 commit comments

Comments
 (0)