We're Hiring!

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

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.

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

Postby amarkwirth » Mon Oct 02, 2017 8:18 am

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
amarkwirth
 
Posts: 2
Joined: Thu Sep 28, 2017 10:34 am

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

Postby rleigh » Tue Oct 03, 2017 6:48 pm

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
User avatar
rleigh
 
Posts: 217
Joined: Tue Mar 13, 2012 11:45 am

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

Postby amarkwirth » Wed Oct 04, 2017 12:40 pm

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
amarkwirth
 
Posts: 2
Joined: Thu Sep 28, 2017 10:34 am

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

Postby rleigh » Thu Oct 05, 2017 9:57 am

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
User avatar
rleigh
 
Posts: 217
Joined: Tue Mar 13, 2012 11:45 am


Return to User Discussion [Legacy]

Who is online

Users browsing this forum: No registered users and 1 guest

cron