Skip to content

Commit e643da4

Browse files
committed
PEP8 compliance for preproc (60%)
1 parent 02e4583 commit e643da4

File tree

1 file changed

+100
-52
lines changed

1 file changed

+100
-52
lines changed

nipype/interfaces/spm/preprocess.py

Lines changed: 100 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class SliceTimingInputSpec(SPMCommandInputSpec):
6060
class SliceTimingOutputSpec(TraitedSpec):
6161
timecorrected_files = OutputMultiPath(
6262
traits.Either(traits.List(File(exists=True)), File(exists=True)),
63-
desc='slice time corrected files')
63+
desc='slice time corrected files')
6464

6565

6666
class SliceTiming(SPMCommand):
@@ -366,8 +366,8 @@ def _list_outputs(self):
366366
if isdefined(self.inputs.apply_to_files):
367367
outputs['coregistered_files'] = self.inputs.apply_to_files
368368
outputs['coregistered_source'] = self.inputs.source
369-
elif (self.inputs.jobtype == "write"
370-
or self.inputs.jobtype == "estwrite"):
369+
elif (self.inputs.jobtype == "write" or
370+
self.inputs.jobtype == "estwrite"):
371371
if isdefined(self.inputs.apply_to_files):
372372
outputs['coregistered_files'] = []
373373
for imgf in filename_to_list(self.inputs.apply_to_files):
@@ -522,8 +522,8 @@ def _list_outputs(self):
522522
outputs['normalized_files'] = self.inputs.apply_to_files
523523
outputs['normalized_source'] = self.inputs.source
524524
elif 'write' in self.inputs.jobtype:
525-
if (isdefined(self.inputs.write_preserve)
526-
and self.inputs.write_preserve):
525+
if (isdefined(self.inputs.write_preserve) and
526+
self.inputs.write_preserve):
527527
prefixNorm = ''.join(['m', self.inputs.out_prefix])
528528
else:
529529
prefixNorm = self.inputs.out_prefix
@@ -607,9 +607,10 @@ class Normalize12InputSpec(SPMCommandInputSpec):
607607

608608
class Normalize12OutputSpec(TraitedSpec):
609609
deformation_field = OutputMultiPath(File(exists=True),
610-
desc=('NIfTI file containing 3 deformation '
611-
'fields for the deformation in '
612-
'x, y and z dimension'))
610+
desc=('NIfTI file containing 3 '
611+
'deformation fields for the '
612+
'deformation in x, y and z '
613+
'dimension'))
613614
normalized_image = OutputMultiPath(File(exists=True),
614615
desc=('Normalized file that needed to '
615616
'be aligned'))
@@ -708,9 +709,11 @@ def _list_outputs(self):
708709

709710

