itkwidgets.viewer

Module Contents

Classes

ViewerRPC

Viewer remote procedure interface.

Viewer

Pythonic Viewer class.

Functions

view

View the image and/or point set.

compare_images

Fuse 2 images with a checkerboard filter or as a 2 component image.

Data

API

itkwidgets.viewer.__all__

[‘Viewer’, ‘view’]

itkwidgets.viewer._viewer_count

1

itkwidgets.viewer._codecs_registered

False

itkwidgets.viewer._cell_watcher

None

class itkwidgets.viewer.ViewerRPC(ui_collapsed: bool = True, rotate: bool = False, ui: str = 'pydata-sphinx', init_data: dict = None, parent: str = None, **add_data_kwargs)

Viewer remote procedure interface.

Initialization

async setup() None
async run(ctx: dict) None

ImJoy plugin setup function.

set_default_ui_values(itk_viewer: dict) None

Set any UI values passed in on initialization.

Parameters:

itk_viewer (dict) – The ImJoy plugin API to use

async create_screenshot() None

Grab a screenshot of the current Viewer and embed it in the notebook cell.

update_screenshot(base64_image: str) None

Embed an image in the current notebook cell.

Parameters:

base64_image (bstring) – An encoded image to be embedded

update_viewer_status()

Update the CellWatcher class to indicate that the Viewer is ready

set_event(event_data: str) None

Set the event in the background thread to indicate that the plugin API is available so that queued setter requests are processed.

Parameters:

event_data (string) – The name of the image that has been rendered

class itkwidgets.viewer.Viewer(ui_collapsed: bool = True, rotate: bool = False, ui: bool = 'pydata-sphinx', **add_data_kwargs)

Pythonic Viewer class.

Initialization

Create a viewer.

_setup_queueing() None

Create a background thread and two queues of requests: one will hold requests that can be run as soon as the plugin API is available, the deferred queue will hold requests that need the data to be rendered before they are applied. Background requests will not return any results.

property loop: asyncio.BaseEventLoop

Return the running event loop in the current OS thread.

Returns:

Current running event loop

Return type:

asyncio.BaseEventLoop

property has_viewer: bool

Whether or not the plugin API is available to call.

Returns:

Availability of API

Return type:

bool

property itk_viewer: dict | None

Return the plugin API if it is available.

Returns:

The plugin API if available, else None

Return type:

dict | None

async run_queued_requests() None

Once the plugin API is available and the viewer_event is set, run all requests queued for the background thread that do not require the data to be available. Once the data has been rendered process any deferred requests.

queue_worker() None

Create a new event loop in the background thread and run until all queued tasks are complete.

call_getter(future: asyncio.Future) None

Create a future for requests that expect a response and set the callback to update the CellWatcher once resolved.

Parameters:

future (asyncio.Future) – A future for the awaitable request that we are waiting to resolve.

queue_request(method: Callable, *args, **kwargs) None

Determine if a request should be run immeditately, queued to run once the plugin API is avaialable, or queued to run once the data has been rendered.

Parameters:

method (Callable) – Function to either call or queue

fetch_value() Callable

Decorator function that wraps the decorated function and returns the wrapper. In this case we decorate our API wrapper functions in order to determine if it needs to be managed by the CellWatcher class.

Parameters:

func (Callable) – Plugin API wrapper

Returns:

wrapper function

Return type:

Callable

set_annotations_enabled(enabled: bool) None

Set whether or not the annotations should be displayed. Queue the function to be run in the background thread once the plugin API is available.

Parameters:

enabled (bool) – Should annotations be enabled

async get_annotations_enabled() asyncio.Future | bool

Determine if annotations are enabled.

Returns:

The future for the coroutine, to be updated with the annotations visibility status.

Return type:

asyncio.Future | bool

set_axes_enabled(enabled: bool) None

Set whether or not the axes should be displayed. Queue the function to be run in the background thread once the plugin API is available.

Parameters:

enabled (bool) – If axes should be enabled

async get_axes_enabled() asyncio.Future | bool

Determine if the axes are enabled.

Returns:

The future for the coroutine, to be updated with the axes visibility status.

Return type:

asyncio.Future | bool

set_background_color(bg_color: List[float]) None

Set the background color for the viewer. Queue the function to be run in the background thread once the plugin API is available.

Parameters:

bg_color (List[float]) – A list of floats [r, g, b, a]

async get_background_color() asyncio.Future | List[float]

