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

import typing
import pathlib
from styxdefs import *
import dataclasses

MRIS_MAKE_TEMPLATE_METADATA = Metadata(
    id="c9957f7fb67720d6d1343a3342eb0a6545f5cf7a.boutiques",
    name="mris_make_template",
    package="freesurfer",
    container_image_tag="freesurfer/freesurfer:7.4.1",
)


class MrisMakeTemplateOutputs(typing.NamedTuple):
    """
    Output object returned when calling `mris_make_template(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""


def mris_make_template(
    hemi: str,
    surface_name: str,
    subjects: list[str],
    output_name: str,
    addframe_parameters: list[str] | None = None,
    vector: bool = False,
    norot: bool = False,
    rot: bool = False,
    annot: bool = False,
    overlay_parameters: list[str] | None = None,
    overlay_dir: str | None = None,
    scale: float | None = None,
    surf_dir: str | None = None,
    smooth_iterations: float | None = None,
    subjects_dir: str | None = None,
    runner: Runner | None = None,
) -> MrisMakeTemplateOutputs:
    """
    This program will add a template into an average surface.
    
    Author: FreeSurfer Developers
    
    URL: https://github.com/freesurfer/freesurfer
    
    Args:
        hemi: Hemisphere (e.g., 'lh' or 'rh').
        surface_name: Surface name (e.g., 'white', 'pial').
        subjects: List of subjects to be averaged.
        output_name: Output name for the template.
        addframe_parameters: Add a frame with specific field and location in\
            atlas.
        vector: Print additional information for addframe.
        norot: Not aligning hemispheres before averaging (default).
        rot: Rough rigid alignment of hemispheres before averaging.
        annot: Zero medial wall.
        overlay_parameters: Read overlay from file, specify number of averages.
        overlay_dir: Use directory for overlay hemi.
        scale: Scale value for transformation.
        surf_dir: Use custom subdirectory instead of 'surf'.
        smooth_iterations: Number of iterations to smooth curvature.
        subjects_dir: Specify SUBJECTS_DIR.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `MrisMakeTemplateOutputs`).
    """
    if addframe_parameters is not None and (len(addframe_parameters) != 2): 
        raise ValueError(f"Length of 'addframe_parameters' must be 2 but was {len(addframe_parameters)}")
    if overlay_parameters is not None and (len(overlay_parameters) != 2): 
        raise ValueError(f"Length of 'overlay_parameters' must be 2 but was {len(overlay_parameters)}")
    runner = runner or get_global_runner()
    execution = runner.start_execution(MRIS_MAKE_TEMPLATE_METADATA)
    cargs = []
    cargs.append("mris_make_template")
    cargs.append(hemi)
    cargs.append(surface_name)
    cargs.extend(subjects)
    cargs.append(output_name)
    if addframe_parameters is not None:
        cargs.extend([
            "-addframe",
            *addframe_parameters
        ])
    if vector:
        cargs.append("-vector")
    if norot:
        cargs.append("-norot")
    if rot:
        cargs.append("-rot")
    if annot:
        cargs.append("-annot")
    if overlay_parameters is not None:
        cargs.extend([
            "-overlay",
            *overlay_parameters
        ])
    if overlay_dir is not None:
        cargs.extend([
            "-overlay-dir",
            overlay_dir
        ])
    if scale is not None:
        cargs.extend([
            "-s",
            str(scale)
        ])
    if surf_dir is not None:
        cargs.extend([
            "-surf_dir",
            surf_dir
        ])
    if smooth_iterations is not None:
        cargs.extend([
            "-a",
            str(smooth_iterations)
        ])
    if subjects_dir is not None:
        cargs.extend([
            "-sdir",
            subjects_dir
        ])
    ret = MrisMakeTemplateOutputs(
        root=execution.output_file("."),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "MRIS_MAKE_TEMPLATE_METADATA",
    "MrisMakeTemplateOutputs",
    "mris_make_template",
]
