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

import typing
import pathlib
from styxdefs import *
import dataclasses

AP_RUN_SIMPLE_REST_METADATA = Metadata(
    id="51acc3d2305cb727e55055aa552281969a79036d.boutiques",
    name="ap_run_simple_rest",
    package="afni",
    container_image_tag="afni/afni_make_build:AFNI_24.2.06",
)


class ApRunSimpleRestOutputs(typing.NamedTuple):
    """
    Output object returned when calling `ap_run_simple_rest(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    run_ap_script: OutputPathType | None
    """afni_proc.py command script"""
    proc_script: OutputPathType | None
    """proc script (if AP is run)"""
    proc_results_dir: OutputPathType | None
    """proc results directory (if run)"""
    text_output_files: OutputPathType
    """Text output files from AP and proc scripts"""


def ap_run_simple_rest(
    epi: list[InputPathType],
    anat: InputPathType | None = None,
    nt_rm: float | None = None,
    run_ap: bool = False,
    run_proc: bool = False,
    subjid: str | None = None,
    template: InputPathType | None = None,
    compressor: str | None = None,
    verb: float | None = None,
    echo: bool = False,
    runner: Runner | None = None,
) -> ApRunSimpleRestOutputs:
    """
    Run a quick afni_proc.py analysis for QC.
    
    Author: AFNI Developers
    
    URL: https://afni.nimh.nih.gov/
    
    Args:
        epi: EPI datasets.
        anat: Single anatomical dataset.
        nt_rm: Number of time points to remove from starts of runs.
        run_ap: Run the afni_proc.py command.
        run_proc: Run the proc script from afni_proc.py command.
        subjid: Specify subject ID for file names.
        template: Specify template for standard space.
        compressor: Control automatic compression of *.BRIK files.
        verb: Specify verbosity level.
        echo: Same as verbosity level 3.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `ApRunSimpleRestOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(AP_RUN_SIMPLE_REST_METADATA)
    cargs = []
    cargs.append("ap_run_simple_rest.tcsh")
    if anat is not None:
        cargs.extend([
            "-anat",
            execution.input_file(anat)
        ])
    cargs.extend([
        "-epi",
        *[execution.input_file(f) for f in epi]
    ])
    if nt_rm is not None:
        cargs.extend([
            "-nt_rm",
            str(nt_rm)
        ])
    if run_ap:
        cargs.append("-run_ap")
    if run_proc:
        cargs.append("-run_proc")
    if subjid is not None:
        cargs.extend([
            "-subjid",
            subjid
        ])
    if template is not None:
        cargs.extend([
            "-template",
            execution.input_file(template)
        ])
    if compressor is not None:
        cargs.extend([
            "-compressor",
            compressor
        ])
    if verb is not None:
        cargs.extend([
            "-verb",
            str(verb)
        ])
    if echo:
        cargs.append("-echo")
    ret = ApRunSimpleRestOutputs(
        root=execution.output_file("."),
        run_ap_script=execution.output_file("run_ap_" + subjid) if (subjid is not None) else None,
        proc_script=execution.output_file("proc." + subjid) if (subjid is not None) else None,
        proc_results_dir=execution.output_file(subjid + ".results") if (subjid is not None) else None,
        text_output_files=execution.output_file("out.*"),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "AP_RUN_SIMPLE_REST_METADATA",
    "ApRunSimpleRestOutputs",
    "ap_run_simple_rest",
]
