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

import typing
import pathlib
from styxdefs import *
import dataclasses

MAKE_AVERAGE_SURFACE_METADATA = Metadata(
    id="f27d1881cb0ec462784332cf8519b93ee957748e.boutiques",
    name="make_average_surface",
    package="freesurfer",
    container_image_tag="freesurfer/freesurfer:7.4.1",
)


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


def make_average_surface(
    subjects: list[str],
    fsgd_file: InputPathType | None = None,
    average_subject_name: str | None = "average",
    subjects_dir: str | None = None,
    sd_out_dir: str | None = None,
    transform_file: str | None = None,
    icosahedron_number: float | None = 7,
    surf_reg: str | None = None,
    left_hemi: bool = False,
    right_hemi: bool = False,
    force: bool = False,
    annot_template: bool = False,
    template_only: bool = False,
    no_template_only: bool = False,
    no_annot: bool = False,
    no_cortex_label: bool = False,
    annot_list: list[str] | None = None,
    meas_list: list[str] | None = None,
    no_surf2surf: bool = False,
    no_symlink: bool = False,
    version: bool = False,
    echo: bool = False,
    runner: Runner | None = None,
) -> MakeAverageSurfaceOutputs:
    """
    Creates average surfaces and curvatures from a set of subjects.
    
    Author: FreeSurfer Developers
    
    URL: https://github.com/freesurfer/freesurfer
    
    Args:
        subjects: List of subject names.
        fsgd_file: File from which to get the subject list.
        average_subject_name: Average subject name.
        subjects_dir: Directory for SUBJECTS_DIR (if different from the\
            environment variable).
        sd_out_dir: Directory to put output data.
        transform_file: Filename of the transform file.
        icosahedron_number: Specify icosahedron number.
        surf_reg: Alternative registration surface name.
        left_hemi: Only process the left hemisphere.
        right_hemi: Only process the right hemisphere.
        force: Overwrite existing average subject data.
        annot_template: Use annotation when making tif.
        template_only: Useful when creating iterative atlases.
        no_template_only: Turns off --template-only.
        no_annot: Do not create average annotations.
        no_cortex_label: Do not create ?h.cortex.label.
        annot_list: List of annotations to use.
        meas_list: List of measurements to use.
        no_surf2surf: Use old parametric surface method.
        no_symlink: Do not use symbolic links, just copy files.
        version: Script version information.
        echo: Enable command echo for debugging.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `MakeAverageSurfaceOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(MAKE_AVERAGE_SURFACE_METADATA)
    cargs = []
    cargs.append("make_average_surface")
    cargs.extend(subjects)
    if fsgd_file is not None:
        cargs.extend([
            "--fsgd",
            execution.input_file(fsgd_file)
        ])
    if average_subject_name is not None:
        cargs.extend([
            "--out",
            average_subject_name
        ])
    if subjects_dir is not None:
        cargs.extend([
            "--sdir",
            subjects_dir
        ])
    if sd_out_dir is not None:
        cargs.extend([
            "--sd-out",
            sd_out_dir
        ])
    if transform_file is not None:
        cargs.extend([
            "--xform",
            transform_file
        ])
    if icosahedron_number is not None:
        cargs.extend([
            "--ico",
            str(icosahedron_number)
        ])
    if surf_reg is not None:
        cargs.extend([
            "--surf-reg",
            surf_reg
        ])
    if left_hemi:
        cargs.append("--lh")
    if right_hemi:
        cargs.append("--rh")
    if force:
        cargs.append("--force")
    if annot_template:
        cargs.append("--annot-template")
    if template_only:
        cargs.append("--template-only")
    if no_template_only:
        cargs.append("--no-template-only")
    if no_annot:
        cargs.append("--no-annot")
    if no_cortex_label:
        cargs.append("--no-cortex-label")
    if annot_list is not None:
        cargs.extend([
            "--annot",
            *annot_list
        ])
    if meas_list is not None:
        cargs.extend([
            "--meas",
            *meas_list
        ])
    if no_surf2surf:
        cargs.append("--no-surf2surf")
    if no_symlink:
        cargs.append("--no-symlink")
    if version:
        cargs.append("--version")
    if echo:
        cargs.append("--echo")
    ret = MakeAverageSurfaceOutputs(
        root=execution.output_file("."),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "MAKE_AVERAGE_SURFACE_METADATA",
    "MakeAverageSurfaceOutputs",
    "make_average_surface",
]
