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

import typing
import pathlib
from styxdefs import *
import dataclasses

V_3D_WINSOR_METADATA = Metadata(
    id="14eef9e3bbd704e0f76d5d49b3f5be8c610834d1.boutiques",
    name="3dWinsor",
    package="afni",
    container_image_tag="afni/afni_make_build:AFNI_24.2.06",
)


class V3dWinsorOutputs(typing.NamedTuple):
    """
    Output object returned when calling `v_3d_winsor(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    outfile_head: OutputPathType | None
    """Output dataset with Winsorizing filter applied."""
    outfile_brik: OutputPathType | None
    """Output dataset with Winsorizing filter applied."""


def v_3d_winsor(
    dataset: InputPathType,
    irad: float | None = None,
    cbot: float | None = None,
    ctop: float | None = None,
    nrep: float | None = None,
    keepzero: bool = False,
    clip: float | None = None,
    prefix: str | None = None,
    mask: InputPathType | None = None,
    runner: Runner | None = None,
) -> V3dWinsorOutputs:
    """
    Apply a 3D 'Winsorizing' filter to a short-valued dataset.
    
    Author: AFNI Team
    
    URL: https://afni.nimh.nih.gov/pub/dist/doc/program_help/3dWinsor.html
    
    Args:
        dataset: Input dataset to apply the filter on.
        irad: Include all points within 'distance' rr in the operation, where\
            distance is defined as sqrt(i*i+j*j+k*k), and (i,j,k) are voxel index\
            offsets.
        cbot: Set bottom clip index to bb.
        ctop: Set top clip index to tt.
        nrep: Repeat filter nn times. If nn < 0, means to repeat filter until\
            less than abs(n) voxels change.
        keepzero: Don't filter voxels that are zero.
        clip: Set voxels at or below 'xx' to zero.
        prefix: Use 'pp' as the prefix for the output dataset.
        mask: Use 'mmm' as a mask dataset - voxels NOT in the mask won't be\
            filtered.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `V3dWinsorOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(V_3D_WINSOR_METADATA)
    cargs = []
    cargs.append("3dWinsor")
    if irad is not None:
        cargs.extend([
            "-irad",
            str(irad)
        ])
    if cbot is not None:
        cargs.extend([
            "-cbot",
            str(cbot)
        ])
    if ctop is not None:
        cargs.extend([
            "-ctop",
            str(ctop)
        ])
    if nrep is not None:
        cargs.extend([
            "-nrep",
            str(nrep)
        ])
    if keepzero:
        cargs.append("-keepzero")
    if clip is not None:
        cargs.extend([
            "-clip",
            str(clip)
        ])
    if prefix is not None:
        cargs.extend([
            "-prefix",
            prefix
        ])
    if mask is not None:
        cargs.extend([
            "-mask",
            execution.input_file(mask)
        ])
    cargs.append(execution.input_file(dataset))
    ret = V3dWinsorOutputs(
        root=execution.output_file("."),
        outfile_head=execution.output_file(prefix + "+*.HEAD") if (prefix is not None) else None,
        outfile_brik=execution.output_file(prefix + "+*.BRIK") if (prefix is not None) else None,
    )
    execution.run(cargs)
    return ret


__all__ = [
    "V3dWinsorOutputs",
    "V_3D_WINSOR_METADATA",
    "v_3d_winsor",
]
