I want to do something similar and as @imagejan posted, the awesome imagej-omero project can be used.
Below code uses imagej-omero in a python script in ImageJ:
#@ OMEROService omeroService #@ ConvertService convert #@ UIService ui from net.imagej.omero import OMEROLocation from ij import ImagePlus from ij.plugin import Duplicator server = "omero.server.address.com" port = 4064 user = "my-user-name" password = "my-password" image_id = my-imageID omero_location = OMEROLocation(server, port, user, password) omero_session = omeroService.createSession(omero_location) client = omero_session.getClient() dataset = omeroService.downloadImage(client, image_id) ui.show(dataset) # convert dataset to ImagePlus if necessary imp = convert.convert(dataset, ImagePlus) imp.show() # duplicate the imp so its no longer virtual imp2 = Duplicator().run(imp) imp2.show() omero_session.close()
Works like a charm with just a few lines, which is really amazing
Without converting to ImagePlus it would be even less lines.
Concerning this, I have some follow-up questions:
- The dataset opens as “virtual”. How to get a “real” dataset? Converting to ImagePlus and duplicating seems not the best way of doing it.
- Whats the imagej-omero way to get all ImageIDs from a given dataset?