OMERO ROIs

OMERO Python library providing utilities for handling regions of interest.

exception omero_rois.InvalidBinaryImage(msg='Invalid labels found')[source]

Exception thrown when invalid labels are found

exception omero_rois.NoMaskFound(msg='No mask found')[source]

Exception thrown when no foreground pixels were found in a mask

omero_rois.mask_from_binary_image(binim, rgba=None, z=None, c=None, t=None, text=None, raise_on_no_mask=True)[source]

Create a mask shape from a binary image (background=0)

Parameters:
  • binim (numpy.array) – Binary 2D array, must contain values [0, 1] only

  • int-4-tuple (rgba) – Optional (red, green, blue, alpha) colour

  • z – Optional Z-index for the mask

  • c – Optional C-index for the mask

  • t – Optional T-index for the mask

  • text – Optional text for the mask

  • raise_on_no_mask – If True (default) throw an exception if no mask found, otherwise return an empty Mask

Returns:

An OMERO mask

Raises:
omero_rois.masks_from_label_image(labelim, rgba=None, z=None, c=None, t=None, text=None, raise_on_no_mask=True)[source]

Create mask shapes from a label image (background=0)

Parameters:
  • labelim (numpy.array) – 2D label array

  • int-4-tuple (rgba) – Optional (red, green, blue, alpha) colour

  • z – Optional Z-index for the mask

  • c – Optional C-index for the mask

  • t – Optional T-index for the mask

  • text – Optional text for the mask

  • raise_on_no_mask – If True (default) throw an exception if no mask found, otherwise return an empty Mask

Returns:

A list of OMERO masks in label order ([] if no labels found)

omero_rois.masks_to_labels(masks: List[omero.model.MaskI], mask_shape: Tuple[int, ...], ignored_dimensions: Set[str] = None, check_overlaps: bool = True) Tuple[numpy.ndarray, Dict[int, str], Dict[int, Dict]][source]
Parameters:
  • List[MaskI] (masks) – List of OMERO masks

  • 5-tuple (mask_shape) – the image dimensions (T, C, Z, Y, X), taking into account ignored_dimensions

  • Set[str] (ignored_dimensions) – Ignore these dimensions and set size to 1

  • bool (check_overlaps) – Whether to check for overlapping masks or not

Returns:

Label image with size mask_shape as well as color metadata and dict of other properties.

omero_rois.shape_to_binary_image(shape: omero.model.Shape) Tuple[numpy.ndarray, Tuple[int, ...]][source]

Convert an OMERO shape to a binary image

Parameters:

Shape (shape) – An OMERO shape

Returns:

tuple of - Binary mask - (T, C, Z, Y, X, h, w) tuple of mask settings (T, C, Z may be None)

Indices