Skip to content

Commit 1a73d68

Browse files
committed
Merge remote-tracking branch 'origin/pr/831'
Conflicts: CHANGES
2 parents d8fd8dd + 6580436 commit 1a73d68

File tree

9 files changed

+261
-17
lines changed

9 files changed

+261
-17
lines changed

CHANGES

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
Next Release
22
============
33

4-
* API: Interfaces to external packages are no longer available in the top-level ``nipype`` namespace, and must be imported directly (e.g. ``from nipype.interfaces import fsl``).
5-
* ENH: nipy.utils.Similarity has been deprecated by algorithms.metrics.Similarity
6-
which is an extension of the former to allow 4D images.
4+
* API: Interfaces to external packages are no longer available in the top-level
5+
``nipype`` namespace, and must be imported directly (e.g.
6+
``from nipype.interfaces import fsl``).
7+
* ENH: New FSL interface: ProbTrackX2
78
* ENH: New ANTs interface: ApplyTransformsToPoints
89
* ENH: New metrics group in algorithms. Now Distance, Overlap, and FuzzyOverlap
910
are found in nipype.algorithms.metrics instead of misc
@@ -33,7 +34,8 @@ Release 0.9.0 (December 20, 2013)
3334
* ENH: new tools for defining workflows: JoinNode, synchronize and itersource
3435
* ENH: W3C PROV support with optional RDF export built into Nipype
3536
* ENH: Added support for Simple Linux Utility Resource Management (SLURM)
36-
* ENH: AFNI interfaces refactor, prefix, suffix are replaced by "flexible_%s_templates"
37+
* ENH: AFNI interfaces refactor, prefix, suffix are replaced by
38+
"flexible_%s_templates"
3739
* ENH: New SPM interfaces:
3840
- spm.ResliceToReference,
3941
- spm.DicomImport

nipype/interfaces/fsl/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121
from .epi import (PrepareFieldmap, TOPUP, ApplyTOPUP, Eddy, EPIDeWarp,
2222
SigLoss, EddyCorrect)
2323

24-
from .dti import (BEDPOSTX, DTIFit, ProbTrackX, VecReg, ProjThresh,
25-
FindTheBiggest, DistanceMap, TractSkeleton, XFibres,
26-
MakeDyadicVectors)
24+
from .dti import (BEDPOSTX, DTIFit, ProbTrackX, ProbTrackX2,
25+
VecReg, ProjThresh, FindTheBiggest, DistanceMap,
26+
TractSkeleton, XFibres, MakeDyadicVectors)
2727
from .maths import (ChangeDataType, Threshold, MeanImage, ApplyMask,
2828
IsotropicSmooth, TemporalFilter, DilateImage, ErodeImage,
2929
SpatialFilter, UnaryMaths, BinaryMaths, MultiImageMaths)

nipype/interfaces/fsl/dti.py

Lines changed: 100 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ def _list_outputs(self):
230230
return outputs
231231

232232

233-
class ProbTrackXInputSpec(FSLCommandInputSpec):
233+
class ProbTrackXBaseInputSpec(FSLCommandInputSpec):
234234
thsamples = InputMultiPath(File(exists=True), mandatory=True)
235235
phsamples = InputMultiPath(File(exists=True), mandatory=True)
236236
fsamples = InputMultiPath(File(exists=True), mandatory=True)
@@ -243,21 +243,13 @@ class ProbTrackXInputSpec(FSLCommandInputSpec):
243243
desc='seed volume(s), or voxel(s)' +
244244
'or freesurfer label file',
245245
argstr='--seed=%s', mandatory=True)
246-
mode = traits.Enum("simple", "two_mask_symm", "seedmask",
247-
desc='options: simple (single seed voxel), seedmask (mask of seed voxels), '
248-
+ 'twomask_symm (two bet binary masks) ',
249-
argstr='--mode=%s', genfile=True)
250246
target_masks = InputMultiPath(File(exits=True), desc='list of target masks - ' +
251247
'required for seeds_to_targets classification', argstr='--targetmasks=%s')
252-
mask2 = File(exists=True, desc='second bet binary mask (in diffusion space) in twomask_symm mode',
253-
argstr='--mask2=%s')
254248
waypoints = File(exists=True, desc='waypoint mask or ascii list of waypoint masks - ' +
255249
'only keep paths going through ALL the masks', argstr='--waypoints=%s')
256250
network = traits.Bool(desc='activate network mode - only keep paths going through ' +
257251
'at least one seed mask (required if multiple seed masks)',
258252
argstr='--network')
259-
mesh = File(exists=True, desc='Freesurfer-type surface descriptor (in ascii format)',
260-
argstr='--mesh=%s')
261253
seed_ref = File(exists=True, desc='reference vol to define seed space in ' +
262254
'simple mode - diffusion space assumed if absent',
263255
argstr='--seedref=%s')
@@ -307,6 +299,15 @@ class ProbTrackXInputSpec(FSLCommandInputSpec):
307299
"Level 2 is required to output particle files.",
308300
argstr="--verbose=%d")
309301

