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

import typing
import pathlib
from styxdefs import *
import dataclasses

V__ANATICOR_METADATA = Metadata(
    id="3db66aed89c32fcb65e127aa5c1e9c35942e3278.boutiques",
    name="@ANATICOR",
    package="afni",
    container_image_tag="afni/afni_make_build:AFNI_24.2.06",
)


class VAnaticorOutputs(typing.NamedTuple):
    """
    Output object returned when calling `v__anaticor(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    output_files: OutputPathType
    """Output files with the prefix specified by the -prefix option."""


def v__anaticor(
    ts: InputPathType,
    polort: str,
    motion: InputPathType,
    aseg: InputPathType,
    prefix: str,
    radius: float | None = None,
    view: str | None = None,
    nuisance: InputPathType | None = None,
    no_ventricles: bool = False,
    rsq_wme: bool = False,
    coverage: bool = False,
    verb: bool = False,
    dirty: bool = False,
    echo: bool = False,
    runner: Runner | None = None,
) -> VAnaticorOutputs:
    """
    Script to produce a residual time series cleaned by ANATICOR model.
    
    Author: AFNI Team
    
    URL: https://afni.nimh.nih.gov/pub/dist/doc/program_help/@ANATICOR.html
    
    Args:
        ts: Time series volume which should have already undergone\
            preprocessing steps such as despiking, RetroIcor, RVT correction, time\
            shifting, and volume registration.
        polort: Polynomial for linear trend removal. Use the same order as for\
            afni_proc.py.
        motion: Head motion parameters from 3dvolreg, also created by\
            afni_proc.py.
        aseg: Aseg file from FreeSurfer's segmentation. This aseg volume must\
            be in register with the EPI time series.
        prefix: Use output (residual time series) for a prefix.
        radius: The radius of a local sphere mask in mm. Default is 15 mm for\
            high resolution 1.7x1.7x3mm data.
        view: Set the view of the output data. Default is +orig. Choose from\
            +orig, +acpc, or +tlrc.
        nuisance: Other nuisance regressors. Each regressor is a column in .1D\
            file.
        no_ventricles: Do not include LVe regressor.
        rsq_wme: Produce an explained variance map for WMeLOCAL regressor.
        coverage: Produce a spatial coverage map of WMeLOCAL regressor.
        verb: Verbose flag.
        dirty: Keep temporary files.
        echo: Echo each script command for debugging.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `VAnaticorOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(V__ANATICOR_METADATA)
    cargs = []
    cargs.append("@ANATICOR")
    cargs.extend([
        "-ts",
        execution.input_file(ts)
    ])
    cargs.extend([
        "-polort",
        polort
    ])
    cargs.extend([
        "-motion",
        execution.input_file(motion)
    ])
    cargs.append(execution.input_file(aseg))
    cargs.extend([
        "-prefix",
        prefix
    ])
    if radius is not None:
        cargs.extend([
            "-radius",
            str(radius)
        ])
    if view is not None:
        cargs.append(view)
    if nuisance is not None:
        cargs.extend([
            "-nuisance",
            execution.input_file(nuisance)
        ])
    if no_ventricles:
        cargs.append("-no_ventricles")
    if rsq_wme:
        cargs.append("-Rsq_WMe")
    if coverage:
        cargs.append("-coverage")
    if verb:
        cargs.append("-verb")
    if dirty:
        cargs.append("-dirty")
    if echo:
        cargs.append("-echo")
    ret = VAnaticorOutputs(
        root=execution.output_file("."),
        output_files=execution.output_file(prefix),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "VAnaticorOutputs",
    "V__ANATICOR_METADATA",
    "v__anaticor",
]
