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

import typing
import pathlib
from styxdefs import *
import dataclasses

V_3D_NWARP_APPLY_METADATA = Metadata(
    id="0a5385bf1fc9acdee0016adc133f63a8ec8a4e36.boutiques",
    name="3dNwarpApply",
    package="afni",
    container_image_tag="afni/afni_make_build:AFNI_24.2.06",
)


class V3dNwarpApplyOutputs(typing.NamedTuple):
    """
    Output object returned when calling `v_3d_nwarp_apply(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    warped_output: OutputPathType | None
    """Warped output dataset"""
    generated_warp: OutputPathType | None
    """Warp dataset generated during application"""


def v_3d_nwarp_apply(
    nwarp: str,
    source: str,
    iwarp: bool = False,
    master: str | None = None,
    newgrid: str | None = None,
    dxyz: str | None = None,
    interp: str | None = None,
    ainterp: str | None = None,
    prefix: str | None = None,
    suffix: str | None = None,
    short: bool = False,
    wprefix: str | None = None,
    quiet: bool = False,
    verb: bool = False,
    runner: Runner | None = None,
) -> V3dNwarpApplyOutputs:
    """
    Program to apply a nonlinear 3D warp saved from 3dQwarp (or 3dNwarpCat, etc.) to
    a 3D dataset, to produce a warped version of the source dataset.
    
    Author: AFNI Developers
    
    URL: https://afni.nimh.nih.gov/
    
    Args:
        nwarp: The name of the 3D warp dataset. Multiple warps can be\
            catenated.
        source: The name of the source dataset to be warped. Multiple datasets\
            can be supplied.
        iwarp: Invert the warp specified in '-nwarp'.
        master: The name of the master dataset which defines the output grid.
        newgrid: The new grid spacing (cubical voxels, in mm).
        dxyz: Specify a different grid spacing (cubical voxels, in mm).
        interp: The interpolation mode ('NN', 'linear', 'cubic', 'quintic',\
            'wsinc5').
        ainterp: Specify a different interpolation mode for the data than the\
            warp.
        prefix: The name of the new output dataset. Multiple names can be\
            supplied if more than one source dataset is input.
        suffix: Change the default suffix '_Nwarp' to a user-defined suffix.
        short: Write output dataset using 16-bit short integers rather than the\
            usual 32-bit floats.
        wprefix: Save every warp generated in the process to a separate\
            dataset.
        quiet: Don't be verbose.
        verb: Be extra verbose.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `V3dNwarpApplyOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(V_3D_NWARP_APPLY_METADATA)
    cargs = []
    cargs.append("3dNwarpApply")
    cargs.extend([
        "-nwarp",
        nwarp
    ])
    if iwarp:
        cargs.append("-iwarp")
    cargs.extend([
        "-source",
        source
    ])
    if master is not None:
        cargs.extend([
            "-master",
            master
        ])
    if newgrid is not None:
        cargs.extend([
            "-newgrid",
            newgrid
        ])
    if dxyz is not None:
        cargs.extend([
            "-dxyz",
            dxyz
        ])
    if interp is not None:
        cargs.extend([
            "-interp",
            interp
        ])
    if ainterp is not None:
        cargs.extend([
            "-ainterp",
            ainterp
        ])
    if prefix is not None:
        cargs.extend([
            "-prefix",
            prefix
        ])
    if suffix is not None:
        cargs.extend([
            "-suffix",
            suffix
        ])
    if short:
        cargs.append("-short")
    if wprefix is not None:
        cargs.extend([
            "-wprefix",
            wprefix
        ])
    if quiet:
        cargs.append("-quiet")
    if verb:
        cargs.append("-verb")
    ret = V3dNwarpApplyOutputs(
        root=execution.output_file("."),
        warped_output=execution.output_file(prefix + "_" + source + "_warped.nii.gz") if (prefix is not None) else None,
        generated_warp=execution.output_file(wprefix + "_warp_????.nii.gz") if (wprefix is not None) else None,
    )
    execution.run(cargs)
    return ret


__all__ = [
    "V3dNwarpApplyOutputs",
    "V_3D_NWARP_APPLY_METADATA",
    "v_3d_nwarp_apply",
]
