Skip to content

Commit 0ff79f2

Browse files
committed
Merge branch 'master' into enh/NewEPIArtifactCorrections
Conflicts: CHANGES
2 parents b9b122f + 785f6dd commit 0ff79f2

File tree

9 files changed

+111
-16
lines changed

9 files changed

+111
-16
lines changed

CHANGES

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

44
* ENH: Deep revision of workflows for correction of dMRI artifacts. New dmri_preprocessing
55
example.
6+
* ENH: New Freesurfer interface: Tkregister2 (for conversion of fsl style matrices to freesurfer format)
67
* ENH: New FSL interfaces: WarpPoints, WarpPointsToStd.
78
* ENH: New Freesurfer interface: MRIPretess
89
* 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)

nipype/interfaces/freesurfer/preprocess.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -807,7 +807,7 @@ class BBRegisterInputSpec(FSTraitedSpec):
807807
init = traits.Enum('spm', 'fsl', 'header', argstr='--init-%s',
808808
mandatory=True, xor=['init_reg_file'],
809809
desc='initialize registration spm, fsl, header')
810-
init_reg_file = File(exists=True,
810+
init_reg_file = File(exists=True, argstr='--init-reg %s',
811811
desc='existing registration file',
812812
xor=['init'], mandatory=True)
813813
contrast_type = traits.Enum('t1', 't2', argstr='--%s',

nipype/interfaces/freesurfer/tests/test_auto_BBRegister.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ def test_BBRegister_inputs():
2020
mandatory=True,
2121
xor=['init_reg_file'],
2222
),
23-
init_reg_file=dict(mandatory=True,
23+
init_reg_file=dict(argstr='--init-reg %s',
24+
mandatory=True,
2425
xor=['init'],
2526
),
2627
intermediate_file=dict(argstr='--int %s',
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+

nipype/interfaces/fsl/preprocess.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -941,18 +941,18 @@ def write_config(self, configfile):
941941

942942
class ApplyWarpInputSpec(FSLCommandInputSpec):
943943
in_file = File(exists=True, argstr='--in=%s',
944-
mandatory=True,
944+
mandatory=True, position=0,
945945
desc='image to be warped')
946-
out_file = File(argstr='--out=%s', genfile=True,
946+
out_file = File(argstr='--out=%s', genfile=True, position=2,
947947
desc='output filename', hash_files=False)
948948
ref_file = File(exists=True, argstr='--ref=%s',
949-
mandatory=True,
949+
mandatory=True, position=1,
950950
desc='reference image')
951951
field_file = File(exists=True, argstr='--warp=%s',
952952
desc='file containing warp field')
953953
abswarp = traits.Bool(argstr='--abs', xor=['relwarp'],
954954
desc="treat warp field as absolute: x' = w(x)")
955-
relwarp = traits.Bool(argstr='--rel', xor=['abswarp'],
955+
relwarp = traits.Bool(argstr='--rel', xor=['abswarp'], position=-1,
956956
desc="treat warp field as relative: x' = x + w(x)")
957957
datatype = traits.Enum('char', 'short', 'int', 'float', 'double',
958958
argstr='--datatype=%s',
@@ -969,7 +969,7 @@ class ApplyWarpInputSpec(FSLCommandInputSpec):
969969
mask_file = File(exists=True, argstr='--mask=%s',
970970
desc='filename for mask image (in reference space)')
971971
interp = traits.Enum(
972-
'nn', 'trilinear', 'sinc', 'spline', argstr='--interp=%s',
972+
'nn', 'trilinear', 'sinc', 'spline', argstr='--interp=%s', position=-2,
973973
desc='interpolation method')
974974

975975

nipype/interfaces/fsl/tests/test_auto_ApplyWarp.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,17 @@ def test_ApplyWarp_inputs():
2020
),
2121
in_file=dict(argstr='--in=%s',
2222
mandatory=True,
23+
position=0,
2324
),
2425
interp=dict(argstr='--interp=%s',
26+
position=-2,
2527
),
2628
mask_file=dict(argstr='--mask=%s',
2729
),
2830
out_file=dict(argstr='--out=%s',
2931
genfile=True,
3032
hash_files=False,
33+
position=2,
3134
),
3235
output_type=dict(),
3336
postmat=dict(argstr='--postmat=%s',
@@ -36,8 +39,10 @@ def test_ApplyWarp_inputs():
3639
),
3740
ref_file=dict(argstr='--ref=%s',
3841
mandatory=True,
42+
position=1,
3943
),
4044
relwarp=dict(argstr='--rel',
45+
position=-1,
4146
xor=['abswarp'],
4247
),
4348
superlevel=dict(argstr='--superlevel=%s',

nipype/interfaces/fsl/tests/test_preprocess.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -455,17 +455,17 @@ def test_applywarp():
455455
field_file = reffile,
456456
**{name : settings[1]})
457457
if name == 'out_file':
458-
realcmd = 'applywarp --warp=%s '\
459-
'--in=%s --out=%s '\
460-
'--ref=%s'%(reffile, infile,
458+
realcmd = 'applywarp --in=%s '\
459+
'--ref=%s --out=%s '\
460+
'--warp=%s'%(infile, reffile,
461461
settings[1],reffile)
462462
else:
463463
outfile = awarp._gen_fname(infile, suffix='_warp')
464-
realcmd = 'applywarp --warp=%s '\
465-
'--in=%s --out=%s '\
466-
'%s --ref=%s'%(reffile, infile,
467-
outfile, settings[0],
468-
reffile)
464+
realcmd = 'applywarp --in=%s '\
465+
'--ref=%s --out=%s '\
466+
'--warp=%s %s'%(infile, reffile,
467+
outfile, reffile,
468+
settings[0])
469469
yield assert_equal, awarp.cmdline, realcmd
470470

471471
awarp = fsl.ApplyWarp(in_file = infile,

0 commit comments

Comments
 (0)