@@ -1188,14 +1188,15 @@ def _gen_filename(self, name):
1188
1188
class FUGUEInputSpec (FSLCommandInputSpec ):
1189
1189
in_file = File (exists = True , argstr = '--in=%s' ,
1190
1190
desc = 'filename of input volume' )
1191
- unwarped_file = File (argstr = '--unwarp=%s' , genfile = True ,
1192
- desc = 'apply unwarping and save as filename' , hash_files = False )
1193
-
1194
- save_warped = traits .Bool (desc = 'apply forward warp and save' )
1195
-
1196
- warped_file = File (argstr = '--warp=%s' , genfile = True ,
1197
- desc = 'apply forward warp and save as filename' , hash_files = False )
1198
-
1191
+ unwarped_file = File (
1192
+ argstr = '--unwarp=%s' , genfile = True ,
1193
+ desc = 'apply unwarping and save as filename' , hash_files = False )
1194
+ forward_warping = traits .Bool (
1195
+ False , usedefault = True ,
1196
+ desc = 'apply forward warping instead of unwarping' )
1197
+ warped_file = File (argstr = '--warp=%s' ,
1198
+ desc = 'apply forward warping and save as filename' ,
1199
+ hash_files = False )
1199
1200
phasemap_file = File (exists = True , argstr = '--phasemap=%s' ,
1200
1201
desc = 'filename for input phase image' )
1201
1202
dwell_to_asym_ratio = traits .Float (argstr = '--dwelltoasym=%.10f' ,
@@ -1211,7 +1212,7 @@ class FUGUEInputSpec(FSLCommandInputSpec):
1211
1212
1212
1213
save_shift = traits .Bool (desc = 'output pixel shift volume' )
1213
1214
1214
- shift_out_file = traits .File (argstr = '--saveshift=%s' , genfile = True ,
1215
+ shift_out_file = traits .File (argstr = '--saveshift=%s' ,
1215
1216
desc = 'filename for saving pixel shift volume' , hash_files = False )
1216
1217
1217
1218
shift_in_file = File (exists = True , argstr = '--loadshift=%s' ,
@@ -1247,25 +1248,20 @@ class FUGUEInputSpec(FSLCommandInputSpec):
1247
1248
desc = 'apply intensity correction only' )
1248
1249
mask_file = File (exists = True , argstr = '--mask=%s' ,
1249
1250
desc = 'filename for loading valid mask' )
1250
- save_unmasked_fmap = traits .Either (traits .Bool ,
1251
- traits .File ,
1252
- argstr = '--unmaskfmap=%s' ,
1253
- requires = ['fmap_out_file' ],
1254
- desc = 'saves the unmasked fieldmap when using --savefmap' , hash_files = False )
1255
- save_unmasked_shift = traits .Either (traits .Bool ,
1256
- traits .File ,
1257
- argstr = '--unmaskshift=%s' ,
1258
- requires = ['shift_out_file' ],
1259
- desc = 'saves the unmasked shiftmap when using --saveshift' , hash_files = False )
1260
- nokspace = traits .Bool (
1261
- argstr = '--nokspace' , desc = 'do not use k-space forward warping' )
1251
+ save_unmasked_fmap = traits .Bool (argstr = '--unmaskfmap' ,
1252
+ requires = ['fmap_out_file' ],
1253
+ desc = 'saves the unmasked fieldmap when using --savefmap' )
1254
+ save_unmasked_shift = traits .Bool (argstr = '--unmaskshift' ,
1255
+ requires = ['shift_out_file' ],
1256
+ desc = 'saves the unmasked shiftmap when using --saveshift' )
1257
+ nokspace = traits .Bool (argstr = '--nokspace' , desc = 'do not use k-space forward warping' )
1262
1258
1263
1259
1264
1260
class FUGUEOutputSpec (TraitedSpec ):
1265
- unwarped_file = File (exists = True , desc = 'unwarped file' )
1261
+ unwarped_file = File (desc = 'unwarped file' )
1262
+ warped_file = File (desc = 'forward warped file' )
1266
1263
shift_out_file = File (desc = 'voxel shift map file' )
1267
- warped_file = File (desc = 'warped file' )
1268
-
1264
+ fmap_out_file = File (desc = 'fieldmap file' )
1269
1265
1270
1266
class FUGUE (FSLCommand ):
1271
1267
"""Use FSL FUGUE to unwarp epi's with fieldmaps
@@ -1299,43 +1295,40 @@ def _parse_inputs(self, skip=None):
1299
1295
1300
1296
def _list_outputs (self ):
1301
1297
outputs = self ._outputs ().get ()
1302
- out_file = self .inputs .unwarped_file
1303
- if not isdefined (out_file ):
1304
- out_file = self ._gen_fname (self .inputs .in_file ,
1305
- suffix = '_unwarped' )
1306
- outputs ['unwarped_file' ] = os .path .abspath (out_file )
1307
-
1308
- if isdefined (self .inputs .save_shift ) and self .inputs .save_shift :
1309
- shift_out = self .inputs .shift_out_file
1310
- if not isdefined (shift_out ):
1311
- shift_out = self ._gen_fname (
1312
- self .inputs .in_file , suffix = '_shift' )
1298
+ if self .inputs .forward_warping :
1299
+ out_field = 'warped_file'
1300
+ else :
1301
+ out_field = 'unwarped_file'
1313
1302
1314
- outputs ['shift_out_file' ] = os .path .abspath (shift_out )
1315
-
1316
- if isdefined (self .inputs .save_warped ) and self .inputs .save_warped :
1317
- warped_out = self .inputs .warped_file
1318
- if not isdefined (warped_out ):
1319
- warped_out = self ._gen_fname (
1320
- self .inputs .in_file , suffix = '_fwdwarp' )
1321
-
1322
- outputs ['warped_file' ] = os .path .abspath (warped_out )
1323
- del outputs ['unwarped_file' ]
1303
+ out_file = getattr (self .inputs ,out_field )
1304
+ if not isdefined (out_file ):
1305
+ if isdefined (self .inputs .in_file ):
1306
+ out_file = self ._gen_fname (self .inputs .in_file ,
1307
+ suffix = '_' + out_field [:- 5 ])
1308
+ if isdefined (out_file ):
1309
+ outputs [out_field ] = os .path .abspath (out_file )
1310
+ if isdefined (self .inputs .fmap_out_file ):
1311
+ outputs ['fmap_out_file' ] = os .path .abspath (self .inputs .fmap_out_file )
1312
+ if isdefined (self .inputs .shift_out_file ):
1313
+ outputs ['shift_out_file' ] = os .path .abspath (self .inputs .shift_out_file )
1324
1314
1325
1315
return outputs
1326
1316
1327
1317
def _gen_filename (self , name ):
1328
- if name == 'unwarped_file' :
1318
+ if name == 'unwarped_file' and not self . inputs . forward_warping :
1329
1319
return self ._list_outputs ()['unwarped_file' ]
1330
-
1331
- if name == 'warped_file' :
1320
+ if name == 'warped_file' and self .inputs .forward_warping :
1332
1321
return self ._list_outputs ()['warped_file' ]
1333
-
1334
- if name == 'shift_out_file' :
1335
- return self ._list_outputs ()['shift_out_file' ]
1336
-
1337
1322
return None
1338
1323
1324
+ def _parse_inputs (self ,skip = None ):
1325
+ if skip == None :
1326
+ skip = []
1327
+ if self .inputs .forward_warping or not isdefined (self .inputs .in_file ):
1328
+ skip += ['unwarped_file' ]
1329
+ if not self .inputs .forward_warping or not isdefined (self .inputs .in_file ):
1330
+ skip += ['warped_file' ]
1331
+ return super (FUGUE ,self )._parse_inputs (skip = skip )
1339
1332
1340
1333
class PRELUDEInputSpec (FSLCommandInputSpec ):
1341
1334
complex_phase_file = File (exists = True , argstr = '--complex=%s' ,
0 commit comments