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

import typing
import pathlib
from styxdefs import *
import dataclasses

V_1DSUM_METADATA = Metadata(
    id="bc19d515e82be4f6b3c9c9f81c1a201e83b798ea.boutiques",
    name="1dsum",
    package="afni",
    container_image_tag="afni/afni_make_build:AFNI_24.2.06",
)


class V1dsumOutputs(typing.NamedTuple):
    """
    Output object returned when calling `v_1dsum(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    output_file: OutputPathType
    """Sum or average of columns in the input files"""


def v_1dsum(
    input_files: list[InputPathType],
    ignore_rows: float | None = None,
    use_rows: float | None = None,
    mean_flag: bool = False,
    nocomment_flag: bool = False,
    okempty_flag: bool = False,
    runner: Runner | None = None,
) -> V1dsumOutputs:
    """
    Sum or average columns of ASCII files with numbers arranged in rows and columns.
    
    Author: AFNI Developers
    
    URL: https://afni.nimh.nih.gov/
    
    Args:
        input_files: Input ASCII files with numbers arranged in rows and\
            columns.
        ignore_rows: Skip the first nn rows of each file.
        use_rows: Use only mm rows from each file.
        mean_flag: Compute the average instead of the sum.
        nocomment_flag: Do not reproduce comments from the header of the first\
            input file to the output.
        okempty_flag: If encountering an empty 1D file, print 0 and exit\
            quietly instead of exiting with an error message.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `V1dsumOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(V_1DSUM_METADATA)
    cargs = []
    cargs.append("1dsum")
    cargs.extend([execution.input_file(f) for f in input_files])
    if ignore_rows is not None:
        cargs.extend([
            "-ignore",
            str(ignore_rows)
        ])
    if use_rows is not None:
        cargs.extend([
            "-use",
            str(use_rows)
        ])
    if mean_flag:
        cargs.append("-mean")
    if nocomment_flag:
        cargs.append("-nocomment")
    if okempty_flag:
        cargs.append("-OKempty")
    ret = V1dsumOutputs(
        root=execution.output_file("."),
        output_file=execution.output_file("output.txt"),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "V1dsumOutputs",
    "V_1DSUM_METADATA",
    "v_1dsum",
]
