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

import typing
import pathlib
from styxdefs import *
import dataclasses

MAKE_AVERAGE_VOLUME_METADATA = Metadata(
    id="52d00009c5f5db471f13423dea8699f07efa357d.boutiques",
    name="make_average_volume",
    package="freesurfer",
    container_image_tag="freesurfer/freesurfer:7.4.1",
)


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


def make_average_volume(
    subjects: list[str],
    fsgd: InputPathType | None = None,
    out: str | None = None,
    topdir: str | None = None,
    xform: str | None = None,
    sdir: str | None = None,
    force_flag: bool = False,
    keep_all_orig_flag: bool = False,
    no_aseg_flag: bool = False,
    ctab: str | None = None,
    ctab_default_flag: bool = False,
    echo_flag: bool = False,
    nocleanup_flag: bool = False,
    runner: Runner | None = None,
) -> MakeAverageVolumeOutputs:
    """
    Creates average volumes from a set of subjects.
    
    Author: FreeSurfer Developers
    
    URL: https://github.com/freesurfer/freesurfer
    
    Args:
        subjects: List of subjects to include in the average.
        fsgd: File containing subject list for averaging.
        out: Output average subject name. Default is 'average'.
        topdir: Directory to put data and link to SUBJECTS_DIR.
        xform: Transformation name to use, default is talairach.xfm.
        sdir: Use specified SUBJECTS_DIR instead of the environment's one.
        force_flag: Overwrite existing average subject data.
        keep_all_orig_flag: Concatenate all original volumes into\
            mri/orig.all.mgz.
        no_aseg_flag: Do not create 'average' aseg.
        ctab: Embed colortable into segmentations.
        ctab_default_flag: Embed FreeSurferColorLUT.txt into segmentations.
        echo_flag: Enable command echo for debugging.
        nocleanup_flag: Do not delete temporary files.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `MakeAverageVolumeOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(MAKE_AVERAGE_VOLUME_METADATA)
    cargs = []
    cargs.append("make_average_volume")
    cargs.extend([
        "--subjects",
        *subjects
    ])
    if fsgd is not None:
        cargs.extend([
            "--fsgd",
            execution.input_file(fsgd)
        ])
    if out is not None:
        cargs.extend([
            "--out",
            out
        ])
    if topdir is not None:
        cargs.extend([
            "--topdir",
            topdir
        ])
    if xform is not None:
        cargs.extend([
            "--xform",
            xform
        ])
    if sdir is not None:
        cargs.extend([
            "--sdir",
            sdir
        ])
    if force_flag:
        cargs.append("--force")
    if keep_all_orig_flag:
        cargs.append("--keep-all-orig")
    if no_aseg_flag:
        cargs.append("--no-aseg")
    if ctab is not None:
        cargs.extend([
            "--ctab",
            ctab
        ])
    if ctab_default_flag:
        cargs.append("--ctab-default")
    if echo_flag:
        cargs.append("--echo")
    if nocleanup_flag:
        cargs.append("--nocleanup")
    ret = MakeAverageVolumeOutputs(
        root=execution.output_file("."),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "MAKE_AVERAGE_VOLUME_METADATA",
    "MakeAverageVolumeOutputs",
    "make_average_volume",
]
