Skip to content

Commit 3d74360

Browse files
committed
ProbtrackX2 interfaces, fixes #792
1 parent cba8e41 commit 3d74360

File tree

1 file changed

+82
-10
lines changed

1 file changed

+82
-10
lines changed

nipype/interfaces/fsl/dti.py

Lines changed: 82 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,78 @@ 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+
_cmd = 'probtrackx2'
486+
input_spec = ProbTrackX2InputSpec
487+
output_spec = ProbTrackX2OutputSpec
488+
489+
def _list_outputs(self):
490+
outputs = super(ProbTrackX2, self)._list_outputs()
491+
492+
if not isdefined(self.inputs.out_dir):
493+
out_dir = os.getcwd()
494+
else:
495+
out_dir = self.inputs.out_dir
496+
497+
if isdefined(self.inputs.omatrix1):
498+
outputs['network_matrix'] = os.path.abspath(os.path.join(out_dir, 'fdt_network_matrix'))
499+
outputs['matrix1_dot'] = os.path.abspath(os.path.join(out_dir, 'fdt_matrix1.dot'))
500+
501+
if isdefined(self.inputs.omatrix2):
502+
outputs['lookup_tractspace'] = \
503+
os.path.abspath(os.path.join(out_dir, 'lookup_tractspace_fdt_matrix2.nii.gz'))
504+
outputs['matrix2_dot'] = os.path.abspath(os.path.join(out_dir, 'fdt_matrix2.dot'))
505+
506+
if isdefined(self.inputs.omatrix3):
507+
outputs['matrix3_dot'] = os.path.abspath(os.path.join(out_dir, 'fdt_matrix3.dot'))
508+
return outputs
509+
438510

439511
class VecRegInputSpec(FSLCommandInputSpec):
440512
in_file = File(exists=True, argstr='-i %s', desc='filename for input vector or tensor field',

0 commit comments

Comments
 (0)