Skip to content

Commit eb3ca37

Browse files
committed
Merge pull request #912 from juhuntenburg/enh/tkregister2
Enh/tkregister2
2 parents 7f35086 + dacd42d commit eb3ca37

File tree

4 files changed

+90
-1
lines changed

4 files changed

+90
-1
lines changed

CHANGES

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

4+
* ENH: New Freesurfer interface: Tkregister2 (for conversion of fsl style matrices to freesurfer format)
45
* ENH: New FSL interfaces: WarpPoints, WarpPointsToStd.
56
* ENH: New Freesurfer interface: MRIPretess
67
* ENH: New miscelaneous interface: AddCSVRow

nipype/interfaces/freesurfer/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212
from .utils import (SampleToSurface, SurfaceSmooth, SurfaceTransform, Surface2VolTransform,
1313
SurfaceSnapshots,ApplyMask, MRIsConvert, MRITessellate, MRIPretess,
1414
MRIMarchingCubes, SmoothTessellation, MakeAverageSubject,
15-
ExtractMainComponent)
15+
ExtractMainComponent, Tkregister2)
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# AUTO-GENERATED by tools/checkspecs.py - DO NOT EDIT
2+
from nipype.testing import assert_equal
3+
from nipype.interfaces.freesurfer.utils import Tkregister2
4+
5+
def test_Tkregister2_inputs():
6+
input_map = dict(args=dict(argstr='%s',
7+
),
8+
environ=dict(nohash=True,
9+
usedefault=True,
10+
),
11+
fsl_in_matrix=dict(argstr='--fsl %s',
12+
),
13+
ignore_exception=dict(nohash=True,
14+
usedefault=True,
15+
),
16+
moving_image=dict(argstr='--mov %s',
17+
mandatory=True,
18+
),
19+
noedit=dict(argstr='--noedit',
20+
usedefault=True,
21+
),
22+
reg_file=dict(argstr='--reg %s',
23+
mandatory=True,
24+
name_source='fsl',
25+
name_template='%s.dat',
26+
),
27+
subject_id=dict(argstr='--s %s',
28+
mandatory=True,
29+
),
30+
subjects_dir=dict(),
31+
terminal_output=dict(mandatory=True,
32+
nohash=True,
33+
),
34+
)
35+
inputs = Tkregister2.input_spec()
36+
37+
for key, metadata in input_map.items():
38+
for metakey, value in metadata.items():
39+
yield assert_equal, getattr(inputs.traits()[key], metakey), value
40+
41+
def test_Tkregister2_outputs():
42+
output_map = dict(reg_file=dict(),
43+
)
44+
outputs = Tkregister2.output_spec()
45+
46+
for key, metadata in output_map.items():
47+
for metakey, value in metadata.items():
48+
yield assert_equal, getattr(outputs.traits()[key], metakey), value
49+

nipype/interfaces/freesurfer/utils.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1188,3 +1188,42 @@ class ExtractMainComponent(CommandLine):
11881188
_cmd='mris_extract_main_component'
11891189
input_spec=ExtractMainComponentInputSpec
11901190
output_spec=ExtractMainComponentOutputSpec
1191+
1192+
1193+
class Tkregister2InputSpec(FSTraitedSpec):
1194+
moving_image = File(exists=True, mandatory=True, argstr="--mov %s",
1195+
desc='moving volume')
1196+
fsl_in_matrix = File(exists=True, argstr="--fsl %s",
1197+
desc='fsl-style registration input matrix')
1198+
subject_id = traits.String(argstr="--s %s", mandatory=True,
1199+
desc='freesurfer subject ID')
1200+
noedit = traits.Bool(True, argstr="--noedit", desc='do not open edit window (exit)', usedefault=True)
1201+
reg_file = File(name_template='%s.dat', name_source='fsl',
1202+
mandatory=True, argstr="--reg %s",
1203+
desc='freesurfer-style registration file')
1204+
1205+
1206+
class Tkregister2OutputSpec(TraitedSpec):
1207+
reg_file = File(exists=True, desc='freesurfer-style registration file')
1208+
1209+
1210+
class Tkregister2(FSCommand):
1211+
"""Use tkregister2 without the manual editing stage to convert
1212+
FSL-style registration matrix (.mat) to FreeSurfer-style registration matrix (.dat)
1213+
1214+
Examples
1215+
--------
1216+
1217+
>>> from nipype.interfaces.freesurfer import Tkregister2
1218+
>>> tk2 = Tkregister2(reg_file='register.dat')
1219+
>>> tk2.inputs.moving_image = 'epi.nii'
1220+
>>> tk2.inputs.fsl_in_matrix = 'flirt.mat'
1221+
>>> tk2.inputs.subject_id = 'test_subject'
1222+
>>> tk2.run() # doctest: +SKIP
1223+
"""
1224+
_cmd = "tkregister2"
1225+
input_spec = Tkregister2InputSpec
1226+
output_spec = Tkregister2OutputSpec
1227+
1228+
1229+

0 commit comments

Comments
 (0)