erlab.interactive.imagetool.core

Provides core functionality of imagetool.

Functions

link_slicer([func, indices, steps, color])

Sync decorated methods across multiple ImageSlicerArea instances.

Classes

ImageSlicerArea([parent, data, cmap, gamma, ...])

A interactive tool based on pyqtgraph for exploring 3D data.

ItoolColorBar(slicer_area, **cbar_kw)

ItoolColorBarItem(slicer_area, **kwargs)

ItoolCursorLine(*args, **kargs)

ItoolCursorSpan(*args, **kargs)

ItoolDisplayObject(axes[, cursor])

ItoolGraphicsLayoutWidget(slicer_area, ...)

ItoolImageItem(axes[, cursor])

ItoolPlotDataItem(axes[, cursor, is_vertical])

ItoolPlotItem(slicer_area, display_axis[, ...])

SlicerLinkProxy(*slicers[, link_colors])

Internal class for handling linked ImageSlicerArea s.

class erlab.interactive.imagetool.core.ImageSlicerArea(parent=None, data=None, cmap='magma', gamma=0.5, zeroCentered=False, rad2deg=False, *, bench=False, image_cls=None, plotdata_cls=None)[source]

Bases: QWidget

A interactive tool based on pyqtgraph for exploring 3D data.

Parameters:
  • parent (QWidget | None) – Parent widget.

  • data (xr.DataArray | npt.ArrayLike | None) – Data to display. The data must have 2 to 4 dimensions.

  • cmap (str | pg.ColorMap) – Default colormap of the data.

  • gamma (float) – Default power law normalization of the colormap.

  • zeroCentered (bool) – If True, the normalization is applied symmetrically from the midpoint of the colormap.

  • rad2deg (bool | Iterable[str]) – If True and data is not None, converts some known angle coordinates to degrees. If an iterable of strings is given, only the coordinates that correspond to the given strings are converted.

  • bench (bool) – Prints the fps on Ctrl + drag, for debug purposes

Signals:
  • sigDataChanged()

  • sigCurrentCursorChanged(index)

  • sigViewOptionChanged()

  • sigCursorCountChanged(n_cursors) – Inherited from erlab.interactive.slicer.ArraySlicer.

  • sigIndexChanged(cursor, axes) – Inherited from erlab.interactive.slicer.ArraySlicer.

  • sigBinChanged(cursor, axes) – Inherited from erlab.interactive.slicer.ArraySlicer.

  • sigShapeChanged() – Inherited from erlab.interactive.slicer.ArraySlicer.

add_cursor()[source]
adjust_layout(horiz_pad=45, vert_pad=30, font_size=11.0, r=(1.2, 1.5, 3.0, 1.0))[source]

Determine the padding and aspect ratios.

Parameters:
  • horiz_pad (int) – Reserved space for the x and y axes.

  • vert_pad (int) – Reserved space for the x and y axes.

  • font_size (float) – Font size in points.

  • r (tuple[float, float, float, float]) – 4 numbers that determine the layout aspect ratios. See notes.

Notes

Axes indices and layout parameters.

     ┌───────────┬───────────┐
r[0] │     1     │     6     │
     │           ├───────────┤
     ├───────────┤     3     │
r[1] │     4     ├───────────┤
     │           │     7     │
     │───────────┼───────┬───┤
     │           │       │   │
r[2] │     0     │   5   │ 2 │
     │           │       │   │
     └───────────┴───────┴───┘
      r[3] * r[2]
center_all_cursors()[source]
center_cursor()[source]
changeEvent(evt)[source]
connect_axes_signals()[source]
connect_signals()[source]
disconnect_axes_signals()[source]
gen_cursor_color(index)[source]
gen_cursor_colors(index)[source]
get_axes(index)[source]
get_axes_widget(index)[source]
get_current_index(axis)[source]
get_current_value(axis, uniform=False)[source]
lock_levels(lock)[source]
on_close()[source]
refresh(cursor, axes=None)[source]
refresh_all(axes=None, only_plots=False)[source]
refresh_current(axes=None)[source]
remove_current_cursor()[source]
remove_cursor(index)[source]
set_bin(axis, value, update=True, cursor=None)[source]
set_bin_all(axis, value, update=True)[source]
set_colormap(cmap=None, gamma=None, reversed=None, highContrast=None, zeroCentered=None, update=True)[source]
set_current_cursor(cursor, update=True)[source]
set_data(data, rad2deg=False)[source]

Set the data to be displayed.

Parameters:
  • data (xr.DataArray | npt.ArrayLike) – The data to be displayed. If a xarray.DataArray is given, the dimensions and coordinates are used to determine the axes of the plots. If a xarray.Dataset is given, the first data variable is used. If a numpy.ndarray is given, it is converted to a xarray.DataArray with default dimensions.

  • rad2deg (bool | Iterable[str]) – If True, converts coords along dimensions that have angle-like names to degrees. If an iterable of strings is given, coordinates for dimensions that correspond to the given strings are converted.

set_index(axis, value, update=True, cursor=None)[source]
set_value(axis, value, update=True, uniform=False, cursor=None)[source]
step_index(axis, value, update=True, cursor=None)[source]
step_index_all(axis, value, update=True)[source]
swap_axes(ax1, ax2)[source]
toggle_snap(value=None)[source]
update_values(values, update=True)[source]

Update only the values of the data.

The coords and shape of the data array are not changed.

Parameters:
  • values (npt.NDArray | xr.DataArray) – The new values to be set. If a xarray.DataArray is given, the dimensions must match the current data array. If a numpy.ndarray is given, the shape must match the current data array. Note that if the user has transposed the current data array, passing a numpy.ndarray with the original shape will fail.

  • update (bool) – If True, the plots are updated after setting the new values.

Note

This method only checks for matching dimension name and shape, and does not check for equal coordinate values.

view_all()[source]
COLORS: tuple[QColor, ...] = (<PyQt6.QtGui.QColor object>, <PyQt6.QtGui.QColor object>, <PyQt6.QtGui.QColor object>, <PyQt6.QtGui.QColor object>, <PyQt6.QtGui.QColor object>, <PyQt6.QtGui.QColor object>, <PyQt6.QtGui.QColor object>)

PySide6.QtGui.QColors for multiple cursors.

property array_slicer: ArraySlicer
property axes: tuple[ItoolPlotItem, ...]

Currently valid subset of self._plots.

property color_locked: bool
property colormap: str | ColorMap
property current_indices: list[int]
property current_values: list[float]
property current_values_uniform: list[float]
property data: xarray.DataArray
property images: tuple[ItoolPlotItem, ...]
property is_linked: bool
property main_image: ItoolPlotItem

Return the main PlotItem.

property n_cursors: int
property profiles: tuple[ItoolPlotItem, ...]
property slices: tuple[ItoolPlotItem, ...]