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

import typing
import pathlib
from styxdefs import *
import dataclasses

V_3D_DETREND_METADATA = Metadata(
    id="e1acbbed353dee123a530befb4df733e98383a20.boutiques",
    name="3dDetrend",
    package="afni",
    container_image_tag="afni/afni_make_build:AFNI_24.2.06",
)


class V3dDetrendOutputs(typing.NamedTuple):
    """
    Output object returned when calling `v_3d_detrend(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    out_file: OutputPathType
    """Output image file name."""
    out_file_: OutputPathType
    """Output file."""


def v_3d_detrend(
    in_file: InputPathType,
    outputtype: typing.Literal["NIFTI", "AFNI", "NIFTI_GZ"] | None = None,
    runner: Runner | None = None,
) -> V3dDetrendOutputs:
    """
    This program removes components from voxel time series using linear least
    squares.
    
    Author: AFNI Developers
    
    URL: https://afni.nimh.nih.gov/
    
    Args:
        in_file: Input file to 3ddetrend.
        outputtype: 'nifti' or 'afni' or 'nifti_gz'. Afni output filetype.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `V3dDetrendOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(V_3D_DETREND_METADATA)
    cargs = []
    cargs.append("3dDetrend")
    cargs.append(execution.input_file(in_file))
    if outputtype is not None:
        cargs.append(outputtype)
    ret = V3dDetrendOutputs(
        root=execution.output_file("."),
        out_file=execution.output_file(pathlib.Path(in_file).name + "_detrend"),
        out_file_=execution.output_file("out_file"),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "V3dDetrendOutputs",
    "V_3D_DETREND_METADATA",
    "v_3d_detrend",
]
