acia.segm.omero.storer#

Classes for OMERO storage interaction

acia.segm.omero.storer.create_roi(updateService, img, shapes)[source]#

Helper function to create the roi object updateService: omero update Service img: omero image object (not the id) shapes: list of omero.model shapes

returns: RoI object

acia.segm.omero.storer.create_roi_fast(updateService, img, shapes)[source]#

Helper function to create the roi object (without waiting) updateService: omero update Service img: omero image object (not the id) shapes: list of omero.model shapes

class acia.segm.omero.storer.OmeroRoIStorer[source]#

Bases: object

Stores and loads overlay results in the roi format (readable by ImageJ)

static storeWithConn(overlay, imageId, conn, force=False)[source]#
Parameters:

imageId (int)

static store(overlay, imageId, username, password, serverUrl, port=4064, secure=True, force=False, conn=None)[source]#

Stores overlay results in OMERO. Uses existing connection if available.

overlay: the overlay to store imageId: omero id of the image sequence username: omero username password: omero password serverUrl: omero web address port: omero port (default: 4064) conn: existing OMERO connection or None. (default: None)

Parameters:
static load(imageId, username, password, serverUrl, port=4064, secure=True, roiId=None, conn=None)[source]#

Loads overlay from omero. Only considers polygons.

imageId: omero id of the image sequence username: omero username password: omero password serverUrl: omero web address port: omero port (default: 4064)

Parameters:
  • imageId (int)

  • username (str)

  • password (str)

  • serverUrl (str)

Return type:

Overlay

static clear(imageId, username=None, password=None, serverUrl=None, port=4064, secure=True, conn=None)[source]#
Parameters:
  • imageId (int)

  • username (str | None)

  • password (str | None)

  • serverUrl (str | None)

class acia.segm.omero.storer.IngoreWithWrapper[source]#

Bases: object

Wrapper to ignore context and do not exit after leaving. Is used for not starting/ending omero connections all the time!

__init__(object)[source]#
class acia.segm.omero.storer.BlitzConn[source]#

Bases: object

Encapsulates standard omero behavior

__init__(username, password, serverUrl, port=4064, secure=True, conn=None, readonly=True)[source]#
make_connection()[source]#
class acia.segm.omero.storer.OmeroSource[source]#

Bases: BlitzConn

Base Class for omero image information. Bundles functionality for image and RoIs.

__init__(imageId, username=None, password=None, serverUrl=None, port=4064, secure=True, conn=None, readonly=True)[source]#
Parameters:
  • imageId (float) – omero image id

  • username (str, optional) – omero username. Not needed when conn is provided. Defaults to None.

  • password (str, optional) – omero password. Not needed when conn is provided. Defaults to None.

  • serverUrl (str, optional) – omero url. Not needed when conn is provided. Defaults to None.

  • port (int, optional) – omero port. Not needed when conn is provided. Defaults to 4064.

  • secure (bool, optional) – Whether to choose secure connection. Defaults to True.

  • conn ([type], optional) – Existing omero connection. Defaults to None.

property rawPixelSize: tuple[omero.model.LengthI, omero.model.LengthI]#

Return the pixel size in omero objects

Returns:

Tuple[LengthI,LengthI] – x and y pixel size in omero objects

property pixelSize: tuple[float, float]#

Return the pixel size in micron

Returns:

Tuple[float,float] – x and y pixel size in micron

property pixel_size: tuple[Quantity, Quantity]#

Return the pixel size in micrometer

Returns:

Tuple[float,float] – x and y pixel size in micrometer

printPixelSize(unit='MICROMETER')[source]#

Output pixel sizes

Parameters:

unit (str, optional) – Name of the unit. Defaults to “MICROMETER”.

class acia.segm.omero.storer.OmeroSequenceSource[source]#

Bases: ImageSequenceSource, OmeroSource, JupyterVisualizationMixin

Uses omero server as a source for images

__init__(imageId, username=None, password=None, serverUrl=None, port=4064, channels=None, z=0, imageQuality=1.0, secure=True, colorList=None, range=None, conn=None, frame_interval=None, timepoints=None, pixel_size=None)[source]#

imageId: id of the image sequence username: omero username password: omero password serverUrl: omero server url port: omero port channels: list of image channels to activate (e.g. include fluorescence channels) z: focus plane imageQuality: quality of the rendered images (1.0=no compression, 0.0=super compression) base_channel: id of the phase contrast channel (visualized over all rgb channels) frame_interval/timepoints: imaging time calibration (pint); see ImageSequenceSource. pixel_size: pixel size (pint); defaults to the OMERO server metadata when omitted.

Parameters:
  • imageId (int)

  • username (str | None)

  • password (str | None)

  • serverUrl (str | None)

property pixel_size#

User-set pixel size (pint), else the OMERO server metadata (x, y).

imageName()[source]#

returns the name of the image

Return type:

str

datasetName()[source]#

returns the name of the dataset

Return type:

str

projectName()[source]#

returns the name of the associated project

Return type:

str

get_frame(frame)[source]#

Get frame at given index.

Parameters:

frame (int)

property num_channels: int#
property num_frames: int#
property frame_list: list[int]#
property size_t: int#
property size_h: int#

Returns the height of the image in pixels.

property size_w: int#

