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

import typing
import pathlib
from styxdefs import *
import dataclasses

SURF_MESH_METADATA = Metadata(
    id="aba9dc7cdd5795dd83c2c7deb8fe8088d1965d12.boutiques",
    name="SurfMesh",
    package="afni",
    container_image_tag="afni/afni_make_build:AFNI_24.2.06",
)


class SurfMeshOutputs(typing.NamedTuple):
    """
    Output object returned when calling `surf_mesh(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    output_surface_file: OutputPathType
    """Output surface file"""


def surf_mesh(
    input_surface: str,
    output_surface: str,
    edge_fraction: float,
    surface_volume: InputPathType | None = None,
    one_state: bool = False,
    anatomical_label: bool = False,
    no_volume_registration: bool = False,
    set_env: str | None = None,
    runner: Runner | None = None,
) -> SurfMeshOutputs:
    """
    Surface mesh manipulation tool.
    
    Author: AFNI Developers
    
    URL: https://afni.nimh.nih.gov/
    
    Args:
        input_surface: Input surface file with specified type.
        output_surface: Output surface file with specified type.
        edge_fraction: Fraction of edges to simplify the surface.
        surface_volume: Surface volume file.
        one_state: Make all input surfaces have the same state.
        anatomical_label: Label all input surfaces as anatomically correct.
        no_volume_registration: Ignore any Rotate, Volreg, Tagalign, or\
            WarpDrive transformations present in the Surface Volume.
        set_env: Set environment variable.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `SurfMeshOutputs`).
    """
    if not (0 <= edge_fraction <= 1): 
        raise ValueError(f"'edge_fraction' must be between 0 <= x <= 1 but was {edge_fraction}")
    runner = runner or get_global_runner()
    execution = runner.start_execution(SURF_MESH_METADATA)
    cargs = []
    cargs.append("SurfMesh")
    cargs.extend([
        "-i_TYPE",
        input_surface
    ])
    cargs.extend([
        "-o_TYPE",
        output_surface
    ])
    cargs.extend([
        "-edges",
        str(edge_fraction)
    ])
    if surface_volume is not None:
        cargs.extend([
            "-sv",
            execution.input_file(surface_volume)
        ])
    if one_state:
        cargs.append("-onestate")
    if anatomical_label:
        cargs.append("-anatomical")
    if no_volume_registration:
        cargs.append("-novolreg")
    if set_env is not None:
        cargs.extend([
            "-setenv",
            set_env
        ])
    ret = SurfMeshOutputs(
        root=execution.output_file("."),
        output_surface_file=execution.output_file(output_surface + ".surface"),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "SURF_MESH_METADATA",
    "SurfMeshOutputs",
    "surf_mesh",
]
