@@ -3369,7 +3369,10 @@ class XfmInvertInputSpec(CommandLineInputSpec):
33693369 desc = 'output file' ,
33703370 genfile = True ,
33713371 argstr = '%s' ,
3372- position = - 1 ,)
3372+ position = - 1 ,
3373+ name_source = ['input_file' ],
3374+ hash_files = False ,
3375+ name_template = '%s_xfminvert.xfm' )
33733376
33743377 verbose = traits .Bool (
33753378 desc = 'Print out log messages. Default: False.' ,
@@ -3383,7 +3386,6 @@ class XfmInvertInputSpec(CommandLineInputSpec):
33833386
33843387class XfmInvertOutputSpec (TraitedSpec ):
33853388 output_file = File (desc = 'output file' , exists = True )
3386- # FIXME is exists=True always correct?
33873389 output_grid = File (desc = 'output grid file' , exists = True )
33883390
33893391
@@ -3405,32 +3407,13 @@ class XfmInvert(CommandLine):
34053407 output_spec = XfmInvertOutputSpec
34063408 _cmd = 'xfminvert'
34073409
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-
34233410 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 ()
34263412
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' ])
34343417
34353418 return outputs
34363419
0 commit comments