Skip to content

Commit 4ddbd05

Browse files
committed
Add 5ttgen interface
1 parent a5c6164 commit 4ddbd05

File tree

5 files changed

+95
-4
lines changed

5 files changed

+95
-4
lines changed

nipype/interfaces/mrtrix3/__init__.py

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

5-
from utils import Mesh2PVE
5+
from utils import Mesh2PVE, Generate5tt
66
from preprocess import ResponseSD, ACTPrepareFSL
77
from tracking import Tractography
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# AUTO-GENERATED by tools/checkspecs.py - DO NOT EDIT
2+
from nipype.testing import assert_equal
3+
from nipype.interfaces.mrtrix3.utils import Generate5tt
4+
5+
def test_Generate5tt_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_fast=dict(argstr='%s',
15+
mandatory=True,
16+
position=-3,
17+
),
18+
in_first=dict(argstr='%s',
19+
position=-2,
20+
),
21+
out_file=dict(argstr='%s',
22+
mandatory=True,
23+
position=-1,
24+
usedefault=True,
25+
),
26+
terminal_output=dict(nohash=True,
27+
),
28+
)
29+
inputs = Generate5tt.input_spec()
30+
31+
for key, metadata in input_map.items():
32+
for metakey, value in metadata.items():
33+
yield assert_equal, getattr(inputs.traits()[key], metakey), value
34+
35+
def test_Generate5tt_outputs():
36+
output_map = dict(out_file=dict(),
37+
)
38+
outputs = Generate5tt.output_spec()
39+
40+
for key, metadata in output_map.items():
41+
for metakey, value in metadata.items():
42+
yield assert_equal, getattr(outputs.traits()[key], metakey), value
43+

nipype/interfaces/mrtrix3/tracking.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ class TractographyInputSpec(CommandLineInputSpec):
9595
desc=('track from the seed point in one direction only '
9696
'(default is to track in both directions)'))
9797
init_dir = traits.Tuple(
98-
traits.Float, traits.Float, traits.Float,
98+
traits.Float, traits.Float, traits.Float,
9999
argstr='-initdirection %f,%f,%f',
100100
desc=('specify an initial direction for the tracking (this '
101101
'should be supplied as a vector of 3 comma-separated values'))

nipype/interfaces/mrtrix3/utils.py

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
import os.path as op
1616

1717
from nipype.interfaces.base import (
18-
CommandLineInputSpec, CommandLine, traits, TraitedSpec, File)
18+
CommandLineInputSpec, CommandLine, traits, TraitedSpec, File,
19+
InputMultiPath)
1920

2021
from nipype.utils.filemanip import split_filename
2122
from nipype.interfaces.traits_extension import isdefined
@@ -55,7 +56,7 @@ class Mesh2PVE(CommandLine):
5556
>>> m2p.inputs.in_first = 'T1.nii.gz'
5657
>>> m2p.cmdline # doctest: +ELLIPSIS
5758
'mesh2pve -first T1.nii.gz surf1.vtk dwi.mif mesh2volume.nii.gz'
58-
>>> resp.run() # doctest: +SKIP
59+
>>> m2p.run() # doctest: +SKIP
5960
"""
6061

6162
_cmd = 'mesh2pve'
@@ -66,3 +67,50 @@ def _list_outputs(self):
6667
outputs = self.output_spec().get()
6768
outputs['out_file'] = op.abspath(self.inputs.out_file)
6869
return outputs
70+
71+
72+
class Generate5ttInputSpec(CommandLineInputSpec):
73+
in_fast = InputMultiPath(
74+
File(exists=True), argstr='%s', mandatory=True, position=-3,
75+
desc='list of PVE images from FAST')
76+
in_first = File(
77+
exists=True, argstr='%s', position=-2,
78+
desc='combined segmentation file from FIRST')
79+
out_file = File(
80+
'act-5tt.mif', argstr='%s', mandatory=True, position=-1,
81+
usedefault=True, desc='name of output file')
82+
83+
84+
class Generate5ttOutputSpec(TraitedSpec):
85+
out_file = File(exists=True, desc='segmentation for ACT in 5tt format')
86+
87+
88+
class Generate5tt(CommandLine):
89+
90+
"""
91+
Concatenate segmentation results from FSL FAST and FIRST into the 5TT
92+
format required for ACT
93+
94+
95+
Example
96+
-------
97+
98+
>>> import nipype.interfaces.mrtrix3 as mrt
99+
>>> seg = mrt.Generate5tt()
100+
>>> seg.inputs.in_fast = ['tpm_00.nii.gz',
101+
... 'tpm_01.nii.gz', 'tpm_02.nii.gz']
102+
>>> seg.inputs.in_first = 'first_merged.nii.gz'
103+
>>> seg.cmdline # doctest: +ELLIPSIS
104+
'5ttgen tpm_00.nii.gz tpm_01.nii.gz tpm_02.nii.gz first_merged.nii.gz\
105+
act-5tt.mif'
106+
>>> seg.run() # doctest: +SKIP
107+
"""
108+
109+
_cmd = '5ttgen'
110+
input_spec = Generate5ttInputSpec
111+
output_spec = Generate5ttOutputSpec
112+
113+
def _list_outputs(self):
114+
outputs = self.output_spec().get()
115+
outputs['out_file'] = op.abspath(self.inputs.out_file)
116+
return outputs

nipype/testing/data/first_merged.nii.gz

Whitespace-only changes.

0 commit comments

Comments
 (0)