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

import typing
import pathlib
from styxdefs import *
import dataclasses

IMSTAT_METADATA = Metadata(
    id="c59c01eb2a12e7d9a2066403a73878b709e55aa5.boutiques",
    name="imstat",
    package="afni",
    container_image_tag="afni/afni_make_build:AFNI_24.2.06",
)


class ImstatOutputs(typing.NamedTuple):
    """
    Output object returned when calling `imstat(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    mean_output: OutputPathType | None
    """Mean of pixel-wise statistics for the collection of 2D images"""
    sdev_output: OutputPathType | None
    """Standard deviation of pixel-wise statistics for the collection of 2D
    images"""


def imstat(
    image_files: list[InputPathType],
    no_label: bool = False,
    quiet: bool = False,
    pixstat_prefix: str | None = None,
    runner: Runner | None = None,
) -> ImstatOutputs:
    """
    Calculation of statistics of one or more images.
    
    Author: AFNI Developers
    
    URL: https://afni.nimh.nih.gov/
    
    Args:
        image_files: Input image file(s).
        no_label: Don't write labels on each file's summary line.
        quiet: Don't print statistics for each file.
        pixstat_prefix: If more than one image file is given, then\
            'prefix.mean' and 'prefix.sdev' will be written as the pixel-wise\
            statistics images of the whole collection. These images will be in the\
            'flim' floating point format. [This option only works on 2D images!].
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `ImstatOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(IMSTAT_METADATA)
    cargs = []
    cargs.append("imstat")
    if no_label:
        cargs.append("-nolabel")
    if quiet:
        cargs.append("-quiet")
    if pixstat_prefix is not None:
        cargs.extend([
            "-pixstat",
            pixstat_prefix
        ])
    cargs.extend([execution.input_file(f) for f in image_files])
    ret = ImstatOutputs(
        root=execution.output_file("."),
        mean_output=execution.output_file(pixstat_prefix + ".mean") if (pixstat_prefix is not None) else None,
        sdev_output=execution.output_file(pixstat_prefix + ".sdev") if (pixstat_prefix is not None) else None,
    )
    execution.run(cargs)
    return ret


__all__ = [
    "IMSTAT_METADATA",
    "ImstatOutputs",
    "imstat",
]