Get the current background color.

Returns:

The future for the coroutine, to be updated with a list of floats representing the current color [r, g, b, a].

Return type:

asyncio.Future | List[float]

set_cropping_planes(cropping_planes: itkwidgets._type_aliases.CroppingPlanes) None

Set the origins and normals for the current cropping planes. Queue the function to be run in the background thread once the plugin API is available.

Parameters:

cropping_planes (CroppingPlanes) – A list of 6 dicts representing the 6 cropping planes. Each dict should contain an ‘origin’ key with the origin with a list of three floats and a ‘normal’ key with a list of three ints.

async get_cropping_planes() asyncio.Future | itkwidgets._type_aliases.CroppingPlanes

Get the origins and normals for the current cropping planes.

Returns:

The future for the coroutine, to be updated with a list of 6 dicts representing the 6 cropping planes. Each dict should contain an ‘origin’ key with the origin with a list of three floats and a ‘normal’ key with a list of three ints.

Return type:

asyncio.Future | CroppingPlanes

set_image(image: itkwidgets._type_aliases.Image, name: str = 'Image') None

Set the image to be rendered. Queue the function to be run in the background thread once the plugin API is available.

Parameters:
  • image (Image) – Image data to render

  • name (str, optional) – Image name, defaults to ‘Image’

async get_image(name: str = 'Image') ngff_zarr.NgffImage

Get the full, highest resolution image.

Parameters:

name (str) – Name of the loaded image data to use. ‘Image’, the default, selects the first loaded image.

Returns:

image

Return type:

NgffImage

set_image_blend_mode(mode: str) None

Set the volume rendering blend mode. Queue the function to be run in the background thread once the plugin API is available.

Parameters:

mode (str) – Volume blend mode. Supported modes: ‘Composite’, ‘Maximum’, ‘Minimum’, ‘Average’. default: ‘Composite’.

async get_image_blend_mode() asyncio.Future | str

Get the current volume rendering blend mode.

Returns:

The future for the coroutine, to be updated with the current blend mode.

Return type:

asyncio.Future | str

property color_map: asyncio.Future | str

Get the color map for the current component/channel.

Returns:

The future for the coroutine, to be updated with the current color map.

Return type:

asyncio.Future | str

set_image_color_map(color_map: str) None

Set the color map for the current component/channel. Queue the function to be run in the background thread once the plugin API is available.

Parameters:

color_map (str) – Color map for the current image. default: ‘Grayscale’

async get_image_color_map() asyncio.Future | str

Get the color map for the current component/channel.

Returns:

The future for the coroutine, to be updated with the current color map.

Return type:

asyncio.Future | str

property color_range: asyncio.Future | List[float]

Get the range of the data values mapped to colors for the given image.

Returns:

description

Return type:

asyncio.Future | List[float]

set_image_color_range(range: List[float]) None

The range of the data values mapped to colors for the given image. Queue the function to be run in the background thread once the plugin API is available.

Parameters:

range (List[float]) – The [min, max] range of the data values

async get_image_color_range() asyncio.Future | List[float]

Get the range of the data values mapped to colors for the given image.

Returns:

The future for the coroutine, to be updated with the [min, max] range of the data values.

Return type:

asyncio.Future | List[float]

property vmin: asyncio.Future | float

Get the minimum data value mapped to colors for the current image.

Returns:

The future for the coroutine, to be updated with the minimum value mapped to the color map.

Return type:

asyncio.Future | float

property vmax: asyncio.Future | float

Get the maximum data value mapped to colors for the current image.

Returns:

The future for the coroutine, to be updated with the maximum value mapped to the color map.

Return type:

asyncio.Future | float

property color_bounds: asyncio.Future | List[float]

Get the range of the data values for color maps.

Returns:

The future for the coroutine, to be updated with the [min, max] range of the data values.

Return type:

asyncio.Future | List[float]

set_image_color_range_bounds(range: List[float]) None

Set the range of the data values for color maps. Queue the function to be run in the background thread once the plugin API is available.

Parameters:

range (List[float]) – The [min, max] range of the data values.

async get_image_color_range_bounds() asyncio.Future | List[float]

Get the range of the data values for color maps.

Returns:

The future for the coroutine, to be updated with the [min, max] range of the data values.

Return type:

asyncio.Future | List[float]

set_image_component_visibility(visibility: bool, component: int) None

Set the given image intensity component index’s visibility. Queue the function to be run in the background thread once the plugin API is available.

