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

import typing
import pathlib
from styxdefs import *

VOLUME_CAPTURE_PLANE_METADATA = Metadata(
    id="fcda0671173456c7a0dc9ad4eeb91facd1507c4f.workbench",
    name="volume-capture-plane",
    package="workbench",
    container_image_tag="nx10x/workbench:2.1.0",
)


_VolumeCapturePlaneParamsDictNoTag = typing.TypedDict('_VolumeCapturePlaneParamsDictNoTag', {
    "volume": InputPathType,
    "subvolume": str,
    "interp": str,
    "h-dim": int,
    "v-dim": int,
    "scale-min": float,
    "scale-max": float,
    "bottom-left-x": float,
    "bottom-left-y": float,
    "bottom-left-z": float,
    "bottom-right-x": float,
    "bottom-right-y": float,
    "bottom-right-z": float,
    "top-left-x": float,
    "top-left-y": float,
    "top-left-z": float,
    "image": str,
})
VolumeCapturePlaneParamsDictTagged = typing.TypedDict('VolumeCapturePlaneParamsDictTagged', {
    "@type": typing.Literal["workbench/volume-capture-plane"],
    "volume": InputPathType,
    "subvolume": str,
    "interp": str,
    "h-dim": int,
    "v-dim": int,
    "scale-min": float,
    "scale-max": float,
    "bottom-left-x": float,
    "bottom-left-y": float,
    "bottom-left-z": float,
    "bottom-right-x": float,
    "bottom-right-y": float,
    "bottom-right-z": float,
    "top-left-x": float,
    "top-left-y": float,
    "top-left-z": float,
    "image": str,
})
VolumeCapturePlaneParamsDict = _VolumeCapturePlaneParamsDictNoTag | VolumeCapturePlaneParamsDictTagged


class VolumeCapturePlaneOutputs(typing.NamedTuple):
    """
    Output object returned when calling `VolumeCapturePlaneParamsDict(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""


def volume_capture_plane_params(
    volume: InputPathType,
    subvolume: str,
    interp: str,
    h_dim: int,
    v_dim: int,
    scale_min: float,
    scale_max: float,
    bottom_left_x: float,
    bottom_left_y: float,
    bottom_left_z: float,
    bottom_right_x: float,
    bottom_right_y: float,
    bottom_right_z: float,
    top_left_x: float,
    top_left_y: float,
    top_left_z: float,
    image: str,
) -> VolumeCapturePlaneParamsDictTagged:
    """
    Build parameters.
    
    Args:
        volume: the volume file to interpolate from.
        subvolume: the name or number of the subvolume to use.
        interp: interpolation type.
        h_dim: width of output image, in pixels.
        v_dim: height of output image, in pixels.
        scale_min: value to render as black.
        scale_max: value to render as white.
        bottom_left_x: x-coordinate of the bottom left of the output image.
        bottom_left_y: y-coordinate of the bottom left of the output image.
        bottom_left_z: z-coordinate of the bottom left of the output image.
        bottom_right_x: x-coordinate of the bottom right of the output image.
        bottom_right_y: y-coordinate of the bottom right of the output image.
        bottom_right_z: z-coordinate of the bottom right of the output image.
        top_left_x: x-coordinate of the top left of the output image.
        top_left_y: y-coordinate of the top left of the output image.
        top_left_z: z-coordinate of the top left of the output image.
        image: output - the output image.
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "workbench/volume-capture-plane",
        "volume": volume,
        "subvolume": subvolume,
        "interp": interp,
        "h-dim": h_dim,
        "v-dim": v_dim,
        "scale-min": scale_min,
        "scale-max": scale_max,
        "bottom-left-x": bottom_left_x,
        "bottom-left-y": bottom_left_y,
        "bottom-left-z": bottom_left_z,
        "bottom-right-x": bottom_right_x,
        "bottom-right-y": bottom_right_y,
        "bottom-right-z": bottom_right_z,
        "top-left-x": top_left_x,
        "top-left-y": top_left_y,
        "top-left-z": top_left_z,
        "image": image,
    }
    return params


