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

import typing
import pathlib
from styxdefs import *
import dataclasses

REG_TOOLS_METADATA = Metadata(
    id="f395b2a3b7977bc04bd46c3a00a35e8d43532b2f.boutiques",
    name="reg_tools",
    package="niftyreg",
    container_image_tag="vnmd/niftyreg_1.4.0:20220819",
)


class RegToolsOutputs(typing.NamedTuple):
    """
    Output object returned when calling `reg_tools(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    output_image_file: OutputPathType | None
    """File containing the output image"""


def reg_tools(
    input_image: InputPathType,
    output_image: str | None = None,
    add_value_or_image: str | None = None,
    sub_value_or_image: str | None = None,
    mul_value_or_image: str | None = None,
    div_value_or_image: str | None = None,
    smooth_value: float | None = None,
    smooth_gaussian: list[float] | None = None,
    rms_image: InputPathType | None = None,
    binarize: bool = False,
    threshold_value: float | None = None,
    nan_mask_image: InputPathType | None = None,
    runner: Runner | None = None,
) -> RegToolsOutputs:
    """
    A versatile tool for manipulating and processing medical images.
    
    Author: NiftyReg Developers
    
    URL: http://cmictig.cs.ucl.ac.uk/wiki/index.php/NiftyReg
    
    Args:
        input_image: Filename of the input image.
        output_image: Filename of the output image.
        add_value_or_image: This image (or value) is added to the input.
        sub_value_or_image: This image (or value) is subtracted from the input.
        mul_value_or_image: This image (or value) is multiplied with the input.
        div_value_or_image: This image (or value) is divided by the input.
        smooth_value: The input image is smoothed using a B-spline curve.
        smooth_gaussian: The input image is smoothed using a Gaussian kernel.
        rms_image: Compute the mean RMS between the input image and this image.
        binarize: Binarize the input image (val!=0?val=1:val=0).
        threshold_value: Threshold the input image (val<thr?val=0:val=1).
        nan_mask_image: This image is used to mask the input image. Voxels\
            outside of the mask are set to NaN.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `RegToolsOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(REG_TOOLS_METADATA)
    cargs = []
    cargs.append("reg_tools")
    cargs.extend([
        "-in",
        execution.input_file(input_image)
    ])
    if output_image is not None:
        cargs.extend([
            "-out",
            output_image
        ])
    if add_value_or_image is not None:
        cargs.extend([
            "-add",
            add_value_or_image
        ])
    if sub_value_or_image is not None:
        cargs.extend([
            "-sub",
            sub_value_or_image
        ])
    if mul_value_or_image is not None:
        cargs.extend([
            "-mul",
            mul_value_or_image
        ])
    if div_value_or_image is not None:
        cargs.extend([
            "-div",
            div_value_or_image
        ])
    if smooth_value is not None:
        cargs.extend([
            "-smo",
            str(smooth_value)
        ])
    if smooth_gaussian is not None:
        cargs.extend([
            "-smoG",
            *map(str, smooth_gaussian)
        ])
    if rms_image is not None:
        cargs.extend([
            "-rms",
            execution.input_file(rms_image)
        ])
    if binarize:
        cargs.append("-bin")
    if threshold_value is not None:
        cargs.extend([
            "-thr",
            str(threshold_value)
        ])
    if nan_mask_image is not None:
        cargs.extend([
            "-nan",
            execution.input_file(nan_mask_image)
        ])
    ret = RegToolsOutputs(
        root=execution.output_file("."),
        output_image_file=execution.output_file(output_image) if (output_image is not None) else None,
    )
    execution.run(cargs)
    return ret


__all__ = [
    "REG_TOOLS_METADATA",
    "RegToolsOutputs",
    "reg_tools",
]
