Skip to content

Commit 496ec95

Browse files
committed
Merge branch 'enh/mri_surf2vol'
2 parents bac6597 + 89ae174 commit 496ec95

File tree

6 files changed

+117
-5
lines changed

6 files changed

+117
-5
lines changed

nipype/interfaces/afni/preprocess.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,6 @@ class AutoTcorrelateInputSpec(AFNICommandInputSpec):
330330
mask_only_targets = traits.Bool(desc="use mask only on targets voxels",
331331
argstr="-mask_only_targets",
332332
xor=['mask_source'])
333-
334333
mask_source = File(exists=True,
335334
desc="mask for source voxels",
336335
argstr="-mask_source %s",

nipype/interfaces/freesurfer/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44

55
from .base import Info, FSCommand
66
from .preprocess import (ParseDICOMDir, UnpackSDICOMDir, MRIConvert, Resample,
7-
ReconAll, BBRegister, ApplyVolTransform, Smooth,
7+
ReconAll, BBRegister, ApplyVolTransform,Smooth,
88
DICOMConvert, RobustRegister, FitMSParams,
99
SynthesizeFLASH)
1010
from .model import (MRISPreproc, GLMFit, OneSampleTTest, Binarize, Concatenate,
1111
SegStats, Label2Vol, MS_LDA)
12-
from .utils import (SampleToSurface, SurfaceSmooth, SurfaceTransform,
12+
from .utils import (SampleToSurface, SurfaceSmooth, SurfaceTransform, Surface2VolTransform,
1313
SurfaceSnapshots,ApplyMask, MRIsConvert, MRITessellate,
1414
MRIMarchingCubes, SmoothTessellation, MakeAverageSubject,
1515
ExtractMainComponent)

nipype/interfaces/freesurfer/preprocess.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -970,7 +970,6 @@ class ApplyVolTransformInputSpec(FSTraitedSpec):
970970
'non-linear morph to resample the input '
971971
'volume. To be used by --m3z.'))
972972

973-
974973
class ApplyVolTransformOutputSpec(TraitedSpec):
975974
transformed_file = File(exists=True, desc='Path to output file if used normally')
976975

@@ -1021,7 +1020,6 @@ def _gen_filename(self, name):
10211020
return self._get_outfile()
10221021
return None
10231022

1024-
10251023
class SmoothInputSpec(FSTraitedSpec):
10261024
in_file = File(exists=True, desc='source volume',
10271025
argstr='--i %s', mandatory=True)
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# AUTO-GENERATED by tools/checkspecs.py - DO NOT EDIT
2+
from nipype.testing import assert_equal
3+
from nipype.interfaces.freesurfer.utils import Surface2VolTransform
4+
def test_Surface2VolTransform_inputs():
5+
input_map = dict(ignore_exception=dict(nohash=True,
6+
usedefault=True,
7+
),
8+
transformed_file=dict(name_source=['source_file'],
9+
hash_files=False,
10+
name_template='%s_asVol.nii',
11+
argstr='--outvol %s',
12+
),
13+
hemi=dict(mandatory=True,
14+
argstr='--hemi %s',
15+
),
16+
template_file=dict(argstr='--template %s',
17+
),
18+
subject_id=dict(xor=['reg_file'],
19+
argstr='--identity %s',
20+
),
21+
args=dict(argstr='%s',
22+
),
23+
surf_name=dict(argstr='--surf %s',
24+
exists=True,
25+
),
26+
vertexvol_file=dict(name_source=['source_file'],
27+
hash_files=False,
28+
name_template='%s_asVol_vertex.nii',
29+
argstr='--vtxvol %s',
30+
),
31+
reg_file=dict(mandatory=True,
32+
argstr='--volreg %s',
33+
xor=['subject_id'],
34+
),
35+
environ=dict(nohash=True,
36+
usedefault=True,
37+
),
38+
subjects_dir=dict(argstr='--sd %s',
39+
),
40+
source_file=dict(copyfile=False,
41+
mandatory=True,
42+
argstr='--surfval %s',
43+
),
44+
projfrac=dict(argstr='--projfrac %s',
45+
exists=True,
46+
),
47+
mkmask=dict(argstr='--mkmask',
48+
),
49+
terminal_output=dict(mandatory=True,
50+
nohash=True,
51+
),
52+
)
53+
inputs = Surface2VolTransform.input_spec()
54+
55+
for key, metadata in input_map.items():
56+
for metakey, value in metadata.items():
57+
yield assert_equal, getattr(inputs.traits()[key], metakey), value
58+
def test_Surface2VolTransform_outputs():
59+
output_map = dict(transformed_file=dict(),
60+
vertexvol_file=dict(),
61+
)
62+
outputs = Surface2VolTransform.output_spec()
63+
64+
for key, metadata in output_map.items():
65+
for metakey, value in metadata.items():
66+
yield assert_equal, getattr(outputs.traits()[key], metakey), value

