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

import typing
import pathlib
from styxdefs import *
import dataclasses

V_3D_RANK_METADATA = Metadata(
    id="05c7817af68d191ce35831e8d5e9772041297b36.boutiques",
    name="3dRank",
    package="afni",
    container_image_tag="afni/afni_make_build:AFNI_24.2.06",
)


class V3dRankOutputs(typing.NamedTuple):
    """
    Output object returned when calling `v_3d_rank(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    output_dataset_head: OutputPathType | None
    """Main output dataset in AFNI format (.HEAD file)"""
    output_dataset_brik: OutputPathType | None
    """Main output dataset in AFNI format (.BRIK file)"""
    rank_map_file: OutputPathType | None
    """Rank map 1D file showing the mapping from the rank to the integral values
    in the input dataset"""


def v_3d_rank(
    input_datasets: list[InputPathType],
    output_prefix: str | None = None,
    version_info: bool = False,
    help_info: bool = False,
    runner: Runner | None = None,
) -> V3dRankOutputs:
    """
    Replaces voxel values by their rank in the set of values collected over all
    voxels in all input datasets.
    
    Author: AFNI Developers
    
    URL: https://afni.nimh.nih.gov/
    
    Args:
        input_datasets: Input datasets. Acceptable data types are: byte, short,\
            and floats.
        output_prefix: Output prefix. If you have multiple datasets on input,\
            the prefix is preceded by r00., r01., etc. If no prefix is given, the\
            default is rank.DATASET1, rank.DATASET2, etc.
        version_info: Print author and version info.
        help_info: Print this help screen.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `V3dRankOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(V_3D_RANK_METADATA)
    cargs = []
    cargs.append("3dRank")
    cargs.extend([execution.input_file(f) for f in input_datasets])
    if output_prefix is not None:
        cargs.extend([
            "-prefix",
            output_prefix
        ])
    if version_info:
        cargs.append("-ver")
    if help_info:
        cargs.append("-help")
    ret = V3dRankOutputs(
        root=execution.output_file("."),
        output_dataset_head=execution.output_file(output_prefix + "*.HEAD") if (output_prefix is not None) else None,
        output_dataset_brik=execution.output_file(output_prefix + "*.BRIK") if (output_prefix is not None) else None,
        rank_map_file=execution.output_file(output_prefix + "*.1D") if (output_prefix is not None) else None,
    )
    execution.run(cargs)
    return ret


__all__ = [
    "V3dRankOutputs",
    "V_3D_RANK_METADATA",
    "v_3d_rank",
]
