22
22
23
23
import os
24
24
import os .path as op
25
+ import re
25
26
from glob import glob
26
27
import warnings
27
28
import tempfile
@@ -608,7 +609,7 @@ def aggregate_outputs(self, runtime=None, needed_outputs=None):
608
609
return outputs
609
610
610
611
611
- class AvScaleInputSpec (FSLCommandInputSpec ):
612
+ class AvScaleInputSpec (CommandLineInputSpec ):
612
613
all_param = traits .Bool (False , argstr = '--allparams' )
613
614
mat_file = File (exists = True , argstr = '%s' ,
614
615
desc = 'mat file to read' , position = - 2 )
@@ -633,7 +634,7 @@ class AvScaleOutputSpec(TraitedSpec):
633
634
translations = traits .List (traits .Float , desc = 'translations' )
634
635
635
636
636
- class AvScale (FSLCommand ):
637
+ class AvScale (CommandLine ):
637
638
"""Use FSL avscale command to extract info from mat file output of FLIRT
638
639
639
640
Examples
@@ -650,11 +651,9 @@ class AvScale(FSLCommand):
650
651
651
652
_cmd = 'avscale'
652
653
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 )
655
656
656
- def aggregate_outputs (self , runtime = None , needed_outputs = None ):
657
- outputs = self ._outputs ()
658
657
659
658
expr = re .compile (
660
659
'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):
669
668
'(?P<fwd_half_xfm>[0-9\.\ \n -]+)[\s\n ]*'
670
669
'Backward\ half\ transform\ =[\s]*\n '
671
670
'(?P<bwd_half_xfm>[0-9\.\ \n -]+)[\s\n ]*' )
672
-
673
671
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 ( ' ' ) ]
679
677
outputs ['average_scaling' ] = float (out ['avg_scaling' ].strip ())
680
678
outputs ['determinant' ] = float (out ['determinant' ].strip ())
681
679
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 ' )]
686
684
687
685
if self .inputs .all_param :
688
686
outputs ['rot_angles' ] = [float (r ) for r in out ['rot_angles' ].strip ().split (' ' )]
689
687
outputs ['translations' ] = [float (r ) for r in out ['translations' ].strip ().split (' ' )]
690
688
691
- return outputs
689
+
690
+ setattr (self , '_results' , outputs )
691
+ return runtime
692
+
693
+ def _list_outputs (self ):
694
+ return self ._results
692
695
693
696
694
697
class OverlayInputSpec (FSLCommandInputSpec ):
0 commit comments