Parameters:
  • visibility (bool) – Whether or not the component should be visible.

  • component (int) – The component to set the visibility for.

async get_image_component_visibility(component: int) asyncio.Future | int

Get the given image intensity component index’s visibility.

Parameters:

component (int) – The component to set the visibility for.

Returns:

The future for the coroutine, to be updated with the component’s visibility.

Return type:

asyncio.Future | int

property gradient_opacity: asyncio.Future | float

Get the gradient opacity for composite volume rendering.

Returns:

The future for the coroutine, to be updated with the gradient opacity.

Return type:

asyncio.Future | float

set_image_gradient_opacity(opacity: float) None

Set the gradient opacity for composite volume rendering. Queue the function to be run in the background thread once the plugin API is available.

Parameters:

opacity (float) – Gradient opacity in the range (0.0, 1.0]. default: 0.5

async get_image_gradient_opacity() asyncio.Future | float

Get the gradient opacity for composite volume rendering.

Returns:

The future for the coroutine, to be updated with the gradient opacity.

Return type:

asyncio.Future | float

property gradient_opacity_scale: asyncio.Future | float

Get the gradient opacity scale for composite volume rendering.

Returns:

The future for the coroutine, to be updated with the current gradient opacity scale.

Return type:

asyncio.Future | float

set_image_gradient_opacity_scale(min: float) None

Set the gradient opacity scale for composite volume rendering. Queue the function to be run in the background thread once the plugin API is available.

Parameters:

min (float) – Gradient opacity scale in the range (0.0, 1.0] default: 0.5

async get_image_gradient_opacity_scale() asyncio.Future | float

Get the gradient opacity scale for composite volume rendering.

Returns:

The future for the coroutine, to be updated with the current gradient opacity scale.

Return type:

asyncio.Future | float

set_image_interpolation_enabled(enabled: bool) None

Set whether to use linear as opposed to nearest neighbor interpolation for image slices. Queue the function to be run in the background thread once the plugin API is available.

Parameters:

enabled (bool) – Use linear interpolation. default: True

async get_image_interpolation_enabled() asyncio.Future | bool

Get whether to use linear as opposed to nearest neighbor interpolation for image slices.

Returns:

The future for the coroutine, to be updated with whether linear interpolation is used.

Return type:

asyncio.Future | bool

set_image_piecewise_function_gaussians(gaussians: itkwidgets._type_aliases.Gaussians) None

Set the volume rendering opacity transfer function Gaussian parameters. For each image component, multiple Gaussians can be specified. Queue the function to be run in the background thread once the plugin API is available.

Parameters:

gaussians (Gaussians) – Opacity transfer function Gaussian parameters. Default Gaussian parameters: {‘position’: 0.5, ‘height’: 1, ‘width’: 0.5, ‘xBias’: 0.51, ‘yBias’: 0.4}

async get_image_piecewise_function_gaussians() asyncio.Future | itkwidgets._type_aliases.Gaussians

Get the volume rendering opacity transfer function Gaussian parameters.

Returns:

The future for the coroutine, to be updated with the opacity transfer function Gaussian parameters.

Return type:

asyncio.Future | Gaussians

set_image_shadow_enabled(enabled: bool) None

Set whether to used gradient-based shadows in the volume rendering. Queue the function to be run in the background thread once the plugin API is available.

Parameters:

enabled (bool) – Apply shadows. default: True

async get_image_shadow_enabled() asyncio.Future | bool

Get whether gradient-based shadows are used in the volume rendering.

Returns:

The future for the coroutine, to be updated with whether gradient-based shadows are used.

Return type:

asyncio.Future | bool

set_image_volume_sample_distance(distance: float) None

Set the sampling distance for volume rendering, normalized from 0.0 to 1.0. Lower values result in a higher quality rendering. High values improve the framerate. Queue the function to be run in the background thread once the plugin API is available.

Parameters:

distance (float) – Sampling distance for volume rendering. default: 0.2

async get_image_volume_sample_distance() asyncio.Future | float

Get the normalized sampling distance for volume rendering.

Returns:

The future for the coroutine, to be updated with the normalized sampling distance.

Return type:

asyncio.Future | float

set_image_volume_scattering_blend(scattering_blend: float) None

Set the volumetric scattering blend. Queue the function to be run in the background thread once the plugin API is available.

Parameters:

scattering_blend (float) – Volumetric scattering blend in the range [0, 1]

