Skip to content

Commit 78e3eee

Browse files
author
bpinsard
committed
pep8
1 parent 1ccd02d commit 78e3eee

File tree

1 file changed

+99
-87
lines changed

1 file changed

+99
-87
lines changed

nipype/interfaces/spm/preprocess.py

Lines changed: 99 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -1092,117 +1092,117 @@ class VBMSegmentInputSpec(SPMCommandInputSpec):
10921092

10931093
tissues = File(
10941094
exists=True, field='estwrite.tpm',
1095-
desc = 'tissue probability map')
1095+
desc='tissue probability map')
10961096
gaussians_per_class = traits.Tuple(
1097-
(2,2,2,3,4,2),*([traits.Int()]*6),
1097+
(2, 2, 2, 3, 4, 2), *([traits.Int()]*6),
10981098
usedefault=True,
10991099
desc='number of gaussians for each tissue class')
11001100
bias_regularization = traits.Enum(
11011101
0.0001,
11021102
(0, 0.00001, 0.0001, 0.001, 0.01, 0.1, 1, 10),
11031103
field='estwrite.opts.biasreg', usedefault=True,
11041104
desc='no(0) - extremely heavy (10)')
1105-
1105+
11061106
bias_fwhm = traits.Enum(
11071107
60,
1108-
(30, 40, 50, 60, 70 , 80, 90, 100, 110, 120, 130, 'Inf'),
1108+
(30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 'Inf'),
11091109
field='estwrite.opts.biasfwhm',
1110-
usedefault=True,
1110+
usedefault=True,
11111111
desc='FWHM of Gaussian smoothness of bias')
11121112
sampling_distance = traits.Float(
11131113
3, usedefault=True, field='estwrite.opts.samp',
11141114
desc='Sampling distance on data for parameter estimation')
11151115
warping_regularization = traits.Float(
11161116
4, usedefault=True, field='estwrite.opts.warpreg',
11171117
desc='Controls balance between parameters and data')
1118-
1119-
spatial_normalization = traits.Enum('high',
1120-
'low',usedefault=True,)
1118+
1119+
spatial_normalization = traits.Enum('high',
1120+
'low', usedefault=True,)
11211121
dartel_template = File(
11221122
exists=True,
11231123
field='estwrite.extopts.dartelwarp.normhigh.darteltpm')
11241124
use_sanlm_denoising_filter = traits.Range(
1125-
0,2,2,usedefault=True,field='estwrite.extopts.sanlm',
1125+
0, 2, 2, usedefault=True, field='estwrite.extopts.sanlm',
11261126
desc="0=No denoising, 1=denoising,2=denoising multi-threaded")
11271127
mrf_weighting = traits.Float(
1128-
0.15,usedefault=True,field='estwrite.extopts.mrf')
1128+
0.15, usedefault=True, field='estwrite.extopts.mrf')
11291129
cleanup_partitions = traits.Int(
1130-
1,usedefault=True,field='estwrite.extopts.cleanup',
1130+
1, usedefault=True, field='estwrite.extopts.cleanup',
11311131
desc="0=None,1=light,2=thorough")
11321132
display_results = traits.Bool(
11331133
True, usedefault=True, field='estwrite.extopts.print')
1134-
1134+
11351135
gm_native = traits.Bool(
1136-
False,usedefault=True,field='estwrite.output.GM.native',)
1136+
False, usedefault=True, field='estwrite.output.GM.native',)
11371137
gm_normalized = traits.Bool(
1138-
False,usedefault=True,field='estwrite.output.GM.warped',)
1138+
False, usedefault=True, field='estwrite.output.GM.warped',)
11391139
gm_modulated_normalized = traits.Range(
1140-
0,2,2,usedefault=True,field='estwrite.output.GM.modulated',
1140+
0, 2, 2, usedefault=True, field='estwrite.output.GM.modulated',
11411141
desc='0=none,1=affine+non-linear(SPM8 default),2=non-linear only')
11421142
gm_dartel = traits.Range(
1143-
0,2,0,usedefault=True,field='estwrite.output.GM.dartel',
1143+
0, 2, 0, usedefault=True, field='estwrite.output.GM.dartel',
11441144
desc="0=None,1=rigid(SPM8 default),2=affine")
11451145

