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

import typing
import pathlib
from styxdefs import *
import dataclasses

IMUPSAM_METADATA = Metadata(
    id="156965091ca5242419f26a19463380332f6a9731.boutiques",
    name="imupsam",
    package="afni",
    container_image_tag="afni/afni_make_build:AFNI_24.2.06",
)


class ImupsamOutputs(typing.NamedTuple):
    """
    Output object returned when calling `imupsam(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    output_image_file: OutputPathType
    """Upsampled image output file"""


def imupsam(
    factor: int,
    input_image: InputPathType,
    output_image: str,
    ascii_flag: bool = False,
    runner: Runner | None = None,
) -> ImupsamOutputs:
    """
    Upsamples a 2D image by a specified factor.
    
    Author: AFNI Developers
    
    URL: https://afni.nimh.nih.gov/
    
    Args:
        factor: Upsampling factor; must be an integer in the range 2 to 30.
        input_image: Path of the input 2D image file.
        output_image: Path of the output upsampled image file. Use '-' to write\
            to stdout.
        ascii_flag: Write the result in ASCII format: all numbers for the file\
            are output, with no header info.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `ImupsamOutputs`).
    """
    if not (2 <= factor <= 30): 
        raise ValueError(f"'factor' must be between 2 <= x <= 30 but was {factor}")
    runner = runner or get_global_runner()
    execution = runner.start_execution(IMUPSAM_METADATA)
    cargs = []
    cargs.append("imupsam")
    if ascii_flag:
        cargs.append("-A")
    cargs.append(str(factor))
    cargs.append(execution.input_file(input_image))
    cargs.append(output_image)
    ret = ImupsamOutputs(
        root=execution.output_file("."),
        output_image_file=execution.output_file(output_image),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "IMUPSAM_METADATA",
    "ImupsamOutputs",
    "imupsam",
]
