OMERO

There are several module for OMERO that will be documented here.

OMERO Downloader

Use to download an OMERO dataset to a folder.

Adtapted from https://gist.github.com/will-moore/a9f90c97b5b6f1a0da277a5179d62c5a Documentation: https://downloads.openmicroscopy.org/omero/5.3.1/api/python/omero/omero.plugins.html

biom3d.omero_downloader.OBJ_INFO = "obj should be 'Project:ID' or 'Dataset:ID'"

Usage: python download_pdi.py Project:123 my_project_directory

biom3d.omero_downloader.download_attachment(hostname: str, username: str, password: str, session_id: str | None, attachment_id: int, config: bool = True) str | None[source]

Download an attachment (OMERO FileAnnotation) to the local file system.

Parameters:
  • hostname (str) – Hostname of the OMERO server.

  • username (str) – OMERO username.

  • password (str) – OMERO password.

  • session_id (str, optional) – Optional OMERO session ID to reuse an existing session.

  • attachment_id (int) – ID of the FileAnnotation to download.

  • config (bool, default=True) – Whether to save to “configs/” directory. If False, saves to “logs/”.

Returns:

Local path of the downloaded file, or None if not found.

Return type:

str or None

biom3d.omero_downloader.download_datasets(conn: omero.gateway.BlitzGateway, datasets: list, target_dir: str) None[source]

Download datasets using OMERO BlitzGateway connection.

Parameters:
  • conn (BlitzGateway) – Active OMERO connection.

  • datasets (list) – List of OMERO dataset objects to download.

  • target_dir (str) – Path to the directory where the datasets will be downloaded.

Return type:

None

biom3d.omero_downloader.download_datasets_cli(datasets: list, target_dir: str) None[source]

Download datasets using OMERO CLI interface.

Parameters:
  • datasets (list) – A list of OMERO Dataset objects to download.

  • target_dir (str) – Path to the directory where the datasets will be downloaded.

Return type:

None

biom3d.omero_downloader.download_object(username: str, password: str, hostname: str, obj: str, target_dir: str, session_id: str | None = None) tuple[list, str][source]

Connect to OMERO and download a dataset or project via BlitzGateway.

Parameters:
  • username (str) – OMERO username.

  • password (str) – OMERO password.

  • hostname (str) – OMERO server hostname.

  • obj (str) – Object identifier, e.g. “Dataset:123” or “Project:456”.

  • target_dir (str) – Target directory for download.

  • session_id (str, optional) – Existing OMERO session ID to reuse.

Returns:

  • datasets (list) – Represent a list of OMERO datasets

  • target_dir (str) – Final target folder path.

biom3d.omero_downloader.download_object_cli(cli: omero.cli.CLI, obj: str, target_dir: str)[source]

Download a dataset or project using OMERO CLI and its ID.

Parameters:
  • cli (omero.cli.CLI) – Authenticated CLI session.

  • obj (str) – OMERO object string, e.g. “Dataset:123” or “Project:456”.

  • target_dir (str) – Directory where data will be downloaded.

Returns:

  • datasets (list) – Represent a list of OMERO datasets

  • target_dir (str) – Final target folder path.

Examples

with cli_login() as cli:
    download_object_cli(cli, args.obj, args.target)
biom3d.omero_downloader.main(argv: list[str]) None[source]

Entry point for downloading OMERO datasets or projects from command-line arguments.

Parses command-line arguments for object identifier, destination directory, and connection credentials. Then triggers the download using download_object.

Parameters:

argv (list of str) – List of command-line arguments (excluding the script name). Typically sys.argv[1:].

Return type:

None

OMERO Uploader

OMERO Prediction

Note

This module can be replaced by preprocess_train with action pred.

Predictions with Omero.

This script can download data from Omero, compute predictions, and upload back into Omero.

biom3d.omero_pred.run(obj: str, target: str, log: str, dir_out: str, host: str | None = None, user: str | None = None, pwd: str | None = None, upload_id: str | None = None, ext: str = '_predictions', attachment: str | None = None, session_id: str | None = None, skip_preprocessing: bool = False) str | None[source]

Download a dataset or project from Omero, perform predictions, and optionally upload the results back.

Depending on whether the object is a “Dataset” or “Project”, the function handles: - downloading the data (either via Omero API or CLI), - running inference, - optionally uploading the predicted results back to Omero, - cleaning up temporary files if upload is done.

Parameters:
  • obj (str) – Type and ID of the object to process (e.g., “Dataset:123” or “Project:456”).

  • target (str) – Target location for downloading.

  • log (str) – Path to the model folder.

  • dir_out (str) – Path to the directory where predictions should be saved.

  • host (str, optional) – Hostname of the Omero server, if using API authentication.

  • user (str, optional) – Username for Omero authentication.

  • pwd (str, optional) – Password for Omero authentication.

  • upload_id (str, optional) – ID of the project to upload predictions back to. If None, uploading is skipped.

  • ext (str, default="_predictions") – Suffix to append to prediction output directories.

  • attachment (str, optional) – Path to an optional attachment file to include in the upload (e.g., logs or configs).

  • session_id (str, optional) – Session ID for Omero (used for authenticated operations).

  • skip_preprocessing (bool, default=False) – Whether to skip preprocessing steps before prediction.

Returns:

Path to the output directory containing predictions, or None if an error occurred.

Return type:

str or None

Notes

  • The function prints messages that can be parsed remotely with the format “REMOTE:key:value”.

  • Uploading back to Omero is deprecated but still supported.

OMERO Preprocess, Train & Pred