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

import typing
import pathlib
from styxdefs import *
import dataclasses

MRIS_MAKE_AVERAGE_SURFACE_METADATA = Metadata(
    id="c7c7dc6c877d2ef020d99e894c96f070fb1a71d2.boutiques",
    name="mris_make_average_surface",
    package="freesurfer",
    container_image_tag="freesurfer/freesurfer:7.4.1",
)


class MrisMakeAverageSurfaceOutputs(typing.NamedTuple):
    """
    Output object returned when calling `mris_make_average_surface(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    output_surface: OutputPathType | None
    """Output averaged surface"""


def mris_make_average_surface(
    hemi: str,
    outsurfname: str,
    cansurfname: str,
    outsubject: str,
    subjects: list[str],
    sdir: str | None = None,
    sdir_out: str | None = None,
    nonorm_flag: bool = False,
    icoorder: float | None = None,
    xfmname: str | None = None,
    templatename: str | None = None,
    surfname: str | None = None,
    surf2surf_flag: bool = False,
    simple: list[str] | None = None,
    diagno: float | None = None,
    runner: Runner | None = None,
) -> MrisMakeAverageSurfaceOutputs:
    """
    A program to average the orig surfaces from the given subject list into a single
    surface using Talairach coords and the spherical transform.
    
    Author: FreeSurfer Developers
    
    URL: https://github.com/freesurfer/freesurfer
    
    Args:
        hemi: Hemisphere, lh or rh.
        outsurfname: Output surface name (e.g., avg_orig).
        cansurfname: Registration surface (e.g., sphere.reg).
        outsubject: Name of subject to store the results in.
        subjects: List of subjects to average.
        sdir: Use sdir instead of SUBJECTS_DIR.
        sdir_out: Save results in sdirout/outsubject instead of\
            SUBJECTS_DIR/outsubject.
        nonorm_flag: Do not normalize area.
        icoorder: Use given icosahedron order (default is 7).
        xfmname: Use transforms/xfmname instead of talairach.xfm.
        templatename: Volume to use as geometry template for output surfaces.
        surfname: Use surfname instead of orig.
        surf2surf_flag: Use surf2surf transform instead of parametric surface.
        simple: Compute an average surface from the list of surfaces. All\
            surfaces must have same number of vertices.
        diagno: Set Gdiag_no to diagno.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `MrisMakeAverageSurfaceOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(MRIS_MAKE_AVERAGE_SURFACE_METADATA)
    cargs = []
    cargs.append("mris_make_average_surface")
    cargs.append(hemi)
    cargs.append(outsurfname)
    cargs.append(cansurfname)
    cargs.append(outsubject)
    cargs.extend(subjects)
    if sdir is not None:
        cargs.extend([
            "-sdir",
            sdir
        ])
    if sdir_out is not None:
        cargs.extend([
            "-sdir-out",
            sdir_out
        ])
    if nonorm_flag:
        cargs.append("-nonorm")
    if icoorder is not None:
        cargs.extend([
            "-i",
            str(icoorder)
        ])
    if xfmname is not None:
        cargs.extend([
            "-x",
            xfmname
        ])
    if templatename is not None:
        cargs.extend([
            "-t",
            templatename
        ])
    if surfname is not None:
        cargs.extend([
            "-s",
            surfname
        ])
    if surf2surf_flag:
        cargs.append("-surf2surf")
    if simple is not None:
        cargs.extend([
            "-simple",
            *simple
        ])
    if diagno is not None:
        cargs.extend([
            "-v",
            str(diagno)
        ])
    ret = MrisMakeAverageSurfaceOutputs(
        root=execution.output_file("."),
        output_surface=execution.output_file(sdir_out + "/" + outsubject + "/" + outsurfname) if (sdir_out is not None) else None,
    )
    execution.run(cargs)
    return ret


__all__ = [
    "MRIS_MAKE_AVERAGE_SURFACE_METADATA",
    "MrisMakeAverageSurfaceOutputs",
    "mris_make_average_surface",
]
