@@ -386,20 +386,19 @@ def _list_outputs(self):
386
386
class FLIRTInputSpec (FSLCommandInputSpec ):
387
387
in_file = File (exists = True , argstr = '-in %s' , mandatory = True ,
388
388
position = 0 , desc = 'input file' )
389
- # XXX Not clear if position is required for mandatory flirt inputs
390
- # since they are prefixed with argstrs. But doing it to follow
391
- # our previous convention and so we can test the generated command
392
- # line.
393
389
reference = File (exists = True , argstr = '-ref %s' , mandatory = True ,
394
390
position = 1 , desc = 'reference file' )
395
391
out_file = File (argstr = '-out %s' , desc = 'registered output file' ,
396
- genfile = True , position = 2 , hash_files = False )
392
+ name_source = ['in_file' ], name_template = '%s_flirt' ,
393
+ position = 2 , hash_files = False )
397
394
out_matrix_file = File (argstr = '-omat %s' ,
395
+ name_source = ['in_file' ], keep_extension = True ,
396
+ name_template = '%s_flirt.mat' ,
398
397
desc = 'output affine matrix in 4x4 asciii format' ,
399
- genfile = True , position = 3 , hash_files = False )
400
-
401
- out_log = File ( desc = 'output log' )
402
-
398
+ position = 3 , hash_files = False )
399
+ out_log = File ( name_source = [ 'in_file' ], keep_extension = True ,
400
+ requires = [ 'save_log' ],
401
+ name_template = '%s_flirt.log' , desc = 'output log' )
403
402
in_matrix_file = File (argstr = '-init %s' , desc = 'input 4x4 affine matrix' )
404
403
apply_xfm = traits .Bool (argstr = '-applyxfm' , requires = ['in_matrix_file' ],
405
404
desc = 'apply transformation supplied by in_matrix_file' )
@@ -533,44 +532,15 @@ class FLIRT(FSLCommand):
533
532
>>> flt = fsl.FLIRT(bins=640, cost_func='mutualinfo')
534
533
>>> flt.inputs.in_file = example_data('structural.nii')
535
534
>>> flt.inputs.reference = example_data('mni.nii')
536
- >>> flt.inputs.out_file = 'moved_subject.nii'
537
- >>> flt.inputs.out_matrix_file = 'subject_to_template. mat'
535
+ >>> flt.cmdline #doctest: +ELLIPSIS
536
+ 'flirt -in .../structural.nii -ref .../mni.nii -out structural_flirt.nii.gz -omat structural_flirt. mat -bins 640 -searchcost mutualinfo '
538
537
>>> res = flt.run() #doctest: +SKIP
539
538
540
539
"""
541
540
_cmd = 'flirt'
542
541
input_spec = FLIRTInputSpec
543
542
output_spec = FLIRTOutputSpec
544
543
545
- def _list_outputs (self ):
546
- outputs = self .output_spec ().get ()
547
- outputs ['out_file' ] = self .inputs .out_file
548
- # Generate an out_file if one is not provided
549
- if not isdefined (outputs ['out_file' ]):
550
- outputs ['out_file' ] = self ._gen_fname (self .inputs .in_file ,
551
- suffix = '_flirt' )
552
- outputs ['out_file' ] = os .path .abspath (outputs ['out_file' ])
553
-
554
- outputs ['out_matrix_file' ] = self .inputs .out_matrix_file
555
-
556
- # Generate an out_matrix file if one is not provided
557
- if not isdefined (outputs ['out_matrix_file' ]):
558
- outputs ['out_matrix_file' ] = self ._gen_fname (self .inputs .in_file ,
559
- suffix = '_flirt.mat' ,
560
- change_ext = False )
561
- outputs ['out_matrix_file' ] = os .path .abspath (
562
- outputs ['out_matrix_file' ])
563
-
564
- if isdefined (self .inputs .save_log ) and self .inputs .save_log :
565
- outputs ['out_log' ] = self .inputs .out_log
566
- # Generate an out_log file if one is not provided
567
- if not isdefined (outputs ['out_log' ]):
568
- outputs ['out_log' ] = self ._gen_fname (self .inputs .in_file ,
569
- suffix = '_flirt.log' ,
570
- change_ext = False )
571
- outputs ['out_log' ] = os .path .abspath (outputs ['out_log' ])
572
- return outputs
573
-
574
544
def aggregate_outputs (self , runtime = None , needed_outputs = None ):
575
545
outputs = super (FLIRT , self ).aggregate_outputs (
576
546
runtime = runtime , needed_outputs = needed_outputs )
@@ -581,21 +551,12 @@ def aggregate_outputs(self, runtime=None, needed_outputs=None):
581
551
582
552
def _parse_inputs (self , skip = None ):
583
553
skip = []
584
-
585
554
if isdefined (self .inputs .save_log ) and self .inputs .save_log :
586
555
if not isdefined (self .inputs .verbose ) or self .inputs .verbose == 0 :
587
556
self .inputs .verbose = 1
588
-
589
557
skip .append ('save_log' )
590
-
591
558
return super (FLIRT , self )._parse_inputs (skip = skip )
592
559
593
- def _gen_filename (self , name ):
594
- if name in ('out_file' , 'out_matrix_file' ):
595
- return self ._list_outputs ()[name ]
596
- else :
597
- return None
598
-
599
560
600
561
class ApplyXfmInputSpec (FLIRTInputSpec ):
601
562
apply_xfm = traits .Bool (
0 commit comments