async get_image_volume_scattering_blend() asyncio.Future | float

Get the volumetric scattering blend.

Returns:

The future for the coroutine, to be updated with the current volumetric scattering blend.

Return type:

asyncio.Future | float

async get_current_scale() asyncio.Future | int

Get the current resolution scale of the primary image.

0 is the highest resolution. Values increase for lower resolutions.

Returns:

scale

Return type:

asyncio.Future | int

async get_roi_image(scale: int = -1, name: str = 'Image') ngff_zarr.NgffImage

Get the image for the current ROI.

Parameters:
  • scale (int) – scale of the primary image to get the slices for the current roi. -1, the default, uses the current scale.

  • name (str) – Name of the loaded image data to use. ‘Image’, the default, selects the first loaded image.

Returns:

roi_image

Return type:

NgffImage

async get_roi_multiscale(name: str = 'Image') ngff_zarr.Multiscales

Build and return a new Multiscales NgffImage for the ROI.

Parameters:

name (str CellWatcher().update_viewer_status(self.name, False)) – Name of the loaded image data to use. ‘Image’, the default, selects the first loaded image.

Returns:

roi_multiscales

Return type:

Multiscales NgffImage

async get_roi_region() asyncio.Future | List[Dict[str, float]]

Get the current region of interest in world / physical space.

Returns [lower_bounds, upper_bounds] in the form:

[{ ‘x’: x0, ‘y’: y0, ‘z’: z0 }, { ‘x’: x1, ‘y’: y1, ‘z’: z1 }]

Returns:

roi_region

Return type:

asyncio.Future | List[Dict[str, float]]

async get_roi_slice(scale: int = -1)

Get the current region of interest as Python slice objects for the current resolution of the primary image. The result is in the order:

[z_slice, y_slice, x_slice]

Not that for standard C-order NumPy arrays, this result can be used to directly extract the region of interest from the array. For example,

roi_array = image.data[roi_slice]

Parameters:

scale (int) – scale of the primary image to get the slices for the current roi. -1, the default, uses the current scale.

Returns:

roi_slice

Return type:

List[slice]

compare_images(fixed_image: Union[str, itkwidgets._type_aliases.Image], moving_image: Union[str, itkwidgets._type_aliases.Image], method: str = None, image_mix: float = None, checkerboard: bool = None, pattern: Union[Tuple[int, int], Tuple[int, int, int]] = None, swap_image_order: bool = None) None

Fuse 2 images with a checkerboard filter or as a 2 component image. The moving image is re-sampled to the fixed image space. Set a keyword argument to None to use defaults based on method. Queue the function to be run in the background thread once the plugin API is available.

Parameters:
  • fixed_image (array_like, itk.Image, or vtk.vtkImageData) – Static image the moving image is re-sampled to. For non-checkerboard methods (‘blend’, ‘green-magenta’, etc.), the fixed image is on the first component.

  • moving_image (array_like, itk.Image, or vtk.vtkImageData) – Image is re-sampled to the fixed_image. For non-checkerboard methods (‘blend’, ‘green-magenta’, etc.), the moving image is on the second component.

  • method (string, default: None, possible values: ‘green-magenta’, ‘cyan-red’, ‘cyan-magenta’, ‘blend’, ‘checkerboard’, ‘disabled’) – The checkerboard method picks pixels from the fixed and moving image to create a checkerboard pattern. Setting the method to checkerboard turns on the checkerboard flag. The non-checkerboard methods (‘blend’, ‘green-magenta’, etc.) put the fixed image on component 0, moving image on component 1. The ‘green-magenta’ and ‘red-cyan’ change the color maps so matching images are grayish white. The ‘cyan-magenta’ color maps produce a purple if the images match.

  • image_mix (float, default: None) – Changes the percent contribution the fixed vs moving image makes to the render by modifying the opacity transfer function. Value of 1 means max opacity for moving image, 0 for fixed image. If value is None and the method is not checkerboard, the image_mix is set to 0.5. If the method is “checkerboard”, the image_mix is set to 0.

  • checkerboard (bool, default: None) – Forces the checkerboard mixing of fixed and moving images for the cyan-magenta and blend methods. The rendered image has 2 components, each component reverses which image is sampled for each checkerboard box.

  • pattern (tuple, default: None) – The number of checkerboard boxes for each dimension.

  • swap_image_order (bool, default: None) – Reverses which image is sampled for each checkerboard box. This simply toggles image_mix between 0 and 1.

