Page 1 of 1

beginner-question: how to use metadata.set-methods correctly

PostPosted: Mon Oct 02, 2017 8:18 am
by amarkwirth
Hello,

we are recording image data that we want to store, together with some parameters, for later reconstruction (superresolution microscopy) on our Omero-server

Our first idea was to attach a text file to the Tiff-stacks by using the Python based Omero command line interface, which didn't work for some reason. Maybe it's disabled on the server side or something.
We then decided that using the Tiff-header to store the information would be the smarter choice anyways, so we tried to modify the Java-examples https://github.com/openmicroscopy/biofo ... eTiff.java and https://github.com/openmicroscopy/biofo ... riter.java by calling .set* -methods of the metadata-objects.
We tested different .set[...]-methods and moved them around a bit, but found that neither of the 2 programs wrote the newly added information into the Tiff-file:

MinimumWriter doesn't add an xml-Header to the file at all.
ConvertToOmeTiff adds an XML-header, but the .set-methods of the IMetaData object didn't change the file (checked by comparing md5sums).

Is there a small Java-class that uses one of the "non-necessary" set-methods that we could use as a starting point for our program? Or is there some obvious change that we should have made to the Java classes mentioned above that is required to write the added information into the header?

Thanks,
Andy

Re: beginner-question: how to use metadata.set-methods corre

PostPosted: Tue Oct 03, 2017 6:48 pm
by rleigh
Dear Andy,

The MinimumWriter example should be sufficient to write OME-TIFF with embedded XML. However, it uses the ImageWriter class, which will select the output format based upon the file extension you pass to setId; this must be ".ome.tiff" or another supported OME-TIFF extension such as ".ome.btf" (BigTIFF). Was the extension you used correct? (https://docs.openmicroscopy.org/ome-mod ... ation.html has a list of allowed extensions.) You can use the OMETiffWriter class directly if you want as a direct substitute for ImageWriter if you will only ever write OME-TIFF.

For the metadata, you can see the required ordering of set methods here: https://github.com/ome/ome-model/blob/m ... erter.java or (a bit more legibly) here https://github.com/ome/ome-model/blob/m ... t.cpp#L379 The Bio-Formats MetadataTools.java class and various reader classes under components/formats-*/src/loci/formats/in go through the steps of creating a valid MetadataStore from CoreMetadata and extended reader metadata. You can copy these, or call the set methods yourself in the same order to achieve the same effect.

If you would like to share any of the code you have written, we can take a look over it for any obvious problems. And I'll of course be happy to answer any other questions you might have if the above information is insufficient to answer your original questions.

Kind regards,
Roger

Re: beginner-question: how to use metadata.set-methods corre

PostPosted: Wed Oct 04, 2017 12:40 pm
by amarkwirth
Hi Roger,

Thank you very much for your help! I successfully stored some metadata in an xml-header with this modification of the MinimumWriter:
https://gist.github.com/amarkwirth/0212 ... cfd3f4fea3

Thanks, Andy

Re: beginner-question: how to use metadata.set-methods corre

PostPosted: Thu Oct 05, 2017 9:57 am
by rleigh
Excellent news! Very glad to hear you got it working.

I took a look over your code, and it seems fine to me. Depending upon how you want to use the annotations, you might want to link it to another part of the model as a followup step, e.g. to Image with setImageAnnotationRef(), or any other part with setFooAnnotationRef().


Regards,
Roger