We're Hiring!

The best ways to edit OME-XML in OME.TIFF files

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.

The best ways to edit OME-XML in OME.TIFF files

Postby Kouichi_C_Nakamura » Wed Oct 17, 2018 4:25 pm

Hi,

Now I want to edit OME-XML header of OME.TIFF files on Windows 10.

I'm looking for a right tool for this, but things look quite complicated so for.

First, we have the command line tool, and `tiffcomment` command seems the one for me. But then I realized that one needs to build the tool. I may be able to do it, but I'm not familiar with building process, and documentation does not seem beginner friendly.

https://docs.openmicroscopy.org/bio-for ... ation.html

Second, `EditTiffComment.java` seemed to be the one as well. But it doesn't appear to be included in `bioformats_package.jar` in Bio-Formats MATLAB toolbox. I don't really know how to access it.

https://docs.openmicroscopy.org/ome-mod ... /code.html

Third, I found `loci.formats.tools.EditTiffG` class in `bioformats_package.jar`. By the name of it, it seemed ideal one. I ran the following code in MATLAB, and a window opened. I was able to open an OME.TIFF file from File > Open menu of the window. Although the XML is shown in a nonsensical manner without any space or new lines, I guess I can edit it and then Save.

ImageJ's Bio-Formats plugin can show the same XML in a more human-friendly way and that could help to identify which bit to edit in what way.

Code: Select all
bfCheckJavaMemory
g = loci.formats.tools.EditTiffG;


It would be actually better to do it programmatically for automation in case of batch processing.

`ome.xml.model` Java API may also be related, but I have no idea of how to use it. There are so many classes. And apparently, they have gone after 5.2.4.



Is `EditTiffG` the best way for a dummy, then?

Thanks,
Kouichi
Kouichi_C_Nakamura
 
Posts: 165
Joined: Thu Oct 19, 2017 1:35 pm

Re: The best ways to edit OME-XML in OME.TIFF files

Postby dgault » Thu Oct 18, 2018 10:16 am

Normally we would recommend using the tiffcomment tool as in https://docs.openmicroscopy.org/bio-for ... /edit.html

You shouldn't need to build the tools and can download them from the Command Line Tools link at https://www.openmicroscopy.org/bio-formats/downloads/

If you wish to do it programmatically then what this tiffcomment is doing internally is using the standard TiffSaver as below (comment being your newly modified OME-XML) :

Code: Select all
      in = new RandomAccessInputStream(file);
      out = new RandomAccessOutputStream(file);
      TiffSaver saver = new TiffSaver(out, file);
      saver.overwriteComment(in, comment);
User avatar
dgault
Team Member
 
Posts: 208
Joined: Fri Aug 14, 2015 2:56 pm


Return to User Discussion [Legacy]

Who is online

Users browsing this forum: No registered users and 1 guest