magmap.gui.pixel_display module#

Customize values displayed in Matplotlib figure footers.

class magmap.gui.pixel_display.PixelDisplay(imgs, ax_imgs, shapes=None, offset=None, cmap_labels=None)[source]#

Bases: object

Custom image intensity display in :attr:Axes.format_coord.

Translates pixel coordinates from the axes space to the coordinates of the corresponding original images, accounting for any image manipulations such as downsampling images or resizing overlaid images to the main image. Also translates offset images and colormap transformations.

Variables:
  • imgs (List[np.ndarray]) – Sequence of 2D images whose intensity values will be displayed. Assumes that images are given in the order, (main_image[, labels_image[, next_image, ...]]).

  • ax_imgs (List[matplotlib.image.AxesImage]) – Nested sequence of Matplotlib images corresponding to imgs.

  • shapes (List[int]) – Original 2D image shapes to translate downsampled and/or resized imgs to the original image space, given as either a single sequence or nested sequence corresponding to imgs; defaults to None.

  • offset (List[int], List[List[int]]) – Coordinates offset in the original image space given as (y, x) or a nested sequence of offsets corresponding to``imgs``; defaults to None.

  • cmap_labels (colormaps.DiscreteColormap) – Labels colormap to find the corresponding RGB value; defaults to None, in which case the corresponding colormap in ax_imgs will be used for the labels (index 1) will be used instead.

__call__(x, y)[source]#

Get the pixel display message.

Parameters:
  • x (int) – x-data coordinate.

  • y (int) – y-data coordinate.

Returns:

Message showing x,y coordinates, intensity values, and corresponding RGB label for each overlaid image at the given location.

Return type:

str

get_msg(event)[source]#

Get the pixel display message from a Matplotlib event.

Parameters:

event (matplotlib.backend_bases.Event) – Matplotlib event.

Returns:

The message based on the data coordinates within the first axes in ax_imgs. None if event is not within these axes.

Return type:

str