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

import typing
import pathlib
from styxdefs import *
import dataclasses

V_3D_CLUST_COUNT_METADATA = Metadata(
    id="98fcc8c7fba23c3985c9517555b10b2b9741fa23.boutiques",
    name="3dClustCount",
    package="afni",
    container_image_tag="afni/afni_make_build:AFNI_24.2.06",
)


class V3dClustCountOutputs(typing.NamedTuple):
    """
    Output object returned when calling `v_3d_clust_count(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    clustcount_niml: OutputPathType | None
    """Summed results file in NIML format."""
    clustcount_1_d: OutputPathType | None
    """Summed results file in 1D format (when '-final' is used)."""
    final_clustcount_niml: OutputPathType | None
    """Summed results file in NIML format (when '-final' is used)."""


def v_3d_clust_count(
    datasets: list[InputPathType],
    prefix: str | None = None,
    final: bool = False,
    quiet: bool = False,
    runner: Runner | None = None,
) -> V3dClustCountOutputs:
    """
    This program takes as input 1 or more datasets, thresholds them at various
    levels, and counts up the number of clusters of various sizes.
    
    Author: AFNI Developers
    
    URL: https://afni.nimh.nih.gov/
    
    Args:
        datasets: Input datasets to be processed.
        prefix: Prefix of the filename into which results will be summed.\
            Actual filename will be 'sss.clustcount.niml'. If this file already\
            exists, results from the current run will be summed into the existing\
            results and the file then re-written.
        final: Output results in a format similar to 3dClustSim -- as 1D and\
            NIML formatted files with probabilities of various cluster sizes. This\
            option can be used without any input datasets to create final output\
            files from saved '.clustcount.niml' output file from earlier runs.
        quiet: Suppresses progress reports and other informational messages.\
            Should be placed first in the command line to quiet most messages.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `V3dClustCountOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(V_3D_CLUST_COUNT_METADATA)
    cargs = []
    cargs.append("3dClustCount")
    cargs.extend([execution.input_file(f) for f in datasets])
    if prefix is not None:
        cargs.extend([
            "-prefix",
            prefix
        ])
    if final:
        cargs.append("-final")
    if quiet:
        cargs.append("-quiet")
    ret = V3dClustCountOutputs(
        root=execution.output_file("."),
        clustcount_niml=execution.output_file(prefix + ".clustcount.niml") if (prefix is not None) else None,
        clustcount_1_d=execution.output_file(prefix + ".1D") if (prefix is not None) else None,
        final_clustcount_niml=execution.output_file(prefix + ".niml") if (prefix is not None) else None,
    )
    execution.run(cargs)
    return ret


__all__ = [
    "V3dClustCountOutputs",
    "V_3D_CLUST_COUNT_METADATA",
    "v_3d_clust_count",
]
