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

import typing
import pathlib
from styxdefs import *
import dataclasses

V_3D_AFNITO_ANALYZE_METADATA = Metadata(
    id="8e009ca0525a816d98d8d648c7fbae2324df58e2.boutiques",
    name="3dAFNItoANALYZE",
    package="afni",
    container_image_tag="afni/afni_make_build:AFNI_24.2.06",
)


class V3dAfnitoAnalyzeOutputs(typing.NamedTuple):
    """
    Output object returned when calling `v_3d_afnito_analyze(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    output_hdr_file: OutputPathType
    """ANALYZE header file for each sub-brick"""
    output_img_file: OutputPathType
    """ANALYZE image file for each sub-brick"""
    output_4d_hdr_file: OutputPathType
    """Single ANALYZE header file if using -4D option"""
    output_4d_img_file: OutputPathType
    """Single ANALYZE image file if using -4D option"""


def v_3d_afnito_analyze(
    output_name: str,
    afni_dataset: InputPathType,
    v_4d_option: bool = False,
    orient_option: str | None = None,
    runner: Runner | None = None,
) -> V3dAfnitoAnalyzeOutputs:
    """
    Writes AFNI dataset to ANALYZE 7.5 format .hdr/.img file pairs.
    
    Author: AFNI Developers
    
    URL: https://afni.nimh.nih.gov/
    
    Args:
        output_name: Output ANALYZE file base name (e.g., aname).
        afni_dataset: Input AFNI dataset.
        v_4d_option: Write all data to one big ANALYZE file pair named\
            aname.hdr/aname.img.
        orient_option: Flip the dataset to a different orientation when writing\
            to ANALYZE files (e.g., LPI).
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `V3dAfnitoAnalyzeOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(V_3D_AFNITO_ANALYZE_METADATA)
    cargs = []
    cargs.append("3dAFNItoANALYZE")
    if v_4d_option:
        cargs.append("-4D")
    if orient_option is not None:
        cargs.extend([
            "-orient",
            orient_option
        ])
    cargs.append(output_name)
    cargs.append(execution.input_file(afni_dataset))
    ret = V3dAfnitoAnalyzeOutputs(
        root=execution.output_file("."),
        output_hdr_file=execution.output_file(output_name + "_[INDEX].hdr"),
        output_img_file=execution.output_file(output_name + "_[INDEX].img"),
        output_4d_hdr_file=execution.output_file(output_name + ".hdr"),
        output_4d_img_file=execution.output_file(output_name + ".img"),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "V3dAfnitoAnalyzeOutputs",
    "V_3D_AFNITO_ANALYZE_METADATA",
    "v_3d_afnito_analyze",
]