set_label_image(label_image: itkwidgets._type_aliases.Image) None

Set the label image to be rendered. Queue the function to be run in the background thread once the plugin API is available.

Parameters:

label_image (Image) – The label map to visualize

async get_label_image() ngff_zarr.NgffImage

Get the full, highest resolution label image.

Returns:

label_image

Return type:

NgffImage

set_label_image_blend(blend: float) None

Set the label map blend with intensity image. Queue the function to be run in the background thread once the plugin API is available.

Parameters:

blend (float) – Blend with intensity image, from 0.0 to 1.0. default: 0.5

async get_label_image_blend() asyncio.Future | float

Get the label map blend with intensity image.

Returns:

The future for the coroutine, to be updated with the blend with the intensity image.

Return type:

asyncio.Future | float

set_label_image_label_names(names: List[str]) None

Set the string names associated with the integer label values. Queue the function to be run in the background thread once the plugin API is available.

Parameters:

names (List[str]) – A list of names for each label map.

async get_label_image_label_names() asyncio.Future | List[str]

Get the string names associated with the integer label values.

Returns:

The future for the coroutine, to be updated with the list of names for each label map.

Return type:

asyncio.Future | List[str]

set_label_image_lookup_table(lookup_table: str) None

Set the lookup table for the label map. Queue the function to be run in the background thread once the plugin API is available.

Parameters:

lookup_table (str) – Label map lookup table. default: ‘glasbey’

async get_label_image_lookup_table() asyncio.Future | str

Get the lookup table for the label map.

Returns:

The future for the coroutine, to be updated with the current label map lookup table.

Return type:

asyncio.Future | str

set_label_image_weights(weights: float) None

Set the rendering weight assigned to current label. Queue the function to be run in the background thread once the plugin API is available.

Parameters:

weights (float) – Assign the current label rendering weight between [0.0, 1.0].

async get_label_image_weights() asyncio.Future | float

Get the rendering weight assigned to current label.

Returns:

The future for the coroutine, to be updated with the current label rendering weight.

Return type:

asyncio.Future | float

select_layer(name: str) None

Set the layer identified by name as the current layer. Queue the function to be run in the background thread once the plugin API is available.

Parameters:

name (str) – The name of thelayer to select.

async get_layer_names() asyncio.Future | List[str]

Get the list of all layer names.

Returns:

The future for the coroutine, to be updated with the list of layer names.

Return type:

asyncio.Future | List[str]

set_layer_visibility(visible: bool, name: str) None

Set whether the layer is visible. Queue the function to be run in the background thread once the plugin API is available.

Parameters:
  • visible (bool) – Layer visibility. default: True

  • name (str) – The name of the layer.

async get_layer_visibility(name: str) asyncio.Future | bool

Get whether the layer is visible.

Parameters:

name (str) – The name of the layer to fetch the visibility for.

Returns:

The future for the coroutine, to be updated with the layer visibility.

Return type:

asyncio.Future | bool

get_loaded_image_names() List[str]

Get the list of loaded image names.

Returns:

List of loaded images.

Return type:

List[str]

add_point_set(point_set: itkwidgets._type_aliases.PointSet) None

Add a point set to the visualization. Queue the function to be run in the background thread once the plugin API is available.

Parameters:

point_set (PointSet) – An array of points to visualize.

set_point_set(point_set: itkwidgets._type_aliases.PointSet) None

Set the point set to the visualization. Queue the function to be run in the background thread once the plugin API is available.

Parameters:

point_set (PointSet) – An array of points to visualize.

set_rendering_view_container_style(container_style: itkwidgets._type_aliases.Style) None

Set the CSS style for the rendering view div’s. Queue the function to be run in the background thread once the plugin API is available.

Parameters:

container_style (Style) – A dict of string keys and sting values representing the desired CSS styling.

async get_rendering_view_container_style() itkwidgets._type_aliases.Style

Get the CSS style for the rendering view div’s.

Returns:

The future for the coroutine, to be updated with a dict of string keys and sting values representing the desired CSS styling.

Return type:

Style

set_rotate(enabled: bool) None

Set whether the camera should continuously rotate around the scene in volume rendering mode. Queue the function to be run in the background thread once the plugin API is available.

Parameters:

enabled (bool) – Rotate the camera. default: False

async get_rotate() bool

Get whether the camera is rotating.

Returns:

