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

import typing
import pathlib
from styxdefs import *
import dataclasses

V_3D_STAT_CLUST_METADATA = Metadata(
    id="fc722addfbc175c71d3a318d604f19ee64fdb599.boutiques",
    name="3dStatClust",
    package="afni",
    container_image_tag="afni/afni_make_build:AFNI_24.2.06",
)


class V3dStatClustOutputs(typing.NamedTuple):
    """
    Output object returned when calling `v_3d_stat_clust(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    output_head: OutputPathType | None
    """Output dataset header"""
    output_brick: OutputPathType | None
    """Output dataset brick"""


def v_3d_stat_clust(
    thresh: str,
    nclust: float,
    datasets: list[str],
    prefix: str | None = None,
    session_dir: str | None = None,
    verbose: bool = False,
    dist_cor: bool = False,
    runner: Runner | None = None,
) -> V3dStatClustOutputs:
    """
    Perform agglomerative hierarchical clustering for user specified parameter
    sub-bricks, for all voxels whose threshold statistic is above a user specified
    value.
    
    Author: AFNI Developers
    
    URL: https://afni.nimh.nih.gov/
    
    Args:
        thresh: Threshold statistic from file tname. Only voxels whose\
            threshold statistic is greater than t in absolute value will be\
            considered. If file tname contains more than 1 sub-brick, the threshold\
            stat. sub-brick must be specified.
        nclust: Maximum number of clusters for output (= number of sub-bricks\
            in output dataset).
        datasets: Parameter datasets.
        prefix: Use 'pname' for the output dataset prefix name.
        session_dir: Use 'dir' for the output dataset session directory.
        verbose: Print out verbose output as the program proceeds.
        dist_cor: Statistical distance for correlated parameters.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `V3dStatClustOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(V_3D_STAT_CLUST_METADATA)
    cargs = []
    cargs.append("3dStatClust")
    if prefix is not None:
        cargs.extend([
            "-prefix",
            prefix
        ])
    if session_dir is not None:
        cargs.extend([
            "-session",
            session_dir
        ])
    if verbose:
        cargs.append("-verb")
    if dist_cor:
        cargs.append("-dist_cor")
    cargs.extend([
        "-thresh",
        thresh
    ])
    cargs.extend([
        "-nclust",
        str(nclust)
    ])
    cargs.extend(datasets)
    ret = V3dStatClustOutputs(
        root=execution.output_file("."),
        output_head=execution.output_file(prefix + "+orig.HEAD") if (prefix is not None) else None,
        output_brick=execution.output_file(prefix + "+orig.BRIK") if (prefix is not None) else None,
    )
    execution.run(cargs)
    return ret


__all__ = [
    "V3dStatClustOutputs",
    "V_3D_STAT_CLUST_METADATA",
    "v_3d_stat_clust",
]
