@@ -3254,11 +3254,7 @@ class XfmAvgInputSpec(CommandLineInputSpec):
3254
3254
desc = 'output file' ,
3255
3255
genfile = True ,
3256
3256
argstr = '%s' ,
3257
- position = - 1 ,
3258
- name_source = ['input_files' ],
3259
- hash_files = False ,
3260
- name_template = '%s_xfmavg.xfm' ,
3261
- keep_extension = False )
3257
+ position = - 1 ,)
3262
3258
3263
3259
verbose = traits .Bool (
3264
3260
desc = 'Print out log messages. Default: False.' ,
@@ -3316,13 +3312,29 @@ class XfmAvg(CommandLine):
3316
3312
output_spec = XfmAvgOutputSpec
3317
3313
_cmd = 'xfmavg'
3318
3314
3315
+ def _gen_filename (self , name ):
3316
+ if name == 'output_file' :
3317
+ output_file = self .inputs .output_file
3318
+
3319
+ if isdefined (output_file ):
3320
+ return os .path .abspath (output_file )
3321
+ else :
3322
+ return aggregate_filename (
3323
+ self .inputs .input_files , 'xfmavg_output' ) + '.xfm'
3324
+ else :
3325
+ raise NotImplemented
3326
+
3327
+ def _gen_outfilename (self ):
3328
+ return self ._gen_filename ('output_file' )
3329
+
3319
3330
def _list_outputs (self ):
3320
- outputs = super (XfmAvg , self )._list_outputs ()
3331
+ outputs = self .output_spec ().get ()
3332
+ outputs ['output_file' ] = os .path .abspath (self ._gen_outfilename ())
3321
3333
3322
- if os .path .exists (outputs ['output_file' ]):
3323
- if 'grid' in open (outputs ['output_file' ], 'r' ).read ():
3324
- outputs ['output_grid' ] = re .sub (
3325
- '.(nlxfm|xfm)$' , '_grid_0.mnc' , outputs ['output_file' ])
3334
+ assert os .path .exists (outputs ['output_file' ])
3335
+ if 'grid' in open (outputs ['output_file' ], 'r' ).read ():
3336
+ outputs ['output_grid' ] = re .sub (
3337
+ '.(nlxfm|xfm)$' , '_grid_0.mnc' , outputs ['output_file' ])
3326
3338
3327
3339
return outputs
3328
3340
@@ -3339,10 +3351,7 @@ class XfmInvertInputSpec(CommandLineInputSpec):
3339
3351
desc = 'output file' ,
3340
3352
genfile = True ,
3341
3353
argstr = '%s' ,
3342
- position = - 1 ,
3343
- name_source = ['input_file' ],
3344
- hash_files = False ,
3345
- name_template = '%s_xfminvert.xfm' )
3354
+ position = - 1 ,)
3346
3355
3347
3356
verbose = traits .Bool (
3348
3357
desc = 'Print out log messages. Default: False.' ,
@@ -3377,13 +3386,29 @@ class XfmInvert(CommandLine):
3377
3386
output_spec = XfmInvertOutputSpec
3378
3387
_cmd = 'xfminvert'
3379
3388
3389
+ def _gen_filename (self , name ):
3390
+ if name == 'output_file' :
3391
+ output_file = self .inputs .output_file
3392
+
3393
+ if isdefined (output_file ):
3394
+ return os .path .abspath (output_file )
3395
+ else :
3396
+ return aggregate_filename (
3397
+ [self .inputs .input_file ], 'xfminvert_output' ) + '.xfm'
3398
+ else :
3399
+ raise NotImplemented
3400
+
3401
+ def _gen_outfilename (self ):
3402
+ return self ._gen_filename ('output_file' )
3403
+
3380
3404
def _list_outputs (self ):
3381
- outputs = super (XfmInvert , self )._list_outputs ()
3405
+ outputs = self .output_spec ().get ()
3406
+ outputs ['output_file' ] = os .path .abspath (self ._gen_outfilename ())
3382
3407
3383
- if os .path .exists (outputs ['output_file' ]):
3384
- if 'grid' in open (outputs ['output_file' ], 'r' ).read ():
3385
- outputs ['output_grid' ] = re .sub (
3386
- '.(nlxfm|xfm)$' , '_grid_0.mnc' , outputs ['output_file' ])
3408
+ assert os .path .exists (outputs ['output_file' ])
3409
+ if 'grid' in open (outputs ['output_file' ], 'r' ).read ():
3410
+ outputs ['output_grid' ] = re .sub (
3411
+ '.(nlxfm|xfm)$' , '_grid_0.mnc' , outputs ['output_file' ])
3387
3412
3388
3413
return outputs
3389
3414
0 commit comments