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

import typing
import pathlib
from styxdefs import *
import dataclasses

MRIS_SKELETONIZE_METADATA = Metadata(
    id="0b067079e3dfa4d5ff1e1cf5bf10adf3ec69d818.boutiques",
    name="mris_skeletonize",
    package="freesurfer",
    container_image_tag="freesurfer/freesurfer:7.4.1",
)


class MrisSkeletonizeOutputs(typing.NamedTuple):
    """
    Output object returned when calling `mris_skeletonize(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    skeleton_output: OutputPathType | None
    """Output skeletonized mask."""
    pointset_output: OutputPathType | None
    """Output point set of the skeleton."""
    skeleton_label: OutputPathType | None
    """Label file for the skeletonized output."""


def mris_skeletonize(
    surface: str,
    surfvals: str,
    mask: str,
    k1: bool = False,
    curv_nonmaxsup: bool = False,
    gyrus: bool = False,
    sulcus: bool = False,
    outdir: str | None = None,
    sphere: str | None = None,
    pointset: str | None = None,
    label: str | None = None,
    nbrsize: float | None = 2,
    threshold: float | None = None,
    cluster: float | None = None,
    fwhm: float | None = None,
    runner: Runner | None = None,
) -> MrisSkeletonizeOutputs:
    """
    Computes the skeleton of gyri (ie, the crowns) or sulci (ie, the fundi).
    
    Author: FreeSurfer Developers
    
    URL: https://github.com/freesurfer/freesurfer
    
    Args:
        surface: Path to the surface file.
        surfvals: Pass input explicitly rather than computing it.
        mask: Final skeletonized mask file.
        k1: Use k1 from surface (not with --curv-nonmaxsup).
        curv_nonmaxsup: Use curvature H computed from surface with non-max\
            suppression (not with --k1).
        gyrus: Skeletonize the crowns of the gyri.
        sulcus: Skeletonize the fundi of the sulci.
        outdir: Directory where all outputs will be saved.
        sphere: Sphere path, only needed for nonmax suppression.
        pointset: Point set of the skeleton (PointSet.json).
        label: Surface label of the skeleton (label file path).
        nbrsize: Neighborhood size for 2nd FF (default is 2).
        threshold: Used to create initial mask that will be skeletonized\
            (typically about 0.3).
        cluster: Cluster the thresholded input and keep the largest nkeep\
            clusters.
        fwhm: Smooth surface values by this FWHM.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `MrisSkeletonizeOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(MRIS_SKELETONIZE_METADATA)
    cargs = []
    cargs.append("mris_skeletonize")
    cargs.extend([
        "--surf",
        surface
    ])
    cargs.extend([
        "--surfvals",
        surfvals
    ])
    cargs.extend([
        "--mask",
        mask
    ])
    if k1:
        cargs.append("--k1")
    if curv_nonmaxsup:
        cargs.append("--curv-nonmaxsup")
    if gyrus:
        cargs.append("--gyrus")
    if sulcus:
        cargs.append("--sulcus")
    if outdir is not None:
        cargs.extend([
            "--outdir",
            outdir
        ])
    if sphere is not None:
        cargs.extend([
            "--sphere",
            sphere
        ])
    if pointset is not None:
        cargs.extend([
            "--ps",
            pointset
        ])
    if label is not None:
        cargs.extend([
            "--label",
            label
        ])
    if nbrsize is not None:
        cargs.extend([
            "--nbrsize",
            str(nbrsize)
        ])
    if threshold is not None:
        cargs.extend([
            "--threshold",
            str(threshold)
        ])
    if cluster is not None:
        cargs.extend([
            "--cluster",
            str(cluster)
        ])
    if fwhm is not None:
        cargs.extend([
            "--fwhm",
            str(fwhm)
        ])
    ret = MrisSkeletonizeOutputs(
        root=execution.output_file("."),
        skeleton_output=execution.output_file(outdir + "/skeleton.mgz") if (outdir is not None) else None,
        pointset_output=execution.output_file(outdir + "/PointSet.json") if (outdir is not None) else None,
        skeleton_label=execution.output_file(outdir + "/skeleton_label.mgz") if (outdir is not None) else None,
    )
    execution.run(cargs)
    return ret


__all__ = [
    "MRIS_SKELETONIZE_METADATA",
    "MrisSkeletonizeOutputs",
    "mris_skeletonize",
]
