@@ -353,7 +353,8 @@ def _parse_inputs(self):
353
353
"""validate spm coregister options if set to None ignore
354
354
"""
355
355
if self .inputs .jobtype == "write" :
356
- einputs = super (Coregister , self )._parse_inputs (skip = ('jobtype' , 'apply_to_files' ))
356
+ einputs = (super (Coregister , self )
357
+ ._parse_inputs (skip = ('jobtype' , 'apply_to_files' )))
357
358
else :
358
359
einputs = super (Coregister , self )._parse_inputs (skip = ('jobtype' ))
359
360
jobtype = self .inputs .jobtype
@@ -371,11 +372,14 @@ def _list_outputs(self):
371
372
if isdefined (self .inputs .apply_to_files ):
372
373
outputs ['coregistered_files' ] = []
373
374
for imgf in filename_to_list (self .inputs .apply_to_files ):
374
- outputs ['coregistered_files' ].append (fname_presuffix (imgf , prefix = self .inputs .out_prefix ))
375
+ (outputs ['coregistered_files' ]
376
+ .append (fname_presuffix (imgf ,
377
+ prefix = self .inputs .out_prefix )))
375
378
376
379
outputs ['coregistered_source' ] = []
377
380
for imgf in filename_to_list (self .inputs .source ):
378
- outputs ['coregistered_source' ].append (fname_presuffix (imgf , prefix = self .inputs .out_prefix ))
381
+ (outputs ['coregistered_source' ]
382
+ .append (fname_presuffix (imgf , prefix = self .inputs .out_prefix )))
379
383
380
384
return outputs
381
385
@@ -391,11 +395,11 @@ class NormalizeInputSpec(SPMCommandInputSpec):
391
395
mandatory = True , copyfile = True )
392
396
jobtype = traits .Enum ('estwrite' , 'est' , 'write' , usedefault = True ,
393
397
desc = 'Estimate, Write or do both' )
394
- apply_to_files = InputMultiPath (traits . Either ( File ( exists = True ),
395
- traits .List (File (exists = True ))),
396
- field = 'subj.resample' ,
397
- desc = 'files to apply transformation to' ,
398
- copyfile = True )
398
+ apply_to_files = InputMultiPath (
399
+ traits . Either ( File ( exists = True ), traits .List (File (exists = True ))),
400
+ field = 'subj.resample' ,
401
+ desc = 'files to apply transformation to' ,
402
+ copyfile = True )
399
403
parameter_file = File (field = 'subj.matname' , mandatory = True ,
400
404
xor = ['source' , 'template' ],
401
405
desc = 'normalization parameter file*_sn.mat' ,
@@ -502,7 +506,8 @@ def _parse_inputs(self):
502
506
if jobtype in ['estwrite' , 'write' ]:
503
507
if not isdefined (self .inputs .apply_to_files ):
504
508
if isdefined (self .inputs .source ):
505
- einputs [0 ]['subj' ]['resample' ] = scans_for_fname (self .inputs .source )
509
+ einputs [0 ]['subj' ]['resample' ] = scans_for_fname (
510
+ self .inputs .source )
506
511
return [{'%s' % (jobtype ): einputs [0 ]}]
507
512
508
513
def _list_outputs (self ):
@@ -512,10 +517,10 @@ def _list_outputs(self):
512
517
if jobtype .startswith ('est' ):
513
518
outputs ['normalization_parameters' ] = []
514
519
for imgf in filename_to_list (self .inputs .source ):
515
- outputs ['normalization_parameters' ].append (fname_presuffix ( imgf ,
516
- suffix = '_sn.mat' ,
517
- use_ext = False ))
518
- outputs [ 'normalization_parameters' ] = list_to_filename ( outputs ['normalization_parameters' ])
520
+ outputs ['normalization_parameters' ].append (
521
+ fname_presuffix ( imgf , suffix = '_sn.mat' , use_ext = False ))
522
+ outputs [ 'normalization_parameters' ] = list_to_filename (
523
+ outputs ['normalization_parameters' ])
519
524
520
525
if self .inputs .jobtype == "estimate" :
521
526
if isdefined (self .inputs .apply_to_files ):
@@ -540,8 +545,8 @@ def _list_outputs(self):
540
545
if isdefined (self .inputs .source ):
541
546
outputs ['normalized_source' ] = []
542
547
for imgf in filename_to_list (self .inputs .source ):
543
- outputs ['normalized_source' ].append (fname_presuffix ( imgf ,
544
- prefix = prefixNorm ))
548
+ outputs ['normalized_source' ].append (
549
+ fname_presuffix ( imgf , prefix = prefixNorm ))
545
550
546
551
return outputs
547
552
@@ -552,11 +557,11 @@ class Normalize12InputSpec(SPMCommandInputSpec):
552
557
'with' ),
553
558
xor = ['deformation_file' ],
554
559
mandatory = True , copyfile = True )
555
- apply_to_files = InputMultiPath (traits . Either ( File ( exists = True ),
556
- traits .List (File (exists = True ))),
557
- field = 'subj.resample' ,
558
- desc = 'files to apply transformation to' ,
559
- copyfile = True )
560
+ apply_to_files = InputMultiPath (
561
+ traits . Either ( File ( exists = True ), traits .List (File (exists = True ))),
562
+ field = 'subj.resample' ,
563
+ desc = 'files to apply transformation to' ,
564
+ copyfile = True )
560
565
deformation_file = File (field = 'subj.def' , mandatory = True ,
561
566
xor = ['image_to_align' , 'tpm' ],
562
567
desc = ('file y_*.nii containing 3 deformation '
@@ -661,8 +666,8 @@ def _format_arg(self, opt, spec, val):
661
666
def _parse_inputs (self , skip = ()):
662
667
"""validate spm normalize options if set to None ignore
663
668
"""
664
- einputs = super (Normalize12 , self )._parse_inputs (skip = ( 'jobtype' ,
665
- 'apply_to_files' ))
669
+ einputs = super (Normalize12 , self )._parse_inputs (
670
+ skip = ( 'jobtype' , 'apply_to_files' ))
666
671
if isdefined (self .inputs .apply_to_files ):
667
672
inputfiles = deepcopy (self .inputs .apply_to_files )
668
673
if isdefined (self .inputs .image_to_align ):
@@ -672,7 +677,8 @@ def _parse_inputs(self, skip=()):
672
677
if jobtype in ['estwrite' , 'write' ]:
673
678
if not isdefined (self .inputs .apply_to_files ):
674
679
if isdefined (self .inputs .image_to_align ):
675
- einputs [0 ]['subj' ]['resample' ] = scans_for_fname (self .inputs .image_to_align )
680
+ einputs [0 ]['subj' ]['resample' ] = scans_for_fname (
681
+ self .inputs .image_to_align )
676
682
return [{'%s' % (jobtype ): einputs [0 ]}]
677
683
678
684
def _list_outputs (self ):
@@ -682,15 +688,16 @@ def _list_outputs(self):
682
688
if jobtype .startswith ('est' ):
683
689
outputs ['deformation_field' ] = []
684
690
for imgf in filename_to_list (self .inputs .image_to_align ):
685
- outputs ['deformation_field' ].append (fname_presuffix (imgf ,
686
- prefix = 'y_' ))
687
- outputs ['deformation_field' ] = list_to_filename (outputs ['deformation_field' ])
691
+ outputs ['deformation_field' ].append (
692
+ fname_presuffix (imgf , prefix = 'y_' ))
693
+ outputs ['deformation_field' ] = list_to_filename (
694
+ outputs ['deformation_field' ])
688
695
689
696
if self .inputs .jobtype == "estimate" :
690
697
if isdefined (self .inputs .apply_to_files ):
691
698
outputs ['normalized_files' ] = self .inputs .apply_to_files
692
- outputs ['normalized_image' ] = fname_presuffix (self . inputs . image_to_align ,
693
- prefix = 'w' )
699
+ outputs ['normalized_image' ] = fname_presuffix (
700
+ self . inputs . image_to_align , prefix = 'w' )
694
701
elif 'write' in self .inputs .jobtype :
695
702
outputs ['normalized_files' ] = []
696
703
if isdefined (self .inputs .apply_to_files ):
@@ -702,8 +709,8 @@ def _list_outputs(self):
702
709
run = [fname_presuffix (f , prefix = 'w' )]
703
710
outputs ['normalized_files' ].extend (run )
704
711
if isdefined (self .inputs .image_to_align ):
705
- outputs ['normalized_image' ] = fname_presuffix (self . inputs . image_to_align ,
706
- prefix = 'w' )
712
+ outputs ['normalized_image' ] = fname_presuffix (
713
+ self . inputs . image_to_align , prefix = 'w' )
707
714
708
715
return outputs
709
716
@@ -745,7 +752,8 @@ class SegmentInputSpec(SPMCommandInputSpec):
745
752
Native + Modulated + Unmodulated: [True,True,True],
746
753
Modulated + Unmodulated Normalised: [True,True,False]""" )
747
754
save_bias_corrected = traits .Bool (field = 'output.biascor' ,
748
- desc = 'True/False produce a bias corrected image' )
755
+ desc = ('True/False produce a bias '
756
+ 'corrected image' ))
749
757
clean_masks = traits .Enum ('no' , 'light' , 'thorough' ,
750
758
field = 'output.cleanup' ,
751
759
desc = ("clean using estimated brain mask "
@@ -861,9 +869,8 @@ def _list_outputs(self):
861
869
('native' , '' )]):
862
870
if getattr (self .inputs , outtype )[idx ]:
863
871
outfield = '%s_%s_image' % (image , tissue )
864
- outputs [outfield ] = fname_presuffix (f ,
865
- prefix = '%sc%d' % (prefix ,
866
- tidx + 1 ))
872
+ outputs [outfield ] = fname_presuffix (
873
+ f , prefix = '%sc%d' % (prefix , tidx + 1 ))
867
874
if isdefined (self .inputs .save_bias_corrected ) and \
868
875
self .inputs .save_bias_corrected :
869
876
outputs ['bias_corrected_image' ] = fname_presuffix (f , prefix = 'm' )
@@ -877,22 +884,25 @@ def _list_outputs(self):
877
884
class NewSegmentInputSpec (SPMCommandInputSpec ):
878
885
channel_files = InputMultiPath (File (exists = True ),
879
886
desc = "A list of files to be segmented" ,
880
- field = 'channel' , copyfile = False , mandatory = True )
887
+ field = 'channel' , copyfile = False ,
888
+ mandatory = True )
881
889
channel_info = traits .Tuple (traits .Float (), traits .Float (),
882
890
traits .Tuple (traits .Bool , traits .Bool ),
883
891
desc = """A tuple with the following fields:
884
892
- bias reguralisation (0-10)
885
893
- FWHM of Gaussian smoothness of bias
886
894
- which maps to save (Corrected, Field) - a tuple of two boolean values""" ,
887
895
field = 'channel' )
888
- tissues = traits .List (traits .Tuple (traits .Tuple (File (exists = True ), traits .Int ()), traits .Int (),
889
- traits .Tuple (traits .Bool , traits .Bool ), traits .Tuple (traits .Bool , traits .Bool )),
890
- desc = """A list of tuples (one per tissue) with the following fields:
896
+ tissues = traits .List (
897
+ traits .Tuple (traits .Tuple (File (exists = True ), traits .Int ()),
898
+ traits .Int (), traits .Tuple (traits .Bool , traits .Bool ),
899
+ traits .Tuple (traits .Bool , traits .Bool )),
900
+ desc = """A list of tuples (one per tissue) with the following fields:
891
901
- tissue probability map (4D), 1-based index to frame
892
902
- number of gaussians
893
903
- which maps to save [Native, DARTEL] - a tuple of two boolean values
894
904
- which maps to save [Unmodulated, Modulated] - a tuple of two boolean values""" ,
895
- field = 'tissue' )
905
+ field = 'tissue' )
896
906
affine_regularization = traits .Enum ('mni' , 'eastern' , 'subj' , 'none' ,
897
907
field = 'warp.affreg' ,
898
908
desc = 'mni, eastern, subj, none ' )
@@ -978,7 +988,7 @@ def _format_arg(self, opt, spec, val):
978
988
"""
979
989
980
990
if opt in ['channel_files' , 'channel_info' ]:
981
- # structure have to be recreated, because of some weird traits error
991
+ # structure have to be recreated because of some weird traits error
982
992
new_channel = {}
983
993
new_channel ['vols' ] = scans_for_fnames (self .inputs .channel_files )
984
994
if isdefined (self .inputs .channel_info ):
@@ -1032,29 +1042,39 @@ def _list_outputs(self):
1032
1042
if isdefined (self .inputs .tissues ):
1033
1043
for i , tissue in enumerate (self .inputs .tissues ):
1034
1044
if tissue [2 ][0 ]:
1035
- outputs ['native_class_images' ][i ].append (os .path .join (pth , "c%d%s.nii" % (i + 1 , base )))
1045
+ outputs ['native_class_images' ][i ].append (
1046
+ os .path .join (pth , "c%d%s.nii" % (i + 1 , base )))
1036
1047
if tissue [2 ][1 ]:
1037
- outputs ['dartel_input_images' ][i ].append (os .path .join (pth , "rc%d%s.nii" % (i + 1 , base )))
1048
+ outputs ['dartel_input_images' ][i ].append (
1049
+ os .path .join (pth , "rc%d%s.nii" % (i + 1 , base )))
1038
1050
if tissue [3 ][0 ]:
1039
- outputs ['normalized_class_images' ][i ].append (os .path .join (pth , "wc%d%s.nii" % (i + 1 , base )))
1051
+ outputs ['normalized_class_images' ][i ].append (
1052
+ os .path .join (pth , "wc%d%s.nii" % (i + 1 , base )))
1040
1053
if tissue [3 ][1 ]:
1041
- outputs ['modulated_class_images' ][i ].append (os .path .join (pth , "mwc%d%s.nii" % (i + 1 , base )))
1054
+ outputs ['modulated_class_images' ][i ].append (
1055
+ os .path .join (pth , "mwc%d%s.nii" % (i + 1 , base )))
1042
1056
else :
1043
1057
for i in range (n_classes ):
1044
- outputs ['native_class_images' ][i ].append (os .path .join (pth , "c%d%s.nii" % (i + 1 , base )))
1045
- outputs ['transformation_mat' ].append (os .path .join (pth , "%s_seg8.mat" % base ))
1058
+ outputs ['native_class_images' ][i ].append (
1059
+ os .path .join (pth , "c%d%s.nii" % (i + 1 , base )))
1060
+ outputs ['transformation_mat' ].append (
1061
+ os .path .join (pth , "%s_seg8.mat" % base ))
1046
1062
1047
1063
if isdefined (self .inputs .write_deformation_fields ):
1048
1064
if self .inputs .write_deformation_fields [0 ]:
1049
- outputs ['inverse_deformation_field' ].append (os .path .join (pth , "iy_%s.nii" % base ))
1065
+ outputs ['inverse_deformation_field' ].append (
1066
+ os .path .join (pth , "iy_%s.nii" % base ))
1050
1067
if self .inputs .write_deformation_fields [1 ]:
1051
- outputs ['forward_deformation_field' ].append (os .path .join (pth , "y_%s.nii" % base ))
1068
+ outputs ['forward_deformation_field' ].append (
1069
+ os .path .join (pth , "y_%s.nii" % base ))
1052
1070
1053
1071
if isdefined (self .inputs .channel_info ):
1054
1072
if self .inputs .channel_info [2 ][0 ]:
1055
- outputs ['bias_corrected_images' ].append (os .path .join (pth , "m%s.nii" % (base )))
1073
+ outputs ['bias_corrected_images' ].append (
1074
+ os .path .join (pth , "m%s.nii" % (base )))
1056
1075
if self .inputs .channel_info [2 ][1 ]:
1057
- outputs ['bias_field_images' ].append (os .path .join (pth , "BiasField_%s.nii" % (base )))
1076
+ outputs ['bias_field_images' ].append (
1077
+ os .path .join (pth , "BiasField_%s.nii" % (base )))
1058
1078
return outputs
1059
1079
1060
1080
@@ -1131,7 +1151,8 @@ class DARTELInputSpec(SPMCommandInputSpec):
1131
1151
desc = 'Prefix for template' )
1132
1152
regularization_form = traits .Enum ('Linear' , 'Membrane' , 'Bending' ,
1133
1153
field = 'warp.settings.rform' ,
1134
- desc = 'Form of regularization energy term' )
1154
+ desc = ('Form of regularization energy '
1155
+ 'term' ))
1135
1156
iteration_parameters = traits .List (traits .Tuple (traits .Range (1 , 10 ),
1136
1157
traits .Tuple (traits .Float ,
1137
1158
traits .Float ,
@@ -1220,14 +1241,18 @@ def _list_outputs(self):
1220
1241
outputs = self ._outputs ().get ()
1221
1242
outputs ['template_files' ] = []
1222
1243
for i in range (6 ):
1223
- outputs ['template_files' ].append (os .path .realpath ('%s_%d.nii' % (self .inputs .template_prefix , i + 1 )))
1224
- outputs ['final_template_file' ] = os .path .realpath ('%s_6.nii' % self .inputs .template_prefix )
1244
+ outputs ['template_files' ].append (
1245
+ os .path .realpath (
1246
+ '%s_%d.nii' % (self .inputs .template_prefix , i + 1 )))
1247
+ outputs ['final_template_file' ] = os .path .realpath (
1248
+ '%s_6.nii' % self .inputs .template_prefix )
1225
1249
outputs ['dartel_flow_fields' ] = []
1226
1250
for filename in self .inputs .image_files [0 ]:
1227
1251
pth , base , ext = split_filename (filename )
1228
- outputs ['dartel_flow_fields' ].append (os .path .realpath ('u_%s_%s%s' % (base ,
1229
- self .inputs .template_prefix ,
1230
- ext )))
1252
+ outputs ['dartel_flow_fields' ].append (
1253
+ os .path .realpath ('u_%s_%s%s' % (base ,
1254
+ self .inputs .template_prefix ,
1255
+ ext )))
1231
1256
return outputs
1232
1257
1233
1258
@@ -1313,7 +1338,8 @@ def _format_arg(self, opt, spec, val):
1313
1338
def _list_outputs (self ):
1314
1339
outputs = self ._outputs ().get ()
1315
1340
pth , base , ext = split_filename (self .inputs .template_file )
1316
- outputs ['normalization_parameter_file' ] = os .path .realpath (base + '_2mni.mat' )
1341
+ outputs ['normalization_parameter_file' ] = os .path .realpath (
1342
+ base + '_2mni.mat' )
1317
1343
outputs ['normalized_files' ] = []
1318
1344
prefix = "w"
1319
1345
if isdefined (self .inputs .modulate ) and self .inputs .modulate :
@@ -1322,9 +1348,8 @@ def _list_outputs(self):
1322
1348
prefix = 's' + prefix
1323
1349
for filename in self .inputs .apply_to_files :
1324
1350
pth , base , ext = split_filename (filename )
1325
- outputs ['normalized_files' ].append (os .path .realpath ('%s%s%s' % (prefix ,
1326
- base ,
1327
- ext )))
1351
+ outputs ['normalized_files' ].append (
1352
+ os .path .realpath ('%s%s%s' % (prefix , base , ext )))
1328
1353
1329
1354
return outputs
1330
1355
@@ -1391,11 +1416,11 @@ def _list_outputs(self):
1391
1416
for filename in self .inputs .image_files :
1392
1417
pth , base , ext = split_filename (filename )
1393
1418
if isdefined (self .inputs .modulate ) and self .inputs .modulate :
1394
- outputs ['warped_files' ].append (os . path . realpath ( 'mw%s%s' % ( base ,
1395
- ext )))
1419
+ outputs ['warped_files' ].append (
1420
+ os . path . realpath ( 'mw%s%s' % ( base , ext )))
1396
1421
else :
1397
- outputs ['warped_files' ].append (os . path . realpath ( 'w%s%s' % ( base ,
1398
- ext )))
1422
+ outputs ['warped_files' ].append (
1423
+ os . path . realpath ( 'w%s%s' % ( base , ext )))
1399
1424
return outputs
1400
1425
1401
1426
@@ -1706,7 +1731,8 @@ def _format_arg(self, opt, spec, val):
1706
1731
elif opt in ['dartel_template' ]:
1707
1732
return np .array ([val ], dtype = object )
1708
1733
elif opt in ['deformation_field' ]:
1709
- return super (VBMSegment , self )._format_arg (opt , spec , [int (val [0 ]), int (val [1 ])])
1734
+ return super (VBMSegment , self )._format_arg (
1735
+ opt , spec , [int (val [0 ]), int (val [1 ])])
1710
1736
else :
1711
1737
return super (VBMSegment , self )._format_arg (opt , spec , val )
1712
1738
@@ -1717,4 +1743,5 @@ def _parse_inputs(self):
1717
1743
einputs [0 ]['estwrite' ]['extopts' ]['dartelwarp' ] = {'normlow' : 1 }
1718
1744
return einputs
1719
1745
else :
1720
- return super (VBMSegment , self )._parse_inputs (skip = ('spatial_normalization' ))
1746
+ return super (VBMSegment , self )._parse_inputs (
1747
+ skip = ('spatial_normalization' ))
0 commit comments