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

import typing
import pathlib
from styxdefs import *
import dataclasses

FROM3D_METADATA = Metadata(
    id="864634840f0f6786ab607ffcdd49ef22b22f25d8.boutiques",
    name="from3d",
    package="afni",
    container_image_tag="afni/afni_make_build:AFNI_24.2.06",
)


class From3dOutputs(typing.NamedTuple):
    """
    Output object returned when calling `from3d(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    extracted_images: OutputPathType
    """Extracted 2D images from the 3D dataset"""


def from3d(
    input_: InputPathType,
    prefix: str,
    verbose: bool = False,
    nsize_: bool = False,
    raw: bool = False,
    float_: bool = False,
    zfirst: float | None = None,
    zlast: float | None = None,
    tfirst: float | None = None,
    tlast: float | None = None,
    runner: Runner | None = None,
) -> From3dOutputs:
    """
    Extract 2D image files from a 3D AFNI dataset.
    
    Author: AFNI Team
    
    URL: https://afni.nimh.nih.gov/pub/dist/doc/program_help/from3d.html
    
    Args:
        input_: Read 3D dataset from file 'fname'.
        prefix: Write 2D images using prefix 'rname'.
        verbose: Print out verbose information during the run.
        nsize_: Adjust size of 2D data file to be NxN, by padding with zeros,\
            where N is a power of 2.
        raw: Write images in 'raw' format (just the data bytes). There will be\
            no header information saying what the image dimensions are.
        float_: Write images as floats, no matter what they are in the dataset\
            itself.
        zfirst: Set 'num' = number of first z slice to be extracted (default =\
            1).
        zlast: Set 'num' = number of last z slice to be extracted (default =\
            largest).
        tfirst: Set 'num' = number of first time slice to be extracted (default\
            = 1).
        tlast: Set 'num' = number of last time slice to be extracted (default =\
            largest).
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `From3dOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(FROM3D_METADATA)
    cargs = []
    cargs.append("from3d")
    if verbose:
        cargs.append("-v")
    if nsize_:
        cargs.append("-nsize")
    if raw:
        cargs.append("-raw")
    if float_:
        cargs.append("-float")
    if zfirst is not None:
        cargs.extend([
            "-zfirst",
            str(zfirst)
        ])
    if zlast is not None:
        cargs.extend([
            "-zlast",
            str(zlast)
        ])
    if tfirst is not None:
        cargs.extend([
            "-tfirst",
            str(tfirst)
        ])
    if tlast is not None:
        cargs.extend([
            "-tlast",
            str(tlast)
        ])
    cargs.append("-input")
    cargs.extend([
        "-input",
        execution.input_file(input_)
    ])
    cargs.append("-prefix")
    cargs.extend([
        "-prefix",
        prefix
    ])
    ret = From3dOutputs(
        root=execution.output_file("."),
        extracted_images=execution.output_file(prefix + "*.img"),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "FROM3D_METADATA",
    "From3dOutputs",
    "from3d",
]
