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

import typing
import pathlib
from styxdefs import *
import dataclasses

MRIS_REMESH_METADATA = Metadata(
    id="2952fb621021ef623340899d397234ce68e0a747.boutiques",
    name="mris_remesh",
    package="freesurfer",
    container_image_tag="freesurfer/freesurfer:7.4.1",
)


class MrisRemeshOutputs(typing.NamedTuple):
    """
    Output object returned when calling `mris_remesh(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    remeshed_output: OutputPathType
    """Remeshed output surface file"""


def mris_remesh(
    input_: InputPathType,
    output: InputPathType,
    edge_length: float | None = None,
    num_vertices: float | None = None,
    face_area: float | None = None,
    remesh: bool = False,
    iterations: float | None = None,
    runner: Runner | None = None,
) -> MrisRemeshOutputs:
    """
    Remeshes a surface to a desired edge length, number of vertices, or average face
    area.
    
    Author: FreeSurfer Developers
    
    URL: https://github.com/freesurfer/freesurfer
    
    Args:
        input_: Input surface file.
        output: Output surface file.
        edge_length: Target average edge length in mm for remeshed surface.
        num_vertices: Target number of vertices for remeshed surface.
        face_area: Desired average face area in mm².
        remesh: Improve the quality while only reducing vertices by a small\
            amount.
        iterations: Number of remeshing iterations (default is 5).
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `MrisRemeshOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(MRIS_REMESH_METADATA)
    cargs = []
    cargs.append("mris_remesh")
    cargs.extend([
        "-i",
        execution.input_file(input_)
    ])
    cargs.extend([
        "-o",
        execution.input_file(output)
    ])
    if edge_length is not None:
        cargs.extend([
            "--edge-len",
            str(edge_length)
        ])
    if num_vertices is not None:
        cargs.extend([
            "--nvert",
            str(num_vertices)
        ])
    if face_area is not None:
        cargs.extend([
            "--desired-face-area",
            str(face_area)
        ])
    if remesh:
        cargs.append("--remesh")
    if iterations is not None:
        cargs.extend([
            "--iters",
            str(iterations)
        ])
    ret = MrisRemeshOutputs(
        root=execution.output_file("."),
        remeshed_output=execution.output_file(pathlib.Path(output).name),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "MRIS_REMESH_METADATA",
    "MrisRemeshOutputs",
    "mris_remesh",
]
