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

import typing
import pathlib
from styxdefs import *
import dataclasses

V_3D_LME_METADATA = Metadata(
    id="e9a80d6729c55d33424066db0a326673e6b70516.boutiques",
    name="3dLME",
    package="afni",
    container_image_tag="afni/afni_make_build:AFNI_24.2.06",
)


class V3dLmeOutputs(typing.NamedTuple):
    """
    Output object returned when calling `v_3d_lme(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    output_nifti: OutputPathType
    """Output file in NIfTI format"""


def v_3d_lme(
    prefix: str,
    model: str,
    data_table: str,
    bounds: list[float] | None = None,
    cio_flag: bool = False,
    cor_str: str | None = None,
    cutoff: float | None = None,
    dbg_args_flag: bool = False,
    jobs: float | None = None,
    glt_code: str | None = None,
    glt_label: str | None = None,
    glf_label: str | None = None,
    glf_code: str | None = None,
    icc_flag: bool = False,
    iccb_flag: bool = False,
    log_lik_flag: bool = False,
    logit_flag: bool = False,
    ml_flag: bool = False,
    qvars_centers: str | None = None,
    qvars: str | None = None,
    raneff: str | None = None,
    mask: InputPathType | None = None,
    num_glf: float | None = None,
    num_glt: float | None = None,
    resid: str | None = None,
    re_: str | None = None,
    reprefix: str | None = None,
    rio_flag: bool = False,
    show_options_flag: bool = False,
    ss_type: float | None = None,
    runner: Runner | None = None,
) -> V3dLmeOutputs:
    """
    AFNI Group Analysis Program with Linear Mixed-Effects Modeling Approach.
    
    Author: AFNI Developers
    
    URL: https://afni.nimh.nih.gov/
    
    Args:
        prefix: Prefix for output files.
        model: Model formula describing the fixed effects.
        data_table: Data table description.
        bounds: Lower and upper bounds for outlier removal.
        cio_flag: Use AFNI's C io functions (default) or R's io functions with\
            -Rio.
        cor_str: Specify the correlation structure of the residuals.
        cutoff: Specify the cutoff value for accuracy in logistic regression\
            analysis.
        dbg_args_flag: Enable saving parameters for debugging.
        jobs: Number of jobs for parallel computing.
        glt_code: General linear test coding.
        glt_label: Label for general linear test.
        glf_label: Label for general linear F-test.
        glf_code: General linear F-test coding.
        icc_flag: Compute voxel-wise intra-class correlation.
        iccb_flag: Compute voxel-wise intra-class correlation with Bayesian\
            approach.
        log_lik_flag: Include voxel-wise log likelihood in the output.
        logit_flag: Perform voxel-wise logistic modeling.
        ml_flag: Use Maximum Likelihood estimation instead of REML.
        qvars_centers: Centering values for quantitative variables.
        qvars: Identify quantitative variables (or covariates).
        raneff: Specify the random effects.
        mask: Mask file for voxel processing.
        num_glf: Number of general linear F-tests.
        num_glt: Number of general linear t-tests.
        resid: Prefix for residuals output file.
        re_: List of variables whose random effects are saved in the output.
        reprefix: Prefix for random effects output file.
        rio_flag: Use R's io functions instead of AFNI's C io functions.
        show_options_flag: List of allowed options.
        ss_type: Specify the type for sums of squares in the F-statistics.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `V3dLmeOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(V_3D_LME_METADATA)
    cargs = []
    cargs.append("3dLME")
    cargs.extend([
        "-prefix",
        prefix
    ])
    cargs.extend([
        "-model",
        model
    ])
    cargs.extend([
        "-dataTable",
        data_table
    ])
    if bounds is not None:
        cargs.extend([
            "-bounds",
            *map(str, bounds)
        ])
    if cio_flag:
        cargs.append("-cio")
    if cor_str is not None:
        cargs.extend([
            "-corStr",
            cor_str
        ])
    if cutoff is not None:
        cargs.extend([
            "-cutoff",
            str(cutoff)
        ])
    if dbg_args_flag:
        cargs.append("-dbgArgs")
    if jobs is not None:
        cargs.extend([
            "-jobs",
            str(jobs)
        ])
    if glt_code is not None:
        cargs.extend([
            "-gltCode",
            glt_code
        ])
    if glt_label is not None:
        cargs.extend([
            "-gltLabel",
            glt_label
        ])
    if glf_label is not None:
        cargs.extend([
            "-glfLabel",
            glf_label
        ])
    if glf_code is not None:
        cargs.extend([
            "-glfCode",
            glf_code
        ])
    if icc_flag:
        cargs.append("-ICC")
    if iccb_flag:
        cargs.append("-ICCb")
    if log_lik_flag:
        cargs.append("-logLik")
    if logit_flag:
        cargs.append("-LOGIT")
    cargs.append("-ml")
    if ml_flag:
        cargs.append("-ML")
    if qvars_centers is not None:
        cargs.extend([
            "-qVarsCenters",
            qvars_centers
        ])
    if qvars is not None:
        cargs.extend([
            "-qVars",
            qvars
        ])
    if raneff is not None:
        cargs.extend([
            "-ranEff",
            raneff
        ])
    if mask is not None:
        cargs.extend([
            "-mask",
            execution.input_file(mask)
        ])
    if num_glf is not None:
        cargs.extend([
            "-num_glf",
            str(num_glf)
        ])
    if num_glt is not None:
        cargs.extend([
            "-num_glt",
            str(num_glt)
        ])
    if resid is not None:
        cargs.extend([
            "-resid",
            resid
        ])
    if re_ is not None:
        cargs.extend([
            "-RE",
            re_
        ])
    if reprefix is not None:
        cargs.extend([
            "-REprefix",
            reprefix
        ])
    cargs.append("-RIO")
    if rio_flag:
        cargs.append("-Rio")
    if show_options_flag:
        cargs.append("-show_allowed_options")
    if ss_type is not None:
        cargs.extend([
            "-SS_type",
            str(ss_type)
        ])
    ret = V3dLmeOutputs(
        root=execution.output_file("."),
        output_nifti=execution.output_file(prefix + ".nii"),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "V3dLmeOutputs",
    "V_3D_LME_METADATA",
    "v_3d_lme",
]
