Open joaomamede opened 2 years ago
I agree completely! We will probably use the ome_types package (https://ome-types.readthedocs.io/en/latest/usage.html) to support safe pythonic creation and manipulation of OME metadata, but maybe I'm biased since I'm a co-author!
(For my own purposes I'll insert this reference to issue #72 which mentions channel names)
I like ome_types! but if we can pass a xml into ashlar, we could basically use any valid xml from any custom script.
As a workaround
import ome_types
xml = ome_types.from_tiff("./AshlarStiched.ome.tif")
names = ["DAPI","GFAP","Iba1-555","TUJ1-647",
"DAPI","p24-ahu-488","Nada","CD68-647",
"DAPI","TMEM119-Rbbad","CD11b-Cy3","PGT121Cy5",
"DAPI","HLA-DR","KC57PE","S100b",
]
for i in range(len(xml.images[0].pixels.channels)):
xml.images[0].pixels.channels[i].name = names[i]
f = open("./names.xml","w")
f.write(xml.to_xml())
f.close()
Then
tiffcomment -set names.xml AshlarStiched.ome.tif
thanks @joaomamede , I tried your proposed code, the problem I am having is that the XML that I obtain with "ome_types" is missing several parts of the original XML, most specifically, I am loosing images from the pyramid.
I tried also just running the line xml = ome_types.from_tiff("./AshlarStiched.ome.tif")
and that XML is already missing that information. If I open the XML data from the image, using ImageJ, I can see all the right metadata. Do you know why that might be the reason?
Thank you
@maiskovich The OME-TIFF specification doesn't define any extra OME-XML content for pyramids, but some tools do add annotations describing the sub-resolution dimensions. Could you share the "good" XML with the right metadata that you'd like to see here? A screenshot from ImageJ and/or the output of tiffcomment
would be useful.
Dear Jeremy,
Thank you for your reply, I am working together with @maiskovich on this. The issue he is referring to is that we have these 7 series of the pyramid within our ashlar-stitched ome.tiff
The OME-XML metadata that we get to extract from the bioformats reader on ImageJ is following this structure:
So basically there is this ImageID "Image:n" tag (as you can see in the image) containing the info of the channels. This tag repeats multiple times, taking values from 0 to 6, this is another example:
Our objective is to overwrite this XML and change the channel names from numbers to the actual markers, but when applying the solution Matias above described, there was only one ImageID ="Image:0" tag, with the rest of them vanishing. This came together with the inability to load this image as a pyramidal tiff in image viewers like Napari or ImageJ itself.
I hope this gives a bit more context to our problem
It would be handy to pass a metadata argument (individual dictionary or even ome xml) when creating the metadata with tifffile in the pyramid or list writer.
Basically to name each channel with the stain/protein/antibody real name, plus define a color to each of the channels, so that we don't always open with monochromatic for each channel.