# 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="3c5bd8bab8c9c3f4b4586c2e6fc553ef1b03f1e4.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 | None
    """Main output bucket dataset in AFNI format."""
    cbucket_output: OutputPathType | None
    """Regression coefficients stored in a dataset."""
    iresp_output: OutputPathType | None
    """Estimated Impulse Response dataset."""
    fitts_output: OutputPathType | None
    """Fitted Time Series dataset in AFNI format."""
    x1d_file: OutputPathType | None
    """X-matrix output file in .1D format."""


def v_3d_deconvolve(
    input_dataset: InputPathType,
    mask_dataset: InputPathType | None = None,
    num_stimts: int | None = None,
    stim_file: str | None = None,
    stim_label: str | None = None,
    stim_base: bool = False,
    stim_times: str | None = None,
    iresp: str | None = None,
    fitts: str | None = None,
    fout: bool = False,
    tout: bool = False,
    bucket: str | None = None,
    cbucket: str | None = None,
    x1_d: str | None = None,
    jobs: int | 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 Developers
    
    URL: https://afni.nimh.nih.gov/
    
    Args:
        input_dataset: Filename of 3D+time input dataset.
        mask_dataset: Filename of 3D mask dataset.
        num_stimts: Number of input stimulus time series.
        stim_file: Filename of kth time series input stimulus.
        stim_label: Label for kth input stimulus.
        stim_base: Kth input stimulus is part of the baseline model.
        stim_times: Deconvolution response model for kth stimulus.
        iresp: Prefix for 3D+time output dataset which will contain the kth\
            estimated impulse response.
        fitts: Prefix for 3D+time output dataset which will contain the (full\
            model) time series fit to the input data.
        fout: Flag to output the F-statistics for each stimulus.
        tout: Flag to output the t-statistics.
        bucket: Create one AFNI 'bucket' dataset containing various parameters\
            of interest.
        cbucket: Save the regression coefficients (no statistics) into a\
            dataset.
        x1_d: Save X matrix to a .xmat.1D (ASCII) file.
        jobs: Run the program with multiple jobs (sub-processes).
        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)
        ])
    if num_stimts is not None:
        cargs.extend([
            "-num_stimts",
            str(num_stimts)
        ])
    if stim_file is not None:
        cargs.extend([
            "-stim_file",
            stim_file
        ])
    if stim_label is not None:
        cargs.extend([
            "-stim_label",
            stim_label
        ])
    if stim_base:
        cargs.append("-stim_base")
    if stim_times is not None:
        cargs.extend([
            "-stim_times",
            stim_times
        ])
    if iresp is not None:
        cargs.extend([
            "-iresp",
            iresp
        ])
    if fitts is not None:
        cargs.extend([
            "-fitts",
            fitts
        ])
    if fout:
        cargs.append("-fout")
    if tout:
        cargs.append("-tout")
    if bucket is not None:
        cargs.extend([
            "-bucket",
            bucket
        ])
    if cbucket is not None:
        cargs.extend([
            "-cbucket",
            cbucket
        ])
    if x1_d is not None:
        cargs.extend([
            "-x1D",
            x1_d
        ])
    if jobs is not None:
        cargs.extend([
            "-jobs",
            str(jobs)
        ])
    ret = V3dDeconvolveOutputs(
        root=execution.output_file("."),
        bucket_output=execution.output_file(bucket + ".HEAD") if (bucket is not None) else None,
        cbucket_output=execution.output_file(cbucket + ".HEAD") if (cbucket is not None) else None,
        iresp_output=execution.output_file(iresp + ".HEAD") if (iresp is not None) else None,
        fitts_output=execution.output_file(fitts + ".HEAD") if (fitts is not None) else None,
        x1d_file=execution.output_file(x1_d + ".1D") if (x1_d is not None) else None,
    )
    execution.run(cargs)
    return ret


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