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

import typing
import pathlib
from styxdefs import *
import dataclasses

NON_LOCAL_SUPER_RESOLUTION_METADATA = Metadata(
    id="6ff1af6734242879ff8b30bf0db9b599017faa19.boutiques",
    name="NonLocalSuperResolution",
    package="ants",
    container_image_tag="antsx/ants:v2.5.3",
)


class NonLocalSuperResolutionOutputs(typing.NamedTuple):
    """
    Output object returned when calling `non_local_super_resolution(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    superresoluted_output: OutputPathType
    """The superresoluted output image."""


def non_local_super_resolution(
    input_image: InputPathType,
    output: InputPathType,
    image_dimensionality: typing.Literal[2, 3, 4] | None = None,
    interpolated_image: InputPathType | None = None,
    reference_image: InputPathType | None = None,
    patch_radius: typing.Literal["1", "1x1x1"] | None = None,
    search_radius: typing.Literal["3", "3x3x3"] | None = None,
    intensity_difference_sigma: float | None = 1.0,
    patch_similarity_sigma: float | None = 1.0,
    scale_levels: str | None = "32x16x8x2x1",
    interpolation: typing.Literal["Linear", "NearestNeighbor", "Gaussian", "BSpline", "CosineWindowedSinc", "WelchWindowedSinc", "HammingWindowedSinc", "LanczosWindowedSinc"] | None = None,
    verbose: typing.Literal[0, 1] | None = None,
    runner: Runner | None = None,
) -> NonLocalSuperResolutionOutputs:
    """
    Non-local super resolution described in the papers by JV Manjon et al., focusing
    on MRI superresolution using self-similarity and image priors.
    
    Author: ANTs Developers
    
    URL: https://github.com/ANTsX/ANTs
    
    Args:
        input_image: A low-resolution input image to be superresoluted.
        output: The output consists of the noise corrected version of the input\
            image. Optionally, one can also output the estimated noise image.
        image_dimensionality: This option forces the image to be treated as a\
            specified-dimensional image. If not specified, the program tries to\
            infer the dimensionality from the input image.
        interpolated_image: An interpolated version of the low-resolution image\
            (such as B-spline). Specify either this option or a high-resolution\
            multi-modal counterpart (cf the -k option).
        reference_image: A high-resolution reference multi-modal image. Assumed\
            to be in the same space as the low-resolution input image. Specify\
            either this option or an interpolated version (cf the -j option).
        patch_radius: Patch radius. Default = 1x1x1.
        search_radius: Search radius. Default = 3x3x3.
        intensity_difference_sigma: Intensity difference sigma. Default = 1.0.
        patch_similarity_sigma: Patch similarity sigma. Default = 1.0.
        scale_levels: Scale levels. Default = 32x16x8x2x1.
        interpolation: Several interpolation options are available in ITK.
        verbose: Verbose output.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `NonLocalSuperResolutionOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(NON_LOCAL_SUPER_RESOLUTION_METADATA)
    cargs = []
    cargs.append("NonLocalSuperResolution")
    if image_dimensionality is not None:
        cargs.extend([
            "-d",
            str(image_dimensionality)
        ])
    cargs.extend([
        "-i",
        execution.input_file(input_image)
    ])
    if interpolated_image is not None:
        cargs.extend([
            "-j",
            execution.input_file(interpolated_image)
        ])
    if reference_image is not None:
        cargs.extend([
            "-k",
            execution.input_file(reference_image)
        ])
    if patch_radius is not None:
        cargs.extend([
            "-p",
            patch_radius
        ])
    if search_radius is not None:
        cargs.extend([
            "-r",
            search_radius
        ])
    if intensity_difference_sigma is not None:
        cargs.extend([
            "-g",
            str(intensity_difference_sigma)
        ])
    if patch_similarity_sigma is not None:
        cargs.extend([
            "-t",
            str(patch_similarity_sigma)
        ])
    if scale_levels is not None:
        cargs.extend([
            "-s",
            scale_levels
        ])
    if interpolation is not None:
        cargs.extend([
            "-n",
            interpolation
        ])
    cargs.extend([
        "-o",
        execution.input_file(output)
    ])
    if verbose is not None:
        cargs.extend([
            "-v",
            str(verbose)
        ])
    ret = NonLocalSuperResolutionOutputs(
        root=execution.output_file("."),
        superresoluted_output=execution.output_file(pathlib.Path(output).name),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "NON_LOCAL_SUPER_RESOLUTION_METADATA",
    "NonLocalSuperResolutionOutputs",
    "non_local_super_resolution",
]
