Skip to content

Commit dfc8453

Browse files
author
Erik Ziegler
committed
Updated CHANGES, removed genfile, added docstrings, updated tests for DTK and MRtrix
1 parent b24be40 commit dfc8453

File tree

8 files changed

+46
-22
lines changed

8 files changed

+46
-22
lines changed

CHANGES

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
Next Release
22
============
33

4+
* ENH: New Diffusion Toolkit interface: TrackMerge
5+
* ENH: New MRtrix interface: FilterTracks
46
* ENH: New FSL interface: EpiReg
57
* ENH: New Freesurfer interface: Tkregister2 (for conversion of fsl style matrices to freesurfer format)
68
* ENH: New FSL interfaces: WarpPoints, WarpPointsToStd.

nipype/interfaces/diffusion_toolkit/postproc.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,23 @@ class SplineFilterOutputSpec(TraitedSpec):
2424
smoothed_track_file = File(exists=True)
2525

2626
class SplineFilter(CommandLine):
27+
"""
28+
Smoothes TrackVis track files with a B-Spline filter.
29+
30+
Helps remove redundant track points and segments
31+
(thus reducing the size of the track file) and also
32+
make tracks nicely smoothed. It will NOT change the
33+
quality of the tracks or lose any original information.
34+
35+
Example
36+
-------
37+
38+
>>> import nipype.interfaces.diffusion_toolkit as dtk
39+
>>> filt = dtk.SplineFilter()
40+
>>> filt.inputs.track_file = 'tracks.trk'
41+
>>> filt.inputs.step_length = 0.5
42+
>>> filt.run() # doctest: +SKIP
43+
"""
2744
input_spec=SplineFilterInputSpec
2845
output_spec=SplineFilterOutputSpec
2946

@@ -43,6 +60,25 @@ class TrackMergeOutputSpec(TraitedSpec):
4360
track_file = File(exists=True)
4461

4562
class TrackMerge(CommandLine):
63+
"""
64+
Merges several TrackVis track files into a single track
65+
file.
66+
67+
An id type property tag is added to each track in the
68+
newly merged file, with each unique id representing where
69+
the track was originally from. When the merged file is
70+
loaded in TrackVis, a property filter will show up in
71+
Track Property panel. Users can adjust that to distinguish
72+
and sub-group tracks by its id (origin).
73+
74+
Example
75+
-------
76+
77+
>>> import nipype.interfaces.diffusion_toolkit as dtk
78+
>>> mrg = dtk.TrackMerge()
79+
>>> mrg.inputs.track_files = ['track1.trk','track2.trk']
80+
>>> mrg.run() # doctest: +SKIP
81+
"""
4682
input_spec=TrackMergeInputSpec
4783
output_spec=TrackMergeOutputSpec
4884

nipype/interfaces/mrtrix/tests/test_auto_FilterTracks.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,10 @@ def test_FilterTracks_inputs():
4343
),
4444
no_mask_interpolation=dict(argstr='-nomaskinterp',
4545
),
46-
out_filename=dict(argstr='%s',
47-
genfile=True,
46+
out_file=dict(argstr='%s',
47+
hash_files=False,
48+
name_source=['in_file'],
49+
name_template='%s_filt',
4850
position=-1,
4951
),
5052
quiet=dict(argstr='-quiet',

nipype/interfaces/mrtrix/tracking.py

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@ class FilterTracksInputSpec(CommandLineInputSpec):
3030
minimum_tract_length = traits.Float(argstr='-minlength %s', units='mm',
3131
desc="Sets the minimum length of any track in millimeters (default is 10 mm).")
3232

33-
out_filename = File(genfile=True, argstr='%s', position=-1, desc='Output filtered track filename')
33+
34+
out_file = File(argstr='%s', position=-1, desc='Output filtered track filename',
35+
name_source=['in_file'], hash_files=False, name_template='%s_filt')
36+
3437
no_mask_interpolation = traits.Bool(argstr='-nomaskinterp', desc="Turns off trilinear interpolation of mask images.")
3538
invert = traits.Bool(argstr='-invert', desc="invert the matching process, so that tracks that would" \
3639
"otherwise have been included are now excluded and vice-versa.")
@@ -60,25 +63,6 @@ class FilterTracks(CommandLine):
6063
input_spec=FilterTracksInputSpec
6164
output_spec=FilterTracksOutputSpec
6265

63-
def _list_outputs(self):
64-
outputs = self.output_spec().get()
65-
outputs['out_file'] = op.abspath(self._gen_outfilename())
66-
return outputs
67-
68-
def _gen_filename(self, name):
69-
if name is 'out_filename':
70-
return self._gen_outfilename()
71-
else:
72-
return None
73-
74-
def _gen_outfilename(self):
75-
if isdefined(self.inputs.out_filename):
76-
path, name , _ = split_filename(self.inputs.out_filename)
77-
return op.join(path, name + '.tck')
78-
else:
79-
_, name , _ = split_filename(self.inputs.in_file)
80-
return op.abspath(name + '_filt.tck')
81-
8266

8367
class Tracks2ProbInputSpec(CommandLineInputSpec):
8468
in_file = File(exists=True, argstr='%s', mandatory=True, position=-2,

nipype/testing/data/track1.trk

Whitespace-only changes.

nipype/testing/data/track2.trk

Whitespace-only changes.

nipype/testing/data/tracks.tck

Whitespace-only changes.

nipype/testing/data/tracks.trk

Whitespace-only changes.

0 commit comments

Comments
 (0)