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

import typing
import pathlib
from styxdefs import *
import dataclasses

PASTE_IMAGE_INTO_IMAGE_METADATA = Metadata(
    id="473380596b87ce0da9928dabd1961225e23dd0a4.boutiques",
    name="PasteImageIntoImage",
    package="ants",
    container_image_tag="antsx/ants:v2.5.3",
)


class PasteImageIntoImageOutputs(typing.NamedTuple):
    """
    Output object returned when calling `paste_image_into_image(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    output_image_file: OutputPathType
    """The final output image with the input image pasted onto the canvas."""


def paste_image_into_image(
    image_dimension: int,
    input_canvas_image: InputPathType,
    input_image: InputPathType,
    output_image: InputPathType,
    start_index: str,
    background_label: int | None = 0,
    paint_over_non_background_voxels: typing.Literal[0, 1, 2] | None = 0,
    conflict_label: int | None = -1,
    runner: Runner | None = None,
) -> PasteImageIntoImageOutputs:
    """
    Paste the input image into the input canvas image. Depending on parameters, it
    can replace or merge existing voxel values.
    
    Author: ANTs Developers
    
    URL: https://github.com/ANTsX/ANTs
    
    Args:
        image_dimension: Specify the dimension of the images.
        input_canvas_image: The canvas image on which the input image will be\
            pasted.
        input_image: The image to be pasted onto the canvas.
        output_image: The resulting image after pasting.
        start_index: The starting index where the input image will be pasted on\
            the canvas.
        background_label: The label value considered as background.
        paint_over_non_background_voxels: Defines behavior when the input image\
            voxel is non-background and the corresponding canvas voxel is\
            background: 0 - leave as is, 1 - replace with input voxel value, 2 -\
            replace with conflict label.
        conflict_label: The label value used for conflicting non-background\
            voxels if 'paintOverNonBackgroundVoxels' is set to 2.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `PasteImageIntoImageOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(PASTE_IMAGE_INTO_IMAGE_METADATA)
    cargs = []
    cargs.append("PasteImageIntoImage")
    cargs.append(str(image_dimension))
    cargs.append(execution.input_file(input_canvas_image))
    cargs.append(execution.input_file(input_image))
    cargs.append(execution.input_file(output_image))
    cargs.append(start_index)
    if background_label is not None:
        cargs.append(str(background_label))
    if paint_over_non_background_voxels is not None:
        cargs.append(str(paint_over_non_background_voxels))
    if conflict_label is not None:
        cargs.append(str(conflict_label))
    ret = PasteImageIntoImageOutputs(
        root=execution.output_file("."),
        output_image_file=execution.output_file(pathlib.Path(output_image).name),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "PASTE_IMAGE_INTO_IMAGE_METADATA",
    "PasteImageIntoImageOutputs",
    "paste_image_into_image",
]
