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

import typing
import pathlib
from styxdefs import *
import dataclasses

MRIS_SEG2ANNOT_METADATA = Metadata(
    id="4bbdc9d57b691b8f7d4b0333b1d194fbe54c8e5b.boutiques",
    name="mris_seg2annot",
    package="freesurfer",
    container_image_tag="freesurfer/freesurfer:7.4.1",
)


class MrisSeg2annotOutputs(typing.NamedTuple):
    """
    Output object returned when calling `mris_seg2annot(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    annotation_file: OutputPathType
    """Output custom annotation file."""


def mris_seg2annot(
    surfseg: InputPathType,
    subject: str,
    hemi: str,
    output_annotation: InputPathType,
    colortable: InputPathType | None = None,
    auto_ctab: str | None = None,
    surf: str | None = None,
    debug: bool = False,
    debug_vertex: float | None = None,
    checkopts: bool = False,
    version: bool = False,
    runner: Runner | None = None,
) -> MrisSeg2annotOutputs:
    """
    Converts a surface-based segmentation into a custom annotation file.
    
    Author: FreeSurfer Developers
    
    URL: https://github.com/freesurfer/freesurfer
    
    Args:
        surfseg: Volume-encoded surface segmentation. Values are indices into\
            the color table.
        subject: Subject name.
        hemi: Surface hemifield.
        output_annotation: Output annotation file. E.g., lh.aparc.annot.
        colortable: Color table used to map segmentation index to name and\
            color.
        auto_ctab: Create a random color table and optionally save it.
        surf: Surface name, default is white.
        debug: Turn on debugging.
        debug_vertex: Turn on debugging for vertex.
        checkopts: Don't run anything, just check options and exit.
        version: Print out version and exit.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `MrisSeg2annotOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(MRIS_SEG2ANNOT_METADATA)
    cargs = []
    cargs.append("mris_seg2annot")
    cargs.extend([
        "--seg",
        execution.input_file(surfseg)
    ])
    if colortable is not None:
        cargs.extend([
            "--ctab",
            execution.input_file(colortable)
        ])
    if auto_ctab is not None:
        cargs.extend([
            "--ctab-auto",
            auto_ctab
        ])
    cargs.extend([
        "--s",
        subject
    ])
    cargs.extend([
        "--h",
        hemi
    ])
    cargs.extend([
        "--o",
        execution.input_file(output_annotation)
    ])
    if surf is not None:
        cargs.extend([
            "--surf",
            surf
        ])
    if debug:
        cargs.append("--debug")
    if debug_vertex is not None:
        cargs.extend([
            "--debug-vertex",
            str(debug_vertex)
        ])
    if checkopts:
        cargs.append("--checkopts")
    if version:
        cargs.append("--version")
    ret = MrisSeg2annotOutputs(
        root=execution.output_file("."),
        annotation_file=execution.output_file(pathlib.Path(output_annotation).name),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "MRIS_SEG2ANNOT_METADATA",
    "MrisSeg2annotOutputs",
    "mris_seg2annot",
]
