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

import typing
import pathlib
from styxdefs import *
import dataclasses

V_3DINFILL_METADATA = Metadata(
    id="263217e116d12496939583b1c3c4001f87f5e06c.boutiques",
    name="3dinfill",
    package="afni",
    container_image_tag="afni/afni_make_build:AFNI_24.2.06",
)


class V3dinfillOutputs(typing.NamedTuple):
    """
    Output object returned when calling `v_3dinfill(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    output_filled: OutputPathType | None
    """Filled volume output"""


def v_3dinfill(
    input_: InputPathType,
    prefix: str | None = None,
    niter: float | None = None,
    blend: typing.Literal["MODE", "AVG", "AUTO", "SOLID", "SOLID_CLEAN"] | None = None,
    minhits: float | None = None,
    ed: list[float] | None = None,
    mask: InputPathType | None = None,
    mask_range: list[float] | None = None,
    mrange: list[float] | None = None,
    cmask: str | None = None,
    runner: Runner | None = None,
) -> V3dinfillOutputs:
    """
    A program to fill holes in volumes.
    
    Author: AFNI Developers
    
    URL: https://afni.nimh.nih.gov/
    
    Args:
        input_: Fill volume dataset.
        prefix: Use PREF for output prefix.
        niter: Do not allow the fill function to do more than NITER passes.
        blend: Method for assigning a value to a hole.
        minhits: Criterion for considering a zero voxel to be a hole. Can only\
            be used with -blend SOLID.
        ed: Erode N times then dilate N times to get rid of hanging chunks.\
            Values filled in by this process get value V.
        mask: Provide mask dataset to select subset of input.
        mask_range: Specify the range of values to consider from mask dataset.
        mrange: Alias for -mask_range option.
        cmask: Provide cmask expression. Voxels where expression is 0 are\
            excluded from computations.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `V3dinfillOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(V_3DINFILL_METADATA)
    cargs = []
    cargs.append("3dinfill")
    cargs.extend([
        "-input",
        execution.input_file(input_)
    ])
    if prefix is not None:
        cargs.extend([
            "-prefix",
            prefix
        ])
    if niter is not None:
        cargs.extend([
            "-Niter",
            str(niter)
        ])
    if blend is not None:
        cargs.extend([
            "-blend",
            blend
        ])
    if minhits is not None:
        cargs.extend([
            "-minhits",
            str(minhits)
        ])
    if ed is not None:
        cargs.extend([
            "-ed",
            *map(str, ed)
        ])
    if mask is not None:
        cargs.extend([
            "-mask",
            execution.input_file(mask)
        ])
    if mask_range is not None:
        cargs.extend([
            "-mask_range",
            *map(str, mask_range)
        ])
    if mrange is not None:
        cargs.extend([
            "-mrange",
            *map(str, mrange)
        ])
    if cmask is not None:
        cargs.extend([
            "-cmask",
            cmask
        ])
    ret = V3dinfillOutputs(
        root=execution.output_file("."),
        output_filled=execution.output_file(prefix + "_filled.nii.gz") if (prefix is not None) else None,
    )
    execution.run(cargs)
    return ret


__all__ = [
    "V3dinfillOutputs",
    "V_3DINFILL_METADATA",
    "v_3dinfill",
]
