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

import typing
import pathlib
from styxdefs import *
import dataclasses

V_3D_MEAN_METADATA = Metadata(
    id="e324408a8ad006ebdb33f912bb6b96f4f9350026.boutiques",
    name="3dMean",
    package="afni",
    container_image_tag="afni/afni_make_build:AFNI_24.2.06",
)


class V3dMeanOutputs(typing.NamedTuple):
    """
    Output object returned when calling `v_3d_mean(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    output_file: OutputPathType | None
    """Output dataset"""


def v_3d_mean(
    input_files: list[InputPathType],
    verbose: bool = False,
    prefix: str | None = None,
    datum: str | None = None,
    fscale: bool = False,
    gscale: bool = False,
    nscale: bool = False,
    non_zero: bool = False,
    stdev: bool = False,
    sqr: bool = False,
    sum_: bool = False,
    count: bool = False,
    max_: bool = False,
    min_: bool = False,
    absmax: bool = False,
    signed_absmax: bool = False,
    mask_inter: bool = False,
    mask_union: bool = False,
    weightset: InputPathType | None = None,
    runner: Runner | None = None,
) -> V3dMeanOutputs:
    """
    Takes the voxel-by-voxel mean of all input datasets; designed to be faster than
    3dcalc.
    
    Author: AFNI Developers
    
    URL: https://afni.nimh.nih.gov/
    
    Args:
        input_files: Input datasets.
        verbose: Print out some information along the way.
        prefix: Sets the prefix of the output dataset.
        datum: Sets the datum of the output dataset.
        fscale: Force scaling of the output to the maximum integer range.
        gscale: Force scaling of the output to the maximum integer range, with\
            uniform scaling factor for each sub-brick.
        nscale: Don't do any scaling on output to byte or short datasets. Only\
            use if you want the output dataset to be integer-valued.
        non_zero: Use only non-zero values for calculation of mean, min, max,\
            sum, squares.
        stdev: Calculate the standard deviation, sqrt(variance), instead of the\
            mean (cannot be used with -sqr, -sum or -non_zero).
        sqr: Average the squares, instead of the values.
        sum_: Just take the sum (don't divide by number of datasets).
        count: Compute only the count of non-zero voxels.
        max_: Find the maximum at each voxel.
        min_: Find the minimum at each voxel.
        absmax: Find maximum absolute value at each voxel.
        signed_absmax: Find extremes with maximum absolute value but preserve\
            sign.
        mask_inter: Create a simple intersection mask.
        mask_union: Create a simple union mask.
        weightset: Sum of N dsets will be weighted by N volume WSET. This\
            weight dataset must be of type float.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `V3dMeanOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(V_3D_MEAN_METADATA)
    cargs = []
    cargs.append("3dMean")
    cargs.extend([execution.input_file(f) for f in input_files])
    if verbose:
        cargs.append("-verbose")
    if prefix is not None:
        cargs.extend([
            "-prefix",
            prefix
        ])
    if datum is not None:
        cargs.extend([
            "-datum",
            datum
        ])
    if fscale:
        cargs.append("-fscale")
    if gscale:
        cargs.append("-gscale")
    if nscale:
        cargs.append("-nscale")
    if non_zero:
        cargs.append("-non_zero")
    if stdev:
        cargs.append("-sd")
    if sqr:
        cargs.append("-sqr")
    if sum_:
        cargs.append("-sum")
    if count:
        cargs.append("-count")
    if max_:
        cargs.append("-max")
    if min_:
        cargs.append("-min")
    if absmax:
        cargs.append("-absmax")
    if signed_absmax:
        cargs.append("-signed_absmax")
    if mask_inter:
        cargs.append("-mask_inter")
    if mask_union:
        cargs.append("-mask_union")
    if weightset is not None:
        cargs.extend([
            "-weightset",
            execution.input_file(weightset)
        ])
    ret = V3dMeanOutputs(
        root=execution.output_file("."),
        output_file=execution.output_file(prefix + "<+optional_extension>") if (prefix is not None) else None,
    )
    execution.run(cargs)
    return ret


__all__ = [
    "V3dMeanOutputs",
    "V_3D_MEAN_METADATA",
    "v_3d_mean",
]