The future for the coroutine, to be updated with the boolean status.

Return type:

bool

set_ui_collapsed(collapsed: bool) None

Collapse the native widget user interface. Queue the function to be run in the background thread once the plugin API is available.

Parameters:

collapsed (bool) – If the UI interface should be collapsed. default: True

async get_ui_collapsed() bool

Get the collapsed status of the UI interface.

Returns:

The future for the coroutine, to be updated with the collapsed state of the UI interface.

Return type:

bool

set_units(units: str) None

Set the units to display in the scale bar. Queue the function to be run in the background thread once the plugin API is available.

Parameters:

units (str) – Units to use.

async get_units() str

Get the units to display in the scale bar.

Returns:

The future for the coroutine, to be updated with the units used in the scale bar.

Return type:

str

set_view_mode(mode: str) None

Set the viewing mode. Queue the function to be run in the background thread once the plugin API is available.

Parameters:

mode (str) – View mode. One of the following: ‘XPlane’, ‘YPlane’, ‘ZPlane’, or ‘Volume’. default: ‘Volume’

async get_view_mode() str

Get the current view mode.

Returns:

The future for the coroutine, to be updated with the view mode.

Return type:

str

set_x_slice(position: float) None

Set the position in world space of the X slicing plane. Queue the function to be run in the background thread once the plugin API is available.

Parameters:

position (float) – Position in world space.

async get_x_slice() float

Get the position in world space of the X slicing plane.

Returns:

The future for the coroutine, to be updated with the position in world space.

Return type:

float

set_y_slice(position: float) None

Set the position in world space of the Y slicing plane. Queue the function to be run in the background thread once the plugin API is available.

Parameters:

position (float) – Position in world space.

async get_y_slice() float

Get the position in world space of the Y slicing plane.

Returns:

The future for the coroutine, to be updated with the position in world space.

Return type:

float

set_z_slice(position: float) None

Set the position in world space of the Z slicing plane. Queue the function to be run in the background thread once the plugin API is available.

Parameters:

position (float) – Position in world space.

async get_z_slice() float

Get the position in world space of the Z slicing plane.

Returns:

The future for the coroutine, to be updated with the position in world space.

Return type:

float

itkwidgets.viewer.view(data=None, **kwargs)

View the image and/or point set.

Creates and returns an ImJoy plugin ipywidget to visualize an image, and/or point set.

The image can be 2D or 3D. The type of the image can be an numpy.array, itkwasm.Image, itk.Image, additional NumPy-arraylike’s, such as a dask.Array, or vtk.vtkImageData.

A point set can be visualized. The type of the point set can be an numpy.array (Nx3 array of point positions).

Parameters

General Interface

Parameters:
  • ui_collapsed (bool) – Collapse the native widget user interface. default: True

  • rotate (bool) – Continuously rotate the camera around the scene in volume rendering mode. default: False

  • annotations (bool) – Display annotations describing orientation and the value of a mouse-position-based data probe. default: True

  • axes (bool) – Display axes. default: False

  • bg_color ((red, green, blue) tuple, components from 0.0 to 1.0) – Background color. default: based on the current Jupyter theme

  • container_style (dict) – The CSS style for the rendering view div’s.

Images

