bec_widgets.widgets.plots.image.image_base#

Classes#

ImageBase

Base class for the Image widget.

ImageLayer

Model for the image layer.

ImageLayerManager

Manager for the image layers.

ImageLayerSync

Model for the image layer synchronization.

Module Contents#

class ImageBase(*args, **kwargs)#

Bases: bec_widgets.widgets.plots.plot_base.PlotBase

Base class for the Image widget.

Initialize the ImageBase widget.

_add_roi_plots()#

Initialize the ROI plots and side panels.

_apply_colormap_to_colorbar(color_map: str) None#
_init_image_base_toolbar()#
_roi_mgr_closed()#
_set_autorange(enabled: bool, sync: bool = True)#

Set the autorange for all layers.

Parameters:
  • enabled (bool) – Whether to enable autorange.

  • sync (bool) – Whether to synchronize the autorange state across all layers.

_set_vrange(value: tuple | list | qtpy.QtCore.QPointF, disable_autorange: bool = True)#
_sync_autorange_switch()#

Synchronize the autorange switch with the current autorange state and mode if changed from outside.

_sync_colorbar_actions()#

Synchronize the colorbar actions with the current colorbar state.

_sync_colorbar_levels()#

Immediately propagate current levels to the active colorbar.

add_layer(name: str | None = None, **kwargs) ImageLayer#

Add a new image layer to the widget.

Parameters:
  • name (str | None) – The name of the image layer. If None, a default name is generated.

  • **kwargs – Additional arguments for the image layer.

Returns:

The added image layer.

Return type:

ImageLayer

add_roi(kind: Literal['rect', 'circle', 'ellipse'] = 'rect', name: str | None = None, line_width: int | None = 5, pos: tuple[float, float] | None = (10, 10), size: tuple[float, float] | None = (50, 50), movable: bool = True, **pg_kwargs) bec_widgets.widgets.plots.roi.image_roi.RectangularROI | bec_widgets.widgets.plots.roi.image_roi.CircularROI#

Add a ROI to the image.

Parameters:
  • kind (str) – The type of ROI to add. Options are “rect” or “circle”.

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

  • line_width (int) – The line width of the ROI.

  • pos (tuple) – The position of the ROI.

  • size (tuple) – The size of the ROI.

  • movable (bool) – Whether the ROI is movable.

  • **pg_kwargs – Additional arguments for the ROI.

Returns:

The created ROI object.

Return type:

RectangularROI | CircularROI

add_side_menus()#

Adds multiple menus to the side panel.

apply_theme(theme: str)#

Apply the theme to the widget.

Parameters:

theme (str, optional) – The theme to be applied.

cleanup()#

Cleanup the widget.

static cleanup_histogram_lut_item(histogram_lut_item: pyqtgraph.HistogramLUTItem)#

Clean up HistogramLUTItem safely, including open ViewBox menus and child widgets.

Parameters:

histogram_lut_item (pg.HistogramLUTItem) – The HistogramLUTItem to clean up.

color_map() str#

Set the color map of the image.

enable_colorbar(enabled: bool, style: Literal['full', 'simple'] = 'full', vrange: tuple[int, int] | None = None)#

Enable the colorbar and switch types of colorbars.

Parameters:
  • enabled (bool) – Whether to enable the colorbar.

  • style (Literal["full", "simple"]) – The type of colorbar to enable.

  • vrange (tuple) – The range of values to use for the colorbar.

enable_full_colorbar() bool#

Enable the full colorbar.

enable_simple_colorbar() bool#

Enable the simple colorbar.

layers() list[ImageLayer]#

Get the list of image layers.

Returns:

The list of image layers.

Return type:

list[ImageLayer]

lock_aspect_ratio() bool#

Whether the aspect ratio is locked.

remove_layer(layer: ImageLayer | str)#

Remove an image layer from the widget.

Parameters:

layer (ImageLayer | str) – The image layer to remove. Can be the layer object or the name of the layer.

