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

import typing
import pathlib
from styxdefs import *
import dataclasses

V_3D_EXTREMA_METADATA = Metadata(
    id="5ac881fa6c2cea8b9186981d23d77e4ec3bd7b85.boutiques",
    name="3dExtrema",
    package="afni",
    container_image_tag="afni/afni_make_build:AFNI_24.2.06",
)


class V3dExtremaOutputs(typing.NamedTuple):
    """
    Output object returned when calling `v_3d_extrema(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    output_head_file: OutputPathType | None
    """Output HEAD file"""
    output_brik_file: OutputPathType | None
    """Output BRIK file"""


def v_3d_extrema(
    input_dataset: InputPathType,
    output_prefix: str | None = None,
    output_session: str | None = None,
    quiet: bool = False,
    mask_file: InputPathType | None = None,
    mask_threshold: float | None = None,
    data_threshold: float | None = None,
    n_best: float | None = None,
    separation_distance: float | None = None,
    minima: bool = False,
    maxima: bool = False,
    strict: bool = False,
    partial: bool = False,
    interior: bool = False,
    closure: bool = False,
    slice_: bool = False,
    volume: bool = False,
    remove: bool = False,
    average: bool = False,
    weight: bool = False,
    runner: Runner | None = None,
) -> V3dExtremaOutputs:
    """
    Find local extrema (minima or maxima) in 3D datasets.
    
    Author: AFNI Team
    
    URL: https://afni.nimh.nih.gov/pub/dist/doc/program_help/3dExtrema.html
    
    Args:
        input_dataset: Input dataset (e.g. dataset+tlrc'[sub-brick]').
        output_prefix: Prefix for the output dataset name.
        output_session: Directory for the output dataset session.
        quiet: Suppress screen output.
        mask_file: Mask statistic from file.
        mask_threshold: Only voxels whose mask statistic is >= m in absolute\
            value will be considered.
        data_threshold: Only voxels whose value (intensity) is greater than d\
            in absolute value will be considered.
        n_best: Only print the first N extrema.
        separation_distance: Minimum separation distance (in mm) for distinct\
            extrema.
        minima: Find local minima.
        maxima: Find local maxima (default).
        strict: Use strict inequality for extrema (default).
        partial: Use partial inequality for extrema.
        interior: Extrema must be interior points (default).
        closure: Extrema may be boundary points.
        slice_: Consider each slice separately (default).
        volume: Consider the volume as a whole.
        remove: Remove all but strongest of neighboring extrema (default).
        average: Replace neighboring extrema by average.
        weight: Replace neighboring extrema by weighted average.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `V3dExtremaOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(V_3D_EXTREMA_METADATA)
    cargs = []
    cargs.append("3dExtrema")
    cargs.append(execution.input_file(input_dataset))
    if output_prefix is not None:
        cargs.extend([
            "-prefix",
            output_prefix
        ])
    if output_session is not None:
        cargs.extend([
            "-session",
            output_session
        ])
    if quiet:
        cargs.append("-quiet")
    if mask_file is not None:
        cargs.extend([
            "-mask_file",
            execution.input_file(mask_file)
        ])
    if mask_threshold is not None:
        cargs.extend([
            "-mask_thr",
            str(mask_threshold)
        ])
    if data_threshold is not None:
        cargs.extend([
            "-data_thr",
            str(data_threshold)
        ])
    if n_best is not None:
        cargs.extend([
            "-nbest",
            str(n_best)
        ])
    if separation_distance is not None:
        cargs.extend([
            "-sep_dist",
            str(separation_distance)
        ])
    if minima:
        cargs.append("-minima")
    if maxima:
        cargs.append("-maxima")
    if strict:
        cargs.append("-strict")
    if partial:
        cargs.append("-partial")
    if interior:
        cargs.append("-interior")
    if closure:
        cargs.append("-closure")
    if slice_:
        cargs.append("-slice")
    if volume:
        cargs.append("-volume")
    if remove:
        cargs.append("-remove")
    if average:
        cargs.append("-average")
    if weight:
        cargs.append("-weight")
    ret = V3dExtremaOutputs(
        root=execution.output_file("."),
        output_head_file=execution.output_file(output_prefix + ".HEAD") if (output_prefix is not None) else None,
        output_brik_file=execution.output_file(output_prefix + ".BRIK") if (output_prefix is not None) else None,
    )
    execution.run(cargs)
    return ret


__all__ = [
    "V3dExtremaOutputs",
    "V_3D_EXTREMA_METADATA",
    "v_3d_extrema",
]
