# This file was auto generated by Styx.
# Do not edit this file directly.

import typing
import pathlib
from styxdefs import *
import dataclasses

V__FIX_FSSPHERE_METADATA = Metadata(
    id="b742177d5b0ebe3a73650e2f92bfe87238f0bcca.boutiques",
    name="@fix_FSsphere",
    package="afni",
    container_image_tag="afni/afni_make_build:AFNI_24.2.06",
)


class VFixFssphereOutputs(typing.NamedTuple):
    """
    Output object returned when calling `v__fix_fssphere(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    corrected_surface: OutputPathType
    """Corrected surface"""


def v__fix_fssphere(
    spec_file: InputPathType,
    sphere_file: InputPathType,
    num_iterations: int | None = None,
    extent_lim: float | None = None,
    project_first: bool = False,
    keep_temp: bool = False,
    runner: Runner | None = None,
) -> VFixFssphereOutputs:
    """
    Tool for fixing errors in FreeSurfer spherical surfaces.
    
    Author: AFNI Developers
    
    URL: https://afni.nimh.nih.gov/
    
    Args:
        spec_file: Spec file.
        sphere_file: SPHERE.asc is the sphere to be used.
        num_iterations: Number of local smoothing operations. Default is 3000.
        extent_lim: Extent, in mm, by which troubled sections are fattened.\
            Default is 6.
        project_first: Project to a sphere, before smoothing. Default is 0.
        keep_temp: Keep temporary files.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `VFixFssphereOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(V__FIX_FSSPHERE_METADATA)
    cargs = []
    cargs.append("@fix_FSsphere")
    cargs.extend([
        "-spec",
        execution.input_file(spec_file)
    ])
    cargs.extend([
        "-sphere",
        execution.input_file(sphere_file)
    ])
    if num_iterations is not None:
        cargs.extend([
            "-niter",
            str(num_iterations)
        ])
    if extent_lim is not None:
        cargs.extend([
            "-lim",
            str(extent_lim)
        ])
    if project_first:
        cargs.append("-project_first")
    if keep_temp:
        cargs.append("-keep_temp")
    ret = VFixFssphereOutputs(
        root=execution.output_file("."),
        corrected_surface=execution.output_file("[SPHERE]_fxd.asc"),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "VFixFssphereOutputs",
    "V__FIX_FSSPHERE_METADATA",
    "v__fix_fssphere",
]
