@@ -2882,19 +2882,47 @@ def _list_outputs(self):
2882
2882
2883
2883
2884
2884
class MRIsExpandInputSpec (FSTraitedSpec ):
2885
+ # Input spec derived from
2886
+ # https://github.com/freesurfer/freesurfer/blob/102e053/mris_expand/mris_expand.c
2885
2887
in_file = File (
2886
2888
exists = True , mandatory = True , argstr = '%s' , position = - 3 ,
2887
2889
desc = 'Surface to expand' )
2888
2890
distance = traits .Float (
2889
2891
mandatory = True , argstr = '%g' , position = - 2 ,
2890
2892
desc = 'Distance in mm or fraction of cortical thickness' )
2891
- out_file = File (
2892
- argstr = '%s' , position = - 1 ,
2893
- name_template = '%s.expanded' , name_source = 'in_file' ,
2894
- desc = 'Output surface file' )
2893
+ out_name = traits . Str (
2894
+ 'expanded' , argstr = '%s' , position = - 1 , usedefault = True ,
2895
+ desc = ( 'Output surface file \n '
2896
+ 'If missing "lh." or "rh.", derive from `in_file`' ) )
2895
2897
thickness = traits .Bool (
2896
2898
argstr = '-thickness' ,
2897
2899
desc = 'Expand by fraction of cortical thickness, not mm' )
2900
+ thickness_name = traits .Str (
2901
+ argstr = "-thickness_name %s" ,
2902
+ desc = ('Name of thickness file (implicit: "thickness")\n '
2903
+ 'If no path, uses directory of `in_file`\n '
2904
+ 'If missing "lh." or "rh.", derive from `in_file`' ))
2905
+ navgs = traits .Tuple (
2906
+ traits .Int , traits .Int ,
2907
+ argstr = '-navgs %d %d' ,
2908
+ desc = ('Tuple of (n_averages, min_averages) parameters '
2909
+ '(implicit: (16, 0))' ))
2910
+ pial = traits .Str (
2911
+ argstr = '-pial %s' ,
2912
+ desc = ('Name of pial file (implicit: "pial")\n '
2913
+ 'If no path, uses directory of `in_file`\n '
2914
+ 'If missing "lh." or "rh.", derive from `in_file`' ))
2915
+ spring = traits .Float (argstr = '-S %g' , desc = "Spring term (implicit: 0.05)" )
2916
+ dt = traits .Float (argstr = '-T %g' , desc = 'dt (implicit: 0.25)' )
2917
+ write_iterations = traits .Int (
2918
+ argstr = '-W %d' ,
2919
+ desc = 'Write snapshots of expansion every N iterations' )
2920
+ smooth_averages = traits .Int (
2921
+ argstr = '-A %d' ,
2922
+ desc = 'Smooth surface with N iterations after expansion' )
2923
+ nsurfaces = traits .Int (
2924
+ argstr = '-N %d' ,
2925
+ desc = 'Number of surfacces to write during expansion' )
2898
2926
2899
2927
2900
2928
class MRIsExpandOutputSpec (TraitedSpec ):
@@ -2920,3 +2948,20 @@ class MRIsExpand(FSCommand):
2920
2948
_cmd = 'mris_expand'
2921
2949
input_spec = MRIsExpandInputSpec
2922
2950
output_spec = MRIsExpandOutputSpec
2951
+
2952
+ def _format_arg (self , name , spec , value ):
2953
+ if name == 'out_name' :
2954
+ value = self ._list_outputs ()['out_file' ]
2955
+ return super (MRIsExpand , self )._format_arg (name , spec , value )
2956
+
2957
+ def _list_outputs (self ):
2958
+ outputs = self ._outputs ().get ()
2959
+ # Mimic FreeSurfer output filename derivation, but in local directory
2960
+ # if no path specified
2961
+ out_file = self .inputs .out_name
2962
+ path , base = os .path .split (out_file )
2963
+ if all ((path == '' , not base .startswith ('lh.' ),
2964
+ not base .startswith ('rh.' ))):
2965
+ out_file = self .inputs .in_file [:3 ] + base
2966
+ outputs ["out_file" ] = os .path .abspath (out_file )
2967
+ return outputs
0 commit comments