710711
class SegmentInputSpec(SPMCommandInputSpec):
711-
data = InputMultiPath(File(exists=True), field='data', desc='one scan per subject',
712+
data = InputMultiPath(File(exists=True), field='data',
713+
desc='one scan per subject',
712714
copyfile=False, mandatory=True)
713-
gm_output_type = traits.List(traits.Bool(), minlen=3, maxlen=3, field='output.GM',
715+
gm_output_type = traits.List(traits.Bool(), minlen=3, maxlen=3,
716+
field='output.GM',
714717
desc="""Options to produce grey matter images: c1*.img, wc1*.img and mwc1*.img.
715718
None: [False,False,False],
716719
Native Space: [False,False,True],
@@ -720,7 +723,8 @@ class SegmentInputSpec(SPMCommandInputSpec):
720723
Native + Modulated Normalised: [True,False,True],
721724
Native + Modulated + Unmodulated: [True,True,True],
722725
Modulated + Unmodulated Normalised: [True,True,False]""")
723-
wm_output_type = traits.List(traits.Bool(), minlen=3, maxlen=3, field='output.WM',
726+
wm_output_type = traits.List(traits.Bool(), minlen=3, maxlen=3,
727+
field='output.WM',
724728
desc="""Options to produce white matter images: c2*.img, wc2*.img and mwc2*.img.
725729
None: [False,False,False],
726730
Native Space: [False,False,True],
@@ -742,38 +746,53 @@ class SegmentInputSpec(SPMCommandInputSpec):
742746
Modulated + Unmodulated Normalised: [True,True,False]""")
743747
save_bias_corrected = traits.Bool(field='output.biascor',
744748
desc='True/False produce a bias corrected image')
745-
clean_masks = traits.Enum('no', 'light', 'thorough', field='output.cleanup',
746-
desc="clean using estimated brain mask ('no','light','thorough')")
749+
clean_masks = traits.Enum('no', 'light', 'thorough',
750+
field='output.cleanup',
751+
desc=("clean using estimated brain mask "
752+
"('no','light','thorough')"))
747753
tissue_prob_maps = traits.List(File(exists=True), field='opts.tpm',
748-
desc='list of gray, white & csf prob. (opt,)')
754+
desc=('list of gray, white & csf prob. '
755+
'(opt,)'))
749756
gaussians_per_class = traits.List(traits.Int(), field='opts.ngaus',
750-
desc='num Gaussians capture intensity distribution')
751-
affine_regularization = traits.Enum('mni', 'eastern', 'subj', 'none', '', field='opts.regtype',
752-
desc='Possible options: "mni", "eastern", "subj", "none" (no reguralisation), "" (no affine registration)')
757+
desc=('num Gaussians capture intensity '
758+
'distribution'))
759+
affine_regularization = traits.Enum('mni', 'eastern', 'subj', 'none', '',
760+
field='opts.regtype',
761+
desc=('Possible options: "mni", '
762+
'"eastern", "subj", "none" '
763+
'(no reguralisation), "" '
764+
'(no affine registration)'))
753765
warping_regularization = traits.Float(field='opts.warpreg',
754-
desc='Controls balance between parameters and data')
755-
warp_frequency_cutoff = traits.Float(field='opts.warpco', desc='Cutoff of DCT bases')
756-
bias_regularization = traits.Enum(0, 0.00001, 0.0001, 0.001, 0.01, 0.1, 1, 10, field='opts.biasreg',
766+
desc=('Controls balance between '
767+
'parameters and data'))
768+
warp_frequency_cutoff = traits.Float(field='opts.warpco',
769+
desc='Cutoff of DCT bases')
770+
bias_regularization = traits.Enum(0, 0.00001, 0.0001, 0.001,
771+
0.01, 0.1, 1, 10, field='opts.biasreg',
757772
desc='no(0) - extremely heavy (10)')
758773
bias_fwhm = traits.Enum(30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130,
759774
'Inf', field='opts.biasfwhm',
760775
desc='FWHM of Gaussian smoothness of bias')
761776
sampling_distance = traits.Float(field='opts.samp',
762-
desc='Sampling distance on data for parameter estimation')
777+
desc=('Sampling distance on data for '
778+
'parameter estimation'))
763779
mask_image = File(exists=True, field='opts.msk',
764780
desc='Binary image to restrict parameter estimation ')
765781

766782

