Skip to content

Commit 8ba033c

Browse files
committed
add tck2vtk
1 parent 9709872 commit 8ba033c

File tree

3 files changed

+98
-1
lines changed

3 files changed

+98
-1
lines changed

nipype/interfaces/mrtrix3/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
# vi: set ft=python sts=4 ts=4 sw=4 et:
33
# -*- coding: utf-8 -*-
44

5-
from utils import Mesh2PVE, Generate5tt, BrainMask, TensorMetrics, ComputeTDI
5+
from utils import (Mesh2PVE, Generate5tt, BrainMask, TensorMetrics,
6+
ComputeTDI, TCK2VTK)
67
from preprocess import ResponseSD, ACTPrepareFSL, ReplaceFSwithFIRST
78
from tracking import Tractography
89
from reconst import FitTensor, EstimateFOD
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# AUTO-GENERATED by tools/checkspecs.py - DO NOT EDIT
2+
from nipype.testing import assert_equal
3+
from nipype.interfaces.mrtrix3.utils import TCK2VTK
4+
5+
def test_TCK2VTK_inputs():
6+
input_map = dict(args=dict(argstr='%s',
7+
),
8+
environ=dict(nohash=True,
9+
usedefault=True,
10+
),
11+
ignore_exception=dict(nohash=True,
12+
usedefault=True,
13+
),
14+
in_file=dict(argstr='%s',
15+
mandatory=True,
16+
position=-2,
17+
),
18+
nthreads=dict(argstr='-nthreads %d',
19+
nohash=True,
20+
),
21+
out_file=dict(argstr='%s',
22+
position=-1,
23+
usedefault=True,
24+
),
25+
reference=dict(argstr='-image %s',
26+
),
27+
terminal_output=dict(nohash=True,
28+
),
29+
voxel=dict(argstr='-image %s',
30+
),
31+
)
32+
inputs = TCK2VTK.input_spec()
33+
34+
for key, metadata in input_map.items():
35+
for metakey, value in metadata.items():
36+
yield assert_equal, getattr(inputs.traits()[key], metakey), value
37+
38+
def test_TCK2VTK_outputs():
39+
output_map = dict(out_file=dict(),
40+
)
41+
outputs = TCK2VTK.output_spec()
42+
43+
for key, metadata in output_map.items():
44+
for metakey, value in metadata.items():
45+
yield assert_equal, getattr(outputs.traits()[key], metakey), value
46+

nipype/interfaces/mrtrix3/utils.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,3 +351,53 @@ def _list_outputs(self):
351351
outputs = self.output_spec().get()
352352
outputs['out_file'] = op.abspath(self.inputs.out_file)
353353
return outputs
354+
355+
356+
class TCK2VTKInputSpec(CommandLineInputSpec):
357+
in_file = File(exists=True, argstr='%s', mandatory=True, position=-2,
358+
desc='input tractography')
359+
out_file = File('tracked.vtk', argstr='%s', usedefault=True, position=-1,
360+
desc='output VTK file')
361+
reference = File(
362+
exists=True, argstr='-image %s', desc='if specified, the properties of'
363+
' this image will be used to convert track point positions from real '
364+
'(scanner) coordinates into image coordinates (in mm).')
365+
voxel = File(
366+
exists=True, argstr='-image %s', desc='if specified, the properties of'
367+
' this image will be used to convert track point positions from real '
368+
'(scanner) coordinates into image coordinates.')
369+
370+
nthreads = traits.Int(
371+
argstr='-nthreads %d', desc='number of threads. if zero, the number'
372+
' of available cpus will be used', nohash=True)
373+
374+
375+
class TCK2VTKOutputSpec(TraitedSpec):
376+
out_file = File(desc='output VTK file')
377+
378+
379+
class TCK2VTK(MRTrix3Base):
380+
381+
"""
382+
383+
384+
Example
385+
-------
386+
387+
>>> import nipype.interfaces.mrtrix3 as mrt
388+
>>> vtk = mrt.TCK2VTK()
389+
>>> vtk.inputs.in_file = 'tracked.tck'
390+
>>> vtk.inputs.reference = 'dwi.nii.gz'
391+
>>> vtk.cmdline # doctest: +ELLIPSIS
392+
'tck2vtk -image dwi.nii.gz tracked.tck tracked.vtk'
393+
>>> vtk.run() # doctest: +SKIP
394+
"""
395+
396+
_cmd = 'tck2vtk'
397+
input_spec = TCK2VTKInputSpec
398+
output_spec = TCK2VTKOutputSpec
399+
400+
def _list_outputs(self):
401+
outputs = self.output_spec().get()
402+
outputs['out_file'] = op.abspath(self.inputs.out_file)
403+
return outputs

0 commit comments

Comments
 (0)