DIAGNijmegen / rse-panimg

Conversion of medical images to MHA and TIFF.
Apache License 2.0
13 stars 5 forks source link

Support parsing OME-TIFF format #107

Closed chrisvanrun closed 6 months ago

chrisvanrun commented 6 months ago

It seems like OME-TIFF format, which contains an OME-XML (https://genomebiology.biomedcentral.com/articles/10.1186/gb-2005-6-5-r47) metadata model in the ImageDescription are seemingly not parsed by panimg.

This metadata also contains physical dimensions (e.g. pixel size in micrometres). The 'regular' tags for this (i.e. XResolution/YResolution and ResolutionUnit) are either set to 0 or to "NONE".

The latter is a problem because panimg explicitly tries to read these to report on this metadata.

chrisvanrun commented 6 months ago

Having read the OME-TIFF documentation a bit more it seems like the physical properties are optional in the XML schema, albeit it is sometimes used as (in the lightmycells challenge):

<Pixels ID="Pixels:0" DimensionOrder="XYZCT" Type="uint16" SignificantBits="12" Interleaved="false" BigEndian="false" 
SizeX="1024" 
SizeY="1024" 
SizeZ="1" 
SizeC="1" 
SizeT="1" 
PhysicalSizeX="0.103580094900373" 
PhysicalSizeXUnit="µm" 
PhysicalSizeY="0.103580094900373" 
PhysicalSizeYUnit="µm"
 PhysicalSizeZ="0.47"
 PhysicalSizeZUnit="µm"
/>

Moreover, the schema contains the following description:

All of the values in the Pixels object when present should match the same value stored in any associated TIFF format (e.g. SizeX should be the same). Where there is a mismatch our readers will take the value from the TIFF structure as overriding the value in the OME-XML. This is simply a pragmatic decision as it increases the likelihood of reading data from a slightly incorrect file.

As such, the physical properties should really be encoded in the correct tiff tags.

chrisvanrun commented 6 months ago

There is a certain irony that the example files from https://docs.openmicroscopy.org/ome-model/5.6.3/ome-tiff/# have incorrect TIFF tags set.