@@ -1092,117 +1092,117 @@ class VBMSegmentInputSpec(SPMCommandInputSpec):
1092
1092
1093
1093
tissues = File (
1094
1094
exists = True , field = 'estwrite.tpm' ,
1095
- desc = 'tissue probability map' )
1095
+ desc = 'tissue probability map' )
1096
1096
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 ),
1098
1098
usedefault = True ,
1099
1099
desc = 'number of gaussians for each tissue class' )
1100
1100
bias_regularization = traits .Enum (
1101
1101
0.0001 ,
1102
1102
(0 , 0.00001 , 0.0001 , 0.001 , 0.01 , 0.1 , 1 , 10 ),
1103
1103
field = 'estwrite.opts.biasreg' , usedefault = True ,
1104
1104
desc = 'no(0) - extremely heavy (10)' )
1105
-
1105
+
1106
1106
bias_fwhm = traits .Enum (
1107
1107
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' ),
1109
1109
field = 'estwrite.opts.biasfwhm' ,
1110
- usedefault = True ,
1110
+ usedefault = True ,
1111
1111
desc = 'FWHM of Gaussian smoothness of bias' )
1112
1112
sampling_distance = traits .Float (
1113
1113
3 , usedefault = True , field = 'estwrite.opts.samp' ,
1114
1114
desc = 'Sampling distance on data for parameter estimation' )
1115
1115
warping_regularization = traits .Float (
1116
1116
4 , usedefault = True , field = 'estwrite.opts.warpreg' ,
1117
1117
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 ,)
1121
1121
dartel_template = File (
1122
1122
exists = True ,
1123
1123
field = 'estwrite.extopts.dartelwarp.normhigh.darteltpm' )
1124
1124
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' ,
1126
1126
desc = "0=No denoising, 1=denoising,2=denoising multi-threaded" )
1127
1127
mrf_weighting = traits .Float (
1128
- 0.15 ,usedefault = True ,field = 'estwrite.extopts.mrf' )
1128
+ 0.15 , usedefault = True , field = 'estwrite.extopts.mrf' )
1129
1129
cleanup_partitions = traits .Int (
1130
- 1 ,usedefault = True ,field = 'estwrite.extopts.cleanup' ,
1130
+ 1 , usedefault = True , field = 'estwrite.extopts.cleanup' ,
1131
1131
desc = "0=None,1=light,2=thorough" )
1132
1132
display_results = traits .Bool (
1133
1133
True , usedefault = True , field = 'estwrite.extopts.print' )
1134
-
1134
+
1135
1135
gm_native = traits .Bool (
1136
- False ,usedefault = True ,field = 'estwrite.output.GM.native' ,)
1136
+ False , usedefault = True , field = 'estwrite.output.GM.native' ,)
1137
1137
gm_normalized = traits .Bool (
1138
- False ,usedefault = True ,field = 'estwrite.output.GM.warped' ,)
1138
+ False , usedefault = True , field = 'estwrite.output.GM.warped' ,)
1139
1139
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' ,
1141
1141
desc = '0=none,1=affine+non-linear(SPM8 default),2=non-linear only' )
1142
1142
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' ,
1144
1144
desc = "0=None,1=rigid(SPM8 default),2=affine" )
1145
1145
1146
1146
wm_native = traits .Bool (
1147
- False ,usedefault = True ,field = 'estwrite.output.WM.native' ,)
1147
+ False , usedefault = True , field = 'estwrite.output.WM.native' ,)
1148
1148
wm_normalized = traits .Bool (
1149
- False ,usedefault = True ,field = 'estwrite.output.WM.warped' ,)
1149
+ False , usedefault = True , field = 'estwrite.output.WM.warped' ,)
1150
1150
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' ,
1152
1152
desc = '0=none,1=affine+non-linear(SPM8 default),2=non-linear only' )
1153
1153
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' ,
1155
1155
desc = "0=None,1=rigid(SPM8 default),2=affine" )
1156
1156
1157
1157
csf_native = traits .Bool (
1158
- False ,usedefault = True ,field = 'estwrite.output.CSF.native' ,)
1158
+ False , usedefault = True , field = 'estwrite.output.CSF.native' ,)
1159
1159
csf_normalized = traits .Bool (
1160
- False ,usedefault = True ,field = 'estwrite.output.CSF.warped' ,)
1160
+ False , usedefault = True , field = 'estwrite.output.CSF.warped' ,)
1161
1161
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' ,
1163
1163
desc = '0=none,1=affine+non-linear(SPM8 default),2=non-linear only' )
1164
1164
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' ,
1166
1166
desc = "0=None,1=rigid(SPM8 default),2=affine" )
1167
1167
1168
1168
bias_corrected_native = traits .Bool (
1169
- False ,usedefault = True ,field = 'estwrite.output.bias.native' ,)
1169
+ False , usedefault = True , field = 'estwrite.output.bias.native' ,)
1170
1170
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' ,)
1174
1174
1175
1175
pve_label_native = traits .Bool (
1176
- False ,usedefault = True ,field = 'estwrite.output.label.native' )
1176
+ False , usedefault = True , field = 'estwrite.output.label.native' )
1177
1177
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' ,
1181
1181
desc = "0=None,1=rigid(SPM8 default),2=affine" )
1182
1182
1183
1183
jacobian_determinant = traits .Bool (
1184
- False ,usedefault = True ,field = 'estwrite.jacobian.warped' )
1184
+ False , usedefault = True , field = 'estwrite.jacobian.warped' )
1185
1185
1186
1186
deformation_field = traits .Tuple (
1187
- (0 ,0 ),traits .Bool ,traits .Bool ,usedefault = True ,
1187
+ (0 , 0 ), traits .Bool , traits .Bool , usedefault = True ,
1188
1188
field = 'estwrite.output.warps' ,
1189
1189
desc = 'forward and inverse field' )
1190
1190
1191
1191
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 )),
1194
1194
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 )),
1196
1196
desc = 'dartel imported class images' )
1197
1197
normalized_class_images = traits .List (traits .List (File (exists = True )),
1198
1198
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 )),
1200
1200
desc = 'modulated+normalized class images' )
1201
1201
transformation_mat = OutputMultiPath (File (exists = True ),
1202
1202
desc = 'Normalization transformation' )
1203
1203
1204
1204
bias_corrected_images = OutputMultiPath (
1205
- File (exists = True ),
1205
+ File (exists = True ),
1206
1206
desc = 'bias corrected images' )
1207
1207
normalized_bias_corrected_images = OutputMultiPath (
1208
1208
File (exists = True ),
@@ -1211,7 +1211,7 @@ class VBMSegmentOuputSpec(TraitedSpec):
1211
1211
pve_label_native_images = OutputMultiPath (File (exists = True ))
1212
1212
pve_label_normalized_images = OutputMultiPath (File (exists = True ))
1213
1213
pve_label_registered_images = OutputMultiPath (File (exists = True ))
1214
-
1214
+
1215
1215
forward_deformation_field = OutputMultiPath (File (exists = True ))
1216
1216
inverse_deformation_field = OutputMultiPath (File (exists = True ))
1217
1217
@@ -1223,102 +1223,114 @@ class VBMSegment(SPMCommand):
1223
1223
1224
1224
_jobtype = 'tools'
1225
1225
_jobname = 'vbm8'
1226
-
1226
+
1227
1227
def _list_outputs (self ):
1228
1228
outputs = self ._outputs ().get ()
1229
-
1229
+
1230
1230
do_dartel = self .inputs .spatial_normalization
1231
1231
dartel_px = ''
1232
1232
if do_dartel :
1233
1233
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' ] = [[], [], []]
1239
1239
1240
1240
outputs ['transformation_mat' ] = []
1241
1241
1242
1242
outputs ['bias_corrected_images' ] = []
1243
1243
outputs ['normalized_bias_corrected_images' ] = []
1244
1244
1245
1245
outputs ['inverse_deformation_field' ] = []
1246
- outputs ['forward_deformation_field' ] = []
1246
+ outputs ['forward_deformation_field' ] = []
1247
1247
outputs ['jacobian_determinant_images' ] = []
1248
-
1248
+
1249
1249
outputs ['pve_label_native_images' ] = []
1250
1250
outputs ['pve_label_normalized_images' ] = []
1251
1251
outputs ['pve_label_registered_images' ] = []
1252
1252
1253
1253
for filename in self .inputs .in_files :
1254
1254
pth , base , ext = split_filename (filename )
1255
1255
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 ))
1257
1258
1258
- for i ,tis in enumerate (['gm' ,'wm' ,'csf' ]):
1259
+ for i , tis in enumerate (['gm' , 'wm' , 'csf' ]):
1259
1260
# native space
1260
1261
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 )))
1271
1283
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
-
1279
1284
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 )))
1281
1287
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 )))
1288
1296
1289
1297
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 )))
1291
1300
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 )))
1293
1303
1294
1304
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 )))
1296
1307
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 )))
1298
1310
1299
1311
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 )))
1301
1314
return outputs
1302
1315
1303
-
1304
1316
def _format_arg (self , opt , spec , val ):
1305
1317
"""Convert input to appropriate format for spm
1306
1318
"""
1307
1319
if opt in ['in_files' ]:
1308
1320
return scans_for_fnames (val , keep4d = True )
1309
1321
elif opt in ['spatial_normalization' ]:
1310
1322
if val == 'low' :
1311
- return {'normlow' :[]}
1323
+ return {'normlow' : []}
1312
1324
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 ])])
1314
1326
else :
1315
1327
return super (VBMSegment , self )._format_arg (opt , spec , val )
1316
-
1328
+
1317
1329
def _parse_inputs (self ):
1318
1330
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 }
1321
1334
return einputs
1322
1335
else :
1323
1336
return super (VBMSegment , self )._parse_inputs (skip = ('spatial_normalization' ))
1324
-
0 commit comments