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

import typing
import pathlib
from styxdefs import *
import dataclasses

MBA_METADATA = Metadata(
    id="759d552c8331c6f9674ba94b1244b4b902aa52b4.boutiques",
    name="MBA",
    package="afni",
    container_image_tag="afni/afni_make_build:AFNI_24.2.06",
)


class MbaOutputs(typing.NamedTuple):
    """
    Output object returned when calling `mba(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    output_txt: OutputPathType
    """Main output text file storing inference information"""
    output_rdata: OutputPathType
    """R data file for post hoc processing and plotting"""
    matrix_plot: OutputPathType
    """Matrix plot visualization of analysis"""


def mba(
    prefix: str,
    data_table: InputPathType,
    chains: int | None = None,
    iterations: int | None = None,
    model: str | None = None,
    eoi: str | None = None,
    cvars: str | None = None,
    qvars: str | None = None,
    qcvar: str | None = None,
    stdz: str | None = None,
    wcp: int | None = None,
    disty: str | None = None,
    se: str | None = None,
    dbg_args: bool = False,
    help_: bool = False,
    runner: Runner | None = None,
) -> MbaOutputs:
    """
    Matrix-Based Analysis Program through Bayesian Multilevel Modeling.
    
    Author: AFNI Team
    
    URL: https://afni.nimh.nih.gov/pub/dist/doc/program_help/MBA.html
    
    Args:
        prefix: Prefix for output file names.
        data_table: Specify the data structure in a table of long format.
        chains: Specify the number of Markov chains.
        iterations: Specify the number of iterations per Markov chain.
        model: Specify the effects associated with explanatory variables.
        eoi: Identify effects of interest in the output.
        cvars: Identify categorical (qualitative) variables.
        qvars: Identify quantitative variables (or covariates).
        qcvar: Identify comparisons of interest between quantitative variables.
        stdz: Identify quantitative variables (or covariates) to be\
            standardized.
        wcp: Invoke within-chain parallelization to speed up runtime.
        disty: Specify the distribution for the response variable.
        se: Specify the column name that designates the standard error for the\
            response variable.
        dbg_args: Enable R to save the parameters in a file called\
            .MBA.dbg.AFNI.args for debugging purposes.
        help_: Show help message.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `MbaOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(MBA_METADATA)
    cargs = []
    cargs.append("MBA")
    cargs.append(prefix)
    if chains is not None:
        cargs.extend([
            "-chains",
            str(chains)
        ])
    if iterations is not None:
        cargs.extend([
            "-iterations",
            str(iterations)
        ])
    if model is not None:
        cargs.extend([
            "-model",
            model
        ])
    if eoi is not None:
        cargs.extend([
            "-EOI",
            eoi
        ])
    cargs.extend([
        "-dataTable",
        execution.input_file(data_table)
    ])
    if cvars is not None:
        cargs.extend([
            "-cVars",
            cvars
        ])
    if qvars is not None:
        cargs.extend([
            "-qVars",
            qvars
        ])
    if qcvar is not None:
        cargs.extend([
            "-qContr",
            qcvar
        ])
    if stdz is not None:
        cargs.extend([
            "-stdz",
            stdz
        ])
    if wcp is not None:
        cargs.extend([
            "-WCP",
            str(wcp)
        ])
    if disty is not None:
        cargs.extend([
            "-distY",
            disty
        ])
    if se is not None:
        cargs.extend([
            "-se",
            se
        ])
    cargs.append("[RPREFIX]")
    if dbg_args:
        cargs.append("-dbgArgs")
    if help_:
        cargs.append("-help")
    ret = MbaOutputs(
        root=execution.output_file("."),
        output_txt=execution.output_file(prefix + ".txt"),
        output_rdata=execution.output_file(prefix + ".RData"),
        matrix_plot=execution.output_file(prefix + "_matrixplot.png"),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "MBA_METADATA",
    "MbaOutputs",
    "mba",
]
