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

import typing
import pathlib
from styxdefs import *
import dataclasses

V_3D_PAR2_AFNI_METADATA = Metadata(
    id="955afce507c339e4fbf43caaf056ad39a659f439.boutiques",
    name="3dPAR2AFNI",
    package="afni",
    container_image_tag="afni/afni_make_build:AFNI_24.2.06",
)


class V3dPar2AfniOutputs(typing.NamedTuple):
    """
    Output object returned when calling `v_3d_par2_afni(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    output_files: OutputPathType
    """Converted output files"""


def v_3d_par2_afni(
    input_file: InputPathType,
    skip_outliers_test: bool = False,
    output_analyze: bool = False,
    output_dir: str | None = None,
    verbose_flag: bool = False,
    gzip_files: bool = False,
    byte_swap_4: bool = False,
    runner: Runner | None = None,
) -> V3dPar2AfniOutputs:
    """
    Convert Philips PAR/REC files to AFNI's BRIK/HEAD, NIfTI, or ANALYZE format.
    
    Author: AFNI Developers
    
    URL: https://afni.nimh.nih.gov/
    
    Args:
        input_file: Input PAR file (e.g., subject1.PAR).
        skip_outliers_test: Skip the outliers test when converting 4D files.\
            The default is to perform the outliers test.
        output_analyze: Output ANALYZE files instead of HEAD/BRIK.
        output_dir: The name of the directory where the created files should be\
            placed. If this directory does not exist, the program exits without\
            performing any conversion.
        verbose_flag: Be verbose in operation.
        gzip_files: Gzip the files created. The default is not to gzip the\
            files.
        byte_swap_4: 4-Byte-swap the files created. The default is not to 4\
            byte-swap.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `V3dPar2AfniOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(V_3D_PAR2_AFNI_METADATA)
    cargs = []
    cargs.append("3dPAR2AFNI.pl")
    cargs.append(execution.input_file(input_file))
    if skip_outliers_test:
        cargs.append("-s")
    if output_analyze:
        cargs.append("-a")
    if output_dir is not None:
        cargs.extend([
            "-o",
            output_dir
        ])
    if verbose_flag:
        cargs.append("-v")
    if gzip_files:
        cargs.append("-g")
    if byte_swap_4:
        cargs.append("-4")
    ret = V3dPar2AfniOutputs(
        root=execution.output_file("."),
        output_files=execution.output_file(pathlib.Path(input_file).name + "_converted"),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "V3dPar2AfniOutputs",
    "V_3D_PAR2_AFNI_METADATA",
    "v_3d_par2_afni",
]