302+
class ProbTrackXInputSpec(ProbTrackXBaseInputSpec):
303+
mode = traits.Enum("simple", "two_mask_symm", "seedmask",
304+
desc='options: simple (single seed voxel), seedmask (mask of seed voxels), '
305+
+ 'twomask_symm (two bet binary masks) ',
306+
argstr='--mode=%s', genfile=True)
307+
mask2 = File(exists=True, desc='second bet binary mask (in diffusion space) in twomask_symm mode',
308+
argstr='--mask2=%s')
309+
mesh = File(exists=True, desc='Freesurfer-type surface descriptor (in ascii format)',
310+
argstr='--mesh=%s')
310311

311312
class ProbTrackXOutputSpec(TraitedSpec):
312313
log = File(exists=True, desc='path/name of a text record of the command that was run')
@@ -320,7 +321,6 @@ class ProbTrackXOutputSpec(TraitedSpec):
320321
'all of the tract samples. Generated only if ' +
321322
'verbose is set to 2')
322323

323-
324324
class ProbTrackX(FSLCommand):
325325
""" Use FSL probtrackx for tractography on bedpostx results
326326
@@ -435,6 +435,96 @@ def _gen_filename(self, name):
435435
else:
436436
return "seedmask"
437437

438+
class ProbTrackX2InputSpec(ProbTrackXBaseInputSpec):
439+
simple = traits.Bool(desc='rack from a list of voxels (seed must be a ASCII list of coordinates)',
440+
usedefault=False, argstr='--simple')
441+
fopd = File(exists=True, desc='Other mask for binning tract distribution',
442+
argstr='--fopd=%s')
443+
waycond = traits.Enum("OR", "AND", argstr='--waycond=%s',
444+
desc='Waypoint condition. Either "AND" (default) or "OR"')
445+
wayorder = traits.Bool(desc='Reject streamlines that do not hit waypoints in given order. ' +
446+
'Only valid if waycond=AND', argstr='--wayorder')
447+
onewaycondition = traits.Bool(desc='Apply waypoint conditions to each half tract separately',
448+
argstr='--onewaycondition')
449+
omatrix1 = traits.Bool(desc='Output matrix1 - SeedToSeed Connectivity',
450+
argstr='--omatrix1')
451+
distthresh1 = traits.Float(argstr='--distthresh1=%.3f',
452+
desc='Discards samples (in matrix1) shorter than this threshold ' +
453+
'(in mm - default=0)')
454+
omatrix2 = traits.Bool(desc='Output matrix2 - SeedToLowResMask', argstr='--omatrix2', requires=['target2'])
455+
target2 = File(exists=True, desc='Low resolution binary brain mask for storing ' +
456+
'connectivity distribution in matrix2 mode', argstr='--target2=%s')
457+
omatrix3 = traits.Bool(desc='Output matrix3 (NxN connectivity matrix)', argstr='--omatrix3',
458+
requires=['target3', 'lrtarget3'])
459+
target3 = File(exists=True, desc='Mask used for NxN connectivity matrix ' +
460+
'(or Nxn if lrtarget3 is set)', argstr='--target3=%s')
461+
lrtarget3 = File(exists=True, desc='Column-space mask used for Nxn connectivity matrix',
462+
argstr='--lrtarget3=%s')
463+
distthresh3 = traits.Float(argstr='--distthresh3=%.3f',
464+
desc='Discards samples (in matrix3) shorter than this threshold ' +
465+
'(in mm - default=0)')
466+
omatrix4 = traits.Bool(desc='Output matrix4 - DtiMaskToSeed (special Oxford Sparse Format)',
467+
argstr='--omatrix4')
468+
colmask4 = File(exists=True, desc='Mask for columns of matrix4 (default=seed mask)',
469+
argstr='--colmask4=%s')
470+
target4 = File(exists=True, desc='Brain mask in DTI space', argstr='--target4=%s')
471+
meshspace = traits.Enum("caret", "freesurfer", "first", "vox", argstr='--meshspace=%s',
472+
desc='Mesh reference space - either "caret" (default) or ' +
473+
'"freesurfer" or "first" or "vox"')
474+
475+
476+
class ProbTrackX2OutputSpec(ProbTrackXOutputSpec):
477+
network_matrix = File(exists=True, desc='the network matrix generated by --omatrix1 option')
478+
matrix1_dot = File(exists=True, desc='Output matrix1.dot - SeedToSeed Connectivity')
479+
lookup_tractspace = File(exists=True, desc='lookup_tractspace generated by --omatrix2 option')
480+
matrix2_dot = File(exists=True, desc='Output matrix2.dot - SeedToLowResMask')
481+
matrix3_dot = File(exists=True, desc='Output matrix3 - NxN connectivity matrix')
482+
483+
484+
class ProbTrackX2(ProbTrackX):
485+
""" Use FSL probtrackx2 for tractography on bedpostx results
486+
487+
Examples
488+
--------
489+
490+
>>> from nipype.interfaces import fsl
491+
>>> pbx2 = fsl.ProbTrackX2()
492+
>>> pbx2.inputs.seed = 'seed_source.nii.gz'
493+
>>> pbx2.inputs.thsamples = 'merged_th1samples.nii.gz'
494+
>>> pbx2.inputs.fsamples = 'merged_f1samples.nii.gz'
495+
>>> pbx2.inputs.phsamples = 'merged_ph1samples.nii.gz'
496+
>>> pbx2.inputs.mask = 'nodif_brain_mask.nii.gz'
497+
>>> pbx2.inputs.out_dir = '.'
498+
>>> pbx2.inputs.n_samples = 3
499+
>>> pbx2.inputs.n_steps = 10
500+
>>> pbx2.cmdline
501+
'probtrackx2 --forcedir -m nodif_brain_mask.nii.gz --nsamples=3 --nsteps=10 --opd --dir=. --samples=merged --seed=seed_source.nii.gz'
502+
"""
503+
_cmd = 'probtrackx2'
504+
input_spec = ProbTrackX2InputSpec
505+
output_spec = ProbTrackX2OutputSpec
506+
507+
def _list_outputs(self):
508+
outputs = super(ProbTrackX2, self)._list_outputs()
509+
510+
if not isdefined(self.inputs.out_dir):
511+
out_dir = os.getcwd()
512+
else:
513+
out_dir = self.inputs.out_dir
514+
515+
if isdefined(self.inputs.omatrix1):
516+
outputs['network_matrix'] = os.path.abspath(os.path.join(out_dir, 'fdt_network_matrix'))
517+
outputs['matrix1_dot'] = os.path.abspath(os.path.join(out_dir, 'fdt_matrix1.dot'))
518+
519+
if isdefined(self.inputs.omatrix2):
520+
outputs['lookup_tractspace'] = \
521+
os.path.abspath(os.path.join(out_dir, 'lookup_tractspace_fdt_matrix2.nii.gz'))
522+
outputs['matrix2_dot'] = os.path.abspath(os.path.join(out_dir, 'fdt_matrix2.dot'))
523+
524+
if isdefined(self.inputs.omatrix3):
525+
outputs['matrix3_dot'] = os.path.abspath(os.path.join(out_dir, 'fdt_matrix3.dot'))
526+
return outputs
527+
438528

439529
class VecRegInputSpec(FSLCommandInputSpec):
440530
in_file = File(exists=True, argstr='-i %s', desc='filename for input vector or tensor field',
Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
# AUTO-GENERATED by tools/checkspecs.py - DO NOT EDIT
2+
from nipype.testing import assert_equal
3+
from nipype.interfaces.fsl.dti import ProbTrackX2
4+
5+
def test_ProbTrackX2_inputs():
6+
input_map = dict(args=dict(argstr='%s',
7+
),
8+
avoid_mp=dict(argstr='--avoid=%s',
9+
),
10+
c_thresh=dict(argstr='--cthr=%.3f',
11+
),
12+
colmask4=dict(argstr='--colmask4=%s',
13+
),
14+
correct_path_distribution=dict(argstr='--pd',
15+
),
16+
dist_thresh=dict(argstr='--distthresh=%.3f',
17+
),
18+
distthresh1=dict(argstr='--distthresh1=%.3f',
19+
),
20+
distthresh3=dict(argstr='--distthresh3=%.3f',
21+
),
22+
environ=dict(nohash=True,
23+
usedefault=True,
24+
),
25+
fibst=dict(argstr='--fibst=%d',
26+
),
27+
fopd=dict(argstr='--fopd=%s',
28+
),
29+
force_dir=dict(argstr='--forcedir',
30+
usedefault=True,
31+
),
32+
fsamples=dict(mandatory=True,
33+
),
34+
ignore_exception=dict(nohash=True,
35+
usedefault=True,
36+
),
37+
inv_xfm=dict(argstr='--invxfm=%s',
38+
),
39+
loop_check=dict(argstr='--loopcheck',
40+
),
41+
lrtarget3=dict(argstr='--lrtarget3=%s',
42+
),
43+
mask=dict(argstr='-m %s',
44+
mandatory=True,
45+
),
46+
meshspace=dict(argstr='--meshspace=%s',
47+
),
48+
mod_euler=dict(argstr='--modeuler',
49+
),
50+
n_samples=dict(argstr='--nsamples=%d',
51+
usedefault=True,
52+
),
53+
n_steps=dict(argstr='--nsteps=%d',
54+
),
55+
network=dict(argstr='--network',
56+
),
57+
omatrix1=dict(argstr='--omatrix1',
58+
),
59+
omatrix2=dict(argstr='--omatrix2',
60+
requires=['target2'],
61+
),
62+
omatrix3=dict(argstr='--omatrix3',
63+
requires=['target3', 'lrtarget3'],
64+
),
65+
omatrix4=dict(argstr='--omatrix4',
66+
),
67+
onewaycondition=dict(argstr='--onewaycondition',
68+
),
69+
opd=dict(argstr='--opd',
70+
usedefault=True,
71+
),
72+
os2t=dict(argstr='--os2t',
73+
),
74+
out_dir=dict(argstr='--dir=%s',
75+
genfile=True,
76+
),
77+
output_type=dict(),
78+
phsamples=dict(mandatory=True,
79+
),
80+
rand_fib=dict(argstr='--randfib=%d',
81+
),
82+
random_seed=dict(argstr='--rseed',
83+
),
84+
s2tastext=dict(argstr='--s2tastext',
85+
),
86+
sample_random_points=dict(argstr='--sampvox',
87+
),
88+
samples_base_name=dict(argstr='--samples=%s',
89+
usedefault=True,
90+
),
91+
seed=dict(argstr='--seed=%s',
92+
mandatory=True,
93+
),
94+
seed_ref=dict(argstr='--seedref=%s',
95+
),
96+
simple=dict(argstr='--simple',
97+
usedefault=False,
98+
),
99+
step_length=dict(argstr='--steplength=%.3f',
100+
),
101+
stop_mask=dict(argstr='--stop=%s',
102+
),
103+
target2=dict(argstr='--target2=%s',
104+
),
105+
target3=dict(argstr='--target3=%s',
106+
),
107+
target4=dict(argstr='--target4=%s',
108+
),
109+
target_masks=dict(argstr='--targetmasks=%s',
110+
),
111+
terminal_output=dict(mandatory=True,
112+
nohash=True,
113+
),
114+
thsamples=dict(mandatory=True,
115+
),
116+
use_anisotropy=dict(argstr='--usef',
117+
),
118+
verbose=dict(argstr='--verbose=%d',
119+
),
120+
waycond=dict(argstr='--waycond=%s',
121+
),
122+
wayorder=dict(argstr='--wayorder',
123+
),
124+
waypoints=dict(argstr='--waypoints=%s',
125+
),
126+
xfm=dict(argstr='--xfm=%s',
127+
),
128+
)
129+
inputs = ProbTrackX2.input_spec()
130+
131+
for key, metadata in input_map.items():
132+
for metakey, value in metadata.items():
133+
yield assert_equal, getattr(inputs.traits()[key], metakey), value
134+
135+
def test_ProbTrackX2_outputs():
136+
output_map = dict(fdt_paths=dict(),
137+
log=dict(),
138+
lookup_tractspace=dict(),
139+
matrix1_dot=dict(),
140+
matrix2_dot=dict(),
141+
matrix3_dot=dict(),
142+
network_matrix=dict(),
143+
particle_files=dict(),
144+
targets=dict(),
145+
way_total=dict(),
146+
)
147+
outputs = ProbTrackX2.output_spec()
148+
149+
for key, metadata in output_map.items():
150+
for metakey, value in metadata.items():
151+
yield assert_equal, getattr(outputs.traits()[key], metakey), value
152+

nipype/testing/data/merged_f1samples.nii.gz

Whitespace-only changes.

nipype/testing/data/merged_ph1samples.nii.gz

Whitespace-only changes.

nipype/testing/data/merged_th1samples.nii.gz

Whitespace-only changes.

nipype/testing/data/nodif_brain_mask.nii.gz

Whitespace-only changes.

nipype/testing/data/seed_source.nii.gz

Whitespace-only changes.

0 commit comments

Comments
 (0)