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

import typing
import pathlib
from styxdefs import *
import dataclasses

SURF_FWHM_METADATA = Metadata(
    id="34840e1bbf88f386954becc95ba3a4074cff6110.boutiques",
    name="SurfFWHM",
    package="afni",
    container_image_tag="afni/afni_make_build:AFNI_24.2.06",
)


class SurfFwhmOutputs(typing.NamedTuple):
    """
    Output object returned when calling `surf_fwhm(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    detrended_output: OutputPathType | None
    """Detrended dataset."""
    main_output: OutputPathType | None
    """Main output dataset."""
    histogram_output: OutputPathType | None
    """Histogram showing the distribution of local FWHM."""
    mask_output: OutputPathType | None
    """Mask output dataset."""


def surf_fwhm(
    input_file: InputPathType,
    mask: InputPathType | None = None,
    surf_1: str | None = None,
    surf_sphere: str | None = None,
    clean: bool = False,
    detrend: float | None = None,
    detpoly: float | None = None,
    detprefix: str | None = None,
    prefix: str | None = None,
    vox_size: float | None = None,
    neighborhood: float | None = None,
    ok_warn: bool = False,
    examples: bool = False,
    slice_: bool = False,
    runner: Runner | None = None,
) -> SurfFwhmOutputs:
    """
    A program for calculating local and global FWHM.
    
    Author: AFNI Team
    
    URL: https://afni.nimh.nih.gov/pub/dist/doc/program_help/SurfFWHM.html
    
    Args:
        input_file: Dataset for which the FWHM is to be calculated.
        mask: Node mask so that only nodes in the mask are used to obtain\
            estimates.
        surf_1: Option for specifying the surface over which the input dataset\
            is defined.
        surf_sphere: Spherical version of -SURF_1 for Local FWHM estimates.
        clean: Strip text from output to simplify parsing.
        detrend: Detrend to order 'q'. If q is not given, the program picks\
            q=NT/30.
        detpoly: Detrend with polynomials of order p.
        detprefix: Save the detrended file into a dataset with prefix 'd'.
        prefix: Prefix of output data set.
        vox_size: Specify the nominal voxel size in mm.
        neighborhood: Neighborhood radius R for local FWHM estimates.
        ok_warn: Flag to set the mode to ok_warn.
        examples: Show command line examples and quit.
        slice_: Use the contours from planar intersections to estimate\
            gradients. For testing and development purposes only.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `SurfFwhmOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(SURF_FWHM_METADATA)
    cargs = []
    cargs.append("SurfFWHM")
    cargs.append(execution.input_file(input_file))
    if mask is not None:
        cargs.extend([
            "-MASK",
            execution.input_file(mask)
        ])
    if surf_1 is not None:
        cargs.extend([
            "-SURF_1",
            surf_1
        ])
    if surf_sphere is not None:
        cargs.extend([
            "-SURF_SPHERE",
            surf_sphere
        ])
    if clean:
        cargs.append("-clean")
    if detrend is not None:
        cargs.extend([
            "-detrend",
            str(detrend)
        ])
    if detpoly is not None:
        cargs.extend([
            "-detpoly",
            str(detpoly)
        ])
    if detprefix is not None:
        cargs.extend([
            "-detprefix",
            detprefix
        ])
    if prefix is not None:
        cargs.extend([
            "-prefix",
            prefix
        ])
    if vox_size is not None:
        cargs.extend([
            "-vox_size",
            str(vox_size)
        ])
    if neighborhood is not None:
        cargs.extend([
            "-hood",
            str(neighborhood)
        ])
    if ok_warn:
        cargs.append("-ok_warn")
    if examples:
        cargs.append("-examples")
    if slice_:
        cargs.append("-slice")
    cargs.append("[TALK_SUMA_OPTIONS]")
    cargs.append("[NIML_OPTIONS]")
    cargs.append("[DEBUG_OPTIONS]")
    cargs.append("[HELP_OPTIONS]")
    ret = SurfFwhmOutputs(
        root=execution.output_file("."),
        detrended_output=execution.output_file(prefix + ".1D.dset") if (prefix is not None) else None,
        main_output=execution.output_file(prefix + ".nii.gz") if (prefix is not None) else None,
        histogram_output=execution.output_file(prefix + "_histog.1D") if (prefix is not None) else None,
        mask_output=execution.output_file(prefix + "_mask.nii.gz") if (prefix is not None) else None,
    )
    execution.run(cargs)
    return ret


__all__ = [
    "SURF_FWHM_METADATA",
    "SurfFwhmOutputs",
    "surf_fwhm",
]
