2222
2323import os
2424import os .path as op
25+ import re
2526from glob import glob
2627import warnings
2728import tempfile
@@ -608,7 +609,7 @@ def aggregate_outputs(self, runtime=None, needed_outputs=None):
608609 return outputs
609610
610611
611- class AvScaleInputSpec (FSLCommandInputSpec ):
612+ class AvScaleInputSpec (CommandLineInputSpec ):
612613 all_param = traits .Bool (False , argstr = '--allparams' )
613614 mat_file = File (exists = True , argstr = '%s' ,
614615 desc = 'mat file to read' , position = - 2 )
@@ -633,7 +634,7 @@ class AvScaleOutputSpec(TraitedSpec):
633634 translations = traits .List (traits .Float , desc = 'translations' )
634635
635636
636- class AvScale (FSLCommand ):
637+ class AvScale (CommandLine ):
637638 """Use FSL avscale command to extract info from mat file output of FLIRT
638639
639640 Examples
@@ -650,11 +651,9 @@ class AvScale(FSLCommand):
650651
651652 _cmd = 'avscale'
652653
653- def _format_arg (self , name , trait_spec , value ):
654- return super (AvScale , self )._format_arg ( name , trait_spec , value )
654+ def _run_interface (self , runtime ):
655+ runtime = super (AvScale , self )._run_interface ( runtime )
655656
656- def aggregate_outputs (self , runtime = None , needed_outputs = None ):
657- outputs = self ._outputs ()
658657
659658 expr = re .compile (
660659 'Rotation\ &\ Translation\ Matrix:\n (?P<rot_tran_mat>[0-9\.\ \n -]+)[\s\n ]*'
@@ -669,26 +668,30 @@ def aggregate_outputs(self, runtime=None, needed_outputs=None):
669668 '(?P<fwd_half_xfm>[0-9\.\ \n -]+)[\s\n ]*'
670669 'Backward\ half\ transform\ =[\s]*\n '
671670 '(?P<bwd_half_xfm>[0-9\.\ \n -]+)[\s\n ]*' )
672-
673671 out = expr .search (runtime .stdout ).groupdict ()
674-
675- outputs ['rotation_translation_matrix' ] = [
676- float (v ) for v in r .split (' ' ) for r in out ['rot_tran_mat' ].strip ().split ('\n ' )]
677- outputs ['scales' ] = [float (s ) for s in out ['scales' ].strip ()]
678- outputs ['skews' ] = [float (s ) for s in out ['skews' ].strip ()]
672+ outputs = {}
673+ outputs ['rotation_translation_matrix' ] = [[
674+ float (v ) for v in r .strip (). split (' ' )] for r in out ['rot_tran_mat' ].strip ().split ('\n ' )]
675+ outputs ['scales' ] = [float (s ) for s in out ['scales' ].strip (). split ( ' ' ) ]
676+ outputs ['skews' ] = [float (s ) for s in out ['skews' ].strip (). split ( ' ' ) ]
679677 outputs ['average_scaling' ] = float (out ['avg_scaling' ].strip ())
680678 outputs ['determinant' ] = float (out ['determinant' ].strip ())
681679 outputs ['left_right_orientation_preserved' ] = out ['lr_orientation' ].strip () == 'preserved'
682- outputs ['forward_half_transform' ] = [
683- float (v ) for v in r .split (' ' ) for r in out ['fwd_half_xfm' ].strip ().split ('\n ' )]
684- outputs ['backward_half_transform' ] = [
685- float (v ) for v in r .split (' ' ) for r in out ['bwd_half_xfm' ].strip ().split ('\n ' )]
680+ outputs ['forward_half_transform' ] = [[
681+ float (v ) for v in r .strip (). split (' ' )] for r in out ['fwd_half_xfm' ].strip ().split ('\n ' )]
682+ outputs ['backward_half_transform' ] = [[
683+ float (v ) for v in r .strip (). split (' ' )] for r in out ['bwd_half_xfm' ].strip ().split ('\n ' )]
686684
687685 if self .inputs .all_param :
688686 outputs ['rot_angles' ] = [float (r ) for r in out ['rot_angles' ].strip ().split (' ' )]
689687 outputs ['translations' ] = [float (r ) for r in out ['translations' ].strip ().split (' ' )]
690688
691- return outputs
689+
690+ setattr (self , '_results' , outputs )
691+ return runtime
692+
693+ def _list_outputs (self ):
694+ return self ._results
692695
693696
694697class OverlayInputSpec (FSLCommandInputSpec ):
0 commit comments