Parameters:
  • image (array_like, itk.Image, or vtk.vtkImageData) – The image to visualize.

  • label_image (array_like, itk.Image, or vtk.vtkImageData) – The label map to visualize. If an image is also provided, the label map must have the same size.

  • label_blend (float) – Label map blend with intensity image, from 0.0 to 1.0. default: 0.5

  • label_names (list of (label_value, label_name)) – String names associated with the integer label values.

  • label_lut (string) – Lookup table for the label map. default: ‘glasbey’

  • label_weights (float) – The rendering weight assigned to current label. Values range from 0.0 to 1.0.

  • color_range (list, default: The [min, max] range of the data values) – The [min, max] range of the data values mapped to colors for the given image component identified by name.

  • vmin (float) – Data values below vmin take the bottom color of the color map.

  • vmax (float) – Data values above vmax take the top color of the color map.

  • color_bounds (list, default: The [min, max] range of the data values) – The [min, max] range of the data values for color maps that provide a bounds for user inputs.

  • cmap (string) – The color map for the current component/channel. default: ‘Grayscale’

  • x_slice (float) – The position in world space of the X slicing plane.

  • y_slice (float) – The position in world space of the Y slicing plane.

  • z_slice (float) – The position in world space of the Z slicing plane.

  • interpolation (bool) – Linear as opposed to nearest neighbor interpolation for image slices. Note: Interpolation is not currently supported with label maps. default: True

  • gradient_opacity (float) – Gradient opacity for composite volume rendering, in the range (0.0, 1.0]. default: 0.5

  • gradient_opacity_scale (float) – Gradient opacity scale for composite volume rendering, in the range (0.0, 1.0]. default: 0.5

  • gaussians (dict) – Volume rendering opacity transfer function Gaussian parameters. For each image component, multiple Gaussians can be specified. Default Gaussian parameters: {‘position’: 0.5, ‘height’: 1, ‘width’: 0.5, ‘xBias’: 0.51, ‘yBias’: 0.4}

  • blend_mode (string) – Volume rendering blend mode. Supported modes: ‘Composite’, ‘Maximum’, ‘Minimum’, ‘Average’. default: ‘Composite’

  • component_visible (bool) – The given image intensity component index’s visibility. default: True

  • shadow_enabled (bool) – Whether to used gradient-based shadows in the volume rendering. default: True

  • view_mode ('XPlane', 'YPlane', 'ZPlane', or 'Volume') – Only relevant for 3D scenes. Viewing mode: ‘XPlane’, ‘YPlane’, ‘ZPlane’, or ‘Volume’. default: ‘Volume’

  • layer (string) – Select the layer identified by name in the user interface.

  • layer_visible (bool) – Whether the current layer is visible. default: True

Point Set

Parameters:

point_set (array_like) – The point set to visualize.

Other Parameters

Parameters:
  • sample_distance (float) – Sampling distance for volume rendering, normalized from 0.0 to 1.0. Lower values result in a higher quality rendering. High values improve the framerate. default: 0.2

  • units (string) – Units to display in the scale bar.

Returns

Returns:

viewer, display by placing at the end of a Jupyter or Colab cell. Query or set properties on the object to change the visualization.

Return type:

Viewer

itkwidgets.viewer.compare_images(fixed_image: Union[str, itkwidgets._type_aliases.Image], moving_image: Union[str, itkwidgets._type_aliases.Image], method: str = None, image_mix: float = None, checkerboard: bool = None, pattern: Union[Tuple[int, int], Tuple[int, int, int]] = None, swap_image_order: bool = None, **kwargs)

Fuse 2 images with a checkerboard filter or as a 2 component image.

The moving image is re-sampled to the fixed image space. Set a keyword argument to None to use defaults based on method.

Parameters:
  • fixed_image (array_like, itk.Image, or vtk.vtkImageData) – Static image the moving image is re-sampled to. For non-checkerboard methods (‘blend’, ‘green-magenta’, etc.), the fixed image is on the first component.

  • moving_image (array_like, itk.Image, or vtk.vtkImageData) – Image is re-sampled to the fixed_image. For non-checkerboard methods (‘blend’, ‘green-magenta’, etc.), the moving image is on the second component.

  • method (string, default: None, possible values: 'green-magenta', 'cyan-red', 'cyan-magenta', 'blend', 'checkerboard', 'disabled') – The checkerboard method picks pixels from the fixed and moving image to create a checkerboard pattern. Setting the method to checkerboard turns on the checkerboard flag. The non-checkerboard methods (‘blend’, ‘green-magenta’, etc.) put the fixed image on component 0, moving image on component 1. The ‘green-magenta’ and ‘red-cyan’ change the color maps so matching images are grayish white. The ‘cyan-magenta’ color maps produce a purple if the images match.

  • image_mix (float, default: None) – Changes the percent contribution the fixed vs moving image makes to the render by modifying the opacity transfer function. Value of 1 means max opacity for moving image, 0 for fixed image. If value is None and the method is not checkerboard, the image_mix is set to 0.5. If the method is “checkerboard”, the image_mix is set to 0.

  • checkerboard (bool, default: None) – Forces the checkerboard mixing of fixed and moving images for the cyan-magenta and blend methods. The rendered image has 2 components, each component reverses which image is sampled for each checkerboard box.

  • pattern (tuple, default: None) – The number of checkerboard boxes for each dimension.

  • swap_image_order (bool, default: None) – Reverses which image is sampled for each checkerboard box. This simply toggles image_mix between 0 and 1.

Returns:

viewer, display by placing at the end of a Jupyter or Colab cell. Query or set properties on the object to change the visualization.

Return type:

Viewer