@@ -3369,7 +3369,10 @@ class XfmInvertInputSpec(CommandLineInputSpec):
3369
3369
desc = 'output file' ,
3370
3370
genfile = True ,
3371
3371
argstr = '%s' ,
3372
- position = - 1 ,)
3372
+ position = - 1 ,
3373
+ name_source = ['input_file' ],
3374
+ hash_files = False ,
3375
+ name_template = '%s_xfminvert.xfm' )
3373
3376
3374
3377
verbose = traits .Bool (
3375
3378
desc = 'Print out log messages. Default: False.' ,
@@ -3383,7 +3386,6 @@ class XfmInvertInputSpec(CommandLineInputSpec):
3383
3386
3384
3387
class XfmInvertOutputSpec (TraitedSpec ):
3385
3388
output_file = File (desc = 'output file' , exists = True )
3386
- # FIXME is exists=True always correct?
3387
3389
output_grid = File (desc = 'output grid file' , exists = True )
3388
3390
3389
3391
@@ -3405,32 +3407,13 @@ class XfmInvert(CommandLine):
3405
3407
output_spec = XfmInvertOutputSpec
3406
3408
_cmd = 'xfminvert'
3407
3409
3408
- def _gen_filename (self , name ):
3409
- if name == 'output_file' :
3410
- output_file = self .inputs .output_file
3411
-
3412
- if isdefined (output_file ):
3413
- return os .path .abspath (output_file )
3414
- else :
3415
- return aggregate_filename (
3416
- [self .inputs .input_file ], 'xfminvert_output' ) + '.xfm'
3417
- else :
3418
- raise NotImplemented
3419
-
3420
- def _gen_outfilename (self ):
3421
- return self ._gen_filename ('output_file' )
3422
-
3423
3410
def _list_outputs (self ):
3424
- outputs = self .output_spec ().get ()
3425
- outputs ['output_file' ] = os .path .abspath (self ._gen_outfilename ())
3411
+ outputs = super (XfmInvert , self )._list_outputs ()
3426
3412
3427
- # FIXME Is this the sensible? No other way to tell if the grid files
3428
- # were produced.
3429
- # FIXME This is safe to assume?
3430
- assert os .path .exists (outputs ['output_file' ])
3431
- if 'grid' in open (outputs ['output_file' ], 'r' ).read ():
3432
- outputs ['output_grid' ] = re .sub (
3433
- '.(nlxfm|xfm)$' , '_grid_0.mnc' , outputs ['output_file' ])
3413
+ if os .path .exists (outputs ['output_file' ]):
3414
+ if 'grid' in open (outputs ['output_file' ], 'r' ).read ():
3415
+ outputs ['output_grid' ] = re .sub (
3416
+ '.(nlxfm|xfm)$' , '_grid_0.mnc' , outputs ['output_file' ])
3434
3417
3435
3418
return outputs
3436
3419
0 commit comments