Skip to content

Commit 41ea062

Browse files
committed
New Freesurfer interface: MRIPretess
1 parent 9a16838 commit 41ea062

File tree

4 files changed

+132
-1
lines changed

4 files changed

+132
-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: MRIPretess
45
* ENH: New miscelaneous interface: AddCSVRow
56
* ENH: FUGUE interface has been refactored to use the name_template system, 3 examples
67
added to doctests, some bugs solved.

nipype/interfaces/freesurfer/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@
1010
from .model import (MRISPreproc, GLMFit, OneSampleTTest, Binarize, Concatenate,
1111
SegStats, Label2Vol, MS_LDA)
1212
from .utils import (SampleToSurface, SurfaceSmooth, SurfaceTransform, Surface2VolTransform,
13-
SurfaceSnapshots,ApplyMask, MRIsConvert, MRITessellate,
13+
SurfaceSnapshots,ApplyMask, MRIsConvert, MRITessellate, MRIPretess,
1414
MRIMarchingCubes, SmoothTessellation, MakeAverageSubject,
1515
ExtractMainComponent)
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# AUTO-GENERATED by tools/checkspecs.py - DO NOT EDIT
2+
from nipype.testing import assert_equal
3+
from nipype.interfaces.freesurfer.utils import MRIPretess
4+
5+
def test_MRIPretess_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_filled=dict(argstr='%s',
15+
mandatory=True,
16+
position=-4,
17+
),
18+
in_norm=dict(argstr='%s',
19+
mandatory=True,
20+
position=-2,
21+
),
22+
keep=dict(argstr='-keep',
23+
),
24+
label=dict(argstr='%s',
25+
mandatory=True,
26+
position=-3,
27+
usedefault=True,
28+
),
29+
nocorners=dict(argstr='-nocorners',
30+
),
31+
out_file=dict(argstr='%s',
32+
genfile=True,
33+
position=-1,
34+
),
35+
subjects_dir=dict(),
36+
terminal_output=dict(mandatory=True,
37+
nohash=True,
38+
),
39+
test=dict(argstr='-test',
40+
),
41+
)
42+
inputs = MRIPretess.input_spec()
43+
44+
for key, metadata in input_map.items():
45+
for metakey, value in metadata.items():
46+
yield assert_equal, getattr(inputs.traits()[key], metakey), value
47+
48+
def test_MRIPretess_outputs():
49+
output_map = dict(out_file=dict(),
50+
)
51+
outputs = MRIPretess.output_spec()
52+
53+
for key, metadata in output_map.items():
54+
for metakey, value in metadata.items():
55+
yield assert_equal, getattr(outputs.traits()[key], metakey), value
56+

nipype/interfaces/freesurfer/utils.py

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -923,6 +923,80 @@ def _gen_outfilename(self):
923923
_, name, ext = split_filename(self.inputs.in_file)
924924
return name + ext + '_' + str(self.inputs.label_value)
925925

926+
927+
class MRIPretessInputSpec(FSTraitedSpec):
928+
in_filled = File(exists=True, mandatory=True, position=-4, argstr='%s',
929+
desc=('filled volume, usually wm.mgz'))
930+
label = traits.Either(traits.Str('wm'), traits.Int(1), argstr='%s', default='wm',
931+
mandatory=True, usedefault=True, position=-3,
932+
desc=('label to be picked up, can be a Freesurfer\'s string like '
933+
'\'wm\' or a label value (e.g. 127 for rh or 255 for lh)'))
934+
in_norm = File(exists=True, mandatory=True, position=-2, argstr='%s',
935+
desc=('the normalized, brain-extracted T1w image. Usually norm.mgz'))
936+
out_file = File(position=-1, argstr='%s', genfile=True,
937+
desc=('the output file after mri_pretess.'))
938+
939+
940+
nocorners = traits.Bool(False, argstr='-nocorners', desc=('do not remove corner configurations'
941+
' in addition to edge ones.'))
942+
keep = traits.Bool(False, argstr='-keep', desc=('keep WM edits'))
943+
test = traits.Bool(False, argstr='-test', desc=('adds a voxel that should be removed by '
944+
'mri_pretess. The value of the voxel is set to that of an ON-edited WM, '
945+
'so it should be kept with -keep. The output will NOT be saved.'))
946+
947+
class MRIPretessOutputSpec(TraitedSpec):
948+
"""
949+
Uses Freesurfer's mri_tessellate to create surfaces by tessellating a given input volume
950+
"""
951+
out_file = File(exists=True, desc='output file after mri_pretess')
952+
953+
954+
class MRIPretess(FSCommand):
955+
"""
956+
Uses Freesurfer's mri_pretess to prepare volumes to be tessellated.
957+
958+
Description
959+
-----------
960+
961+
Changes white matter (WM) segmentation so that the neighbors of all
962+
voxels labeled as WM have a face in common - no edges or corners
963+
allowed.
964+
965+
Example
966+
-------
967+
968+
>>> import nipype.interfaces.freesurfer as fs
969+
>>> pretess = fs.MRIPretess()
970+
>>> pretess.inputs.in_filled = 'wm.mgz'
971+
>>> pretess.inputs.in_norm = 'norm.mgz'
972+
>>> pretess.inputs.nocorners = True
973+
>>> pretess.cmdline
974+
'mri_pretess -nocorners wm.mgz wm norm.mgz wm_pretesswm.mgz'
975+
>>> pretess.run() # doctest: +SKIP
976+
"""
977+
_cmd = 'mri_pretess'
978+
input_spec = MRIPretessInputSpec
979+
output_spec = MRIPretessOutputSpec
980+
981+
def _list_outputs(self):
982+
outputs = self.output_spec().get()
983+
outputs['out_file'] = os.path.abspath(self._gen_outfilename())
984+
return outputs
985+
986+
def _gen_filename(self, name):
987+
if name is 'out_file':
988+
return self._gen_outfilename()
989+
else:
990+
return None
991+
992+
def _gen_outfilename(self):
993+
if isdefined(self.inputs.out_file):
994+
return self.inputs.out_file
995+
else:
996+
_, name, ext = split_filename(self.inputs.in_filled)
997+
return name + '_pretess' + str(self.inputs.label) + ext
998+
999+
9261000
class MRIMarchingCubesInputSpec(FSTraitedSpec):
9271001
"""
9281002
Uses Freesurfer's mri_mc to create surfaces by tessellating a given input volume

0 commit comments

Comments
 (0)