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

import typing
import pathlib
from styxdefs import *
import dataclasses

SURF_EXTREMA_METADATA = Metadata(
    id="559cda037dd05375e303c0e3226813b4366b2fa3.boutiques",
    name="SurfExtrema",
    package="afni",
    container_image_tag="afni/afni_make_build:AFNI_24.2.06",
)


class SurfExtremaOutputs(typing.NamedTuple):
    """
    Output object returned when calling `surf_extrema(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    output_grd: OutputPathType
    """Output file containing the scaled average gradient values."""
    output_ext: OutputPathType
    """Output file containing the nodes with maximum values."""


def surf_extrema(
    prefix: str,
    input_: InputPathType | None = None,
    hood: float | None = None,
    thresh: float | None = None,
    gthresh: float | None = None,
    gscale: typing.Literal["NONE", "LMEAN", "GMEAN"] | None = None,
    extype: typing.Literal["MAX", "MIN", "ABS"] | None = None,
    table: str | None = None,
    runner: Runner | None = None,
) -> SurfExtremaOutputs:
    """
    A program finding the local extrema in a dataset.
    
    Author: AFNI Team
    
    URL: https://afni.nimh.nih.gov/pub/dist/doc/program_help/SurfExtrema.html
    
    Args:
        prefix: Prefix for the output datasets.
        input_: Input dataset in which Extrema are to be identified.
        hood: Neighborhood radius (R) in mm. Default is 8 mm.
        thresh: Do not consider nodes with value less than this threshold.\
            Default is 0.
        gthresh: Do not consider nodes with gradient less than this threshold.\
            Default is 0.01.
        gscale: Scaling to apply to gradient computation.
        extype: Find maxima, minima, or extrema. Options are MAX (default),\
            MIN, ABS.
        table: Name of file in which to store a record of the extrema found.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `SurfExtremaOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(SURF_EXTREMA_METADATA)
    cargs = []
    cargs.append("SurfExtrema")
    if input_ is not None:
        cargs.extend([
            "-input",
            execution.input_file(input_)
        ])
    if hood is not None:
        cargs.extend([
            "-nbhd_rad",
            str(hood)
        ])
    if thresh is not None:
        cargs.extend([
            "-thresh",
            str(thresh)
        ])
    if gthresh is not None:
        cargs.extend([
            "-gthresh",
            str(gthresh)
        ])
    if gscale is not None:
        cargs.extend([
            "-gscale",
            gscale
        ])
    if extype is not None:
        cargs.extend([
            "-extype",
            extype
        ])
    cargs.extend([
        "-prefix",
        prefix
    ])
    if table is not None:
        cargs.extend([
            "-table",
            table
        ])
    ret = SurfExtremaOutputs(
        root=execution.output_file("."),
        output_grd=execution.output_file(prefix + ".grd"),
        output_ext=execution.output_file(prefix + ".ext"),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "SURF_EXTREMA_METADATA",
    "SurfExtremaOutputs",
    "surf_extrema",
]
