bioio-devs / bioio

Image reading, metadata management, and image writing for Microscopy images in Python
https://bioio-devs.github.io/bioio/OVERVIEW.html
BSD 3-Clause "New" or "Revised" License
18 stars 1 forks source link

bioio-tifffile and bioio-ome-tiff parse ome-tiff metadata differently #38

Open TimMonko opened 3 months ago

TimMonko commented 3 months ago

Describe the Bug

bioio-tifffile.Reader does not properly parse ome-tiff metadata, but bioio-ome-tiff does. There is not notice given to the user which reader is being used, and given bioio-tifffile being required for bioio-ome-tiff to work (see: https://github.com/bioio-devs/bioio-ome-tiff/issues/11), results in bad default behavior where bioio-tifffile is being used as the default reader.

Expected Behavior

I would expect bioio_ome_tiff to be the preferred reader if the given files is an ome-tiff. I would also expect if it is not the default reader, that bioio-tifffile would parse the metadata correctly.

Reproduction

from bioio import BioImage
import bioio_ome_tiff
import bioio_tifffile

img = BioImage(
    img_path,
)

print(img.metadata)
print(f'channels: {img.channel_names}')
print(f'pixel sizes: {img.physical_pixel_sizes}')
<OME xmlns="http://www.openmicroscopy.org/Schemas/OME/2016-06" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.openmicroscopy.org/Schemas/OME/2016-06 http://www.openmicroscopy.org/Schemas/OME/2016-06/ome.xsd" Creator="aicsimageio 4.11.0">
  <Image ID="Image:0">
    <Pixels ID="Pixels:0:0" DimensionOrder="XYZCT" Type="uint16" SizeX="1676" SizeY="1694" SizeZ="1" SizeC="2" SizeT="1" PhysicalSizeX="0.18097556" PhysicalSizeY="0.18097556">
      <Channel ID="Channel:0:0" Name="AF546" SamplesPerPixel="1"/>
      <Channel ID="Channel:0:1" Name="Oblique" SamplesPerPixel="1"/>
      <TiffData IFD="0" PlaneCount="2"/>
    </Pixels>
  </Image>
</OME>
channels: ['Channel:0:0', 'Channel:0:1']
pixel sizes: PhysicalPixelSizes(Z=None, Y=1.0, X=1.0)

The same exact behavior is reproduced with

img = BioImage(
    img_path,
    reader=bioio_ome_tiff.Reader
)

But is very different with the ome_tiff reader

img = BioImage(
    img_path,
    reader=bioio_ome_tiff.Reader
)

print(img.metadata)
print(img.metadata.images)
print(f'channels: {img.channel_names}')
print(f'pixel sizes: {img.physical_pixel_sizes}')

returns:

images=[<1 field_type>] creator='aicsimageio 4.11.0'
[Image(
   id='Image:0',
   pixels={'channels': [{'id': 'Channel:0:0', 'name': 'AF546', 'samples_per_pixel': 1}, {'id': 'Channel:0:1', 'name': 'Oblique', 'samples_per_pixel': 1}], 'tiff_data_blocks': [{'plane_count': 2}], 'id': 'Pixels:0:0', 'dimension_order': <Pixels_DimensionOrder.XYZCT: 'XYZCT'>, 'type': <PixelType.UINT16: 'uint16'>, 'size_x': 1676, 'size_y': 1694, 'size_z': 1, 'size_c': 2, 'size_t': 1, 'physical_size_x': 0.18097556, 'physical_size_y': 0.18097556},
)]
channels: ['AF546', 'Oblique']
pixel sizes: PhysicalPixelSizes(Z=None, Y=0.18097556, X=0.18097556)

Environment

toloudis commented 3 months ago

Thank you for reporting this! In the same environment, could you run bioio.plugins.dump_plugins() and put the output here?

TimMonko commented 3 months ago

This dump_plugins() output suggests that my (ome).tif files could be read by default with the ome reader, so just to double check (since I may have installed bioio-czi after submitting the bug report, but I can't remember), I reran my original code and got the same results as my submission. I suspect looking at the last 3 lines of the output that it's reading the file as a 'tif' and using tifffile instead of the '.tiff' supported via ome

bioio-imageio
  Author  : None
  Version : 1.0.0
  License : MIT License
  Date    : 2024-04-08 12:54:52.611875
  Supported Extensions : 264, 265, 3fr, 3g2, A64, IMT, MCIDAS, PCX, SPIDER, XVTHUMB, a64, adp, amr, amv, apng, arw, asf, avc, avi, avs, avs2, bay, bif, bmp, cdg, cgi, cif, ct, dcr, dib, dip, dng, dnxhd, dv, dvd, erf, exr, fff, gif, icb, if, iiq, ism, jif, jfif, jng, jp2, jpg, mov, mp4, mpo, msp, pdf, pngppm, ps, zif
bioio-ome-tiff
  Author  : None
  Version : 1.0.0
  License : MIT License
  Date    : 2024-04-08 12:54:52.540949
  Supported Extensions : .ome.tiff, .tiff
bioio-czi
  Author  : None
  Version : 1.0.0
  License : MIT License
  Date    : 2024-04-08 12:54:52.727745
  Supported Extensions : .czi
bioio-tifffile
  Author  : None
  Version : 1.0.0
  License : MIT License
  Date    : 2024-04-08 13:03:46.419103
  Supported Extensions : tif, tiff
Plugins for extensions:
.czi: [PluginEntry(entrypoint=EntryPoint(name='bioio-czi', value='bioio_czi', group='bioio.readers'), metadata=<class 'bioio_czi.reader_metadata.ReaderMetadata'>, timestamp=1712598892.7277448)]
.ome.tiff: [PluginEntry(entrypoint=EntryPoint(name='bioio-ome-tiff', value='bioio_ome_tiff', group='bioio.readers'), metadata=<class 'bioio_ome_tiff.reader_metadata.ReaderMetadata'>, timestamp=1712598892.5409486)]
.tiff: [PluginEntry(entrypoint=EntryPoint(name='bioio-ome-tiff', value='bioio_ome_tiff', group='bioio.readers'), metadata=<class 'bioio_ome_tiff.reader_metadata.ReaderMetadata'>, timestamp=1712598892.5409486)]
264: [PluginEntry(entrypoint=EntryPoint(name='bioio-imageio', value='bioio_imageio', group='bioio.readers'), metadata=<class 'bioio_imageio.reader_metadata.ReaderMetadata'>, timestamp=1712598892.6118748)]
265: [PluginEntry(entrypoint=EntryPoint(name='bioio-imageio', value='bioio_imageio', group='bioio.readers'), metadata=<class 'bioio_imageio.reader_metadata.ReaderMetadata'>, timestamp=1712598892.6118748)]
3fr: [PluginEntry(entrypoint=EntryPoint(name='bioio-imageio', value='bioio_imageio', group='bioio.readers'), metadata=<class 'bioio_imageio.reader_metadata.ReaderMetadata'>, timestamp=1712598892.6118748)]
3g2: [PluginEntry(entrypoint=EntryPoint(name='bioio-imageio', value='bioio_imageio', group='bioio.readers'), metadata=<class 'bioio_imageio.reader_metadata.ReaderMetadata'>, timestamp=1712598892.6118748)]
A64: [PluginEntry(entrypoint=EntryPoint(name='bioio-imageio', value='bioio_imageio', group='bioio.readers'), metadata=<class 'bioio_imageio.reader_metadata.ReaderMetadata'>, timestamp=1712598892.6118748)]
IMT: [PluginEntry(entrypoint=EntryPoint(name='bioio-imageio', value='bioio_imageio', group='bioio.readers'), metadata=<class 'bioio_imageio.reader_metadata.ReaderMetadata'>, timestamp=1712598892.6118748)]
MCIDAS: [PluginEntry(entrypoint=EntryPoint(name='bioio-imageio', value='bioio_imageio', group='bioio.readers'), metadata=<class 'bioio_imageio.reader_metadata.ReaderMetadata'>, timestamp=1712598892.6118748)]
PCX: [PluginEntry(entrypoint=EntryPoint(name='bioio-imageio', value='bioio_imageio', group='bioio.readers'), metadata=<class 'bioio_imageio.reader_metadata.ReaderMetadata'>, timestamp=1712598892.6118748)]
SPIDER: [PluginEntry(entrypoint=EntryPoint(name='bioio-imageio', value='bioio_imageio', group='bioio.readers'), metadata=<class 'bioio_imageio.reader_metadata.ReaderMetadata'>, timestamp=1712598892.6118748)]
XVTHUMB: [PluginEntry(entrypoint=EntryPoint(name='bioio-imageio', value='bioio_imageio', group='bioio.readers'), metadata=<class 'bioio_imageio.reader_metadata.ReaderMetadata'>, timestamp=1712598892.6118748)]
a64: [PluginEntry(entrypoint=EntryPoint(name='bioio-imageio', value='bioio_imageio', group='bioio.readers'), metadata=<class 'bioio_imageio.reader_metadata.ReaderMetadata'>, timestamp=1712598892.6118748)]
adp: [PluginEntry(entrypoint=EntryPoint(name='bioio-imageio', value='bioio_imageio', group='bioio.readers'), metadata=<class 'bioio_imageio.reader_metadata.ReaderMetadata'>, timestamp=1712598892.6118748)]
amr: [PluginEntry(entrypoint=EntryPoint(name='bioio-imageio', value='bioio_imageio', group='bioio.readers'), metadata=<class 'bioio_imageio.reader_metadata.ReaderMetadata'>, timestamp=1712598892.6118748)]
amv: [PluginEntry(entrypoint=EntryPoint(name='bioio-imageio', value='bioio_imageio', group='bioio.readers'), metadata=<class 'bioio_imageio.reader_metadata.ReaderMetadata'>, timestamp=1712598892.6118748)]
apng: [PluginEntry(entrypoint=EntryPoint(name='bioio-imageio', value='bioio_imageio', group='bioio.readers'), metadata=<class 'bioio_imageio.reader_metadata.ReaderMetadata'>, timestamp=1712598892.6118748)]
arw: [PluginEntry(entrypoint=EntryPoint(name='bioio-imageio', value='bioio_imageio', group='bioio.readers'), metadata=<class 'bioio_imageio.reader_metadata.ReaderMetadata'>, timestamp=1712598892.6118748)]
asf: [PluginEntry(entrypoint=EntryPoint(name='bioio-imageio', value='bioio_imageio', group='bioio.readers'), metadata=<class 'bioio_imageio.reader_metadata.ReaderMetadata'>, timestamp=1712598892.6118748)]
avc: [PluginEntry(entrypoint=EntryPoint(name='bioio-imageio', value='bioio_imageio', group='bioio.readers'), metadata=<class 'bioio_imageio.reader_metadata.ReaderMetadata'>, timestamp=1712598892.6118748)]
avi: [PluginEntry(entrypoint=EntryPoint(name='bioio-imageio', value='bioio_imageio', group='bioio.readers'), metadata=<class 'bioio_imageio.reader_metadata.ReaderMetadata'>, timestamp=1712598892.6118748)]
avs: [PluginEntry(entrypoint=EntryPoint(name='bioio-imageio', value='bioio_imageio', group='bioio.readers'), metadata=<class 'bioio_imageio.reader_metadata.ReaderMetadata'>, timestamp=1712598892.6118748)]
avs2: [PluginEntry(entrypoint=EntryPoint(name='bioio-imageio', value='bioio_imageio', group='bioio.readers'), metadata=<class 'bioio_imageio.reader_metadata.ReaderMetadata'>, timestamp=1712598892.6118748)]
bay: [PluginEntry(entrypoint=EntryPoint(name='bioio-imageio', value='bioio_imageio', group='bioio.readers'), metadata=<class 'bioio_imageio.reader_metadata.ReaderMetadata'>, timestamp=1712598892.6118748)]
bif: [PluginEntry(entrypoint=EntryPoint(name='bioio-imageio', value='bioio_imageio', group='bioio.readers'), metadata=<class 'bioio_imageio.reader_metadata.ReaderMetadata'>, timestamp=1712598892.6118748)]
bmp: [PluginEntry(entrypoint=EntryPoint(name='bioio-imageio', value='bioio_imageio', group='bioio.readers'), metadata=<class 'bioio_imageio.reader_metadata.ReaderMetadata'>, timestamp=1712598892.6118748)]
cdg: [PluginEntry(entrypoint=EntryPoint(name='bioio-imageio', value='bioio_imageio', group='bioio.readers'), metadata=<class 'bioio_imageio.reader_metadata.ReaderMetadata'>, timestamp=1712598892.6118748)]
cgi: [PluginEntry(entrypoint=EntryPoint(name='bioio-imageio', value='bioio_imageio', group='bioio.readers'), metadata=<class 'bioio_imageio.reader_metadata.ReaderMetadata'>, timestamp=1712598892.6118748)]
cif: [PluginEntry(entrypoint=EntryPoint(name='bioio-imageio', value='bioio_imageio', group='bioio.readers'), metadata=<class 'bioio_imageio.reader_metadata.ReaderMetadata'>, timestamp=1712598892.6118748)]
ct: [PluginEntry(entrypoint=EntryPoint(name='bioio-imageio', value='bioio_imageio', group='bioio.readers'), metadata=<class 'bioio_imageio.reader_metadata.ReaderMetadata'>, timestamp=1712598892.6118748)]
dcr: [PluginEntry(entrypoint=EntryPoint(name='bioio-imageio', value='bioio_imageio', group='bioio.readers'), metadata=<class 'bioio_imageio.reader_metadata.ReaderMetadata'>, timestamp=1712598892.6118748)]
dib: [PluginEntry(entrypoint=EntryPoint(name='bioio-imageio', value='bioio_imageio', group='bioio.readers'), metadata=<class 'bioio_imageio.reader_metadata.ReaderMetadata'>, timestamp=1712598892.6118748)]
dip: [PluginEntry(entrypoint=EntryPoint(name='bioio-imageio', value='bioio_imageio', group='bioio.readers'), metadata=<class 'bioio_imageio.reader_metadata.ReaderMetadata'>, timestamp=1712598892.6118748)]
dng: [PluginEntry(entrypoint=EntryPoint(name='bioio-imageio', value='bioio_imageio', group='bioio.readers'), metadata=<class 'bioio_imageio.reader_metadata.ReaderMetadata'>, timestamp=1712598892.6118748)]
dnxhd: [PluginEntry(entrypoint=EntryPoint(name='bioio-imageio', value='bioio_imageio', group='bioio.readers'), metadata=<class 'bioio_imageio.reader_metadata.ReaderMetadata'>, timestamp=1712598892.6118748)]
dv: [PluginEntry(entrypoint=EntryPoint(name='bioio-imageio', value='bioio_imageio', group='bioio.readers'), metadata=<class 'bioio_imageio.reader_metadata.ReaderMetadata'>, timestamp=1712598892.6118748)]
dvd: [PluginEntry(entrypoint=EntryPoint(name='bioio-imageio', value='bioio_imageio', group='bioio.readers'), metadata=<class 'bioio_imageio.reader_metadata.ReaderMetadata'>, timestamp=1712598892.6118748)]
erf: [PluginEntry(entrypoint=EntryPoint(name='bioio-imageio', value='bioio_imageio', group='bioio.readers'), metadata=<class 'bioio_imageio.reader_metadata.ReaderMetadata'>, timestamp=1712598892.6118748)]
exr: [PluginEntry(entrypoint=EntryPoint(name='bioio-imageio', value='bioio_imageio', group='bioio.readers'), metadata=<class 'bioio_imageio.reader_metadata.ReaderMetadata'>, timestamp=1712598892.6118748)]
fff: [PluginEntry(entrypoint=EntryPoint(name='bioio-imageio', value='bioio_imageio', group='bioio.readers'), metadata=<class 'bioio_imageio.reader_metadata.ReaderMetadata'>, timestamp=1712598892.6118748)]
gif: [PluginEntry(entrypoint=EntryPoint(name='bioio-imageio', value='bioio_imageio', group='bioio.readers'), metadata=<class 'bioio_imageio.reader_metadata.ReaderMetadata'>, timestamp=1712598892.6118748)]
icb: [PluginEntry(entrypoint=EntryPoint(name='bioio-imageio', value='bioio_imageio', group='bioio.readers'), metadata=<class 'bioio_imageio.reader_metadata.ReaderMetadata'>, timestamp=1712598892.6118748)]
if: [PluginEntry(entrypoint=EntryPoint(name='bioio-imageio', value='bioio_imageio', group='bioio.readers'), metadata=<class 'bioio_imageio.reader_metadata.ReaderMetadata'>, timestamp=1712598892.6118748)]
iiq: [PluginEntry(entrypoint=EntryPoint(name='bioio-imageio', value='bioio_imageio', group='bioio.readers'), metadata=<class 'bioio_imageio.reader_metadata.ReaderMetadata'>, timestamp=1712598892.6118748)]
ism: [PluginEntry(entrypoint=EntryPoint(name='bioio-imageio', value='bioio_imageio', group='bioio.readers'), metadata=<class 'bioio_imageio.reader_metadata.ReaderMetadata'>, timestamp=1712598892.6118748)]
jfif: [PluginEntry(entrypoint=EntryPoint(name='bioio-imageio', value='bioio_imageio', group='bioio.readers'), metadata=<class 'bioio_imageio.reader_metadata.ReaderMetadata'>, timestamp=1712598892.6118748)]
jif: [PluginEntry(entrypoint=EntryPoint(name='bioio-imageio', value='bioio_imageio', group='bioio.readers'), metadata=<class 'bioio_imageio.reader_metadata.ReaderMetadata'>, timestamp=1712598892.6118748)]
jng: [PluginEntry(entrypoint=EntryPoint(name='bioio-imageio', value='bioio_imageio', group='bioio.readers'), metadata=<class 'bioio_imageio.reader_metadata.ReaderMetadata'>, timestamp=1712598892.6118748)]
jp2: [PluginEntry(entrypoint=EntryPoint(name='bioio-imageio', value='bioio_imageio', group='bioio.readers'), metadata=<class 'bioio_imageio.reader_metadata.ReaderMetadata'>, timestamp=1712598892.6118748)]
jpg: [PluginEntry(entrypoint=EntryPoint(name='bioio-imageio', value='bioio_imageio', group='bioio.readers'), metadata=<class 'bioio_imageio.reader_metadata.ReaderMetadata'>, timestamp=1712598892.6118748)]
mov: [PluginEntry(entrypoint=EntryPoint(name='bioio-imageio', value='bioio_imageio', group='bioio.readers'), metadata=<class 'bioio_imageio.reader_metadata.ReaderMetadata'>, timestamp=1712598892.6118748)]
mp4: [PluginEntry(entrypoint=EntryPoint(name='bioio-imageio', value='bioio_imageio', group='bioio.readers'), metadata=<class 'bioio_imageio.reader_metadata.ReaderMetadata'>, timestamp=1712598892.6118748)]
mpo: [PluginEntry(entrypoint=EntryPoint(name='bioio-imageio', value='bioio_imageio', group='bioio.readers'), metadata=<class 'bioio_imageio.reader_metadata.ReaderMetadata'>, timestamp=1712598892.6118748)]
msp: [PluginEntry(entrypoint=EntryPoint(name='bioio-imageio', value='bioio_imageio', group='bioio.readers'), metadata=<class 'bioio_imageio.reader_metadata.ReaderMetadata'>, timestamp=1712598892.6118748)]
pdf: [PluginEntry(entrypoint=EntryPoint(name='bioio-imageio', value='bioio_imageio', group='bioio.readers'), metadata=<class 'bioio_imageio.reader_metadata.ReaderMetadata'>, timestamp=1712598892.6118748)]
pngppm: [PluginEntry(entrypoint=EntryPoint(name='bioio-imageio', value='bioio_imageio', group='bioio.readers'), metadata=<class 'bioio_imageio.reader_metadata.ReaderMetadata'>, timestamp=1712598892.6118748)]
ps: [PluginEntry(entrypoint=EntryPoint(name='bioio-imageio', value='bioio_imageio', group='bioio.readers'), metadata=<class 'bioio_imageio.reader_metadata.ReaderMetadata'>, timestamp=1712598892.6118748)]
tif: [PluginEntry(entrypoint=EntryPoint(name='bioio-tifffile', value='bioio_tifffile', group='bioio.readers'), metadata=<class 'bioio_tifffile.reader_metadata.ReaderMetadata'>, timestamp=1712599426.4191027)]
tiff: [PluginEntry(entrypoint=EntryPoint(name='bioio-tifffile', value='bioio_tifffile', group='bioio.readers'), metadata=<class 'bioio_tifffile.reader_metadata.ReaderMetadata'>, timestamp=1712599426.4191027)]
zif: [PluginEntry(entrypoint=EntryPoint(name='bioio-imageio', value='bioio_imageio', group='bioio.readers'), metadata=<class 'bioio_imageio.reader_metadata.ReaderMetadata'>, timestamp=1712598892.6118748)]