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

import typing
import pathlib
from styxdefs import *
import dataclasses

ISO_SURFACE_METADATA = Metadata(
    id="ae4f55d6aa3df9abb44d283d9623f609eefee601.boutiques",
    name="IsoSurface",
    package="afni",
    container_image_tag="afni/afni_make_build:AFNI_24.2.06",
)


class IsoSurfaceOutputs(typing.NamedTuple):
    """
    Output object returned when calling `iso_surface(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    output_surface_ply: OutputPathType
    """Output isosurface in PLY format."""
    output_surface_gii: OutputPathType
    """Output isosurface in GIFTI format."""
    output_surface_stl: OutputPathType
    """Output isosurface in STL format."""


def iso_surface(
    input_vol: InputPathType | None = None,
    shape_spec: list[str] | None = None,
    isorois: bool = False,
    isoval: str | None = None,
    isorange: list[str] | None = None,
    isocmask: str | None = None,
    output_prefix: str | None = None,
    tsmooth: list[str] | None = None,
    debug: str | None = None,
    autocrop: bool = False,
    remesh: str | None = None,
    xform: str | None = None,
    novolreg: bool = False,
    noxform: bool = False,
    runner: Runner | None = None,
) -> IsoSurfaceOutputs:
    """
    A program to perform isosurface extraction from a volume.
    
    Author: AFNI Developers
    
    URL: https://afni.nimh.nih.gov/
    
    Args:
        input_vol: Input volume file.
        shape_spec: Built-in shape specification.
        isorois: Create isosurface for each unique value in the input volume.
        isoval: Create isosurface where volume = V.
        isorange: Create isosurface where V0 <= volume < V1.
        isocmask: Create isosurface where MASK_COM != 0.
        output_prefix: Prefix of output surface file.
        tsmooth: Smooth resultant surface using Taubin smoothing with\
            parameters KPB and NITER.
        debug: Debug levels of 0 (default), 1, 2, 3.
        autocrop: Crop input volume before extraction.
        remesh: Remesh the surface(s).
        xform: Transform to apply to volume values before extracting.
        novolreg: Ignore any Rotate, Volreg, Tagalign, or WarpDrive\
            transformations.
        noxform: Same as -novolreg.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `IsoSurfaceOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(ISO_SURFACE_METADATA)
    cargs = []
    cargs.append("IsoSurface")
    if input_vol is not None:
        cargs.extend([
            "-input",
            execution.input_file(input_vol)
        ])
    if shape_spec is not None:
        cargs.extend([
            "-shape",
            *shape_spec
        ])
    if isorois:
        cargs.append("-isorois")
    if isoval is not None:
        cargs.extend([
            "-isoval",
            isoval
        ])
    if isorange is not None:
        cargs.extend([
            "-isorange",
            *isorange
        ])
    if isocmask is not None:
        cargs.extend([
            "-isocmask",
            isocmask
        ])
    if output_prefix is not None:
        cargs.extend([
            "-o_TYPE",
            output_prefix
        ])
    if tsmooth is not None:
        cargs.extend([
            "-Tsmooth",
            *tsmooth
        ])
    if debug is not None:
        cargs.extend([
            "-debug",
            debug
        ])
    if autocrop:
        cargs.append("-autocrop")
    if remesh is not None:
        cargs.extend([
            "-remesh",
            remesh
        ])
    if xform is not None:
        cargs.extend([
            "-xform",
            xform
        ])
    if novolreg:
        cargs.append("-novolreg")
    if noxform:
        cargs.append("-noxform")
    ret = IsoSurfaceOutputs(
        root=execution.output_file("."),
        output_surface_ply=execution.output_file("[MASK]_surf.ply"),
        output_surface_gii=execution.output_file("[MASK]_surf.gii"),
        output_surface_stl=execution.output_file("[MASK]_surf.stl"),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "ISO_SURFACE_METADATA",
    "IsoSurfaceOutputs",
    "iso_surface",
]