767783
class SegmentOutputSpec(TraitedSpec):
768784
native_gm_image = File(desc='native space grey probability map')
769785
normalized_gm_image = File(desc='normalized grey probability map',)
770-
modulated_gm_image = File(desc='modulated, normalized grey probability map')
786+
modulated_gm_image = File(desc=('modulated, normalized grey '
787+
'probability map'))
771788
native_wm_image = File(desc='native space white probability map')
772789
normalized_wm_image = File(desc='normalized white probability map')
773-
modulated_wm_image = File(desc='modulated, normalized white probability map')
790+
modulated_wm_image = File(desc=('modulated, normalized white '
791+
'probability map'))
774792
native_csf_image = File(desc='native space csf probability map')
775793
normalized_csf_image = File(desc='normalized csf probability map')
776-
modulated_csf_image = File(desc='modulated, normalized csf probability map')
794+
modulated_csf_image = File(desc=('modulated, normalized csf '
795+
'probability map'))
777796
modulated_input_image = File(deprecated='0.10',
778797
new_name='bias_corrected_image',
779798
desc='bias-corrected version of input image')
@@ -874,31 +893,44 @@ class NewSegmentInputSpec(SPMCommandInputSpec):
874893
- which maps to save [Native, DARTEL] - a tuple of two boolean values
875894
- which maps to save [Unmodulated, Modulated] - a tuple of two boolean values""",
876895
field='tissue')
877-
affine_regularization = traits.Enum('mni', 'eastern', 'subj', 'none', field='warp.affreg',
896+
affine_regularization = traits.Enum('mni', 'eastern', 'subj', 'none',
897+
field='warp.affreg',
878898
desc='mni, eastern, subj, none ')
879899
warping_regularization = traits.Float(field='warp.reg',
880-
desc='Aproximate distance between sampling points.')
900+
desc=('Aproximate distance between '
901+
'sampling points.'))
881902
sampling_distance = traits.Float(field='warp.samp',
882-
desc='Sampling distance on data for parameter estimation')
883-
write_deformation_fields = traits.List(traits.Bool(), minlen=2, maxlen=2, field='warp.write',
884-
desc="Which deformation fields to write:[Inverse, Forward]")
903+
desc=('Sampling distance on data for '
904+
'parameter estimation'))
905+
write_deformation_fields = traits.List(traits.Bool(), minlen=2, maxlen=2,
906+
field='warp.write',
907+
desc=("Which deformation fields to "
908+
"write:[Inverse, Forward]"))
885909

886910

887911
class NewSegmentOutputSpec(TraitedSpec):
888-
native_class_images = traits.List(traits.List(File(exists=True)), desc='native space probability maps')
889-
dartel_input_images = traits.List(traits.List(File(exists=True)), desc='dartel imported class images')
890-
normalized_class_images = traits.List(traits.List(File(exists=True)), desc='normalized class images')
891-
modulated_class_images = traits.List(traits.List(File(exists=True)), desc='modulated+normalized class images')
892-
transformation_mat = OutputMultiPath(File(exists=True), desc='Normalization transformation')
893-
bias_corrected_images = OutputMultiPath(File(exists=True), desc='bias corrected images')
894-
bias_field_images = OutputMultiPath(File(exists=True), desc='bias field images')
912+
native_class_images = traits.List(traits.List(File(exists=True)),
913+
desc='native space probability maps')
914+
dartel_input_images = traits.List(traits.List(File(exists=True)),
915+
desc='dartel imported class images')
916+
normalized_class_images = traits.List(traits.List(File(exists=True)),
917+
desc='normalized class images')
918+
modulated_class_images = traits.List(traits.List(File(exists=True)),
919+
desc=('modulated+normalized class '
920+
'images'))
921+
transformation_mat = OutputMultiPath(File(exists=True),
922+
desc='Normalization transformation')
923+
bias_corrected_images = OutputMultiPath(File(exists=True),
924+
desc='bias corrected images')
925+
bias_field_images = OutputMultiPath(File(exists=True),
926+
desc='bias field images')
895927
forward_deformation_field = OutputMultiPath(File(exists=True))
896928
inverse_deformation_field = OutputMultiPath(File(exists=True))
897929

898930

899931
class NewSegment(SPMCommand):
900-
"""Use spm_preproc8 (New Segment) to separate structural images into different
901-
tissue classes. Supports multiple modalities.
932+
"""Use spm_preproc8 (New Segment) to separate structural images into
933+
different tissue classes. Supports multiple modalities.
902934
903935
NOTE: This interface currently supports single channel input only
904936
@@ -959,14 +991,18 @@ def _format_arg(self, opt, spec, val):
959991
new_tissues = []
960992
for tissue in val:
961993
new_tissue = {}
962-
new_tissue['tpm'] = np.array([','.join([tissue[0][0], str(tissue[0][1])])], dtype=object)
994+
new_tissue['tpm'] = np.array([','.join([tissue[0][0],
995+
str(tissue[0][1])])],
996+
dtype=object)
963997
new_tissue['ngaus'] = tissue[1]
964998
new_tissue['native'] = [int(tissue[2][0]), int(tissue[2][1])]
965999
new_tissue['warped'] = [int(tissue[3][0]), int(tissue[3][1])]
9661000
new_tissues.append(new_tissue)
9671001
return new_tissues
9681002
elif opt == 'write_deformation_fields':
969-
return super(NewSegment, self)._format_arg(opt, spec, [int(val[0]), int(val[1])])
1003+
return super(NewSegment, self)._format_arg(opt, spec,
1004+
[int(val[0]),
1005+
int(val[1])])
9701006
else:
9711007
return super(NewSegment, self)._format_arg(opt, spec, val)
9721008

@@ -1080,14 +1116,16 @@ def _list_outputs(self):
10801116
outputs['smoothed_files'] = []
10811117

10821118
for imgf in filename_to_list(self.inputs.in_files):
1083-
outputs['smoothed_files'].append(fname_presuffix(imgf, prefix=self.inputs.out_prefix))
1119+
outputs['smoothed_files'].append(
1120+
fname_presuffix(imgf, prefix=self.inputs.out_prefix))
10841121
return outputs
10851122

10861123

10871124
class DARTELInputSpec(SPMCommandInputSpec):
10881125
image_files = traits.List(traits.List(File(exists=True)),
10891126
desc="A list of files to be segmented",
1090-
field='warp.images', copyfile=False, mandatory=True)
1127+
field='warp.images', copyfile=False,
1128+
mandatory=True)
10911129
template_prefix = traits.Str('Template', usedefault=True,
10921130
field='warp.settings.template',
10931131
desc='Prefix for template')
@@ -1101,8 +1139,8 @@ class DARTELInputSpec(SPMCommandInputSpec):
11011139
traits.Enum(1, 2, 4, 8, 16,
11021140
32, 64, 128,
11031141
256, 512),
1104-
traits.Enum(0, 0.5, 1, 2, 4,
1105-
8, 16, 32)),
1142+
traits.Enum(0, 0.5, 1, 2,
1143+
4, 8, 16, 32)),
11061144
minlen=3,
11071145
maxlen=12,
11081146
field='warp.settings.param',
@@ -1124,8 +1162,11 @@ class DARTELInputSpec(SPMCommandInputSpec):
11241162

11251163
class DARTELOutputSpec(TraitedSpec):
11261164
final_template_file = File(exists=True, desc='final DARTEL template')
1127-
template_files = traits.List(File(exists=True), desc='Templates from different stages of iteration')
1128-
dartel_flow_fields = traits.List(File(exists=True), desc='DARTEL flow fields')
1165+
template_files = traits.List(File(exists=True),
1166+
desc=('Templates from different stages of '
1167+
'iteration'))
1168+
dartel_flow_fields = traits.List(File(exists=True),
1169+
desc='DARTEL flow fields')
11291170

11301171

11311172
class DARTEL(SPMCommand):
@@ -1193,7 +1234,8 @@ def _list_outputs(self):
11931234
class DARTELNorm2MNIInputSpec(SPMCommandInputSpec):
11941235
template_file = File(exists=True,
11951236
desc="DARTEL template",
1196-
field='mni_norm.template', copyfile=False, mandatory=True)
1237+
field='mni_norm.template', copyfile=False,
1238+
mandatory=True)
11971239
flowfield_files = InputMultiPath(File(exists=True),
11981240
desc="DARTEL flow fields u_rc1*",
11991241
field='mni_norm.data.subjs.flowfields',
@@ -1210,15 +1252,19 @@ class DARTELNorm2MNIInputSpec(SPMCommandInputSpec):
12101252
desc="Voxel sizes for output file",
12111253
field='mni_norm.bb')
12121254
modulate = traits.Bool(field='mni_norm.preserve',
1213-
desc="Modulate out images - no modulation preserves concentrations")
1255+
desc=("Modulate out images - no modulation "
1256+
"preserves concentrations"))
12141257
fwhm = traits.Either(traits.List(traits.Float(), minlen=3, maxlen=3),
12151258
traits.Float(), field='mni_norm.fwhm',
12161259
desc='3-list of fwhm for each dimension')
12171260

12181261

12191262
class DARTELNorm2MNIOutputSpec(TraitedSpec):
1220-
normalized_files = OutputMultiPath(File(exists=True), desc='Normalized files in MNI space')
1221-
normalization_parameter_file = File(exists=True, desc='Transform parameters to MNI space')
1263+
normalized_files = OutputMultiPath(File(exists=True),
1264+
desc='Normalized files in MNI space')
1265+
normalization_parameter_file = File(exists=True,
1266+
desc=('Transform parameters to MNI '
1267+
'space'))
12221268

12231269

12241270
class DARTELNorm2MNI(SPMCommand):
@@ -1354,7 +1400,8 @@ def _list_outputs(self):
13541400

13551401

13561402
class ApplyDeformationFieldInputSpec(SPMCommandInputSpec):
1357-
in_files = InputMultiPath(File(exists=True), mandatory=True, field='fnames')
1403+
in_files = InputMultiPath(File(exists=True), mandatory=True,
1404+
field='fnames')
13581405
deformation_field = File(exists=True, mandatory=True, field='comp{1}.def')
13591406
reference_volume = File(exists=True, mandatory=True,
13601407
field='comp{2}.id.space')
@@ -1511,7 +1558,8 @@ class VBMSegmentOuputSpec(TraitedSpec):
15111558
normalized_class_images = traits.List(traits.List(File(exists=True)),
15121559
desc='normalized class images')
15131560
modulated_class_images = traits.List(traits.List(File(exists=True)),
1514-
desc='modulated+normalized class images')
1561+
desc=('modulated+normalized class '
1562+
'images'))
15151563
transformation_mat = OutputMultiPath(File(exists=True),
15161564
desc='Normalization transformation')
15171565

0 commit comments

Comments
 (0)