nipype/interfaces/freesurfer/utils.py

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,55 @@ def _gen_filename(self, name):
382382
return self._list_outputs()[name]
383383
return None
384384

385+
class Surface2VolTransformInputSpec(FSTraitedSpec):
386+
source_file = File(exists=True, argstr='--surfval %s',
387+
copyfile=False, mandatory=True,
388+
desc='This is the source of the surface values')
389+
hemi = traits.Str(argstr='--hemi %s', mandatory=True, desc='hemisphere of data')
390+
transformed_file = File(name_template="%s_asVol.nii", desc='Output volume', argstr='--outvol %s',
391+
name_source=['source_file'], hash_files=False)
392+
reg_file = File(exists=True, argstr='--volreg %s',
393+
mandatory=True,
394+
desc='tkRAS-to-tkRAS matrix (tkregister2 format)',
395+
xor=['subject_id'])
396+
template_file = File(exists=True, argstr='--template %s',
397+
desc='Output template volume')
398+
mkmask = traits.Bool(desc='make a mask instead of loading surface values', argstr='--mkmask')
399+
vertexvol_file = File(name_template="%s_asVol_vertex.nii", desc='Path name of the vertex output '
400+
'volume, which is the same as output volume except that the value of each '
401+
'voxel is the vertex-id that is mapped to that voxel.',
402+
argstr='--vtxvol %s', name_source=['source_file'], hash_files=False)
403+
surf_name = traits.Str(exists=True, argstr='--surf %s',desc='surfname (default is white)')
404+
projfrac = traits.Float(exists=True, argstr='--projfrac %s',desc='thickness fraction')
405+
subjects_dir = traits.Str(argstr='--sd %s',desc='freesurfer subjects directory defaults to $SUBJECTS_DIR')
406+
subject_id = traits.Str(argstr='--identity %s',desc='subject id', xor=['reg_file'])
407+
408+
class Surface2VolTransformOutputSpec(TraitedSpec):
409+
transformed_file = File(exists=True, desc='Path to output file if used normally')
410+
vertexvol_file = File(desc='vertex map volume path id. Optional')
411+
412+
class Surface2VolTransform(FSCommand):
413+
"""Use FreeSurfer mri_surf2vol to apply a transform.
414+
415+
Examples
416+
--------
417+
418+
>>> from nipype.interfaces.freesurfer import Surface2VolTransform
419+
>>> xfm2vol = Surface2VolTransform()
420+
>>> xfm2vol.inputs.source_file = 'lh.cope1.mgz'
421+
>>> xfm2vol.inputs.reg_file = 'register.mat'
422+
>>> xfm2vol.inputs.hemi = 'lh'
423+
>>> xfm2vol.inputs.template_file = 'cope1.nii.gz'
424+
>>> xfm2vol.inputs.subjects_dir = '.'
425+
>>> xfm2vol.cmdline
426+
'mri_surf2vol --hemi lh --volreg register.mat --surfval lh.cope1.mgz --sd . --template cope1.nii.gz --outvol lh.cope1_asVol.nii --vtxvol lh.cope1_asVol_vertex.nii'
427+
>>> res = xfm2vol.run()# doctest: +SKIP
428+
429+
"""
430+
431+
_cmd = 'mri_surf2vol'
432+
input_spec = Surface2VolTransformInputSpec
433+
output_spec = Surface2VolTransformOutputSpec
385434

386435
class ApplyMaskInputSpec(FSTraitedSpec):
387436

nipype/testing/data/register.mat

Whitespace-only changes.

0 commit comments

Comments
 (0)