@@ -2909,19 +2909,47 @@ def _list_outputs(self):
2909
2909
2910
2910
2911
2911
class MRIsExpandInputSpec (FSTraitedSpec ):
2912
+ # Input spec derived from
2913
+ # https://github.com/freesurfer/freesurfer/blob/102e053/mris_expand/mris_expand.c
2912
2914
in_file = File (
2913
2915
exists = True , mandatory = True , argstr = '%s' , position = - 3 ,
2914
2916
desc = 'Surface to expand' )
2915
2917
distance = traits .Float (
2916
2918
mandatory = True , argstr = '%g' , position = - 2 ,
2917
2919
desc = 'Distance in mm or fraction of cortical thickness' )
2918
- out_file = File (
2919
- argstr = '%s' , position = - 1 ,
2920
- name_template = '%s.expanded' , name_source = 'in_file' ,
2921
- desc = 'Output surface file' )
2920
+ out_name = traits . Str (
2921
+ 'expanded' , argstr = '%s' , position = - 1 , usedefault = True ,
2922
+ desc = ( 'Output surface file \n '
2923
+ 'If missing "lh." or "rh.", derive from `in_file`' ) )
2922
2924
thickness = traits .Bool (
2923
2925
argstr = '-thickness' ,
2924
2926
desc = 'Expand by fraction of cortical thickness, not mm' )
2927
+ thickness_name = traits .Str (
2928
+ argstr = "-thickness_name %s" ,
2929
+ desc = ('Name of thickness file (implicit: "thickness")\n '
2930
+ 'If no path, uses directory of `in_file`\n '
2931
+ 'If missing "lh." or "rh.", derive from `in_file`' ))
2932
+ navgs = traits .Tuple (
2933
+ traits .Int , traits .Int ,
2934
+ argstr = '-navgs %d %d' ,
2935
+ desc = ('Tuple of (n_averages, min_averages) parameters '
2936
+ '(implicit: (16, 0))' ))
2937
+ pial = traits .Str (
2938
+ argstr = '-pial %s' ,
2939
+ desc = ('Name of pial file (implicit: "pial")\n '
2940
+ 'If no path, uses directory of `in_file`\n '
2941
+ 'If missing "lh." or "rh.", derive from `in_file`' ))
2942
+ spring = traits .Float (argstr = '-S %g' , desc = "Spring term (implicit: 0.05)" )
2943
+ dt = traits .Float (argstr = '-T %g' , desc = 'dt (implicit: 0.25)' )
2944
+ write_iterations = traits .Int (
2945
+ argstr = '-W %d' ,
2946
+ desc = 'Write snapshots of expansion every N iterations' )
2947
+ smooth_averages = traits .Int (
2948
+ argstr = '-A %d' ,
2949
+ desc = 'Smooth surface with N iterations after expansion' )
2950
+ nsurfaces = traits .Int (
2951
+ argstr = '-N %d' ,
2952
+ desc = 'Number of surfacces to write during expansion' )
2925
2953
2926
2954
2927
2955
class MRIsExpandOutputSpec (TraitedSpec ):
@@ -2938,12 +2966,30 @@ class MRIsExpand(FSCommand):
2938
2966
>>> from nipype.interfaces.freesurfer import MRIsExpand
2939
2967
>>> mris_expand = MRIsExpand(thickness=True, distance=0.5)
2940
2968
>>> mris_expand.inputs.in_file = 'lh.white'
2941
- >>> mris_expand.cmdline # doctest: +ALLOW_UNICODE
2942
- 'mris_expand -thickness lh.white 0.5 lh.expanded'
2943
- >>> mris_expand.inputs.out_file = 'lh. graymid'
2944
- >>> mris_expand.cmdline # doctest: +ALLOW_UNICODE
2945
- 'mris_expand -thickness lh.white 0.5 lh.graymid'
2969
+ >>> mris_expand.cmdline # doctest: +ALLOW_UNICODE, +ELLIPSIS
2970
+ 'mris_expand -thickness lh.white 0.5 .../ lh.expanded'
2971
+ >>> mris_expand.inputs.out_name = 'graymid'
2972
+ >>> mris_expand.cmdline # doctest: +ALLOW_UNICODE, +ELLIPSIS
2973
+ 'mris_expand -thickness lh.white 0.5 .../ lh.graymid'
2946
2974
"""
2947
2975
_cmd = 'mris_expand'
2948
2976
input_spec = MRIsExpandInputSpec
2949
2977
output_spec = MRIsExpandOutputSpec
2978
+
2979
+ def _format_arg (self , name , spec , value ):
2980
+ if name == 'out_name' :
2981
+ value = self ._list_outputs ()['out_file' ]
2982
+ return super (MRIsExpand , self )._format_arg (name , spec , value )
2983
+
2984
+ def _list_outputs (self ):
2985
+ outputs = self ._outputs ().get ()
2986
+ # Mimic FreeSurfer output filename derivation, but in local directory
2987
+ # if no path specified
2988
+ out_file = self .inputs .out_name
2989
+ path , base = os .path .split (out_file )
2990
+ if path == '' and base [:3 ] not in ('lh.' , 'rh.' ):
2991
+ in_file = os .path .basename (self .inputs .in_file )
2992
+ if in_file [:3 ] in ('lh.' , 'rh.' ):
2993
+ out_file = os .path .basename (self .inputs .in_file )[:3 ] + base
2994
+ outputs ["out_file" ] = os .path .abspath (out_file )
2995
+ return outputs
0 commit comments