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

import typing
import pathlib
from styxdefs import *
import dataclasses

RESAMPLE_IMAGE_METADATA = Metadata(
    id="09cbfa81905a40fb69e7164887ae36302a83bb75.boutiques",
    name="ResampleImage",
    package="ants",
    container_image_tag="antsx/ants:v2.5.3",
)


class ResampleImageOutputs(typing.NamedTuple):
    """
    Output object returned when calling `resample_image(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    resampled_output_image: OutputPathType
    """The resultant image after resampling."""


def resample_image(
    image_dimension: int,
    input_image: InputPathType,
    output_image: InputPathType,
    size_spacing: str,
    interpolate_type: typing.Literal["0", "1", "2", "3", "4"] | None = None,
    pixeltype: typing.Literal["0", "1", "2", "3", "4", "5", "6", "7"] | None = None,
    runner: Runner | None = None,
) -> ResampleImageOutputs:
    """
    ResampleImage is a tool used to resample images to specified sizes and spacings,
    using various interpolation methods and pixel types.
    
    Author: ANTs Developers
    
    URL: https://github.com/ANTsX/ANTs
    
    Args:
        image_dimension: Dimension of the image to be resampled.
        input_image: The image file to be resampled.
        output_image: The output image file after resampling.
        size_spacing: Resampling size and spacing specification, e.g., 'MxNxO'.
        interpolate_type: Specifies the interpolation type. 0: linear\
            (default), 1: nearest-neighbor, 2: gaussian, 3: windowedSinc, 4:\
            B-Spline.
        pixeltype: Specifies the pixel type of the output image. 0: char, 1:\
            unsigned char, 2: short, 3: unsigned short, 4: int, 5: unsigned int, 6:\
            float (default), 7: double.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `ResampleImageOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(RESAMPLE_IMAGE_METADATA)
    cargs = []
    cargs.append("ResampleImage")
    cargs.append(str(image_dimension))
    cargs.append(execution.input_file(input_image))
    cargs.append(execution.input_file(output_image))
    cargs.append(size_spacing)
    if interpolate_type is not None:
        cargs.append(interpolate_type)
    if pixeltype is not None:
        cargs.append(pixeltype)
    ret = ResampleImageOutputs(
        root=execution.output_file("."),
        resampled_output_image=execution.output_file(pathlib.Path(output_image).name),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "RESAMPLE_IMAGE_METADATA",
    "ResampleImageOutputs",
    "resample_image",
]
