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

import typing
import pathlib
from styxdefs import *
import dataclasses

V_3DEDGEDOG_METADATA = Metadata(
    id="9e99566b54cfbbe32a2b727088bdd1879b2a5924.boutiques",
    name="3dedgedog",
    package="afni",
    container_image_tag="afni/afni_make_build:AFNI_24.2.06",
)


class V3dedgedogOutputs(typing.NamedTuple):
    """
    Output object returned when calling `v_3dedgedog(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    out_edge: OutputPathType
    """Output edge dataset"""
    out_dog: OutputPathType
    """Output difference of Gaussian dataset"""
    out_edt2: OutputPathType
    """Output Euclidean Distance Transform squared dataset"""
    out_blur_inner: OutputPathType
    """Output inner Gaussian blurred dataset"""
    out_blur_outer: OutputPathType
    """Output outer Gaussian blurred dataset"""


def v_3dedgedog(
    input_: InputPathType,
    prefix: str,
    mask: InputPathType | None = None,
    automask: str | None = None,
    sigma_rad: float | None = None,
    sigma_nvox: float | None = None,
    ratio_sigma: float | None = None,
    output_intermed: bool = False,
    edge_bnd_nn: float | None = None,
    edge_bnd_side: str | None = None,
    edge_bnd_scale: bool = False,
    only2d: str | None = None,
    runner: Runner | None = None,
) -> V3dedgedogOutputs:
    """
    Calculate edges in an image using the Difference of Gaussians (DOG) method with
    extensions/tweaks of the Marr-Hildreth algorithm.
    
    Author: AFNI Developers
    
    URL: https://afni.nimh.nih.gov/
    
    Args:
        input_: Input dataset.
        prefix: Output prefix name.
        mask: Mask dataset applied after Euclidean Distance Transform\
            calculation.
        automask: Calculate mask automatically. Optionally, you can provide an\
            integer X to dilate the initial automask X times (e.g., -automask+X).
        sigma_rad: Radius for 'inner' Gaussian, in mm; must be greater than 0\
            (default: 1.40).
        sigma_nvox: Define radius for 'inner' Gaussian by providing a\
            multiplicative factor for voxel edge length greater than 0 (default:\
            use sigma_rad).
        ratio_sigma: Ratio of inner and outer Gaussian sigma values (default:\
            1.40).
        output_intermed: Output intermediate datasets: DOG, EDT2, BLURS\
            (default: not output).
        edge_bnd_nn: Nearest neighbor (NN) value for connectedness of\
            boundaries; must be 1 (face only), 2 (face+edge), or 3 (face+edge+node)\
            (default: 1).
        edge_bnd_side: Specify boundary layer to use: NEG, POS, BOTH, BOTH_SIGN\
            (default: NEG).
        edge_bnd_scale: Scale edge values to have relative magnitude between 0\
            and 100 (default: edge locations have value=1).
        only2d: Calculate edges in 2D per plane specified by SLI: 'axi', 'cor',\
            'sag'.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `V3dedgedogOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(V_3DEDGEDOG_METADATA)
    cargs = []
    cargs.append("3dedgedog")
    cargs.append(execution.input_file(input_))
    cargs.append(prefix)
    if mask is not None:
        cargs.extend([
            "-mask",
            execution.input_file(mask)
        ])
    if automask is not None:
        cargs.extend([
            "-automask",
            automask
        ])
    if sigma_rad is not None:
        cargs.extend([
            "-sigma_rad",
            str(sigma_rad)
        ])
    if sigma_nvox is not None:
        cargs.extend([
            "-sigma_nvox",
            str(sigma_nvox)
        ])
    if ratio_sigma is not None:
        cargs.extend([
            "-ratio_sigma",
            str(ratio_sigma)
        ])
    if output_intermed:
        cargs.append("-output_intermed")
    if edge_bnd_nn is not None:
        cargs.extend([
            "-edge_bnd_NN",
            str(edge_bnd_nn)
        ])
    if edge_bnd_side is not None:
        cargs.extend([
            "-edge_bnd_side",
            edge_bnd_side
        ])
    if edge_bnd_scale:
        cargs.append("-edge_bnd_scale")
    if only2d is not None:
        cargs.extend([
            "-only2D",
            only2d
        ])
    ret = V3dedgedogOutputs(
        root=execution.output_file("."),
        out_edge=execution.output_file(prefix + "_edge.nii.gz"),
        out_dog=execution.output_file(prefix + "_dog.nii.gz"),
        out_edt2=execution.output_file(prefix + "_edt2.nii.gz"),
        out_blur_inner=execution.output_file(prefix + "_blur_inner.nii.gz"),
        out_blur_outer=execution.output_file(prefix + "_blur_outer.nii.gz"),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "V3dedgedogOutputs",
    "V_3DEDGEDOG_METADATA",
    "v_3dedgedog",
]
