@@ -678,17 +678,17 @@ def _list_outputs(self):
678
678
'_variance.ext' , cwd = cwd )
679
679
outputs ['std_img' ] = self ._gen_fname (outputs ['out_file' ] +
680
680
'_sigma.ext' , cwd = cwd )
681
-
681
+
682
682
# The mean image created if -stats option is specified ('meanvol')
683
- # is missing the top and bottom slices. Therefore we only expose the
684
- # mean image created by -meanvol option ('mean_reg') which isn't
683
+ # is missing the top and bottom slices. Therefore we only expose the
684
+ # mean image created by -meanvol option ('mean_reg') which isn't
685
685
# corrupted.
686
686
# Note that the same problem holds for the std and variance image.
687
-
687
+
688
688
if isdefined (self .inputs .mean_vol ) and self .inputs .mean_vol :
689
689
outputs ['mean_img' ] = self ._gen_fname (outputs ['out_file' ] +
690
690
'_mean_reg.ext' , cwd = cwd )
691
-
691
+
692
692
if isdefined (self .inputs .save_mats ) and self .inputs .save_mats :
693
693
_ , filename = os .path .split (outputs ['out_file' ])
694
694
matpathname = os .path .join (cwd , filename + '.mat' )
@@ -1159,9 +1159,8 @@ def _gen_filename(self, name):
1159
1159
class FUGUEInputSpec (FSLCommandInputSpec ):
1160
1160
in_file = File (exists = True , argstr = '--in=%s' ,
1161
1161
desc = 'filename of input volume' )
1162
- unwarped_file = File (
1163
- argstr = '--unwarp=%s' , genfile = True ,
1164
- desc = 'apply unwarping and save as filename' , hash_files = False )
1162
+ unwarped_file = File (argstr = '--unwarp=%s' , desc = 'apply unwarping and save as filename' ,
1163
+ hash_files = False )
1165
1164
forward_warping = traits .Bool (
1166
1165
False , usedefault = True ,
1167
1166
desc = 'apply forward warping instead of unwarping' )
@@ -1242,7 +1241,16 @@ class FUGUE(FSLCommand):
1242
1241
Examples
1243
1242
--------
1244
1243
1245
- Please insert examples for use of this command
1244
+ >>> from nipype.interfaces.fsl.preprocess import FUGUE
1245
+ >>> fugue = FUGUE()
1246
+ >>> fugue.inputs.forward_warping = True
1247
+ >>> fugue.inputs.in_file = 'epi.nii'
1248
+ >>> fugue.inputs.mask_file = 'epi_mask.nii'
1249
+ >>> fugue.inputs.shift_in_file = 'image.nii' # Previously computed with fugue as well
1250
+ >>> fugue.inputs.unwarp_direction = 'y'
1251
+ >>> fugue.cmdline #doctest: +ELLIPSIS
1252
+ 'fugue --in=epi.nii --mask=epi_mask.nii --loadshift=image.nii --unwarpdir=y --warp=.../epi_warped.nii.gz'
1253
+ >>> fugue.run() #doctest: +SKIP
1246
1254
1247
1255
"""
1248
1256
@@ -1257,10 +1265,14 @@ def __init__(self, **kwargs):
1257
1265
1258
1266
def _list_outputs (self ):
1259
1267
outputs = self ._outputs ().get ()
1260
- if self .inputs .forward_warping :
1268
+
1269
+ if isdefined (self .inputs .forward_warping ) and self .inputs .forward_warping :
1261
1270
out_field = 'warped_file'
1271
+ self .inputs .unwarped_file = Undefined
1272
+ outputs .pop ('unwarped_file' )
1262
1273
else :
1263
1274
out_field = 'unwarped_file'
1275
+ outputs .pop ('warped_file' )
1264
1276
1265
1277
out_file = getattr (self .inputs , out_field )
1266
1278
if not isdefined (out_file ):
@@ -1279,10 +1291,11 @@ def _list_outputs(self):
1279
1291
return outputs
1280
1292
1281
1293
def _gen_filename (self , name ):
1282
- if name == 'unwarped_file' and not self .inputs .forward_warping :
1283
- return self ._list_outputs ()['unwarped_file' ]
1284
- if name == 'warped_file' and self .inputs .forward_warping :
1285
- return self ._list_outputs ()['warped_file' ]
1294
+ is_fwd = isdefined (self .inputs .forward_warping ) and self .inputs .forward_warping
1295
+
1296
+ if (is_fwd and name == 'warped_file' ) or (not is_fwd and name == 'unwarped_file' ):
1297
+ return self ._list_outputs ()[name ]
1298
+
1286
1299
return None
1287
1300
1288
1301
def _parse_inputs (self , skip = None ):
0 commit comments