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

import typing
import pathlib
from styxdefs import *
import dataclasses

AFNI_METADATA = Metadata(
    id="40dab3442f2e18227072a94a9827898d65dc4372.boutiques",
    name="afni",
    package="afni",
    container_image_tag="afni/afni_make_build:AFNI_24.2.06",
)


class AfniOutputs(typing.NamedTuple):
    """
    Output object returned when calling `afni_(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    session_output: OutputPathType
    """Output file for the session data"""


def afni_(
    session_directories: str | None = None,
    bysub: list[str] | None = None,
    all_dsets: bool = False,
    purge: bool = False,
    posfunc: bool = False,
    recursive: bool = False,
    no1_d: bool = False,
    nocsv: bool = False,
    notsv: bool = False,
    unique: bool = False,
    orient: str | None = None,
    noplugins: bool = False,
    seehidden: bool = False,
    allow_all_plugins: bool = False,
    yesplugouts: bool = False,
    debug_plugouts: bool = False,
    noplugouts: bool = False,
    skip_afnirc: bool = False,
    layout: InputPathType | None = None,
    niml: bool = False,
    np: int | None = None,
    npq: int | None = None,
    npb: int | None = None,
    com: str | None = None,
    comsep: str | None = None,
    runner: Runner | None = None,
) -> AfniOutputs:
    """
    Tool for reading in sessions of 3D datasets and visualizing them.
    
    Author: AFNI Developers
    
    URL: https://afni.nimh.nih.gov/
    
    Args:
        session_directories: Input session directories containing the datasets.
        bysub: Gather all datasets corresponding to a single subject identifier.
        all_dsets: Read in all datasets from all listed folders together.
        purge: Conserve memory by purging unused datasets.
        posfunc: Start up the color 'pbar' to use only positive function values.
        recursive: Recursively search each session_directory for more session\
            subdirectories.
        no1_d: Tells AFNI not to read *.1D timeseries files.
        nocsv: Tells AFNI not to read *.csv files.
        notsv: Tells AFNI not to read *.tsv files.
        unique: Create a unique set of colors for each AFNI controller window.
        orient: Orientation code for displaying x-y-z coordinates.
        noplugins: Do not load plugins.
        seehidden: Show hidden plugins.
        allow_all_plugins: Do not hide plugins.
        yesplugouts: Listen for plugouts.
        debug_plugouts: Plugout code prints lots of messages (for debugging).
        noplugouts: Do not listen for plugouts.
        skip_afnirc: Do not read .afnirc file.
        layout: Read initial windows layout from a file.
        niml: Turn on listening for NIML-formatted data from SUMA.
        np: Provide a port offset for multiple instances.
        npq: Like -np but quieter in case of errors.
        npb: Provide a block of port numbers.
        com: Specify command strings to drive AFNI on startup.
        comsep: Character to use as a separator for commands.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `AfniOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(AFNI_METADATA)
    cargs = []
    cargs.append("afni")
    if session_directories is not None:
        cargs.append(session_directories)
    if bysub is not None:
        cargs.extend([
            "-bysub",
            *bysub
        ])
    if all_dsets:
        cargs.append("-all_dsets")
    if purge:
        cargs.append("-purge")
    if posfunc:
        cargs.append("-posfunc")
    if recursive:
        cargs.append("-R")
    if no1_d:
        cargs.append("-no1D")
    if nocsv:
        cargs.append("-nocsv")
    if notsv:
        cargs.append("-notsv")
    if unique:
        cargs.append("-unique")
    if orient is not None:
        cargs.extend([
            "-orient",
            orient
        ])
    if noplugins:
        cargs.append("-noplugins")
    if seehidden:
        cargs.append("-seehidden")
    if allow_all_plugins:
        cargs.append("-DAFNI_ALLOW_ALL_PLUGINS=YES")
    if yesplugouts:
        cargs.append("-yesplugouts")
    if debug_plugouts:
        cargs.append("-YESplugouts")
    if noplugouts:
        cargs.append("-noplugouts")
    if skip_afnirc:
        cargs.append("-skip_afnirc")
    if layout is not None:
        cargs.extend([
            "-layout",
            execution.input_file(layout)
        ])
    if niml:
        cargs.append("-niml")
    if np is not None:
        cargs.extend([
            "-np",
            str(np)
        ])
    if npq is not None:
        cargs.extend([
            "-npq",
            str(npq)
        ])
    if npb is not None:
        cargs.extend([
            "-npb",
            str(npb)
        ])
    if com is not None:
        cargs.extend([
            "-com",
            com
        ])
    if comsep is not None:
        cargs.extend([
            "-comsep",
            comsep
        ])
    ret = AfniOutputs(
        root=execution.output_file("."),
        session_output=execution.output_file("output_session.nii.gz"),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "AFNI_METADATA",
    "AfniOutputs",
    "afni_",
]