remove_roi(roi: int | str)#

Remove an ROI by index or label via the ROIController.

show_roi_manager_popup()#
toggle_autorange(enabled: bool, mode: str)#

Toggle autorange.

Parameters:
  • enabled (bool) – Whether to enable autorange.

  • mode (str) – The autorange mode. Options are “max” or “mean”.

toggle_roi_panels(checked: bool)#

Show or hide the ROI panels based on the test action toggle state.

Parameters:

checked (bool) – Whether the test action is checked.

update_image_slices(coordinates: tuple[int, int, int] = None)#

Update the image slices based on the crosshair position.

Parameters:

coordinates (tuple) – The coordinates of the crosshair.

v_range() qtpy.QtCore.QPointF#

Set the v_range of the main image.

MAX_TICKS_COLORBAR = 10#
autorange = True#
autorange_mode = 'mean'#
image_updated#
layer_added#
layer_manager: ImageLayerManager#
layer_removed#
roi_controller#
roi_manager_dialog = None#
property rois: list[bec_widgets.widgets.plots.roi.image_roi.BaseROI]#

Get the list of ROIs.

sync_colorbar_with_autorange#
property v_max: float#

Get the maximum value of the v_range.

property v_min: float#

Get the minimum value of the v_range.

x_roi = None#
y_roi = None#
class ImageLayer(/, **data: Any)#

Bases: pydantic.BaseModel

Model for the image layer.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

image: bec_widgets.widgets.plots.image.image_item.ImageItem = None#
model_config#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

name: str = None#
sync: ImageLayerSync = None#
class ImageLayerManager(parent: ImageBase, plot_item: pyqtgraph.PlotItem, on_add: qtpy.QtCore.SignalInstance | None = None, on_remove: qtpy.QtCore.SignalInstance | None = None)#

Manager for the image layers.

__getitem__(name: str) ImageLayer#

Get an image layer by name.

Parameters:

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

Returns:

The image layer with the given name.

Return type:

ImageLayer

__iter__()#

Iterate over the image layers.

Returns:

An iterator over the image layers.

Return type:

Iterator[ImageLayer]

__len__() int#

Get the number of image layers.

Returns:

The number of image layers.

Return type:

int

_get_bottom_z_position() int#

Get the bottom z position of the image layers, capping it to the minimum z value.

Returns:

The bottom z position of the image layers.

Return type:

int

_get_top_z_position() int#

Get the top z position of the image layers, capping it to the maximum z value.

Returns:

The top z position of the image layers.

Return type:

int

_remove_destroyed_layer(layer: str)#

Remove a layer that has been destroyed.

Parameters:

layer (str) – The name of the layer to remove.

add(name: str | None = None, z_position: int | Literal['top', 'bottom'] | None = None, sync: ImageLayerSync | None = None, **kwargs) ImageLayer#

Add an image layer to the widget.

Parameters:
  • name (str | None) – The name of the image layer. If None, a default name is generated.

  • image (ImageItem) – The image layer to add.

  • z_position (int | None) – The z position of the image layer. If None, the layer is added to the top.

  • sync (ImageLayerSync | None) – The synchronization settings for the image layer.

  • **kwargs – ImageLayerSync settings. Only used if sync is None.

clear()#

Clear all image layers from the manager.

remove(layer: ImageLayer | str)#

Remove an image layer from the widget.

Parameters:

layer (ImageLayer | str) – The image layer to remove. Can be the layer object or the name of the layer.

Z_RANGE_USER#
layers: dict[str, ImageLayer]#
on_add = None#
on_remove = None#
parent#
plot_item#
class ImageLayerSync(/, **data: Any)#

Bases: pydantic.BaseModel

Model for the image layer synchronization.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

autorange: bool = None#
autorange_mode: bool = None#
color_map: bool = None#
fft: bool = None#
log: bool = None#
rotation: bool = None#
transpose: bool = None#
v_range: bool = None#