Skip to content

Commit 02e4583

Browse files
committed
PEP8 compliance for preproc (25%)
1 parent 58a2c66 commit 02e4583

File tree

1 file changed

+56
-32
lines changed

1 file changed

+56
-32
lines changed

nipype/interfaces/spm/preprocess.py

Lines changed: 56 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ class SliceTimingInputSpec(SPMCommandInputSpec):
5858

5959

6060
class SliceTimingOutputSpec(TraitedSpec):
61-
timecorrected_files = OutputMultiPath(traits.Either(traits.List(File(exists=True)),
62-
File(exists=True)),
63-
desc='slice time corrected files')
61+
timecorrected_files = OutputMultiPath(
62+
traits.Either(traits.List(File(exists=True)), File(exists=True)),
63+
desc='slice time corrected files')
6464

6565

6666
class SliceTiming(SPMCommand):
@@ -237,7 +237,8 @@ def _list_outputs(self):
237237
break
238238
if self.inputs.jobtype == "estimate":
239239
outputs['realigned_files'] = self.inputs.in_files
240-
if self.inputs.jobtype == "estimate" or self.inputs.jobtype == "estwrite":
240+
if (self.inputs.jobtype == "estimate" or
241+
self.inputs.jobtype == "estwrite"):
241242
outputs['modified_in_files'] = self.inputs.in_files
242243
if self.inputs.jobtype == "write" or self.inputs.jobtype == "estwrite":
243244
if isinstance(self.inputs.in_files[0], list):
@@ -246,20 +247,21 @@ def _list_outputs(self):
246247
first_image = self.inputs.in_files[0]
247248

248249
if resliced_mean:
249-
outputs['mean_image'] = fname_presuffix(first_image, prefix='mean')
250+
outputs['mean_image'] = fname_presuffix(first_image,
251+
prefix='mean')
250252

251253
if resliced_all:
252254
outputs['realigned_files'] = []
253255
for idx, imgf in enumerate(filename_to_list(self.inputs.in_files)):
254256
realigned_run = []
255257
if isinstance(imgf, list):
256258
for i, inner_imgf in enumerate(filename_to_list(imgf)):
257-
newfile = fname_presuffix(inner_imgf,
258-
prefix=self.inputs.out_prefix)
259+
newfile = fname_presuffix(
260+
inner_imgf, prefix=self.inputs.out_prefix)
259261
realigned_run.append(newfile)
260262
else:
261-
realigned_run = fname_presuffix(imgf,
262-
prefix=self.inputs.out_prefix)
263+
realigned_run = fname_presuffix(
264+
imgf, prefix=self.inputs.out_prefix)
263265
outputs['realigned_files'].append(realigned_run)
264266
return outputs
265267

