Skip to content

Commit c397662

Browse files
committed
Fix doctest and make vars more explicit
1 parent 39715f2 commit c397662

File tree

2 files changed

+21
-23
lines changed

2 files changed

+21
-23
lines changed

nipype/interfaces/spm/base.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,8 @@ def _format_arg(self, opt, spec, val):
375375
"""Convert input to appropriate format for SPM."""
376376
if spec.is_trait_type(traits.Bool):
377377
return int(val)
378+
elif spec.is_trait_type(traits.Tuple):
379+
return list(val)
378380
else:
379381
return val
380382

nipype/interfaces/spm/preprocess.py

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -33,35 +33,35 @@
3333
class FieldMapInputSpec(SPMCommandInputSpec):
3434
jobtype = traits.Enum('calculatevdm', 'applyvdm', usedefault=True,
3535
desc='one of: calculatevdm, applyvdm')
36-
phase = File(mandatory=True, exists=True, copyfile=False,
36+
phase_file = File(mandatory=True, exists=True, copyfile=False,
3737
field='subj.data.presubphasemag.phase',
3838
desc='presubstracted phase file')
39-
magnitude = File(mandatory=True, exists=True, copyfile=False,
39+
magnitude_file = File(mandatory=True, exists=True, copyfile=False,
4040
field='subj.data.presubphasemag.magnitude',
4141
desc='presubstracted magnitude file')
42-
et = traits.Tuple(traits.Float, traits.Float, mandatory=True,
42+
echo_times = traits.Tuple(traits.Float, traits.Float, mandatory=True,
4343
field='subj.defaults.defaultsval.et',
4444
desc='short and long echo times')
4545
maskbrain = traits.Bool(True, usedefault=True,
4646
field='subj.defaults.defaultsval.maskbrain',
4747
desc='masking or no masking of the brain')
48-
blipdir = traits.Enum(1, -1, mandatory=True,
48+
blip_direction = traits.Enum(1, -1, mandatory=True,
4949
field='subj.defaults.defaultsval.blipdir',
5050
desc='polarity of the phase-encode blips')
51-
tert = traits.Float(mandatory=True,
51+
total_readout_time = traits.Float(mandatory=True,
5252
field='subj.defaults.defaultsval.tert',
5353
desc='total EPI readout time')
5454
epifm = traits.Bool(False, usedefault=True,
5555
field='subj.defaults.defaultsval.epifm',
5656
desc='epi-based field map');
57-
ajm = traits.Bool(False, usedefault=True,
57+
jacobian_modulation = traits.Bool(False, usedefault=True,
5858
field='subj.defaults.defaultsval.ajm',
5959
desc='jacobian modulation');
6060
# Unwarping defaults parameters
6161
method = traits.Enum('Mark3D', 'Mark2D', 'Huttonish', usedefault=True,
6262
desc='One of: Mark3D, Mark2D, Huttonish',
6363
field='subj.defaults.defaultsval.uflags.method');
64-
fwhm = traits.Range(low=0, value=10, usedefault=True,
64+
unwarp_fwhm = traits.Range(low=0, value=10, usedefault=True,
6565
field='subj.defaults.defaultsval.uflags.fwhm',
6666
desc='gaussian smoothing kernel width');
6767
pad = traits.Range(low=0, value=0, usedefault=True,
@@ -74,7 +74,7 @@ class FieldMapInputSpec(SPMCommandInputSpec):
7474
template = File(copyfile=False, exists=True,
7575
field='subj.defaults.defaultsval.mflags.template',
7676
desc='template image for brain masking');
77-
fwhm = traits.Range(low=0, value=5, usedefault=True,
77+
mask_fwhm = traits.Range(low=0, value=5, usedefault=True,
7878
field='subj.defaults.defaultsval.mflags.fwhm',
7979
desc='gaussian smoothing kernel width');
8080
nerode = traits.Range(low=0, value=2, usedefault=True,
@@ -90,7 +90,7 @@ class FieldMapInputSpec(SPMCommandInputSpec):
9090
field='subj.defaults.defaultsval.mflags.reg',
9191
desc='regularization value used in the segmentation');
9292
# EPI unwarping for quality check
93-
epi = File(copyfile=False, exists=True, mandatory=True,
93+
epi_file = File(copyfile=False, exists=True, mandatory=True,
9494
field='subj.session.epi',
9595
desc='EPI to unwarp');
9696
matchvdm = traits.Bool(True, usedefault=True,
@@ -102,7 +102,7 @@ class FieldMapInputSpec(SPMCommandInputSpec):
102102
writeunwarped = traits.Bool(False, usedefault=True,
103103
field='subj.writeunwarped',
104104
desc='write unwarped EPI');
105-
anat = File(copyfile=False, exists=True,
105+
anat_file = File(copyfile=False, exists=True,
106106
field='subj.anat',
107107
desc='anatomical image for comparison');
108108
matchanat = traits.Bool(True, usedefault=True,
@@ -127,12 +127,12 @@ class FieldMap(SPMCommand):
127127
--------
128128
>>> from nipype.interfaces.spm import FieldMap
129129
>>> fm = FieldMap()
130-
>>> fm.inputs.phase = 'phase.nii'
131-
>>> fm.inputs.magnitude = 'magnitude.nii'
132-
>>> fm.inputs.et = [5.19, 7.65]
133-
>>> fm.inputs.blipdir = 1
134-
>>> fm.inputs.tert = 15.6
135-
>>> fm.inputs.epi = 'bold.nii'
130+
>>> fm.inputs.phase_file = 'phase.nii'
131+
>>> fm.inputs.magnitude_file = 'magnitude.nii'
132+
>>> fm.inputs.echo_times = (5.19, 7.65)
133+
>>> fm.inputs.blip_direction = 1
134+
>>> fm.inputs.total_readout_time = 15.6
135+
>>> fm.inputs.epi_file = 'bold.nii'
136136
>>> fm.run() # doctest: +SKIP
137137
138138
"""
@@ -145,7 +145,7 @@ class FieldMap(SPMCommand):
145145
def _format_arg(self, opt, spec, val):
146146
"""Convert input to appropriate format for spm
147147
"""
148-
if opt in ['phase', 'magnitude', 'anat', 'epi']:
148+
if opt in ['phase_file', 'magnitude_file', 'anat_file', 'epi_file']:
149149
return scans_for_fname(filename_to_list(val))
150150

151151
return super(FieldMap, self)._format_arg(opt, spec, val)
@@ -154,17 +154,13 @@ def _parse_inputs(self):
154154
"""validate spm fieldmap options if set to None ignore
155155
"""
156156
einputs = super(FieldMap, self)._parse_inputs()
157-
jobtype = self.inputs.jobtype
158-
return [{'%s' % (jobtype): einputs[0]}]
157+
return [{self.inputs.jobtype: einputs[0]}]
159158

160159
def _list_outputs(self):
161160
outputs = self._outputs().get()
162161
jobtype = self.inputs.jobtype
163162
if jobtype == "calculatevdm":
164-
outputs['vdm'] = []
165-
for phase in filename_to_list(self.inputs.phase):
166-
outputs['vdm'].append(fname_presuffix(phase, prefix='vdm5_sc'))
167-
outputs['vdm'] = list_to_filename(outputs['vdm'])
163+
outputs['vdm'] = fname_presuffix(self.inputs.phase_file, prefix='vdm5_sc')
168164

169165
return outputs
170166

0 commit comments

Comments
 (0)