11461146
wm_native = traits.Bool(
1147-
False,usedefault=True,field='estwrite.output.WM.native',)
1147+
False, usedefault=True, field='estwrite.output.WM.native',)
11481148
wm_normalized = traits.Bool(
1149-
False,usedefault=True,field='estwrite.output.WM.warped',)
1149+
False, usedefault=True, field='estwrite.output.WM.warped',)
11501150
wm_modulated_normalized = traits.Range(
1151-
0,2,2,usedefault=True,field='estwrite.output.WM.modulated',
1151+
0, 2, 2, usedefault=True, field='estwrite.output.WM.modulated',
11521152
desc='0=none,1=affine+non-linear(SPM8 default),2=non-linear only')
11531153
wm_dartel = traits.Range(
1154-
0,2,0,usedefault=True,field='estwrite.output.WM.dartel',
1154+
0, 2, 0, usedefault=True, field='estwrite.output.WM.dartel',
11551155
desc="0=None,1=rigid(SPM8 default),2=affine")
11561156

11571157
csf_native = traits.Bool(
1158-
False,usedefault=True,field='estwrite.output.CSF.native',)
1158+
False, usedefault=True, field='estwrite.output.CSF.native',)
11591159
csf_normalized = traits.Bool(
1160-
False,usedefault=True,field='estwrite.output.CSF.warped',)
1160+
False, usedefault=True, field='estwrite.output.CSF.warped',)
11611161
csf_modulated_normalized = traits.Range(
1162-
0,2,2,usedefault=True,field='estwrite.output.CSF.modulated',
1162+
0, 2, 2, usedefault=True, field='estwrite.output.CSF.modulated',
11631163
desc='0=none,1=affine+non-linear(SPM8 default),2=non-linear only')
11641164
csf_dartel = traits.Range(
1165-
0,2,0,usedefault=True,field='estwrite.output.CSF.dartel',
1165+
0, 2, 0, usedefault=True, field='estwrite.output.CSF.dartel',
11661166
desc="0=None,1=rigid(SPM8 default),2=affine")
11671167

11681168
bias_corrected_native = traits.Bool(
1169-
False,usedefault=True,field='estwrite.output.bias.native',)
1169+
False, usedefault=True, field='estwrite.output.bias.native',)
11701170
bias_corrected_normalized = traits.Bool(
1171-
True,usedefault=True,field='estwrite.output.bias.warped',)
1172-
bias_corrected_affine= traits.Bool(
1173-
False,usedefault=True,field='estwrite.output.bias.affine',)
1171+
True, usedefault=True, field='estwrite.output.bias.warped',)
1172+
bias_corrected_affine = traits.Bool(
1173+
False, usedefault=True, field='estwrite.output.bias.affine',)
11741174

11751175
pve_label_native = traits.Bool(
1176-
False,usedefault=True,field='estwrite.output.label.native')
1176+
False, usedefault=True, field='estwrite.output.label.native')
11771177
pve_label_normalized = traits.Bool(
1178-
False,usedefault=True,field='estwrite.output.label.warped')
1179-
pve_label_dartel = traits.Range(
1180-
0,2,0,usedefault=True,field='estwrite.output.label.dartel',
1178+
False, usedefault=True, field='estwrite.output.label.warped')
1179+
pve_label_dartel = traits.Range(
1180+
0, 2, 0, usedefault=True, field='estwrite.output.label.dartel',
11811181
desc="0=None,1=rigid(SPM8 default),2=affine")
11821182