@@ -278,7 +280,8 @@ class CoregisterInputSpec(SPMCommandInputSpec):
278280
copyfile=True)
279281
cost_function = traits.Enum('mi', 'nmi', 'ecc', 'ncc',
280282
field='eoptions.cost_fun',
281-
desc="""cost function, one of: 'mi' - Mutual Information,
283+
desc="""cost function, one of:
284+
'mi' - Mutual Information,
282285
'nmi' - Normalised Mutual Information,
283286
'ecc' - Entropy Correlation Coefficient,
284287
'ncc' - Normalised Cross Correlation""")
@@ -290,10 +293,12 @@ class CoregisterInputSpec(SPMCommandInputSpec):
290293
tolerance = traits.List(traits.Float(), field='eoptions.tol',
291294
desc='acceptable tolerance for each of 12 params')
292295
write_interp = traits.Range(low=0, high=7, field='roptions.interp',
293-
desc='degree of b-spline used for interpolation')
296+
desc=('degree of b-spline used for '
297+
'interpolation'))
294298
write_wrap = traits.List(traits.Int(), minlen=3, maxlen=3,
295299
field='roptions.wrap',
296-
desc='Check if interpolation should wrap in [x,y,z]')
300+
desc=('Check if interpolation should wrap in '
301+
'[x,y,z]'))
297302
write_mask = traits.Bool(field='roptions.mask',
298303
desc='True/False mask output image')
299304
out_prefix = traits.String('r', field='roptions.prefix', usedefault=True,
@@ -331,7 +336,8 @@ class Coregister(SPMCommand):
331336
def _format_arg(self, opt, spec, val):
332337
"""Convert input to appropriate format for spm
333338
"""
334-
if opt == 'target' or (opt == 'source' and self.inputs.jobtype != "write"):
339+
if (opt == 'target' or
340+
(opt == 'source' and self.inputs.jobtype != "write")):
335341
return scans_for_fnames(filename_to_list(val),
336342
keep4d=True)
337343
if opt == 'apply_to_files':
@@ -360,7 +366,8 @@ def _list_outputs(self):
360366
if isdefined(self.inputs.apply_to_files):
361367
outputs['coregistered_files'] = self.inputs.apply_to_files
362368
outputs['coregistered_source'] = self.inputs.source
363-
elif self.inputs.jobtype == "write" or self.inputs.jobtype == "estwrite":
369+
elif (self.inputs.jobtype == "write"
370+
or self.inputs.jobtype == "estwrite"):
364371
if isdefined(self.inputs.apply_to_files):
365372
outputs['coregistered_files'] = []
366373
for imgf in filename_to_list(self.inputs.apply_to_files):
@@ -391,11 +398,14 @@ class NormalizeInputSpec(SPMCommandInputSpec):
391398
copyfile=True)
392399
parameter_file = File(field='subj.matname', mandatory=True,
393400
xor=['source', 'template'],
394-
desc='normalization parameter file*_sn.mat', copyfile=False)
401+
desc='normalization parameter file*_sn.mat',
402+
copyfile=False)
395403
source_weight = File(field='subj.wtsrc',
396-
desc='name of weighting image for source', copyfile=False)
404+
desc='name of weighting image for source',
405+
copyfile=False)
397406
template_weight = File(field='eoptions.weight',
398-
desc='name of weighting image for template', copyfile=False)
407+
desc='name of weighting image for template',
408+
copyfile=False)
399409
source_image_smoothing = traits.Float(field='eoptions.smosrc',
400410
desc='source smoothing')
401411
template_image_smoothing = traits.Float(field='eoptions.smoref',
@@ -406,9 +416,13 @@ class NormalizeInputSpec(SPMCommandInputSpec):
406416
DCT_period_cutoff = traits.Float(field='eoptions.cutoff',
407417
desc='Cutoff of for DCT bases')
408418
nonlinear_iterations = traits.Int(field='eoptions.nits',
409-
desc='Number of iterations of nonlinear warping')
419+
desc=('Number of iterations of '
420+
'nonlinear warping'))
410421
nonlinear_regularization = traits.Float(field='eoptions.reg',
411-
desc='the amount of the regularization for the nonlinear part of the normalization')
422+
desc=('the amount of the '
423+
'regularization for the '
424+
'nonlinear part of the '
425+
'normalization'))
412426
write_preserve = traits.Bool(field='roptions.preserve',
413427
desc='True/False warped images are modulated')
414428
write_bounding_box = traits.List(traits.List(traits.Float(), minlen=3,
@@ -419,17 +433,20 @@ class NormalizeInputSpec(SPMCommandInputSpec):
419433
minlen=3, maxlen=3,
420434
desc='3-element list')
421435
write_interp = traits.Range(low=0, high=7, field='roptions.interp',
422-
desc='degree of b-spline used for interpolation')
436+
desc=('degree of b-spline used for '
437+
'interpolation'))
423438
write_wrap = traits.List(traits.Int(), field='roptions.wrap',
424-
desc=('Check if interpolation should wrap in [x,y,z]'
425-
'- list of bools'))
439+
desc=('Check if interpolation should wrap in '
440+
'[x,y,z] - list of bools'))
426441
out_prefix = traits.String('w', field='roptions.prefix', usedefault=True,
427442
desc='normalized output prefix')
428443

429444

430445
class NormalizeOutputSpec(TraitedSpec):
431446
normalization_parameters = OutputMultiPath(File(exists=True),
432-
desc='MAT files containing the normalization parameters')
447+
desc=('MAT files containing '
448+
'the normalization '
449+
'parameters'))
433450
normalized_source = OutputMultiPath(File(exists=True),
434451
desc='Normalized source files')
435452
normalized_files = OutputMultiPath(File(exists=True),
@@ -505,7 +522,8 @@ def _list_outputs(self):
505522
outputs['normalized_files'] = self.inputs.apply_to_files
506523
outputs['normalized_source'] = self.inputs.source
507524
elif 'write' in self.inputs.jobtype:
508-
if isdefined(self.inputs.write_preserve) and self.inputs.write_preserve:
525+
if (isdefined(self.inputs.write_preserve)
526+
and self.inputs.write_preserve):
509527
prefixNorm = ''.join(['m', self.inputs.out_prefix])
510528
else:
511529
prefixNorm = self.inputs.out_prefix
@@ -514,7 +532,8 @@ def _list_outputs(self):
514532
filelist = filename_to_list(self.inputs.apply_to_files)
515533
for f in filelist:
516534
if isinstance(f, list):
517-
run = [fname_presuffix(in_f, prefix=prefixNorm) for in_f in f]
535+
run = [fname_presuffix(in_f, prefix=prefixNorm)
536+
for in_f in f]
518537
else:
519538
run = [fname_presuffix(f, prefix=prefixNorm)]
520539
outputs['normalized_files'].extend(run)
@@ -529,7 +548,8 @@ def _list_outputs(self):
529548

530549
class Normalize12InputSpec(SPMCommandInputSpec):
531550
image_to_align = File(exists=True, field='subj.vol',
532-
desc='file to estimate normalization parameters with',
551+
desc=('file to estimate normalization parameters '
552+
'with'),
533553
xor=['deformation_file'],
534554
mandatory=True, copyfile=True)
535555
apply_to_files = InputMultiPath(traits.Either(File(exists=True),
@@ -539,8 +559,9 @@ class Normalize12InputSpec(SPMCommandInputSpec):
539559
copyfile=True)
540560
deformation_file = File(field='subj.def', mandatory=True,
541561
xor=['image_to_align', 'tpm'],
542-
desc=('file y_*.nii containing 3 deformation fields '
543-
'for the deformation in x, y and z dimension'),
562+
desc=('file y_*.nii containing 3 deformation '
563+
'fields for the deformation in x, y and z '
564+
'dimension'),
544565
copyfile=False)
545566
jobtype = traits.Enum('estwrite', 'est', 'write', usedefault=True,
546567
desc='Estimate, Write or do Both')
@@ -551,7 +572,8 @@ class Normalize12InputSpec(SPMCommandInputSpec):
551572
140, 150, 'Inf', field='eoptions.biasfwhm',
552573
desc='FWHM of Gaussian smoothness of bias')
553574
tpm = File(exists=True, field='eoptions.tpm',
554-
desc='template in form of tissue probablitiy maps to normalize to',
575+
desc=('template in form of tissue probablitiy maps to '
576+
'normalize to'),
555577
xor=['deformation_file'],
556578
copyfile=False)
557579
affine_regularization_type = traits.Enum('mni', 'size', 'none',
@@ -570,15 +592,17 @@ class Normalize12InputSpec(SPMCommandInputSpec):
570592
write_bounding_box = traits.List(traits.List(traits.Float(),
571593
minlen=3, maxlen=3),
572594
field='woptions.bb', minlen=2, maxlen=2,
573-
desc=('3x2-element list of lists representing '
574-
'the bounding box (in mm) to be written'))
595+
desc=('3x2-element list of lists '
596+
'representing the bounding box '
597+
'(in mm) to be written'))
575598
write_voxel_sizes = traits.List(traits.Float(), field='woptions.vox',
576599
minlen=3, maxlen=3,
577600
desc=('3-element list representing the '
578601
'voxel sizes (in mm) of the written '
579602
'normalised images'))
580603
write_interp = traits.Range(low=0, high=7, field='woptions.interp',
581-
desc='degree of b-spline used for interpolation')
604+
desc=('degree of b-spline used for '
605+
'interpolation'))
582606

583607

584608
class Normalize12OutputSpec(TraitedSpec):

0 commit comments

Comments
 (0)