@@ -2909,19 +2909,47 @@ def _list_outputs(self):
29092909
29102910
29112911class MRIsExpandInputSpec (FSTraitedSpec ):
2912+ # Input spec derived from
2913+ # https://github.com/freesurfer/freesurfer/blob/102e053/mris_expand/mris_expand.c
29122914 in_file = File (
29132915 exists = True , mandatory = True , argstr = '%s' , position = - 3 ,
29142916 desc = 'Surface to expand' )
29152917 distance = traits .Float (
29162918 mandatory = True , argstr = '%g' , position = - 2 ,
29172919 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`' ) )
29222924 thickness = traits .Bool (
29232925 argstr = '-thickness' ,
29242926 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' )
29252953
29262954
29272955class MRIsExpandOutputSpec (TraitedSpec ):
@@ -2938,12 +2966,30 @@ class MRIsExpand(FSCommand):
29382966 >>> from nipype.interfaces.freesurfer import MRIsExpand
29392967 >>> mris_expand = MRIsExpand(thickness=True, distance=0.5)
29402968 >>> 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'
29462974 """
29472975 _cmd = 'mris_expand'
29482976 input_spec = MRIsExpandInputSpec
29492977 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