Skip to content

Commit 5ee8621

Browse files
committed
ENH: Add mris_expand interface
1 parent dfde970 commit 5ee8621

File tree

3 files changed

+86
-1
lines changed

3 files changed

+86
-1
lines changed

nipype/interfaces/freesurfer/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
MRIFill, MRIsInflate, Sphere, FixTopology, EulerNumber,
2222
RemoveIntersection, MakeSurfaces, Curvature, CurvatureStats,
2323
Jacobian, MRIsCalc, VolumeMask, ParcellationStats, Contrast,
24-
RelabelHypointensities, Aparc2Aseg, Apas2Aseg)
24+
RelabelHypointensities, Aparc2Aseg, Apas2Aseg, MRIsExpand)
2525
from .longitudinal import (RobustTemplate, FuseSegmentations)
2626
from .registration import (MPRtoMNI305, RegisterAVItoTalairach, EMRegister, Register,
2727
Paint)
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# AUTO-GENERATED by tools/checkspecs.py - DO NOT EDIT
2+
from __future__ import unicode_literals
3+
from ..utils import MRIsExpand
4+
5+
6+
def test_MRIsExpand_inputs():
7+
input_map = dict(args=dict(argstr='%s',
8+
),
9+
distance=dict(argstr='%g',
10+
mandatory=True,
11+
position=-2,
12+
),
13+
environ=dict(nohash=True,
14+
usedefault=True,
15+
),
16+
ignore_exception=dict(nohash=True,
17+
usedefault=True,
18+
),
19+
in_file=dict(argstr='%s',
20+
mandatory=True,
21+
position=-3,
22+
),
23+
out_file=dict(name_source='in_file',
24+
name_template='%s_expanded',
25+
position=-1,
26+
),
27+
subjects_dir=dict(),
28+
terminal_output=dict(nohash=True,
29+
),
30+
thickness=dict(argstr='-thickness',
31+
),
32+
)
33+
inputs = MRIsExpand.input_spec()
34+
35+
for key, metadata in list(input_map.items()):
36+
for metakey, value in list(metadata.items()):
37+
assert getattr(inputs.traits()[key], metakey) == value
38+
39+
40+
def test_MRIsExpand_outputs():
41+
output_map = dict(out_file=dict(),
42+
)
43+
outputs = MRIsExpand.output_spec()
44+
45+
for key, metadata in list(output_map.items()):
46+
for metakey, value in list(metadata.items()):
47+
assert getattr(outputs.traits()[key], metakey) == value

nipype/interfaces/freesurfer/utils.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2906,3 +2906,41 @@ def _list_outputs(self):
29062906
outputs = self._outputs().get()
29072907
outputs["out_file"] = os.path.abspath(self.inputs.out_file)
29082908
return outputs
2909+
2910+
2911+
class MRIsExpandInputSpec(FSTraitedSpec):
2912+
in_file = File(
2913+
exists=True, mandatory=True, argstr='%s', position=-3,
2914+
desc='Surface to expand')
2915+
distance = traits.Float(
2916+
mandatory=True, argstr='%g', position=-2,
2917+
desc='Distance in mm or fraction of cortical thickness')
2918+
out_file = File(
2919+
name_template='%s_expanded', name_source='in_file', position=-1,
2920+
desc='Output surface file')
2921+
thickness = traits.Bool(
2922+
argstr='-thickness',
2923+
desc='Expand by fraction of cortical thickness, not mm')
2924+
2925+
2926+
class MRIsExpandOutputSpec(TraitedSpec):
2927+
out_file = File(desc='Output surface file')
2928+
2929+
2930+
class MRIsExpand(FSCommand):
2931+
"""
2932+
Expands a surface (typically ?h.white) outwards while maintaining
2933+
smoothness and self-intersection constraints.
2934+
2935+
Examples
2936+
========
2937+
>>> from nipype.interfaces.freesurfer import MRIsExpand
2938+
>>> mris_expand = MRIsExpand(thickness=True, distance=0.5)
2939+
>>> mris_expand.inputs.in_file = 'lh.white'
2940+
>>> mris_expand.inputs.out_file = 'lh.graymid'
2941+
>>> mris_expand.cmdline # doctest: +ALLOW_UNICODE
2942+
'mris_expand -thickness lh.white 0.5 lh.graymid'
2943+
"""
2944+
_cmd = 'mris_expand'
2945+
input_spec = MRIsExpandInputSpec
2946+
output_spec = MRIsExpandOutputSpec

0 commit comments

Comments
 (0)