11831183
jacobian_determinant = traits.Bool(
1184-
False,usedefault=True,field='estwrite.jacobian.warped')
1184+
False, usedefault=True, field='estwrite.jacobian.warped')
11851185

11861186
deformation_field = traits.Tuple(
1187-
(0,0),traits.Bool,traits.Bool,usedefault=True,
1187+
(0, 0), traits.Bool, traits.Bool, usedefault=True,
11881188
field='estwrite.output.warps',
11891189
desc='forward and inverse field')
11901190

11911191
class VBMSegmentOuputSpec(TraitedSpec):
1192-
1193-
native_class_images = traits.List(traits.List(File(exists=True)),
1192+
1193+
native_class_images = traits.List(traits.List(File(exists=True)),
11941194
desc='native space probability maps')
1195-
dartel_input_images = traits.List(traits.List(File(exists=True)),
1195+
dartel_input_images = traits.List(traits.List(File(exists=True)),
11961196
desc='dartel imported class images')
11971197
normalized_class_images = traits.List(traits.List(File(exists=True)),
11981198
desc='normalized class images')
1199-
modulated_class_images = traits.List(traits.List(File(exists=True)),
1199+
modulated_class_images = traits.List(traits.List(File(exists=True)),
12001200
desc='modulated+normalized class images')
12011201
transformation_mat = OutputMultiPath(File(exists=True),
12021202
desc='Normalization transformation')
12031203

12041204
bias_corrected_images = OutputMultiPath(
1205-
File(exists=True),
1205+
File(exists=True),
12061206
desc='bias corrected images')
12071207
normalized_bias_corrected_images = OutputMultiPath(
12081208
File(exists=True),
@@ -1211,7 +1211,7 @@ class VBMSegmentOuputSpec(TraitedSpec):
12111211
pve_label_native_images = OutputMultiPath(File(exists=True))
12121212
pve_label_normalized_images = OutputMultiPath(File(exists=True))
12131213
pve_label_registered_images = OutputMultiPath(File(exists=True))
1214-
1214+
12151215
forward_deformation_field = OutputMultiPath(File(exists=True))
12161216
inverse_deformation_field = OutputMultiPath(File(exists=True))
12171217

@@ -1223,102 +1223,114 @@ class VBMSegment(SPMCommand):
12231223

12241224
_jobtype = 'tools'
12251225
_jobname = 'vbm8'
1226-
1226+
12271227
def _list_outputs(self):
12281228
outputs = self._outputs().get()
1229-
1229+
12301230
do_dartel = self.inputs.spatial_normalization
12311231
dartel_px = ''
12321232
if do_dartel:
12331233
dartel_px = 'r'
1234-
1235-
outputs['native_class_images'] = [[],[],[]]
1236-
outputs['dartel_input_images'] = [[],[],[]]
1237-
outputs['normalized_class_images'] = [[],[],[]]
1238-
outputs['modulated_class_images'] = [[],[],[]]
1234+
1235+
outputs['native_class_images'] = [[], [], []]
1236+
outputs['dartel_input_images'] = [[], [], []]
1237+
outputs['normalized_class_images'] = [[], [], []]
1238+
outputs['modulated_class_images'] = [[], [], []]
12391239

12401240
outputs['transformation_mat'] = []
12411241

12421242
outputs['bias_corrected_images'] = []
12431243
outputs['normalized_bias_corrected_images'] = []
12441244

12451245
outputs['inverse_deformation_field'] = []
1246-
outputs['forward_deformation_field'] = []
1246+
outputs['forward_deformation_field'] = []
12471247
outputs['jacobian_determinant_images'] = []
1248-
1248+
12491249
outputs['pve_label_native_images'] = []
12501250
outputs['pve_label_normalized_images'] = []
12511251
outputs['pve_label_registered_images'] = []
12521252

12531253
for filename in self.inputs.in_files:
12541254
pth, base, ext = split_filename(filename)
12551255

1256-
outputs['transformation_mat'].append(os.path.join(pth, "%s_seg8.mat" % base))
1256+
outputs['transformation_mat'].append(
1257+
os.path.join(pth, "%s_seg8.mat" % base))
12571258

1258-
for i,tis in enumerate(['gm','wm','csf']):
1259+
for i, tis in enumerate(['gm', 'wm', 'csf']):
12591260
# native space
12601261

1261-
if getattr(self.inputs,'%s_native'%tis):
1262-
outputs['native_class_images'][i].append(os.path.join(pth,"p%d%s.nii"%(i+1, base)))
1263-
if getattr(self.inputs,'%s_dartel'%tis) == 1:
1264-
outputs['dartel_input_images'][i].append(os.path.join(pth,"rp%d%s.nii"%(i+1, base)))
1265-
elif getattr(self.inputs,'%s_dartel'%tis) == 2:
1266-
outputs['dartel_input_images'][i].append(os.path.join(pth,"rp%d%s_affine.nii"%(i+1, base)))
1267-
1268-
#normalized space
1269-
if getattr(self.inputs,'%s_normalized'%tis):
1270-
outputs['normalized_class_images'][i].append(os.path.join(pth,"w%sp%d%s.nii"%(dartel_px,i+1, base)))
1262+
if getattr(self.inputs, '%s_native' % tis):
1263+
outputs['native_class_images'][i].append(
1264+
os.path.join(pth, "p%d%s.nii" % (i+1, base)))
1265+
if getattr(self.inputs, '%s_dartel' % tis) == 1:
1266+
outputs['dartel_input_images'][i].append(
1267+
os.path.join(pth, "rp%d%s.nii" % (i+1, base)))
1268+
elif getattr(self.inputs, '%s_dartel' % tis) == 2:
1269+
outputs['dartel_input_images'][i].append(
1270+
os.path.join(pth, "rp%d%s_affine.nii" % (i+1, base)))
1271+
1272+
# normalized space
1273+
if getattr(self.inputs, '%s_normalized' % tis):
1274+
outputs['normalized_class_images'][i].append(
1275+
os.path.join(pth, "w%sp%d%s.nii" % (dartel_px, i+1, base)))
1276+
1277+
if getattr(self.inputs, '%s_modulated_normalized' % tis) == 1:
1278+
outputs['modulated_class_images'][i].append(os.path.join(
1279+
pth, "mw%sp%d%s.nii" % (dartel_px, i+1, base)))
1280+
elif getattr(self.inputs, '%s_modulated_normalized' % tis) == 2:
1281+
outputs['normalized_class_images'][i].append(os.path.join(
1282+
pth, "m0w%sp%d%s.nii" % (dartel_px, i+1, base)))
12711283

1272-
if getattr(self.inputs,'%s_modulated_normalized'%tis)==1:
1273-
outputs['modulated_class_images'][i].append(os.path.join(pth,"mw%sp%d%s.nii"%(dartel_px, i+1, base)))
1274-
elif getattr(self.inputs,'%s_modulated_normalized'%tis)==2:
1275-
outputs['normalized_class_images'][i].append(os.path.join(pth,"m0w%sp%d%s.nii"%(dartel_px,i+1, base)))
1276-
1277-
1278-
12791284
if self.inputs.pve_label_native:
1280-
outputs['pve_label_native_images'].append(os.path.join(pth,"p0%s.nii"%(base)))
1285+
outputs['pve_label_native_images'].append(
1286+
os.path.join(pth, "p0%s.nii" % (base)))
12811287
if self.inputs.pve_label_normalized:
1282-
outputs['pve_label_normalized_images'].append(os.path.join(pth,"w%sp0%s.nii"%(dartel_px,base)))
1283-
if self.inputs.pve_label_dartel==1:
1284-
outputs['pve_label_registered_images'].append(os.path.join(pth,"rp0%s.nii"%( base)))
1285-
elif self.inputs.pve_label_dartel==2:
1286-
outputs['pve_label_registered_images'].append(os.path.join(pth,"rp0%s_affine.nii"%( base)))
1287-
1288+
outputs['pve_label_normalized_images'].append(
1289+
os.path.join(pth, "w%sp0%s.nii" % (dartel_px, base)))
1290+
if self.inputs.pve_label_dartel == 1:
1291+
outputs['pve_label_registered_images'].append(
1292+
os.path.join(pth, "rp0%s.nii" % (base)))
1293+
elif self.inputs.pve_label_dartel == 2:
1294+
outputs['pve_label_registered_images'].append(
1295+
os.path.join(pth, "rp0%s_affine.nii" % (base)))
12881296

12891297
if self.inputs.bias_corrected_native:
1290-
outputs['bias_corrected_images'].append(os.path.join(pth,"m%s.nii"%(base)))
1298+
outputs['bias_corrected_images'].append(
1299+
os.path.join(pth, "m%s.nii" % (base)))
12911300
if self.inputs.bias_corrected_normalized:
1292-
outputs['normalized_bias_corrected_images'].append(os.path.join(pth,"wm%s%s.nii"%(dartel_px,base)))
1301+
outputs['normalized_bias_corrected_images'].append(
1302+
os.path.join(pth, "wm%s%s.nii" % (dartel_px, base)))
12931303

12941304
if self.inputs.deformation_field[0]:
1295-
outputs['forward_deformation_field'].append(os.path.join(pth,"y_%s%s.nii"%(dartel_px,base)))
1305+
outputs['forward_deformation_field'].append(
1306+
os.path.join(pth, "y_%s%s.nii" % (dartel_px, base)))
12961307
if self.inputs.deformation_field[1]:
1297-
outputs['inverse_deformation_field'].append(os.path.join(pth,"iy_%s%s.nii"%(dartel_px,base)))
1308+
outputs['inverse_deformation_field'].append(
1309+
os.path.join(pth, "iy_%s%s.nii" % (dartel_px, base)))
12981310

12991311
if self.inputs.jacobian_determinant and do_dartel:
1300-
outputs['jacobian_determinant_images'].append(os.path.join(pth,"jac_wrp1%s.nii"%(base)))
1312+
outputs['jacobian_determinant_images'].append(
1313+
os.path.join(pth, "jac_wrp1%s.nii" % (base)))
13011314
return outputs
13021315

1303-
13041316
def _format_arg(self, opt, spec, val):
13051317
"""Convert input to appropriate format for spm
13061318
"""
13071319
if opt in ['in_files']:
13081320
return scans_for_fnames(val, keep4d=True)
13091321
elif opt in ['spatial_normalization']:
13101322
if val == 'low':
1311-
return {'normlow':[]}
1323+
return {'normlow': []}
13121324
elif opt in ['deformation_field']:
1313-
return super(VBMSegment, self)._format_arg(opt, spec, [int(val[0]), int(val[1])])
1325+
return super(VBMSegment, self)._format_arg(opt, spec, [int(val[0]), int(val[1])])
13141326
else:
13151327
return super(VBMSegment, self)._format_arg(opt, spec, val)
1316-
1328+
13171329
def _parse_inputs(self):
13181330
if self.inputs.spatial_normalization == 'low':
1319-
einputs = super(VBMSegment, self)._parse_inputs(skip=('spatial_normalization', 'dartel_template'))
1320-
einputs[0]['estwrite']['extopts']['dartelwarp']={'normlow':1}
1331+
einputs = super(VBMSegment, self)._parse_inputs(
1332+
skip=('spatial_normalization', 'dartel_template'))
1333+
einputs[0]['estwrite']['extopts']['dartelwarp'] = {'normlow': 1}
13211334
return einputs
13221335
else:
13231336
return super(VBMSegment, self)._parse_inputs(skip=('spatial_normalization'))
1324-

0 commit comments

Comments
 (0)