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

import typing
import pathlib
from styxdefs import *
import dataclasses

V__REORDER_METADATA = Metadata(
    id="93af53020ee1088a33b0e58234dc8960b688e23e.boutiques",
    name="@Reorder",
    package="afni",
    container_image_tag="afni/afni_make_build:AFNI_24.2.06",
)


class VReorderOutputs(typing.NamedTuple):
    """
    Output object returned when calling `v__reorder(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    output_dataset: OutputPathType
    """Reordered output dataset"""


def v__reorder(
    input_dataset: InputPathType,
    mapfile: InputPathType,
    prefix: str,
    offset: float | None = None,
    save_work: bool = False,
    test: bool = False,
    runner: Runner | None = None,
) -> VReorderOutputs:
    """
    Reorder sub-bricks of a dataset based on event mapping. Works similarly to the
    Reorder plugin.
    
    Author: AFNI Developers
    
    URL: https://afni.nimh.nih.gov/
    
    Args:
        input_dataset: Input dataset to reorder (e.g. EPI+tlrc).
        mapfile: TR to event mapping file (e.g. events.txt).
        prefix: Prefix for the output dataset.
        offset: Offset mapfile TR indices by OFFSET (in TRs).
        save_work: Do not delete work directory (reorder.work.dir) at the end.
        test: Just report sub-bricks, do not create datasets.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `VReorderOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(V__REORDER_METADATA)
    cargs = []
    cargs.append("@Reorder")
    cargs.append(execution.input_file(input_dataset))
    cargs.append(execution.input_file(mapfile))
    cargs.append(prefix)
    if offset is not None:
        cargs.extend([
            "-offset",
            str(offset)
        ])
    if save_work:
        cargs.append("-save_work")
    if test:
        cargs.append("-test")
    ret = VReorderOutputs(
        root=execution.output_file("."),
        output_dataset=execution.output_file(prefix + "+tlrc"),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "VReorderOutputs",
    "V__REORDER_METADATA",
    "v__reorder",
]
