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

import typing
import pathlib
from styxdefs import *
import dataclasses

MRI_TESSELLATE_METADATA = Metadata(
    id="9dcf92c1d5089255feba7b2627ab0237e0be1c67.boutiques",
    name="mri_tessellate",
    package="freesurfer",
    container_image_tag="freesurfer/freesurfer:7.4.1",
)


class MriTessellateOutputs(typing.NamedTuple):
    """
    Output object returned when calling `mri_tessellate(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    output_surface_file: OutputPathType
    """Output file of the tessellation surface, typically ?h.orig."""


def mri_tessellate(
    input_volume: InputPathType,
    label_value: int,
    output_surf: str,
    different_labels: bool = False,
    max_vertices: int | None = None,
    real_ras: bool = False,
    runner: Runner | None = None,
) -> MriTessellateOutputs:
    """
    This program creates a surface by tessellating a given input volume.
    
    Author: FreeSurfer Developers
    
    URL: https://github.com/freesurfer/freesurfer
    
    Args:
        input_volume: Input volume (e.g., a filled MRI image).
        label_value: Label value for the tessellation. Integer value, if input\
            is filled volume, 127 is rh, 255 is lh.
        output_surf: Binary surface of the tessellation, output file.
        different_labels: Tessellate the surface of all voxels with different\
            labels.
        max_vertices: Set the max number of vertices to nvertices, and the max\
            number of faces to (2 * nvertices).
        real_ras: Save surface with real RAS coordinates where c_(r,a,s) != 0.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `MriTessellateOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(MRI_TESSELLATE_METADATA)
    cargs = []
    cargs.append("mri_tessellate")
    cargs.append(execution.input_file(input_volume))
    cargs.append(str(label_value))
    cargs.append(output_surf)
    if different_labels:
        cargs.append("-a")
    if max_vertices is not None:
        cargs.extend([
            "-maxv",
            str(max_vertices)
        ])
    if real_ras:
        cargs.append("-n")
    ret = MriTessellateOutputs(
        root=execution.output_file("."),
        output_surface_file=execution.output_file(output_surf),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "MRI_TESSELLATE_METADATA",
    "MriTessellateOutputs",
    "mri_tessellate",
]
