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

import typing
import pathlib
from styxdefs import *
import dataclasses

ANATOMICAL_AVERAGE_METADATA = Metadata(
    id="247f0a40aa16f444290b87939a981d90386a5a1a.boutiques",
    name="AnatomicalAverage",
    package="fsl",
    container_image_tag="brainlife/fsl:6.0.4-patched2",
)


class AnatomicalAverageOutputs(typing.NamedTuple):
    """
    Output object returned when calling `anatomical_average(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    avg_output: OutputPathType
    """Averaged anatomical image"""


def anatomical_average(
    output_basename: str,
    input_images: list[InputPathType],
    standard_image: InputPathType | None = None,
    standard_brain_mask: InputPathType | None = None,
    no_crop_flag: bool = False,
    work_dir: str | None = None,
    brainsize: float | None = None,
    noclean_flag: bool = False,
    verbose_flag: bool = False,
    runner: Runner | None = None,
) -> AnatomicalAverageOutputs:
    """
    Tool to create an anatomical average of input brain images.
    
    Author: FMRIB Analysis Group, University of Oxford
    
    URL: https://fsl.fmrib.ox.ac.uk/fsl/fslwiki
    
    Args:
        output_basename: Output basename.
        input_images: List of input images.
        standard_image: Standard image (default is MNI152_T1_2mm).
        standard_brain_mask: Standard brain mask (default is\
            MNI152_T1_2mm_brain_mask_dil).
        no_crop_flag: Do not crop images.
        work_dir: Local, temporary working directory (to be cleaned up - i.e.\
            deleted).
        brainsize: Specify brainsize in mm for internal ROI (via robustfov).
        noclean_flag: Do not run the cleanup.
        verbose_flag: Verbose output.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `AnatomicalAverageOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(ANATOMICAL_AVERAGE_METADATA)
    cargs = []
    cargs.append("AnatomicalAverage")
    cargs.extend([
        "-o",
        output_basename
    ])
    cargs.extend([execution.input_file(f) for f in input_images])
    if standard_image is not None:
        cargs.extend([
            "-s",
            execution.input_file(standard_image)
        ])
    if standard_brain_mask is not None:
        cargs.extend([
            "-m",
            execution.input_file(standard_brain_mask)
        ])
    if no_crop_flag:
        cargs.append("-n")
    if work_dir is not None:
        cargs.extend([
            "-w",
            work_dir
        ])
    if brainsize is not None:
        cargs.extend([
            "-b",
            str(brainsize)
        ])
    if noclean_flag:
        cargs.append("--noclean")
    if verbose_flag:
        cargs.append("-v")
    ret = AnatomicalAverageOutputs(
        root=execution.output_file("."),
        avg_output=execution.output_file(output_basename + "_avg.nii.gz"),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "ANATOMICAL_AVERAGE_METADATA",
    "AnatomicalAverageOutputs",
    "anatomical_average",
]
