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

import typing
import pathlib
from styxdefs import *
import dataclasses

FAT_MVM_SCRIPTER_PY_METADATA = Metadata(
    id="2b93a491c79b77f3d34fa9c5577a2b3807db847a.boutiques",
    name="fat_mvm_scripter.py",
    package="afni",
    container_image_tag="afni/afni_make_build:AFNI_24.2.06",
)


class FatMvmScripterPyOutputs(typing.NamedTuple):
    """
    Output object returned when calling `fat_mvm_scripter_py(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    generated_script: OutputPathType
    """Script for running 3dMVM, using the prescribed variables along with each
    individual parameter."""
    results_file: OutputPathType
    """Text file of the test results."""


def fat_mvm_scripter_py(
    prefix: str,
    table: InputPathType,
    log: InputPathType,
    vars_: str | None = None,
    file_vars: InputPathType | None = None,
    pars: str | None = None,
    file_pars: InputPathType | None = None,
    rois: str | None = None,
    file_rois: InputPathType | None = None,
    no_posthoc: bool = False,
    na_warn_off: bool = False,
    subnet_pref: str | None = None,
    cat_pair_off: bool = False,
    runner: Runner | None = None,
) -> FatMvmScripterPyOutputs:
    """
    Automated tool to create command scripts for 3dMVM statistical modeling.
    
    Author: AFNI Developers
    
    URL: https://afni.nimh.nih.gov/
    
    Args:
        prefix: Output prefix for the script file, which will ultimately create\
            a PREFIX_MVM.txt file of statistical results from 3dMVM.
        table: Text file containing columns of subject data, one subject per\
            row, formatted as a *_MVMtbl.txt output by fat_mvm_prep.py.
        log: File formatted according to fat_mvm_prep.py containing commented\
            headings and lists of cross-group ROIs and parameters.
        vars_: List of variables for the 3dMVM model. Names must be separated\
            with whitespace. Categorical variables will be detected automatically\
            by the presence of nonnumeric characters in their columns.
        file_vars: Second method for supplying a list of variables for 3dMVM.\
            VAR_FILE is a text file with a single column of variable names.
        pars: List of parameters (names of matrices) to run in distinct 3dMVM\
            models. Names must be separated with whitespace.
        file_pars: Second method for supplying a list of parameters for 3dMVM\
            runs. PAR_FILE is a text file with a single column of parameter names.
        rois: Optional command to select a subset of available network ROIs.\
            Names must be separated with whitespace.
        file_rois: Second method for supplying a subset of ROIs for 3dMVM runs.\
            ROI_FILE is a text file with a single column of variable names.
        no_posthoc: Switch to turn off the automatic generation of per-ROI post\
            hoc tests.
        na_warn_off: Switch to turn off the automatic warnings as the data\
            table is created. 3dMVM will excise subjects with NA values, so there\
            shouldn't be NA values in columns you want to model.
        subnet_pref: Name SUBPR for the new table file that is created when a\
            subnetwork list of ROIs is used.
        cat_pair_off: Switch to turn off the test for categorical variables\
            undergoing posthoc testing.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `FatMvmScripterPyOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(FAT_MVM_SCRIPTER_PY_METADATA)
    cargs = []
    cargs.append("fat_mvm_scripter.py")
    cargs.extend([
        "--prefix",
        prefix
    ])
    cargs.extend([
        "--table",
        execution.input_file(table)
    ])
    cargs.extend([
        "--log",
        execution.input_file(log)
    ])
    if vars_ is not None:
        cargs.extend([
            "--vars",
            vars_
        ])
    if file_vars is not None:
        cargs.extend([
            "--file_vars",
            execution.input_file(file_vars)
        ])
    if pars is not None:
        cargs.extend([
            "--Pars",
            pars
        ])
    if file_pars is not None:
        cargs.extend([
            "--File_Pars",
            execution.input_file(file_pars)
        ])
    if rois is not None:
        cargs.extend([
            "--rois",
            rois
        ])
    if file_rois is not None:
        cargs.extend([
            "--file_rois",
            execution.input_file(file_rois)
        ])
    if no_posthoc:
        cargs.append("--no_posthoc")
    if na_warn_off:
        cargs.append("--NA_warn_off")
    if subnet_pref is not None:
        cargs.extend([
            "--subnet_pref",
            subnet_pref
        ])
    if cat_pair_off:
        cargs.append("--cat_pair_off")
    ret = FatMvmScripterPyOutputs(
        root=execution.output_file("."),
        generated_script=execution.output_file(prefix + "_scri.tcsh"),
        results_file=execution.output_file(prefix + "_MVM.txt"),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "FAT_MVM_SCRIPTER_PY_METADATA",
    "FatMvmScripterPyOutputs",
    "fat_mvm_scripter_py",
]
