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

import typing
import pathlib
from styxdefs import *
import dataclasses

V_3DROTATE_METADATA = Metadata(
    id="dae9478b93184d9121e61e24d56f3c564e520ade.boutiques",
    name="3drotate",
    package="afni",
    container_image_tag="afni/afni_make_build:AFNI_24.2.06",
)


class V3drotateOutputs(typing.NamedTuple):
    """
    Output object returned when calling `v_3drotate(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    out_head: OutputPathType | None
    """Output dataset header file"""
    out_brick: OutputPathType | None
    """Output dataset brick file"""


def v_3drotate(
    dataset: InputPathType,
    prefix: str | None = None,
    verbose: bool = False,
    ashift: list[float] | None = None,
    bshift: list[float] | None = None,
    rotate: list[str] | None = None,
    rotparent: InputPathType | None = None,
    gridparent: InputPathType | None = None,
    matvec_dicom: InputPathType | None = None,
    matvec_order: InputPathType | None = None,
    matvec_dset: InputPathType | None = None,
    dfile: InputPathType | None = None,
    v_1_dfile: InputPathType | None = None,
    points: bool = False,
    origin: list[float] | None = None,
    fourier: bool = False,
    nn: bool = False,
    linear: bool = False,
    cubic: bool = False,
    quintic: bool = False,
    heptic: bool = False,
    fourier_nopad: bool = False,
    clipit: bool = False,
    noclip: bool = False,
    zpad: float | None = None,
    runner: Runner | None = None,
) -> V3drotateOutputs:
    """
    Rotates and/or translates all bricks from an AFNI dataset.
    
    Author: AFNI Developers
    
    URL: https://afni.nimh.nih.gov/
    
    Args:
        dataset: Input AFNI dataset, may contain a sub-brick selector list.
        prefix: Sets the output dataset prefix name.
        verbose: Prints out progress reports (to stderr).
        ashift: Shifts the dataset by specified distances (dx, dy, dz) in mm in\
            x, y, z directions respectively, AFTER rotation.
        bshift: Shifts the dataset by specified distances (dx, dy, dz) in mm in\
            x, y, z directions respectively, BEFORE rotation.
        rotate: Specifies the 3D rotation angles (th1, th2, th3) about certain\
            axes.
        rotparent: Rotation and translation should be taken from the first\
            3dvolreg transformation found in the header of dataset 'rset'.
        gridparent: Output dataset should be shifted to match the grid of\
            dataset 'gset'. Can only be used with -rotparent.
        matvec_dicom: Rotation and translation should be read from DICOM file\
            'mfile'.
        matvec_order: Rotation and translation should be read from file 'mfile'\
            with dataset coordinate order.
        matvec_dset: Rotation and translation should be read from the .HEAD\
            file of dataset 'mset' created by 3dTagalign.
        dfile: Reads movement parameters for each sub-brick from an ASCII file\
            'dname'.
        v_1_dfile: Reads movement parameters for each sub-brick from a 1D ASCII\
            file 'dname'.
        points: Specifies that (x,y,z) points are to be rotated instead of a\
            dataset.
        origin: Specifies the rotation origin point (xo, yo, zo).
        fourier: Use Fourier interpolation method during transformation.
        nn: Use nearest neighbor interpolation method during transformation.
        linear: Use linear interpolation (1st order polynomial) during\
            transformation.
        cubic: Use cubic interpolation (3rd order polynomial) during\
            transformation.
        quintic: Use quintic interpolation (5th order Lagrange polynomial)\
            during transformation.
        heptic: Use heptic interpolation (7th order Lagrange polynomial) during\
            transformation.
        fourier_nopad: Use the Fourier method WITHOUT padding.
        clipit: Clip results to input brick range [default option].
        noclip: Do not clip results to input brick range.
        zpad: Zero pad around the edges by 'n' voxels during rotations.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `V3drotateOutputs`).
    """
    if rotate is not None and (len(rotate) != 3): 
        raise ValueError(f"Length of 'rotate' must be 3 but was {len(rotate)}")
    runner = runner or get_global_runner()
    execution = runner.start_execution(V_3DROTATE_METADATA)
    cargs = []
    cargs.append("3drotate")
    cargs.append(execution.input_file(dataset))
    if prefix is not None:
        cargs.extend([
            "-prefix",
            prefix
        ])
    if verbose:
        cargs.append("-verbose")
    if ashift is not None:
        cargs.extend([
            "-ashift",
            *map(str, ashift)
        ])
    if bshift is not None:
        cargs.extend([
            "-bshift",
            *map(str, bshift)
        ])
    if rotate is not None:
        cargs.extend([
            "-rotate",
            *rotate
        ])
    if rotparent is not None:
        cargs.extend([
            "-rotparent",
            execution.input_file(rotparent)
        ])
    if gridparent is not None:
        cargs.extend([
            "-gridparent",
            execution.input_file(gridparent)
        ])
    if matvec_dicom is not None:
        cargs.extend([
            "-matvec_dicom",
            execution.input_file(matvec_dicom)
        ])
    if matvec_order is not None:
        cargs.extend([
            "-matvec_order",
            execution.input_file(matvec_order)
        ])
    if matvec_dset is not None:
        cargs.extend([
            "-matvec_dset",
            execution.input_file(matvec_dset)
        ])
    if dfile is not None:
        cargs.extend([
            "-dfile",
            execution.input_file(dfile)
        ])
    if v_1_dfile is not None:
        cargs.extend([
            "-1Dfile",
            execution.input_file(v_1_dfile)
        ])
    if points:
        cargs.append("-points")
    if origin is not None:
        cargs.extend([
            "-origin",
            *map(str, origin)
        ])
    if fourier:
        cargs.append("-Fourier")
    if nn:
        cargs.append("-NN")
    if linear:
        cargs.append("-linear")
    if cubic:
        cargs.append("-cubic")
    if quintic:
        cargs.append("-quintic")
    if heptic:
        cargs.append("-heptic")
    if fourier_nopad:
        cargs.append("-Fourier_nopad")
    if clipit:
        cargs.append("-clipit")
    if noclip:
        cargs.append("-noclip")
    if zpad is not None:
        cargs.extend([
            "-zpad",
            str(zpad)
        ])
    ret = V3drotateOutputs(
        root=execution.output_file("."),
        out_head=execution.output_file(prefix + "+orig.HEAD") if (prefix is not None) else None,
        out_brick=execution.output_file(prefix + "+orig.BRIK") if (prefix is not None) else None,
    )
    execution.run(cargs)
    return ret


__all__ = [
    "V3drotateOutputs",
    "V_3DROTATE_METADATA",
    "v_3drotate",
]
