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

import typing
import pathlib
from styxdefs import *
import dataclasses

V_3D_NLFIM_METADATA = Metadata(
    id="b2553c2bf57346747079630757e1d16620ea8119.boutiques",
    name="3dNLfim",
    package="afni",
    container_image_tag="afni/afni_make_build:AFNI_24.2.06",
)


class V3dNlfimOutputs(typing.NamedTuple):
    """
    Output object returned when calling `v_3d_nlfim(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    freg_outfile: OutputPathType
    """F-test for significance of the regression"""
    frsqr_outfile: OutputPathType
    """R^2 calculation for regression"""
    fsmax_outfile: OutputPathType
    """Signed maximum signal estimate"""
    ftmax_outfile: OutputPathType
    """Time of signed maximum estimate"""
    fpsmax_outfile: OutputPathType
    """Maximum percentage change estimate"""
    farea_outfile: OutputPathType
    """Area between signal and baseline"""
    fparea_outfile: OutputPathType
    """Percentage area of signal estimate"""
    fscoef_outfile: OutputPathType
    """Signal parameter estimate"""
    fncoef_outfile: OutputPathType
    """Noise parameter estimate"""
    tscoef_outfile: OutputPathType
    """T-test for significance of signal parameter"""
    tncoef_outfile: OutputPathType
    """T-test for significance of noise parameter"""
    bucket_outfile: OutputPathType
    """AFNI 'bucket' dataset"""
    sfit_outfile: OutputPathType
    """Output 3d+time signal model fit"""
    snfit_outfile: OutputPathType
    """Output 3d+time signal+noise fit"""


def v_3d_nlfim(
    input_file: InputPathType,
    signal_model: str,
    noise_model: str,
    runner: Runner | None = None,
) -> V3dNlfimOutputs:
    """
    Nonlinear regression for each voxel of the input AFNI 3d+time data set.
    
    Author: AFNI Developers
    
    URL: https://afni.nimh.nih.gov/
    
    Args:
        input_file: Filename of 3d+time data file for input.
        signal_model: Name of the nonlinear signal model.
        noise_model: Name of the linear noise model.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `V3dNlfimOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(V_3D_NLFIM_METADATA)
    cargs = []
    cargs.append("3dNLfim")
    cargs.extend([
        "-input",
        execution.input_file(input_file)
    ])
    cargs.extend([
        "-signal",
        signal_model
    ])
    cargs.extend([
        "-noise",
        noise_model
    ])
    cargs.append("[ADDITIONAL_OPTIONS]")
    ret = V3dNlfimOutputs(
        root=execution.output_file("."),
        freg_outfile=execution.output_file("[FREG].fift"),
        frsqr_outfile=execution.output_file("[FRSQR].fift"),
        fsmax_outfile=execution.output_file("[FSMAX].fift"),
        ftmax_outfile=execution.output_file("[FTMAX].fift"),
        fpsmax_outfile=execution.output_file("[FPSMAX].fift"),
        farea_outfile=execution.output_file("[FAREA].fift"),
        fparea_outfile=execution.output_file("[FPAREA].fift"),
        fscoef_outfile=execution.output_file("[FSCOEF].fift"),
        fncoef_outfile=execution.output_file("[FNCOEF].fift"),
        tscoef_outfile=execution.output_file("[TSCOEF].fitt"),
        tncoef_outfile=execution.output_file("[TNCOEF].fitt"),
        bucket_outfile=execution.output_file("[BUCKET].bucket"),
        sfit_outfile=execution.output_file("[SFIT].sfit"),
        snfit_outfile=execution.output_file("[SNFIT].snfit"),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "V3dNlfimOutputs",
    "V_3D_NLFIM_METADATA",
    "v_3d_nlfim",
]
