Skip to content

Commit db81db1

Browse files
committed
Merge pull request #809 from chrisfilo/fix/mrtrix_prob_spec
Important bugfix for MRTrix tracking
2 parents b46d6be + 0d0c188 commit db81db1

6 files changed

+87
-62
lines changed

CHANGES

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1-
Release 0.9.2 (January 31, 2014)
2-
===========
1+
Next Release
2+
============
33

44
* ENH: New ANTs interface: ApplyTransformsToPoints
5+
* FIX: MRTrix tracking algorithms were ignoring mask parameters.
6+
7+
Release 0.9.2 (January 31, 2014)
8+
============
59

610
* FIX: DataFinder was broken due to a typo
711
* FIX: Order of DataFinder outputs was not guaranteed, it's human sorted now

nipype/interfaces/mrtrix/tests/test_auto_DiffusionTensorStreamlineTrack.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,13 @@ def test_DiffusionTensorStreamlineTrack_inputs():
1616
usedefault=True,
1717
),
1818
exclude_file=dict(argstr='-exclude %s',
19-
position=2,
19+
xor=['exclude_file', 'exclude_spec'],
2020
),
21-
exclude_spec=dict(argstr='-seed %s',
21+
exclude_spec=dict(argstr='-exclude %s',
2222
position=2,
2323
sep=',',
2424
units='mm',
25+
xor=['exclude_file', 'exclude_spec'],
2526
),
2627
gradient_encoding_file=dict(argstr='-grad %s',
2728
mandatory=True,
@@ -35,12 +36,13 @@ def test_DiffusionTensorStreamlineTrack_inputs():
3536
position=-2,
3637
),
3738
include_file=dict(argstr='-include %s',
38-
position=2,
39+
xor=['include_file', 'include_spec'],
3940
),
40-
include_spec=dict(argstr='-seed %s',
41+
include_spec=dict(argstr='-include %s',
4142
position=2,
4243
sep=',',
4344
units='mm',
45+
xor=['include_file', 'include_spec'],
4446
),
4547
initial_cutoff_value=dict(argstr='-initcutoff %s',
4648
units='NA',
@@ -52,13 +54,14 @@ def test_DiffusionTensorStreamlineTrack_inputs():
5254
position=-3,
5355
usedefault=True,
5456
),
55-
mask_file=dict(argstr='-exclude %s',
56-
position=2,
57+
mask_file=dict(argstr='-mask %s',
58+
xor=['mask_file', 'mask_spec'],
5759
),
58-
mask_spec=dict(argstr='-seed %s',
60+
mask_spec=dict(argstr='-mask %s',
5961
position=2,
6062
sep=',',
6163
units='mm',
64+
xor=['mask_file', 'mask_spec'],
6265
),
6366
maximum_number_of_tracks=dict(argstr='-maxnum %d',
6467
),
@@ -74,16 +77,19 @@ def test_DiffusionTensorStreamlineTrack_inputs():
7477
no_mask_interpolation=dict(argstr='-nomaskinterp',
7578
),
7679
out_file=dict(argstr='%s',
77-
genfile=True,
80+
name_source=['in_file'],
81+
name_template='%s_tracked.tck',
82+
output_name='tracked.tck',
7883
position=-1,
7984
),
8085
seed_file=dict(argstr='-seed %s',
81-
position=2,
86+
xor=['seed_file', 'seed_spec'],
8287
),
8388
seed_spec=dict(argstr='-seed %s',
8489
position=2,
8590
sep=',',
8691
units='mm',
92+
xor=['seed_file', 'seed_spec'],
8793
),
8894
step_size=dict(argstr='-step %s',
8995
units='mm',

nipype/interfaces/mrtrix/tests/test_auto_ProbabilisticSphericallyDeconvolutedStreamlineTrack.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,13 @@ def test_ProbabilisticSphericallyDeconvolutedStreamlineTrack_inputs():
1616
usedefault=True,
1717
),
1818
exclude_file=dict(argstr='-exclude %s',
19-
position=2,
19+
xor=['exclude_file', 'exclude_spec'],
2020
),
21-
exclude_spec=dict(argstr='-seed %s',
21+
exclude_spec=dict(argstr='-exclude %s',
2222
position=2,
2323
sep=',',
2424
units='mm',
25+
xor=['exclude_file', 'exclude_spec'],
2526
),
2627
ignore_exception=dict(nohash=True,
2728
usedefault=True,
@@ -31,12 +32,13 @@ def test_ProbabilisticSphericallyDeconvolutedStreamlineTrack_inputs():
3132
position=-2,
3233
),
3334
include_file=dict(argstr='-include %s',
34-
position=2,
35+
xor=['include_file', 'include_spec'],
3536
),
36-
include_spec=dict(argstr='-seed %s',
37+
include_spec=dict(argstr='-include %s',
3738
position=2,
3839
sep=',',
3940
units='mm',
41+
xor=['include_file', 'include_spec'],
4042
),
4143
initial_cutoff_value=dict(argstr='-initcutoff %s',
4244
units='NA',
@@ -48,13 +50,14 @@ def test_ProbabilisticSphericallyDeconvolutedStreamlineTrack_inputs():
4850
position=-3,
4951
usedefault=True,
5052
),
51-
mask_file=dict(argstr='-exclude %s',
52-
position=2,
53+
mask_file=dict(argstr='-mask %s',
54+
xor=['mask_file', 'mask_spec'],
5355
),
54-
mask_spec=dict(argstr='-seed %s',
56+
mask_spec=dict(argstr='-mask %s',
5557
position=2,
5658
sep=',',
5759
units='mm',
60+
xor=['mask_file', 'mask_spec'],
5861
),
5962
maximum_number_of_tracks=dict(argstr='-maxnum %d',
6063
),
@@ -72,16 +75,19 @@ def test_ProbabilisticSphericallyDeconvolutedStreamlineTrack_inputs():
7275
no_mask_interpolation=dict(argstr='-nomaskinterp',
7376
),
7477
out_file=dict(argstr='%s',
75-
genfile=True,
78+
name_source=['in_file'],
79+
name_template='%s_tracked.tck',
80+
output_name='tracked.tck',
7681
position=-1,
7782
),
7883
seed_file=dict(argstr='-seed %s',
79-
position=2,
84+
xor=['seed_file', 'seed_spec'],
8085
),
8186
seed_spec=dict(argstr='-seed %s',
8287
position=2,
8388
sep=',',
8489
units='mm',
90+
xor=['seed_file', 'seed_spec'],
8591
),
8692
step_size=dict(argstr='-step %s',
8793
units='mm',

nipype/interfaces/mrtrix/tests/test_auto_SphericallyDeconvolutedStreamlineTrack.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,13 @@ def test_SphericallyDeconvolutedStreamlineTrack_inputs():
1616
usedefault=True,
1717
),
1818
exclude_file=dict(argstr='-exclude %s',
19-
position=2,
19+
xor=['exclude_file', 'exclude_spec'],
2020
),
21-
exclude_spec=dict(argstr='-seed %s',
21+
exclude_spec=dict(argstr='-exclude %s',
2222
position=2,
2323
sep=',',
2424
units='mm',
25+
xor=['exclude_file', 'exclude_spec'],
2526
),
2627
ignore_exception=dict(nohash=True,
2728
usedefault=True,
@@ -31,12 +32,13 @@ def test_SphericallyDeconvolutedStreamlineTrack_inputs():
3132
position=-2,
3233
),
3334
include_file=dict(argstr='-include %s',
34-
position=2,
35+
xor=['include_file', 'include_spec'],
3536
),
36-
include_spec=dict(argstr='-seed %s',
37+
include_spec=dict(argstr='-include %s',
3738
position=2,
3839
sep=',',
3940
units='mm',
41+
xor=['include_file', 'include_spec'],
4042
),
4143
initial_cutoff_value=dict(argstr='-initcutoff %s',
4244
units='NA',
@@ -48,13 +50,14 @@ def test_SphericallyDeconvolutedStreamlineTrack_inputs():
4850
position=-3,
4951
usedefault=True,
5052
),
51-
mask_file=dict(argstr='-exclude %s',
52-
position=2,
53+
mask_file=dict(argstr='-mask %s',
54+
xor=['mask_file', 'mask_spec'],
5355
),
54-
mask_spec=dict(argstr='-seed %s',
56+
mask_spec=dict(argstr='-mask %s',
5557
position=2,
5658
sep=',',
5759
units='mm',
60+
xor=['mask_file', 'mask_spec'],
5861
),
5962
maximum_number_of_tracks=dict(argstr='-maxnum %d',
6063
),
@@ -70,16 +73,19 @@ def test_SphericallyDeconvolutedStreamlineTrack_inputs():
7073
no_mask_interpolation=dict(argstr='-nomaskinterp',
7174
),
7275
out_file=dict(argstr='%s',
73-
genfile=True,
76+
name_source=['in_file'],
77+
name_template='%s_tracked.tck',
78+
output_name='tracked.tck',
7479
position=-1,
7580
),
7681
seed_file=dict(argstr='-seed %s',
77-
position=2,
82+
xor=['seed_file', 'seed_spec'],
7883
),
7984
seed_spec=dict(argstr='-seed %s',
8085
position=2,
8186
sep=',',
8287
units='mm',
88+
xor=['seed_file', 'seed_spec'],
8389
),
8490
step_size=dict(argstr='-step %s',
8591
units='mm',

nipype/interfaces/mrtrix/tests/test_auto_StreamlineTrack.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,13 @@ def test_StreamlineTrack_inputs():
1616
usedefault=True,
1717
),
1818
exclude_file=dict(argstr='-exclude %s',
19-
position=2,
19+
xor=['exclude_file', 'exclude_spec'],
2020
),
21-
exclude_spec=dict(argstr='-seed %s',
21+
exclude_spec=dict(argstr='-exclude %s',
2222
position=2,
2323
sep=',',
2424
units='mm',
25+
xor=['exclude_file', 'exclude_spec'],
2526
),
2627
ignore_exception=dict(nohash=True,
2728
usedefault=True,
@@ -31,12 +32,13 @@ def test_StreamlineTrack_inputs():
3132
position=-2,
3233
),
3334
include_file=dict(argstr='-include %s',
34-
position=2,
35+
xor=['include_file', 'include_spec'],
3536
),
36-
include_spec=dict(argstr='-seed %s',
37+
include_spec=dict(argstr='-include %s',
3738
position=2,
3839
sep=',',
3940
units='mm',
41+
xor=['include_file', 'include_spec'],
4042
),
4143
initial_cutoff_value=dict(argstr='-initcutoff %s',
4244
units='NA',
@@ -48,13 +50,14 @@ def test_StreamlineTrack_inputs():
4850
position=-3,
4951
usedefault=True,
5052
),
51-
mask_file=dict(argstr='-exclude %s',
52-
position=2,
53+
mask_file=dict(argstr='-mask %s',
54+
xor=['mask_file', 'mask_spec'],
5355
),
54-
mask_spec=dict(argstr='-seed %s',
56+
mask_spec=dict(argstr='-mask %s',
5557
position=2,
5658
sep=',',
5759
units='mm',
60+
xor=['mask_file', 'mask_spec'],
5861
),
5962
maximum_number_of_tracks=dict(argstr='-maxnum %d',
6063
),
@@ -70,16 +73,19 @@ def test_StreamlineTrack_inputs():
7073
no_mask_interpolation=dict(argstr='-nomaskinterp',
7174
),
7275
out_file=dict(argstr='%s',
73-
genfile=True,
76+
name_source=['in_file'],
77+
name_template='%s_tracked.tck',
78+
output_name='tracked.tck',
7479
position=-1,
7580
),
7681
seed_file=dict(argstr='-seed %s',
77-
position=2,
82+
xor=['seed_file', 'seed_spec'],
7883
),
7984
seed_spec=dict(argstr='-seed %s',
8085
position=2,
8186
sep=',',
8287
units='mm',
88+
xor=['seed_file', 'seed_spec'],
8389
),
8490
step_size=dict(argstr='-step %s',
8591
units='mm',

nipype/interfaces/mrtrix/tracking.py

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -75,19 +75,26 @@ class StreamlineTrackInputSpec(CommandLineInputSpec):
7575
in_file = File(exists=True, argstr='%s', mandatory=True, position=-2, desc='the image containing the source data.' \
7676
'The type of data required depends on the type of tracking as set in the preceeding argument. For DT methods, ' \
7777
'the base DWI are needed. For SD methods, the SH harmonic coefficients of the FOD are needed.')
78-
79-
seed_file = File(exists=True, argstr='-seed %s', position=2, desc='seed file')
78+
79+
seed_xor = ['seed_file', 'seed_spec']
80+
seed_file = File(exists=True, argstr='-seed %s', desc='seed file', xor = seed_xor)
8081
seed_spec = traits.List(traits.Float, desc='seed specification in mm and radius (x y z r)', position=2,
81-
argstr='-seed %s', minlen=4, maxlen=4, sep=',', units='mm')
82-
include_file = File(exists=True, argstr='-include %s', position=2, desc='inclusion file')
82+
argstr='-seed %s', minlen=4, maxlen=4, sep=',', units='mm', xor = seed_xor)
83+
84+
include_xor = ['include_file', 'include_spec']
85+
include_file = File(exists=True, argstr='-include %s', desc='inclusion file', xor = include_xor)
8386
include_spec = traits.List(traits.Float, desc='inclusion specification in mm and radius (x y z r)', position=2,
84-
argstr='-seed %s', minlen=4, maxlen=4, sep=',', units='mm')
85-
exclude_file = File(exists=True, argstr='-exclude %s', position=2, desc='exclusion file')
87+
argstr='-include %s', minlen=4, maxlen=4, sep=',', units='mm', xor = include_xor)
88+
89+
exclude_xor = ['exclude_file', 'exclude_spec']
90+
exclude_file = File(exists=True, argstr='-exclude %s', desc='exclusion file', xor = exclude_xor)
8691
exclude_spec = traits.List(traits.Float, desc='exclusion specification in mm and radius (x y z r)', position=2,
87-
argstr='-seed %s', minlen=4, maxlen=4, sep=',', units='mm')
88-
mask_file = File(exists=True, argstr='-exclude %s', position=2, desc='mask file. Only tracks within mask.')
92+
argstr='-exclude %s', minlen=4, maxlen=4, sep=',', units='mm', xor = exclude_xor)
93+
94+
mask_xor = ['mask_file', 'mask_spec']
95+
mask_file = File(exists=True, argstr='-mask %s', desc='mask file. Only tracks within mask.', xor = mask_xor)
8996
mask_spec = traits.List(traits.Float, desc='Mask specification in mm and radius (x y z r). Tracks will be terminated when they leave the ROI.', position=2,
90-
argstr='-seed %s', minlen=4, maxlen=4, sep=',', units='mm')
97+
argstr='-mask %s', minlen=4, maxlen=4, sep=',', units='mm', xor = mask_xor)
9198

9299
inputmodel = traits.Enum('DT_STREAM', 'SD_PROB', 'SD_STREAM',
93100
argstr='%s', desc='input model type', usedefault=True, position=-3)
@@ -120,7 +127,8 @@ class StreamlineTrackInputSpec(CommandLineInputSpec):
120127

121128
initial_direction = traits.List(traits.Int, desc='Specify the initial tracking direction as a vector',
122129
argstr='-initdirection %s', minlen=2, maxlen=2, units='voxels')
123-
out_file = File(argstr='%s', position= -1, genfile=True, desc='output data file')
130+
out_file = File(argstr='%s', position= -1, name_source = ['in_file'], name_template='%s_tracked.tck',
131+
output_name='tracked.tck', desc='output data file')
124132

125133
class StreamlineTrackOutputSpec(TraitedSpec):
126134
tracked = File(exists=True, desc='output file containing reconstructed tracts')
@@ -140,26 +148,15 @@ class StreamlineTrack(CommandLine):
140148
>>> strack.inputs.inputmodel = 'SD_PROB'
141149
>>> strack.inputs.in_file = 'data.Bfloat'
142150
>>> strack.inputs.seed_file = 'seed_mask.nii'
151+
>>> strack.inputs.mask_file = 'mask.nii'
152+
>>> strack.cmdline
153+
'streamtrack -mask mask.nii -seed seed_mask.nii SD_PROB data.Bfloat data_tracked.tck'
143154
>>> strack.run() # doctest: +SKIP
144155
"""
145156
_cmd = 'streamtrack'
146157
input_spec = StreamlineTrackInputSpec
147158
output_spec = StreamlineTrackOutputSpec
148159

149-
def _list_outputs(self):
150-
outputs = self.output_spec().get()
151-
outputs['tracked'] = op.abspath(self._gen_outfilename())
152-
return outputs
153-
154-
def _gen_filename(self, name):
155-
if name is 'out_file':
156-
return self._gen_outfilename()
157-
else:
158-
return None
159-
160-
def _gen_outfilename(self):
161-
_, name , _ = split_filename(self.inputs.in_file)
162-
return name + '_tracked.tck'
163160

164161
class DiffusionTensorStreamlineTrackInputSpec(StreamlineTrackInputSpec):
165162
gradient_encoding_file = File(exists=True, argstr='-grad %s', mandatory=True, position=-2,

0 commit comments

Comments
 (0)