We're Hiring!

Accessing Multiple Images (aka Series) programmatically

Historical discussions about the Bio-Formats library. Please look for and ask new questions at https://forum.image.sc/tags/bio-formats
Please note:
Historical discussions about the Bio-Formats library. Please look for and ask new questions at https://forum.image.sc/tags/bio-formats

If you are having trouble with image files, there is information about reporting bugs in the Bio-Formats documentation. Please send us the data and let us know what version of Bio-Formats you are using. For issues with your code, please provide a link to a public repository, ideally GitHub.

Re: Accessing Multiple Images (aka Series) programmatically

Postby waxenegger » Thu Jul 02, 2015 3:39 am

Do note that the terminology here is slightly tricky. OMEXMLReader refers to reading data from an OME-XML file; OMEXMLService/OMEXMLMetadata refers to using objects from the ome.xml.model package (http://downloads.openmicroscopy.org/bio ... mmary.html) to store metadata in a format-independent manner, for querying or when exporting a file to a different format.


well, that clears up a misconception.

in the end, I think, I'm going to deal with my problem in a similar fashion this reader deals with it:
https://github.com/openmicroscopy/bioformats/blob/v5.1.2/components/formats-gpl/src/loci/formats/in/OperettaReader.java by subclassing from FormatReader and overrriding the relevant sections.

I'm going to extract the individual file location from the meta-data (XML) and read the tiff data via the tiff reader. That way I get my desired group behavior and one file extraction logic over the indices (dimensions).

There is only one piece of advice that would be useful: Aiming at accessing OME XML for the purpose of meta-info extraction I struggle to get through the encapsulation used:

Code: Select all
OMEXMLMetadataRoot root = (OMEXMLMetadataRoot) reader.getMetadataStoreRoot();

so working with the OMEXMLMetadataRoot my way from the root upwards to then iterate over some elements (TiffData e.g.) is not exactly elegant (using array out of bounds to know the end) since I could not find convenient getters to do so (and array length). Did I miss a method to get to the elements by name?

I suppose, alternatively, I could abandon the idea in favor of a more custom solution (since I plan to extend from FormatReader) to do it in a fashion the above mentioned reader does (and writing my own handler for the xml):
Code: Select all
  String xmlData = DataTools.readFile(id);
    OperettaHandler handler = new OperettaHandler();
    XMLTools.parseXML(xmlData, handler);


    ArrayList<Plane> planeList = handler.getPlanes();
    ....
User avatar
waxenegger
 
Posts: 12
Joined: Wed May 20, 2015 10:20 pm

Re: Accessing Multiple Images (aka Series) programmatically

Postby rleigh » Thu Jul 02, 2015 9:30 am

In terms of the metadata encapsulation:

OMEXMLMetadataStore implements both the MetadataStore and MetadataRetrieve methods.
It is a wrapper providing access to a tree of OME-XML model objects (ome.xml.model.*). The root of this model object tree is ome.xml.model.OME, corresponding to the OME root element in the OME-XML ome.xsd schema. The getMetadataStoreRoot() method returns an abstract interface corresponding to whatever provides the concept of "root" metadata object in any concrete implementation of the metadata interfaces. In the case of OMEXMLMetadataStore, that is the OME root element.

For the most part, every method in the MetadataStore and Retrieve interfaces uses indexes into the various lists contained in the tree of OME-XML model objects, with corresponding Count() methods. For example:

Code: Select all
   NonNegativeInteger getTiffDataIFD(int imageIndex, int tiffDataIndex);

To know the valid index values, you would use:

Code: Select all
int getImageCount();
int getTiffDataCount(int imageIndex);


If you were using the OME-XML model objects directly, you could use in ome.xml.model.OME:

Code: Select all
public int sizeOfImageList()
public Image getImage(int index)


This would get you the ome.xml.model.Image object for the image of interest. You would then call on that image:

Code: Select all
public Pixels getPixels()

to get the pixel data for the image, and then on the ome.xml.model.Pixels:

Code: Select all
public int sizeOfTiffDataList()
public TiffData getTiffData(int index)


Finally, with the TiffData object, we can call

Code: Select all
public NonNegativeInteger getIFD()


Using the model objects directly is certainly possible, as you can see. And if you look at the OMEXMLMetadataStoreImpl implementation, you will see that it does the steps outlined above for you, and the same applies to all of its methods, which navigate the object tree appropriately. Essentially, the MetadataStore/Retrive APIs are a convenience to make it easier to manipulate the tree, or at least reduce the amount of effort you need to expend and amount of code you need to write.

I hope this answers your question. If it doesn't please let me know.
User avatar
rleigh
 
Posts: 217
Joined: Tue Mar 13, 2012 11:45 am

Re: Accessing Multiple Images (aka Series) programmatically

Postby waxenegger » Mon Jul 06, 2015 8:16 am

Thank you very much. I will have another look at the interfaces. Hmm, looking at the java doc online I see the size... getters. Wonder what hierarchies I jumped in eclipse in my frenzy to not see that the first time...
User avatar
waxenegger
 
Posts: 12
Joined: Wed May 20, 2015 10:20 pm

Previous

Return to User Discussion [Legacy]

Who is online

Users browsing this forum: Google [Bot] and 1 guest