Cambridge
8th December, 2017
Will Moore, Balaji Ramalingam, Petr Walczysko
$ pip install zeroc-ice>3.5,<3.7
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
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();
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
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