Image Processing with OMERO

Cambridge
8th December, 2017
Will Moore, Balaji Ramalingam, Petr Walczysko

Outline of the Day

  • Presentation: OMERO, model & API
  • Intro to OMERO.web client
  • Client-side: ImageJ/Fiji
    • Manual processing
    • Python-scripted batch processing
  • Server-side: OMERO.script (Python)
    • SciPy Gaussian Filter
  • Scripting OMERO.figure (JavaScript)
  • Jupyter Notebook
    • OMERO Python Hello World
    • CellProfiler
    • R

OMERO is a server with clients

OMERO model objects


See All Objects

Remote Objects & Proxy Services


Developer Documentation

Connecting to OMERO: Python setup

  • Download OMERO.py libs , add to PYTHONPATH
  • Install Python binding for ZeroC Ice
    $ pip install zeroc-ice>3.5,<3.7

Connecting to OMERO: Python code

import omero

client = omero.client("omeroserver.org")
# login to create a session (Service Factory)
session = client.createSession("username", "password")
# get a Stateless Service
queryService = session.getQueryService()
# get a local omero.model.DatasetI
dataset = queryService.get("Dataset", 1)
print dataset               # see what's loaded
print dataset.name.val      # rtypes same as getName().getValue()
print dataset.copyImageLinks()      # omero.UnloadedEntityException!

client.closeSession()           # Free server resourses

Connecting to OMERO: Java Setup

Connecting to OMERO: Java Code

import omero.api.IQueryPrx;
import omero.api.ServiceFactoryPrx;
import omero.model.Dataset;

omero.client client = new omero.client("omeroserver.org");
// create Service Factory
ServiceFactoryPrx session = client.createSession("username", "password");
// get a Stateless Service
IQueryPrx queryService = session.getQueryService();
// get a local omero.model.DatasetI
Dataset dataset = (Dataset) queryService.get("Dataset", 1);
System.err.println(dataset.getId().getValue());
System.err.println(dataset.getName().getValue());
// omero.UnloadedEntityException!
System.err.println(dataset.copyImageLinks());

client.closeSession();

OMERO client libraries


See Docs: Python | Java | Matlab | JSON

Connecting to OMERO: Python BlitzGateway

from omero.gateway import BlitzGateway
# Connect to OMERO
conn = BlitzGateway("username", "password", host="omeroserver.org")
conn.connect()

# Load a Dataset
dataset = conn.getObject("Dataset", 123)    # DatasetWrapper
print dataset.getName()
# To get the wrapped omero.model.DatasetI...
print dataset._obj

# Object Wrappers have their own 'conn' - can load data on the fly
for image in dataset.listChildren():
    print image             # ImageWrapper id=152
    print image.getPrimaryPixels().getPlane(0, 0, 0)   # numpy 2D array

BlitzGateway source code

Connecting to OMERO: Java Gateway

import omero.gateway.LoginCredentials;
import omero.log.SimpleLogger;
import omero.gateway.Gateway;
import omero.gateway.model.ExperimenterData;
import omero.gateway.facility.BrowseFacility;
import omero.gateway.model.ImageData;
import java.util.Collection;
import java.util.Iterator;
import java.util.Arrays;

LoginCredentials cred = new LoginCredentials("username", "password", "omeroserver.org", 4064);
Gateway gateway = new Gateway(new SimpleLogger());
ExperimenterData user = gateway.connect(cred);

BrowseFacility browse = gateway.getFacility(BrowseFacility.class);
// List images in a Dataset
Collection<ImageData> images = browse.getImagesForDatasets(ctx, Arrays.asList(1));
Iterator<ImageData> j = images.iterator();
ImageData image;
while (j.hasNext()) {
    image = j.next();
    System.err.println("image:" + image.getId() + " " + image.getName());
}
Java Gateway API

Server-side vs client-side analysis

Today

  • Introduction to OMERO.web client
  • Client-side: ImageJ/Fiji
    • Manual processing
    • Python-scripted batch processing
  • Server-side: OMERO.script (Python)
    • SciPy Gaussian Filter
  • Scripting OMERO.figure (JavaScript)
  • Jupyter Notebook
    • OMERO Python Hello World
    • CellProfiler
    • R