Skip to content

Commit 657e124

Browse files
committed
fixed pull request issues:
wrapping Surface2VolTransform, -moved from preprocess.py to utils.py -improved input descriptions -renamed output suffix
1 parent 3f7253f commit 657e124

File tree

4 files changed

+62
-64
lines changed

4 files changed

+62
-64
lines changed

nipype/interfaces/afni/preprocess.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,8 +329,7 @@ class AutoTcorrelateInputSpec(AFNICommandInputSpec):
329329
argstr="-mask %s")
330330
mask_only_targets = traits.Bool(desc="use mask only on targets voxels",
331331
argstr="-mask_only_targets",
332-
xor=['mask_source'])
333-
argstr="-mask_only_targets")
332+
xor=['mask_source']))
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, Surface2VolTransform, 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 & 60 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,65 +1020,6 @@ def _gen_filename(self, name):
10211020
return self._get_outfile()
10221021
return None
10231022

1024-
class Surface2VolTransformInputSpec(FSTraitedSpec):
1025-
source_file = File(exists=True, argstr='--surfval %s',
1026-
copyfile=False, mandatory=True,
1027-
desc='This is the source of the surface values')
1028-
hemi = traits.Str(argstr='--hemi %s',desc='hemisphere of data')
1029-
transformed_file = File(desc='Output volume', argstr='--outvol %s', genfile=True)
1030-
reg_file = File(exists=True, argstr='--volreg %s',
1031-
mandatory=True,
1032-
desc='tkRAS-to-tkRAS matrix (tkregister2 format)')
1033-
template_file = File(exists=True, argstr='--template %s',
1034-
desc='Output template volume')
1035-
mkmask = traits.Bool(desc='make a mask instead of loading surfval', argstr='--mkmask')
1036-
vertexvol_file = File(desc='vertex map volume path id', argstr='--vtxvol %s', genfile=True)
1037-
surf_file = File(exists=True, argstr='--surf %s',desc='surfname (default is white)')
1038-
projfrac_file = File(exists=True, argstr='--projfrac %s',desc='thickness fraction')
1039-
subjects_dir = traits.Str(argstr='--sd %s',desc='freesurfer subjects directory defaults to $SUBJECTS_DIR')
1040-
identity = traits.Str(argstr='--identity %s',desc='use identity (must supply subject name)')
1041-
1042-
class Surface2VolTransformOutputSpec(TraitedSpec):
1043-
transformed_file = File(exists=True, desc='Path to output file if used normally')
1044-
vertexvol_file = File(desc='vertex map volume path id. Optional')
1045-
1046-
class Surface2VolTransform(FSCommand):
1047-
"""Use FreeSurfer mri_surf2vol to apply a transform.
1048-
1049-
Examples
1050-
--------
1051-
1052-
>>> from nipype.interfaces.freesurfer import Surface2VolTransform
1053-
>>> xfm2vol = Surface2VolTransform()
1054-
>>> xfm2vol.inputs.source_file = 'surface.nii'
1055-
>>> xfm2vol.inputs.reg_file = 'register.dat'
1056-
>>> xfm2vol.inputs.hemi = 'lh'
1057-
>>> xfm2vol.cmdline
1058-
'mri_surf2vol --volreg register.dat --surfval structural.nii --hemi lh'
1059-
1060-
"""
1061-
1062-
_cmd = 'mri_surf2vol'
1063-
input_spec = Surface2VolTransformInputSpec
1064-
output_spec = Surface2VolTransformOutputSpec
1065-
1066-
def _get_outfile(self):
1067-
outfile = self.inputs.transformed_file
1068-
if not isdefined(outfile):
1069-
outfile = self._gen_fname(self.inputs.source_file,
1070-
suffix='_xfm2vol')
1071-
return outfile
1072-
1073-
def _list_outputs(self):
1074-
outputs = self.output_spec().get()
1075-
outputs['transformed_file'] = self._get_outfile()
1076-
return outputs
1077-
1078-
def _gen_filename(self, name):
1079-
if name == 'transformed_file':
1080-
return self._get_outfile()
1081-
return None
1082-
10831023
class SmoothInputSpec(FSTraitedSpec):
10841024
in_file = File(exists=True, desc='source volume',
10851025
argstr='--i %s', mandatory=True)

nipype/interfaces/freesurfer/utils.py

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,65 @@ 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',desc='hemisphere of data')
390+
transformed_file = File(desc='Output volume', argstr='--outvol %s', genfile=True)
391+
reg_file = File(exists=True, argstr='--volreg %s',
392+
mandatory=True,
393+
desc='tkRAS-to-tkRAS matrix (tkregister2 format)'
394+
xor=['subject_id'])
395+
template_file = File(exists=True, argstr='--template %s',
396+
desc='Output template volume')
397+
mkmask = traits.Bool(desc='make a mask instead of loading surface values', argstr='--mkmask')
398+
vertexvol_file = File(desc='Path name of the vertex output volume, which is the same as output volume except that the value of each voxel is the vertex-id that is mapped to that voxel.', argstr='--vtxvol %s', genfile=True)
399+
surf_file = File(exists=True, argstr='--surf %s',desc='surfname (default is white)')
400+
projfrac_file = traits.Float(exists=True, argstr='--projfrac %s',desc='thickness fraction')
401+
subjects_dir = traits.Str(argstr='--sd %s',desc='freesurfer subjects directory defaults to $SUBJECTS_DIR')
402+
subject_id = traits.Str(argstr='--identity %s',desc='subject id', xor=['reg_file'])
403+
404+
class Surface2VolTransformOutputSpec(TraitedSpec):
405+
transformed_file = File(exists=True, desc='Path to output file if used normally')
406+
vertexvol_file = File(desc='vertex map volume path id. Optional')
407+
408+
class Surface2VolTransform(FSCommand):
409+
"""Use FreeSurfer mri_surf2vol to apply a transform.
410+
411+
Examples
412+
--------
413+
414+
>>> from nipype.interfaces.freesurfer import Surface2VolTransform
415+
>>> xfm2vol = Surface2VolTransform()
416+
>>> xfm2vol.inputs.source_file = 'surface.nii'
417+
>>> xfm2vol.inputs.reg_file = 'register.dat'
418+
>>> xfm2vol.inputs.hemi = 'lh'
419+
>>> xfm2vol.cmdline
420+
'mri_surf2vol --volreg register.dat --surfval surface.nii --hemi lh'
421+
422+
"""
423+
424+
_cmd = 'mri_surf2vol'
425+
input_spec = Surface2VolTransformInputSpec
426+
output_spec = Surface2VolTransformOutputSpec
427+
428+
def _get_outfile(self):
429+
outfile = self.inputs.transformed_file
430+
if not isdefined(outfile):
431+
outfile = self._gen_fname(self.inputs.source_file,
432+
suffix='_asVol')
433+
return outfile
434+
435+
def _list_outputs(self):
436+
outputs = self.output_spec().get()
437+
outputs['transformed_file'] = self._get_outfile()
438+
return outputs
439+
440+
def _gen_filename(self, name):
441+
if name == 'transformed_file':
442+
return self._get_outfile()
443+
return None
385444

386445
class ApplyMaskInputSpec(FSTraitedSpec):
387446

0 commit comments

Comments
 (0)