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

import typing
import pathlib
from styxdefs import *
import dataclasses

V_3D_MSS_METADATA = Metadata(
    id="121bc2fa9d402372cae4610a91a167c407c33ae3.boutiques",
    name="3dMSS",
    package="afni",
    container_image_tag="afni/afni_make_build:AFNI_24.2.06",
)


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


def v_3d_mss(
    prefix: str,
    data_table: InputPathType,
    jobs: float | None = None,
    mrr_formula: str | None = None,
    lme_formula: str | None = None,
    random_effect: str | None = None,
    qvars: str | None = None,
    mask: InputPathType | None = None,
    bounds: list[float] | None = None,
    prediction_table: InputPathType | None = None,
    cio_flag: bool = False,
    rio_flag: bool = False,
    help_flag: bool = False,
    dbg_args_flag: bool = False,
    if_name: str | None = None,
    show_allowed_options_flag: bool = False,
    sdiff_vars: str | None = None,
    vt_formula: str | None = None,
    runner: Runner | None = None,
) -> V3dMssOutputs:
    """
    Voxelwise Multilevel Smoothing Spline (MSS) Analysis.
    
    Author: AFNI Team
    
    URL: https://afni.nimh.nih.gov/pub/dist/doc/program_help/3dMSS.html
    
    Args:
        prefix: Output file name. For AFNI format, provide prefix only, with no\
            view+suffix needed. Filename for NIfTI format should have .nii\
            attached.
        data_table: List the data structure with a header as the first line.
        jobs: Number of CPU cores for parallel processing.
        mrr_formula: Model formulation through multilevel smoothing splines.
        lme_formula: Specify the fixed effect components of the model.
        random_effect: Specify the random effect components of the model.
        qvars: Identify quantitative variables (or covariates). The list with\
            more than one variable has to be separated with comma without any other\
            characters.
        mask: Process voxels inside this mask only.
        bounds: Outlier removal bounds. Any values in the input data that are\
            beyond the bounds will be removed and treated as missing.
        prediction_table: Provide a data table so that predicted values could\
            be generated for graphical illustration.
        cio_flag: Use AFNI's C io functions, which is default.
        rio_flag: Use R's io functions.
        help_flag: Display help message.
        dbg_args_flag: Enable R to save the parameters in a file called\
            .3dMSS.dbg.AFNI.args for debugging.
        if_name: Specify the column name that is designated for input files of\
            effect estimate. Default is 'InputFile'.
        show_allowed_options_flag: List of allowed options.
        sdiff_vars: Specify the factors for group comparisons.
        vt_formula: Specify varying smoothing terms. Two components are\
            required: the first one 'var' indicates the variable (e.g., subject)\
            around which the smoothing will vary while the second component\
            specifies the smoothing formulation.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `V3dMssOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(V_3D_MSS_METADATA)
    cargs = []
    cargs.append("3dMSS")
    cargs.append(prefix)
    if jobs is not None:
        cargs.extend([
            "-jobs",
            str(jobs)
        ])
    if mrr_formula is not None:
        cargs.extend([
            "-mrr",
            mrr_formula
        ])
    if lme_formula is not None:
        cargs.extend([
            "-lme",
            lme_formula
        ])
    if random_effect is not None:
        cargs.extend([
            "-ranEff",
            random_effect
        ])
    if qvars is not None:
        cargs.extend([
            "-qVars",
            qvars
        ])
    if mask is not None:
        cargs.extend([
            "-mask",
            execution.input_file(mask)
        ])
    if bounds is not None:
        cargs.extend([
            "-bounds",
            *map(str, bounds)
        ])
    if prediction_table is not None:
        cargs.extend([
            "-prediction",
            execution.input_file(prediction_table)
        ])
    cargs.extend([
        "-dataTable",
        execution.input_file(data_table)
    ])
    if cio_flag:
        cargs.append("-cio")
    if rio_flag:
        cargs.append("-Rio")
    if help_flag:
        cargs.append("-help")
    if dbg_args_flag:
        cargs.append("-dbgArgs")
    if if_name is not None:
        cargs.extend([
            "-IF",
            if_name
        ])
    if show_allowed_options_flag:
        cargs.append("-show_allowed_options")
    if sdiff_vars is not None:
        cargs.extend([
            "-sdiff",
            sdiff_vars
        ])
    if vt_formula is not None:
        cargs.extend([
            "-vt",
            vt_formula
        ])
    ret = V3dMssOutputs(
        root=execution.output_file("."),
        output_file=execution.output_file(prefix + ".nii"),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "V3dMssOutputs",
    "V_3D_MSS_METADATA",
    "v_3d_mss",
]
