Hi Zeev,
I can give you an example for how to access the pixels data using Java, that's quite simple using the Java Gateway. I also add an example for how to get the full path of the image files. This is unfortunately not so straightforward, as you already noticed. There's not a simple Gateway method for this, yet, so you'd have to use an HQL query.
Here's the example. I hope this is of any help for you.
- Code: Select all
final long imageID = 1;
LoginCredentials lc = new LoginCredentials("root", "omero", "localhost");
Gateway gw = new Gateway(new SimpleLogger());
ExperimenterData user = gw.connect(lc);
SecurityContext ctx = new SecurityContext(user.getGroupId());
// Access to pixel data:
BrowseFacility browse = gw.getFacility(BrowseFacility.class);
ImageData img = browse.getImage(ctx, imageID);
RawDataFacility rdf = gw.getFacility(RawDataFacility.class);
Plane2D plane = rdf
.getPlane(ctx, img.getDefaultPixels(), 0, 0, 0, true);
double pixel = plane.getPixelValue(0, 0);
System.out.println("Pixel value of image ID=" + imageID
+ " at z=0, t=0, channel=0, x=0, y=0: " + pixel);
// Get the image file paths:
IQueryPrx queryService = gw.getQueryService(ctx);
ParametersI param = new ParametersI();
String filesetQuery = "select fs from Fileset as fs "
+ "join fetch fs.images as image "
+ "left outer join fetch fs.usedFiles as usedFile "
+ "join fetch usedFile.originalFile as f "
+ "join fetch f.hasher " + "where image.id = :imageId";
param.add("imageId", omero.rtypes.rlong(imageID));
List<?> filesets = queryService.findAllByQuery(filesetQuery, param);
Iterator<?> i = filesets.iterator();
Fileset set;
List<FilesetEntry> entries;
Iterator<FilesetEntry> j;
System.out.println("Image files:");
while (i.hasNext()) {
set = (Fileset) i.next();
entries = set.copyUsedFiles();
j = entries.iterator();
while (j.hasNext()) {
FilesetEntry fs = j.next();
OriginalFile file = fs.getOriginalFile();
System.out.println(file.getPath().getValue()
+ file.getName().getValue());
}
}
gw.disconnect();
If you want to write a Java client for accessing your OMERO server, I'd recommend you take a look at the "minimal-omero-client" example:
https://github.com/ome/minimal-omero-client Respectively the documentation with some more examples:
https://www.openmicroscopy.org/site/sup ... /Java.htmlRegards,
Dominik