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

import typing
import pathlib
from styxdefs import *
import dataclasses

TRR_METADATA = Metadata(
    id="fa558271c9da9bb419e2a1146021b4c1c11a0615.boutiques",
    name="TRR",
    package="afni",
    container_image_tag="afni/afni_make_build:AFNI_24.2.06",
)


class TrrOutputs(typing.NamedTuple):
    """
    Output object returned when calling `trr(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    output_file_txt: OutputPathType
    """Main output file containing inference information for effects of
    interest"""
    output_file_pdf: OutputPathType
    """Density plot of the TRR distribution"""
    output_file_rdata: OutputPathType
    """Saved R data in binary format for post hoc processing"""


def trr(
    prefix: str,
    response_var: str,
    subject_var: str,
    data_table: InputPathType,
    chains: float | None = None,
    iterations: float | None = None,
    repetition_var: str | None = None,
    condition_var: str | None = None,
    categorical_vars: str | None = None,
    quantitative_vars: str | None = None,
    response_dist: str | None = None,
    model: str | None = None,
    plot_size: list[float] | None = None,
    standard_error: str | None = None,
    t_stat: str | None = None,
    within_chain_parallelization: float | None = None,
    debug: bool = False,
    verbose: float | None = None,
    runner: Runner | None = None,
) -> TrrOutputs:
    """
    Test-Retest Reliability Program through Bayesian Multilevel Modeling.
    
    Author: AFNI Team
    
    URL: https://afni.nimh.nih.gov/pub/dist/doc/program_help/TRR.html
    
    Args:
        prefix: Prefix for output file names.
        response_var: Specify the column name for the response variable.
        subject_var: Specify the column name for the subject variable.
        data_table: Specify the path to the data table in pure text format.
        chains: Specify the number of Markov chains.
        iterations: Specify the number of iterations per Markov chain.
        repetition_var: Specify the column name for the repetition variable.
        condition_var: Specify the column name for the condition variable.
        categorical_vars: Identify categorical (qualitative) variables.
        quantitative_vars: Identify quantitative (covariate) variables.
        response_dist: Specify the distribution for the response variable\
            (e.g., 'gaussian', 'student', 'exgaussian').
        model: Specify the effects associated with explanatory variables.
        plot_size: Specify the layout of posterior distribution plot (PDP) with\
            width and height in inches.
        standard_error: Include standard error for the response variable as\
            input.
        t_stat: Specify the column name for the t-statistic values.
        within_chain_parallelization: Invoke within-chain parallelization;\
            specify number of threads per chain.
        debug: Enable R to save the parameters for debugging.
        verbose: Specify verbose level.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `TrrOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(TRR_METADATA)
    cargs = []
    cargs.append("TRR")
    cargs.extend([
        "-prefix",
        prefix
    ])
    if chains is not None:
        cargs.extend([
            "-chains",
            str(chains)
        ])
    if iterations is not None:
        cargs.extend([
            "-iterations",
            str(iterations)
        ])
    cargs.extend([
        "-Y",
        response_var
    ])
    cargs.extend([
        "-subject",
        subject_var
    ])
    if repetition_var is not None:
        cargs.extend([
            "-repetition",
            repetition_var
        ])
    if condition_var is not None:
        cargs.extend([
            "-condition",
            condition_var
        ])
    cargs.extend([
        "-dataTable",
        execution.input_file(data_table)
    ])
    if categorical_vars is not None:
        cargs.extend([
            "-cVars",
            categorical_vars
        ])
    if quantitative_vars is not None:
        cargs.extend([
            "-qVars",
            quantitative_vars
        ])
    if response_dist is not None:
        cargs.extend([
            "-distY",
            response_dist
        ])
    if model is not None:
        cargs.extend([
            "-model",
            model
        ])
    if plot_size is not None:
        cargs.extend([
            "-PDP",
            *map(str, plot_size)
        ])
    if standard_error is not None:
        cargs.extend([
            "-se",
            standard_error
        ])
    if t_stat is not None:
        cargs.extend([
            "-tstat",
            t_stat
        ])
    if within_chain_parallelization is not None:
        cargs.extend([
            "-WCP",
            str(within_chain_parallelization)
        ])
    if debug:
        cargs.append("-dbgArgs")
    if verbose is not None:
        cargs.extend([
            "-verb",
            str(verbose)
        ])
    ret = TrrOutputs(
        root=execution.output_file("."),
        output_file_txt=execution.output_file(prefix + ".txt"),
        output_file_pdf=execution.output_file(prefix + ".pdf"),
        output_file_rdata=execution.output_file(prefix + ".RData"),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "TRR_METADATA",
    "TrrOutputs",
    "trr",
]
