# 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="3003fb7861d0366b3de9ce16dec83be8cdbe44e5.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
    """Main output dataset in AFNI format (.HEAD file)"""
    output_dataset_brik: OutputPathType
    """Main output dataset in AFNI format (.BRIK file)"""
    rank_map_file: OutputPathType
    """Rank map 1D file showing the mapping from the rank to the integral values
    in the input dataset"""


def v_3d_rank(
    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 Team
    
    URL: https://afni.nimh.nih.gov/pub/dist/doc/program_help/3dRank.html
    
    Args:
        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.append("[-prefix")
    cargs.append("PREFIX]")
    cargs.append("<-input")
    cargs.append("DATASET1")
    cargs.append("[DATASET2")
    cargs.append("...]>")
    ret = V3dRankOutputs(
        root=execution.output_file("."),
        output_dataset_head=execution.output_file("[PREFIX]*.HEAD"),
        output_dataset_brik=execution.output_file("[PREFIX]*.BRIK"),
        rank_map_file=execution.output_file("[PREFIX]*.1D"),
    )
    execution.run(cargs)
    return ret


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