|
14 | 14 | import os, os.path as op
|
15 | 15 | from nipype.interfaces.traits_extension import isdefined
|
16 | 16 |
|
| 17 | +class FilterTracksInputSpec(CommandLineInputSpec): |
| 18 | + in_file = File(exists=True, argstr='%s', mandatory=True, position=-2, |
| 19 | + desc='input tracks to be filtered') |
| 20 | + include_xor = ['include_file', 'include_spec'] |
| 21 | + include_file = File(exists=True, argstr='-include %s', desc='inclusion file', xor = include_xor) |
| 22 | + include_spec = traits.List(traits.Float, desc='inclusion specification in mm and radius (x y z r)', position=2, |
| 23 | + argstr='-include %s', minlen=4, maxlen=4, sep=',', units='mm', xor = include_xor) |
| 24 | + |
| 25 | + exclude_xor = ['exclude_file', 'exclude_spec'] |
| 26 | + exclude_file = File(exists=True, argstr='-exclude %s', desc='exclusion file', xor = exclude_xor) |
| 27 | + exclude_spec = traits.List(traits.Float, desc='exclusion specification in mm and radius (x y z r)', position=2, |
| 28 | + argstr='-exclude %s', minlen=4, maxlen=4, sep=',', units='mm', xor = exclude_xor) |
| 29 | + |
| 30 | + minimum_tract_length = traits.Float(argstr='-minlength %s', units='mm', |
| 31 | + desc="Sets the minimum length of any track in millimeters (default is 10 mm).") |
| 32 | + |
| 33 | + out_filename = File(genfile=True, argstr='%s', position=-1, desc='Output filtered track filename') |
| 34 | + no_mask_interpolation = traits.Bool(argstr='-nomaskinterp', desc="Turns off trilinear interpolation of mask images.") |
| 35 | + invert = traits.Bool(argstr='-invert', desc="invert the matching process, so that tracks that would" / |
| 36 | + "otherwise have been included are now excluded and vice-versa.") |
| 37 | + |
| 38 | + |
| 39 | + quiet = traits.Bool(argstr='-quiet', position=1, desc="Do not display information messages or progress status.") |
| 40 | + debug = traits.Bool(argstr='-debug', position=1, desc="Display debugging messages.") |
| 41 | + |
| 42 | +class FilterTracksOutputSpec(TraitedSpec): |
| 43 | + out_file = File(exists=True, desc='the output image of the major eigenvectors of the diffusion tensor image.') |
| 44 | + |
| 45 | +class FilterTracks(CommandLine): |
| 46 | + """ |
| 47 | + Use regions-of-interest to select a sub-set of tracks |
| 48 | + from a given track file. |
| 49 | +
|
| 50 | + Example |
| 51 | + ------- |
| 52 | +
|
| 53 | + >>> import nipype.interfaces.mrtrix as mrt |
| 54 | + >>> filt = mrt.FilterTracks() |
| 55 | + >>> filt.inputs.in_file = 'tracks.tck' |
| 56 | + >>> filt.run() # doctest: +SKIP |
| 57 | + """ |
| 58 | + |
| 59 | + _cmd = 'filter_tracks' |
| 60 | + input_spec=FilterTracksInputSpec |
| 61 | + output_spec=FilterTracksOutputSpec |
| 62 | + |
| 63 | + def _list_outputs(self): |
| 64 | + outputs = self.output_spec().get() |
| 65 | + outputs['out_file'] = self.inputs.out_filename |
| 66 | + if not isdefined(outputs['out_file']): |
| 67 | + outputs['out_file'] = op.abspath(self._gen_outfilename()) |
| 68 | + else: |
| 69 | + outputs['out_file'] = op.abspath(outputs['out_file']) |
| 70 | + return outputs |
| 71 | + |
| 72 | + def _gen_filename(self, name): |
| 73 | + if name is 'out_filename': |
| 74 | + return self._gen_outfilename() |
| 75 | + else: |
| 76 | + return None |
| 77 | + def _gen_outfilename(self): |
| 78 | + _, name , _ = split_filename(self.inputs.in_file) |
| 79 | + return name + '_filt.tck' |
| 80 | + |
| 81 | + |
17 | 82 | class Tracks2ProbInputSpec(CommandLineInputSpec):
|
18 | 83 | in_file = File(exists=True, argstr='%s', mandatory=True, position=-2,
|
19 | 84 | desc='tract file')
|
|
0 commit comments