def volume_capture_plane_validate(
    params: typing.Any,
) -> None:
    """
    Validate parameters. Throws an error if `params` is not a valid
    `VolumeCapturePlaneParamsDict` object.
    
    Args:
        params: The parameters object to validate.
    """
    if params is None or not isinstance(params, dict):
        raise StyxValidationError(f'Params object has the wrong type \'{type(params)}\'')
    if params.get("volume", None) is None:
        raise StyxValidationError("`volume` must not be None")
    if not isinstance(params["volume"], (pathlib.Path, str)):
        raise StyxValidationError(f'`volume` has the wrong type: Received `{type(params.get("volume", None))}` expected `InputPathType`')
    if params.get("subvolume", None) is None:
        raise StyxValidationError("`subvolume` must not be None")
    if not isinstance(params["subvolume"], str):
        raise StyxValidationError(f'`subvolume` has the wrong type: Received `{type(params.get("subvolume", None))}` expected `str`')
    if params.get("interp", None) is None:
        raise StyxValidationError("`interp` must not be None")
    if not isinstance(params["interp"], str):
        raise StyxValidationError(f'`interp` has the wrong type: Received `{type(params.get("interp", None))}` expected `str`')
    if params.get("h-dim", None) is None:
        raise StyxValidationError("`h-dim` must not be None")
    if not isinstance(params["h-dim"], int):
        raise StyxValidationError(f'`h-dim` has the wrong type: Received `{type(params.get("h-dim", None))}` expected `int`')
    if params.get("v-dim", None) is None:
        raise StyxValidationError("`v-dim` must not be None")
    if not isinstance(params["v-dim"], int):
        raise StyxValidationError(f'`v-dim` has the wrong type: Received `{type(params.get("v-dim", None))}` expected `int`')
    if params.get("scale-min", None) is None:
        raise StyxValidationError("`scale-min` must not be None")
    if not isinstance(params["scale-min"], (float, int)):
        raise StyxValidationError(f'`scale-min` has the wrong type: Received `{type(params.get("scale-min", None))}` expected `float`')
    if params.get("scale-max", None) is None:
        raise StyxValidationError("`scale-max` must not be None")
    if not isinstance(params["scale-max"], (float, int)):
        raise StyxValidationError(f'`scale-max` has the wrong type: Received `{type(params.get("scale-max", None))}` expected `float`')
    if params.get("bottom-left-x", None) is None:
        raise StyxValidationError("`bottom-left-x` must not be None")
    if not isinstance(params["bottom-left-x"], (float, int)):
        raise StyxValidationError(f'`bottom-left-x` has the wrong type: Received `{type(params.get("bottom-left-x", None))}` expected `float`')
    if params.get("bottom-left-y", None) is None:
        raise StyxValidationError("`bottom-left-y` must not be None")
    if not isinstance(params["bottom-left-y"], (float, int)):
        raise StyxValidationError(f'`bottom-left-y` has the wrong type: Received `{type(params.get("bottom-left-y", None))}` expected `float`')
    if params.get("bottom-left-z", None) is None:
        raise StyxValidationError("`bottom-left-z` must not be None")
    if not isinstance(params["bottom-left-z"], (float, int)):
        raise StyxValidationError(f'`bottom-left-z` has the wrong type: Received `{type(params.get("bottom-left-z", None))}` expected `float`')
    if params.get("bottom-right-x", None) is None:
        raise StyxValidationError("`bottom-right-x` must not be None")
    if not isinstance(params["bottom-right-x"], (float, int)):
        raise StyxValidationError(f'`bottom-right-x` has the wrong type: Received `{type(params.get("bottom-right-x", None))}` expected `float`')
    if params.get("bottom-right-y", None) is None:
        raise StyxValidationError("`bottom-right-y` must not be None")
    if not isinstance(params["bottom-right-y"], (float, int)):
        raise StyxValidationError(f'`bottom-right-y` has the wrong type: Received `{type(params.get("bottom-right-y", None))}` expected `float`')
    if params.get("bottom-right-z", None) is None:
        raise StyxValidationError("`bottom-right-z` must not be None")
    if not isinstance(params["bottom-right-z"], (float, int)):
        raise StyxValidationError(f'`bottom-right-z` has the wrong type: Received `{type(params.get("bottom-right-z", None))}` expected `float`')
    if params.get("top-left-x", None) is None:
        raise StyxValidationError("`top-left-x` must not be None")
    if not isinstance(params["top-left-x"], (float, int)):
        raise StyxValidationError(f'`top-left-x` has the wrong type: Received `{type(params.get("top-left-x", None))}` expected `float`')
    if params.get("top-left-y", None) is None:
        raise StyxValidationError("`top-left-y` must not be None")
    if not isinstance(params["top-left-y"], (float, int)):
        raise StyxValidationError(f'`top-left-y` has the wrong type: Received `{type(params.get("top-left-y", None))}` expected `float`')
    if params.get("top-left-z", None) is None:
        raise StyxValidationError("`top-left-z` must not be None")
    if not isinstance(params["top-left-z"], (float, int)):
        raise StyxValidationError(f'`top-left-z` has the wrong type: Received `{type(params.get("top-left-z", None))}` expected `float`')
    if params.get("image", None) is None:
        raise StyxValidationError("`image` must not be None")
    if not isinstance(params["image"], str):
        raise StyxValidationError(f'`image` has the wrong type: Received `{type(params.get("image", None))}` expected `str`')


def volume_capture_plane_cargs(
    params: VolumeCapturePlaneParamsDict,
    execution: Execution,
) -> list[str]:
    """
    Build command-line arguments from parameters.
    
    Args:
        params: The parameters.
        execution: The execution object for resolving input paths.
    Returns:
        Command-line arguments.
    """
    cargs = []
    cargs.extend([
        "wb_command",
        "-volume-capture-plane"
    ])
    cargs.append(execution.input_file(params.get("volume", None)))
    cargs.append(params.get("subvolume", None))
    cargs.append(params.get("interp", None))
    cargs.append(str(params.get("h-dim", None)))
    cargs.append(str(params.get("v-dim", None)))
    cargs.append(str(params.get("scale-min", None)))
    cargs.append(str(params.get("scale-max", None)))
    cargs.append(str(params.get("bottom-left-x", None)))
    cargs.append(str(params.get("bottom-left-y", None)))
    cargs.append(str(params.get("bottom-left-z", None)))
    cargs.append(str(params.get("bottom-right-x", None)))
    cargs.append(str(params.get("bottom-right-y", None)))
    cargs.append(str(params.get("bottom-right-z", None)))
    cargs.append(str(params.get("top-left-x", None)))
    cargs.append(str(params.get("top-left-y", None)))
    cargs.append(str(params.get("top-left-z", None)))
    cargs.append(params.get("image", None))
    return cargs


