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

import typing
import pathlib
from styxdefs import *
import dataclasses

V_3D_DWUNCERT_METADATA = Metadata(
    id="8f7f239d86c536d7e540a83e127aed316e05a15c.boutiques",
    name="3dDWUncert",
    package="afni",
    container_image_tag="afni/afni_make_build:AFNI_24.2.06",
)


class V3dDwuncertOutputs(typing.NamedTuple):
    """
    Output object returned when calling `v_3d_dwuncert(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    output_file: OutputPathType
    """AFNI-format file with 6 subbricks, containing uncertainty information."""


def v_3d_dwuncert(
    input_file: InputPathType,
    input_prefix: str,
    output_prefix: str,
    grad_file: InputPathType | None = None,
    bmatrix_file: InputPathType | None = None,
    num_iters: float | None = None,
    mask_file: InputPathType | None = None,
    calc_thr_fa: float | None = None,
    csf_fa: float | None = None,
    runner: Runner | None = None,
) -> V3dDwuncertOutputs:
    """
    Use jackknifing to estimate uncertainty of DTI parameters, important for
    probabilistic tractography.
    
    Author: AFNI Developers
    
    URL: https://afni.nimh.nih.gov/
    
    Args:
        input_file: Input file with b0 and DWI subbricks.
        input_prefix: Basename of DTI volumes.
        output_prefix: Output file name prefix.
        grad_file: File with 3 columns for x-, y-, and z-comps of DW-gradients.
        bmatrix_file: File with gradient info in b-matrix format.
        num_iters: Number of jackknife resample iterations.
        mask_file: Mask file within which to calculate uncertainty.
        calc_thr_fa: Threshold for the minimum FA value above which to\
            calculate uncertainty.
        csf_fa: Number marking FA value of 'bad' voxels.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `V3dDwuncertOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(V_3D_DWUNCERT_METADATA)
    cargs = []
    cargs.append("3dDWUncert")
    cargs.extend([
        "-inset",
        execution.input_file(input_file)
    ])
    cargs.extend([
        "-input",
        input_prefix
    ])
    cargs.extend([
        "-prefix",
        output_prefix
    ])
    if grad_file is not None:
        cargs.extend([
            "-grads",
            execution.input_file(grad_file)
        ])
    if bmatrix_file is not None:
        cargs.extend([
            "-bmatrix_FULL",
            execution.input_file(bmatrix_file)
        ])
    if num_iters is not None:
        cargs.extend([
            "-iters",
            str(num_iters)
        ])
    if mask_file is not None:
        cargs.extend([
            "-mask",
            execution.input_file(mask_file)
        ])
    if calc_thr_fa is not None:
        cargs.extend([
            "-calc_thr_FA",
            str(calc_thr_fa)
        ])
    if csf_fa is not None:
        cargs.extend([
            "-csf_fa",
            str(csf_fa)
        ])
    ret = V3dDwuncertOutputs(
        root=execution.output_file("."),
        output_file=execution.output_file(output_prefix + "+*.HEAD/" + output_prefix + "+*.BRIK"),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "V3dDwuncertOutputs",
    "V_3D_DWUNCERT_METADATA",
    "v_3d_dwuncert",
]
