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

import typing
import pathlib
from styxdefs import *
import dataclasses

V__SCALE_VOLUME_METADATA = Metadata(
    id="4000996fdc6423040b991fc320209305f64cb474.boutiques",
    name="@ScaleVolume",
    package="afni",
    container_image_tag="afni/afni_make_build:AFNI_24.2.06",
)


class VScaleVolumeOutputs(typing.NamedTuple):
    """
    Output object returned when calling `v__scale_volume(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    output_file: OutputPathType
    """Output scaled dataset"""


def v__scale_volume(
    input_dset: InputPathType,
    prefix: str,
    val_clip: list[float] | None = None,
    perc_clip: list[float] | None = None,
    scale_by_mean: bool = False,
    scale_by_median: bool = False,
    norm: bool = False,
    mask: InputPathType | None = None,
    runner: Runner | None = None,
) -> VScaleVolumeOutputs:
    """
    A tool to scale the volume of datasets.
    
    Author: AFNI Developers
    
    URL: https://afni.nimh.nih.gov/
    
    Args:
        input_dset: Dataset to scale.
        prefix: Prefix of output.
        val_clip: Min and Max of output dataset. Default V0 = 0 and V1 = 255.
        perc_clip: Set lowest P0 percentile to Min and highest P1 percentile to\
            Max. Default P0 = 2 and P1 = 98.
        scale_by_mean: Divide each sub-brick by mean of non-zero voxels.
        scale_by_median: Divide each sub-brick by median of non-zero voxels.
        norm: For each time series T, Tnorm = (T - mean(T)) / stdev(T).
        mask: Restrict to non-zero values of given mask dataset.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `VScaleVolumeOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(V__SCALE_VOLUME_METADATA)
    cargs = []
    cargs.append("@ScaleVolume")
    cargs.append(execution.input_file(input_dset))
    cargs.append(prefix)
    if val_clip is not None:
        cargs.extend([
            "-val_clip",
            *map(str, val_clip)
        ])
    if perc_clip is not None:
        cargs.extend([
            "-perc_clip",
            *map(str, perc_clip)
        ])
    if scale_by_mean:
        cargs.append("-scale_by_mean")
    if scale_by_median:
        cargs.append("-scale_by_median")
    if norm:
        cargs.append("-norm")
    if mask is not None:
        cargs.extend([
            "-mask",
            execution.input_file(mask)
        ])
    ret = VScaleVolumeOutputs(
        root=execution.output_file("."),
        output_file=execution.output_file("<-prefix PREFIX>_scaled"),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "VScaleVolumeOutputs",
    "V__SCALE_VOLUME_METADATA",
    "v__scale_volume",
]
