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

import typing
import pathlib
from styxdefs import *
import dataclasses

MKSURFATLAS_METADATA = Metadata(
    id="e6c489c83a055f531b66d649615579c36de7f9af.boutiques",
    name="mksurfatlas",
    package="freesurfer",
    container_image_tag="freesurfer/freesurfer:7.4.1",
)


class MksurfatlasOutputs(typing.NamedTuple):
    """
    Output object returned when calling `mksurfatlas(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    output_atlas: OutputPathType
    """Resulting atlas file in TIFF format."""


def mksurfatlas(
    atlas: str,
    hemi: str,
    subjects: list[str],
    surfval: str,
    surfvaldir: str | None = "label",
    regsurf: str | None = "sphere",
    debug: bool = False,
    version: bool = False,
    help_: bool = False,
    runner: Runner | None = None,
) -> MksurfatlasOutputs:
    """
    Creates an atlas using mris_make_template. The atlas can then be used to create
    the surface registration for each subject based on this atlas.
    
    Author: FreeSurfer Developers
    
    URL: https://github.com/freesurfer/freesurfer
    
    Args:
        atlas: Save results to this file (tif file).
        hemi: Hemisphere to process.
        subjects: Subject(s) to process. Multiple subjects can be specified by\
            repeating the flag.
        surfval: Surface values file. Looks for\
            subject/surfvaldir/hemi.surfval.
        surfvaldir: Directory for surface values; default is 'label'.
        regsurf: Registration surface; default is 'sphere'.
        debug: Turn on debugging.
        version: Print version and exit.
        help_: Print help and exit.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `MksurfatlasOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(MKSURFATLAS_METADATA)
    cargs = []
    cargs.append("mksurfatlas")
    cargs.extend([
        "--a",
        atlas
    ])
    cargs.extend([
        "--h",
        hemi
    ])
    cargs.extend([
        "--s",
        *subjects
    ])
    cargs.extend([
        "--v",
        surfval
    ])
    if surfvaldir is not None:
        cargs.extend([
            "--d",
            surfvaldir
        ])
    if regsurf is not None:
        cargs.extend([
            "--r",
            regsurf
        ])
    if debug:
        cargs.append("--debug")
    if version:
        cargs.append("--version")
    if help_:
        cargs.append("--help")
    ret = MksurfatlasOutputs(
        root=execution.output_file("."),
        output_atlas=execution.output_file(atlas),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "MKSURFATLAS_METADATA",
    "MksurfatlasOutputs",
    "mksurfatlas",
]