def volume_capture_plane_outputs(
    params: VolumeCapturePlaneParamsDict,
    execution: Execution,
) -> VolumeCapturePlaneOutputs:
    """
    Build outputs object containing output file paths and possibly stdout/stderr.
    
    Args:
        params: The parameters.
        execution: The execution object for resolving input paths.
    Returns:
        Outputs object.
    """
    ret = VolumeCapturePlaneOutputs(
        root=execution.output_file("."),
    )
    return ret


def volume_capture_plane_execute(
    params: VolumeCapturePlaneParamsDict,
    runner: Runner | None = None,
) -> VolumeCapturePlaneOutputs:
    """
    INTERPOLATE IMAGE FROM PLANE THROUGH VOLUME.
    
    NOTE: If you want to generate an image with all of the capabilities of the
    GUI rendering, see -show-scene.
    
    Renders an image of an arbitrary plane through the volume file, with a
    simple linear grayscale palette. The parameter <interp> must be one of:
    
    CUBIC
    ENCLOSING_VOXEL
    TRILINEAR.
    
    Args:
        params: The parameters.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `VolumeCapturePlaneOutputs`).
    """
    volume_capture_plane_validate(params)
    runner = runner or get_global_runner()
    execution = runner.start_execution(VOLUME_CAPTURE_PLANE_METADATA)
    params = execution.params(params)
    cargs = volume_capture_plane_cargs(params, execution)
    ret = volume_capture_plane_outputs(params, execution)
    execution.run(cargs)
    return ret


def volume_capture_plane(
    volume: InputPathType,
    subvolume: str,
    interp: str,
    h_dim: int,
    v_dim: int,
    scale_min: float,
    scale_max: float,
    bottom_left_x: float,
    bottom_left_y: float,
    bottom_left_z: float,
    bottom_right_x: float,
    bottom_right_y: float,
    bottom_right_z: float,
    top_left_x: float,
    top_left_y: float,
    top_left_z: float,
    image: str,
    runner: Runner | None = None,
) -> VolumeCapturePlaneOutputs:
    """
    INTERPOLATE IMAGE FROM PLANE THROUGH VOLUME.
    
    NOTE: If you want to generate an image with all of the capabilities of the
    GUI rendering, see -show-scene.
    
    Renders an image of an arbitrary plane through the volume file, with a
    simple linear grayscale palette. The parameter <interp> must be one of:
    
    CUBIC
    ENCLOSING_VOXEL
    TRILINEAR.
    
    Args:
        volume: the volume file to interpolate from.
        subvolume: the name or number of the subvolume to use.
        interp: interpolation type.
        h_dim: width of output image, in pixels.
        v_dim: height of output image, in pixels.
        scale_min: value to render as black.
        scale_max: value to render as white.
        bottom_left_x: x-coordinate of the bottom left of the output image.
        bottom_left_y: y-coordinate of the bottom left of the output image.
        bottom_left_z: z-coordinate of the bottom left of the output image.
        bottom_right_x: x-coordinate of the bottom right of the output image.
        bottom_right_y: y-coordinate of the bottom right of the output image.
        bottom_right_z: z-coordinate of the bottom right of the output image.
        top_left_x: x-coordinate of the top left of the output image.
        top_left_y: y-coordinate of the top left of the output image.
        top_left_z: z-coordinate of the top left of the output image.
        image: output - the output image.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `VolumeCapturePlaneOutputs`).
    """
    params = volume_capture_plane_params(
        volume=volume,
        subvolume=subvolume,
        interp=interp,
        h_dim=h_dim,
        v_dim=v_dim,
        scale_min=scale_min,
        scale_max=scale_max,
        bottom_left_x=bottom_left_x,
        bottom_left_y=bottom_left_y,
        bottom_left_z=bottom_left_z,
        bottom_right_x=bottom_right_x,
        bottom_right_y=bottom_right_y,
        bottom_right_z=bottom_right_z,
        top_left_x=top_left_x,
        top_left_y=top_left_y,
        top_left_z=top_left_z,
        image=image,
    )
    return volume_capture_plane_execute(params, runner)


__all__ = [
    "VOLUME_CAPTURE_PLANE_METADATA",
    "VolumeCapturePlaneOutputs",
    "VolumeCapturePlaneParamsDict",
    "VolumeCapturePlaneParamsDictTagged",
    "volume_capture_plane",
    "volume_capture_plane_execute",
    "volume_capture_plane_params",
]
