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

import typing
import pathlib
from styxdefs import *
import dataclasses

V_3D_DECONVOLVE_METADATA = Metadata(
    id="5e4431741fecb6d1d8debcf228eba178f6aa57f6.boutiques",
    name="3dDeconvolve",
    package="afni",
    container_image_tag="afni/afni_make_build:AFNI_24.2.06",
)


class V3dDeconvolveOutputs(typing.NamedTuple):
    """
    Output object returned when calling `v_3d_deconvolve(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    bucket_output: OutputPathType
    """Main output bucket dataset in AFNI format."""
    cbucket_output: OutputPathType
    """Regression coefficients stored in a dataset."""
    iresp_output: OutputPathType
    """Estimated Impulse Response dataset."""
    fitts_output: OutputPathType
    """Fitted Time Series dataset in AFNI format."""
    x1d_file: OutputPathType
    """X-matrix output file in .1D format."""


def v_3d_deconvolve(
    input_dataset: InputPathType,
    mask_dataset: InputPathType | None = None,
    runner: Runner | None = None,
) -> V3dDeconvolveOutputs:
    """
    Program to calculate the deconvolution of a measurement 3D+time dataset with a
    specified input stimulus time series.
    
    Author: AFNI Team
    
    URL: https://afni.nimh.nih.gov/pub/dist/doc/program_help/3dDeconvolve.html
    
    Args:
        input_dataset: Filename of 3D+time input dataset.
        mask_dataset: Filename of 3D mask dataset.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `V3dDeconvolveOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(V_3D_DECONVOLVE_METADATA)
    cargs = []
    cargs.append("3dDeconvolve")
    cargs.extend([
        "-input",
        execution.input_file(input_dataset)
    ])
    if mask_dataset is not None:
        cargs.extend([
            "-mask",
            execution.input_file(mask_dataset)
        ])
    cargs.append("[OPTIONS...]")
    ret = V3dDeconvolveOutputs(
        root=execution.output_file("."),
        bucket_output=execution.output_file("[BUCKET].HEAD"),
        cbucket_output=execution.output_file("[CBUCKET].HEAD"),
        iresp_output=execution.output_file("[IRESP].HEAD"),
        fitts_output=execution.output_file("[FITTS].HEAD"),
        x1d_file=execution.output_file("[X1D].1D"),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "V3dDeconvolveOutputs",
    "V_3D_DECONVOLVE_METADATA",
    "v_3d_deconvolve",
]