Returns the width of the image in pixels.

property size_c: int#

Returns the number of channels.

toTHWC()[source]#

Convert to THWCSequenceSource

Returns:

THWCSequenceSource – the same image sequence but as THWCSequenceSource

Return type:

THWCSequenceSource

class acia.segm.omero.storer.OmeroRawSource[source]#

Bases: ImageSequenceSource, OmeroSource, JupyterVisualizationMixin

Raw OMERO source: Allows to easily access raw that is, e.g. 16-bit data of your OMERO images

__init__(imageId, username=None, password=None, serverUrl=None, port=4064, secure=True, conn=None, channels=None)[source]#
Parameters:
  • imageId (int)

  • username (str | None)

  • password (str | None)

  • serverUrl (str | None)

property pixel_size#

User-set pixel size (pint), else the OMERO server metadata (x, y).

get_frame(frame)[source]#

Get frame at given index.

property num_channels: int#
property size_t: int#
property size_h: int#

Returns the height of the image in pixels.

property size_w: int#

Returns the width of the image in pixels.

property size_c: int#

Returns the number of channels.

toTHWC()[source]#

Convert to THWCSequenceSource

Returns:

THWCSequenceSource – the same image sequence but as THWCSequenceSource

Return type:

THWCSequenceSource

class acia.segm.omero.storer.OmeroRoISource[source]#

Bases: OmeroSource, RoISource

Source for OMERO RoIs beloging to an OMERO image sequence

__init__(imageId, username, password, serverUrl, port=4064, secure=True, roiSelector=<function OmeroRoISource.<lambda>>, range=None, scale=None, conn=None)[source]#
Parameters:
  • imageId (float) – omero image id

  • username (str, optional) – omero username. Not needed when conn is provided. Defaults to None.

  • password (str, optional) – omero password. Not needed when conn is provided. Defaults to None.

  • serverUrl (str, optional) – omero url. Not needed when conn is provided. Defaults to None.

  • port (int, optional) – omero port. Not needed when conn is provided. Defaults to 4064.

  • secure (bool, optional) – Whether to choose secure connection. Defaults to True.

  • conn ([type], optional) – Existing omero connection. Defaults to None.

get_overlay()[source]#
acia.segm.omero.storer.upload_file(omero_type, omero_id, file_path, conn, mime_type='text/plain', namespace=None)[source]#

Upload a file attachement for an OMERO object (Image, Datase, Project)

Parameters:
  • omero_type (str) – Image, Dataset or Project

  • omero_id (int) – id of the omero object

  • file_path (Path) – file path of the file to upload

  • conn (BlitzGateway) – connection to OMERO

  • mime_type (str, optional) – mime type of the uploaded data. Defaults to “text/plain”.

  • namespace (str, optional) – OMERO namespace of the uploaded file

Returns:

_type_ – created annotation object

acia.segm.omero.storer.download_file_from_object(omero_type, omero_id, file_name, output_path, conn, append_filename=False)[source]#

Download a file annotation with a given name from an OMERO object

Parameters:
  • omero_type (str) – Image, Dataset or Project

  • omero_id (int) – unique id of the OMERO object

  • file_name (str) – the name of the file attachment to download

  • output_path (Path) – output path to save the file

  • conn (_type_) – OMERO connection

  • append_filename (bool, optional) – If true the filename is appended to the output path. Defaults to False.

Raises:

ValueError – _description_

acia.segm.omero.storer.download_file_from_annotation(ann, output_path, append_filename=False)[source]#

Download OMERO file attachment

Parameters:
  • ann (_type_) – OMERO annotation object

  • output_path (Path) – path to write the file to

  • append_filename (bool, optional) – If True treats output_path as a folder and appends the OMERO file name. Defaults to False.

acia.segm.omero.storer.delete_file_annotation(annotation_id, conn)[source]#

Delete an OMERO file attachement

Parameters:
  • annotation_id (int) – id of the annotation object

  • conn (BlitzGateway) – OMERO connection

acia.segm.omero.storer.list_file_annotations(omero_type, omero_id, conn)[source]#

List all file annotations of an OMERO object

Parameters:
  • omero_type (str) – Image, Dataset or Project OMERO object type

  • omero_id (int) – unique OMERO id of the object

  • conn (BlitzGateway) – OMERO connection

Returns:

_type_ – List of OMERO annotation objects for files

acia.segm.omero.storer.replace_file_annotation(omero_type, omero_id, file_path, conn, mime_type='text/plain')[source]#

Replace an OMERO file by a new version.

Deletes existing file attachements on OMERO with the same name and uploads the new file.

Parameters:
  • omero_type (str) – Image, Dataset or Project OMERO object type

  • omero_id (int) – unique OMERO id of the object

  • file_path (Path) – path of the file to upload

  • conn (_type_) – OMERO connection

  • mime_type (str, optional) – MIME type of the data file to upload. Defaults to “text/plain”.

Returns:

_type_ – new annotation object of the uploaded file

acia.segm.omero.storer.print_file_annotations(omero_type, omero_id, conn)[source]#

List all file annotations

Parameters:
  • omero_type (str) – Image, Dataset or Project OMERO object type

  • omero_id (int) – unique OMERO id of the object

  • conn (BlitzGateway) – OMERO connection