Page 1 of 1

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

PostPosted: Wed Oct 17, 2018 4:25 pm
by Kouichi_C_Nakamura
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

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

PostPosted: Thu Oct 18, 2018 10:16 am
by dgault
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);