Features / Bugs / Eva Notes
Wanted to give the new libraries a whirl and figured I would make a couple of notes as I go along. I will try to resolve these issues / features this weekend or something as many of them are "optional" / maybe nice for dev and debugging experience.
-
BIOIO_BASE_DIST_NAMEneeds to be updated frombioio-typestobioio-base -
It would be nice to have access to what plugin read the file somehow. Currently on image read, the
__repr__returns:<BioImage [Reader: Reader, Image-is-in-Memory: False]>but it might be better to return<BioImage [plugin: {plugin_name}, Image-is-in-Memory: False]>, esp. because most plugins will generally all use the same class name ofReaderinstead of sayOmeTiffReader, better might be<BioImage [reader_path: {python_module_path_of_reader}, Image-is-in-Memory: False]> -
plugin_cacheshould be made into a set, dict, or deduped list:
In [2]: from bioio.plugins import get_plugins
In [3]: get_plugins()
Out[3]:
[PluginEntry(entrypoint=EntryPoint(name='bioio-tifffile', value='bioio_tifffile', group='bioio.readers'), metadata=<class 'bioio_tifffile.reader_metadata.ReaderMetadata'>, timestamp=1698949015.0319347),
PluginEntry(entrypoint=EntryPoint(name='bioio-ome-tiff', value='bioio_ome_tiff', group='bioio.readers'), metadata=<class 'bioio_ome_tiff.reader_metadata.ReaderMetadata'>, timestamp=1698949015.0319347),
PluginEntry(entrypoint=EntryPoint(name='bioio-ome-zarr', value='bioio_ome_zarr', group='bioio.readers'), metadata=<class 'bioio_ome_zarr.reader_metadata.ReaderMetadata'>, timestamp=1698949015.0319347),
PluginEntry(entrypoint=EntryPoint(name='bioio-lif', value='bioio_lif', group='bioio.readers'), metadata=<class 'bioio_lif.reader_metadata.ReaderMetadata'>, timestamp=1698949015.0319347)]
In [4]: get_plugins()
Out[4]:
[PluginEntry(entrypoint=EntryPoint(name='bioio-tifffile', value='bioio_tifffile', group='bioio.readers'), metadata=<class 'bioio_tifffile.reader_metadata.ReaderMetadata'>, timestamp=1698949015.0319347),
PluginEntry(entrypoint=EntryPoint(name='bioio-ome-tiff', value='bioio_ome_tiff', group='bioio.readers'), metadata=<class 'bioio_ome_tiff.reader_metadata.ReaderMetadata'>, timestamp=1698949015.0319347),
PluginEntry(entrypoint=EntryPoint(name='bioio-ome-zarr', value='bioio_ome_zarr', group='bioio.readers'), metadata=<class 'bioio_ome_zarr.reader_metadata.ReaderMetadata'>, timestamp=1698949015.0319347),
PluginEntry(entrypoint=EntryPoint(name='bioio-lif', value='bioio_lif', group='bioio.readers'), metadata=<class 'bioio_lif.reader_metadata.ReaderMetadata'>, timestamp=1698949015.0319347),
PluginEntry(entrypoint=EntryPoint(name='bioio-tifffile', value='bioio_tifffile', group='bioio.readers'), metadata=<class 'bioio_tifffile.reader_metadata.ReaderMetadata'>, timestamp=1698949015.0319347),
PluginEntry(entrypoint=EntryPoint(name='bioio-ome-tiff', value='bioio_ome_tiff', group='bioio.readers'), metadata=<class 'bioio_ome_tiff.reader_metadata.ReaderMetadata'>, timestamp=1698949015.0319347),
PluginEntry(entrypoint=EntryPoint(name='bioio-ome-zarr', value='bioio_ome_zarr', group='bioio.readers'), metadata=<class 'bioio_ome_zarr.reader_metadata.ReaderMetadata'>, timestamp=1698949015.0319347),
PluginEntry(entrypoint=EntryPoint(name='bioio-lif', value='bioio_lif', group='bioio.readers'), metadata=<class 'bioio_lif.reader_metadata.ReaderMetadata'>, timestamp=1698949015.0319347)]
-
get_pluginsshould be called at the top ofdetermine_reader? Currently cannot read files until manualget_pluginscall (ignore debugging print statements):
In [1]: from bioio import BioImage, plugins
In [2]: img = BioImage("../aicsimageio/aicsimageio/tests/resources/3d-cell-viewer.ome.tiff")
---------------------------------------------------------------------------
UnsupportedFileFormatError Traceback (most recent call last)
Cell In[2], line 1
----> 1 img = BioImage("../aicsimageio/aicsimageio/tests/resources/3d-cell-viewer.ome.tiff")
File ~/active/cell/bioio/bioio/bio_image.py:196, in BioImage.__init__(self, image, reader, reconstruct_mosaic, fs_kwargs, **kwargs)
186 def __init__(
187 self,
188 image: biob.types.ImageLike,
(...)
192 **kwargs: Any,
193 ):
194 if reader is None:
195 # Determine reader class and create dask delayed array
--> 196 ReaderClass = BioImage.determine_reader(
197 image, fs_kwargs=fs_kwargs, **kwargs
198 )
199 else:
200 # Init reader
201 ReaderClass = reader
File ~/active/cell/bioio/bioio/bio_image.py:177, in BioImage.determine_reader(image, fs_kwargs, **kwargs)
174 # If we haven't hit anything yet, we likely don't support this file / object
175 # with the current plugins installed
176 image_type = str(type(image))
--> 177 raise biob.exceptions.UnsupportedFileFormatError(
178 "BioImage",
179 image_type,
180 msg_extra=(
181 "You may need to install an extra format dependency. "
182 "See bioio README for list of some known plugins."
183 ),
184 )
UnsupportedFileFormatError: BioImage does not support the image: '<class 'str'>'. You may need to install an extra format dependency. See bioio README for list of some known plugins.
In [3]: plugins.get_plugins()
Out[3]:
[PluginEntry(entrypoint=EntryPoint(name='bioio-tifffile', value='bioio_tifffile', group='bioio.readers'), metadata=<class 'bioio_tifffile.reader_metadata.ReaderMetadata'>, timestamp=1698949015.0319347),
PluginEntry(entrypoint=EntryPoint(name='bioio-ome-tiff', value='bioio_ome_tiff', group='bioio.readers'), metadata=<class 'bioio_ome_tiff.reader_metadata.ReaderMetadata'>, timestamp=1698949015.0319347),
PluginEntry(entrypoint=EntryPoint(name='bioio-ome-zarr', value='bioio_ome_zarr', group='bioio.readers'), metadata=<class 'bioio_ome_zarr.reader_metadata.ReaderMetadata'>, timestamp=1698949015.0319347),
PluginEntry(entrypoint=EntryPoint(name='bioio-lif', value='bioio_lif', group='bioio.readers'), metadata=<class 'bioio_lif.reader_metadata.ReaderMetadata'>, timestamp=1698949015.0319347)]
In [4]: img = BioImage("../aicsimageio/aicsimageio/tests/resources/3d-cell-viewer.ome.tiff")
In [5]: img
Out[5]: <BioImage [Reader: Reader, Image-is-in-Memory: False]>
-
I think the error that is throw in
determine_readershould include the image path (and parameter type) rather than just the parameter type. For example:UnsupportedFileFormatError: BioImage does not support the image: '<class 'str'>'. You may need to install an extra format dependency. See bioio README for list of some known plugins.is a confusing error because uhhh "what do you mean you don't take astrpath? Do you want apathlib.Pathpath?" -
Related to 2 and 4, I think all of the readers calling their image reading class
Readeris causing namespace / object override issues? I havebioio-lifinstalled locally and can read LIF files directly using it's reader but reading fails frombioiodirectly. I think this is especially true because I installedbioio-tifffilelater thanbioio-ome-tiffand even though I am trying to read an OME-TIFF, it is using thetifffilereader. I also wonder if this is because each of the plugins has this line in their base level__init__.py:from .reader import Readerand that is causing the namespace override, whichever plugin is installed most recently is the only plugin that has a "valid"Readerobject. All the others are just pointers to the newly installedReader?
In [1]: import bioio_lif
In [2]: bioio_lif.Reader("../aicsimageio/aicsimageio/tests/resources/tiled.lif")
Out[2]: <Reader [Image-is-in-Memory: False]>
In [3]: from bioio import BioImage, plugins
In [4]: plugins.get_plugins()
Out[4]:
[PluginEntry(entrypoint=EntryPoint(name='bioio-tifffile', value='bioio_tifffile', group='bioio.readers'), metadata=<class 'bioio_tifffile.reader_metadata.ReaderMetadata'>, timestamp=1698950076.8994923),
PluginEntry(entrypoint=EntryPoint(name='bioio-ome-tiff', value='bioio_ome_tiff', group='bioio.readers'), metadata=<class 'bioio_ome_tiff.reader_metadata.ReaderMetadata'>, timestamp=1698950076.8994923),
PluginEntry(entrypoint=EntryPoint(name='bioio-ome-zarr', value='bioio_ome_zarr', group='bioio.readers'), metadata=<class 'bioio_ome_zarr.reader_metadata.ReaderMetadata'>, timestamp=1698950076.8994923),
PluginEntry(entrypoint=EntryPoint(name='bioio-lif', value='bioio_lif', group='bioio.readers'), metadata=<class 'bioio_lif.reader_metadata.ReaderMetadata'>, timestamp=1698950076.8994923)]
In [5]: BioImage("../aicsimageio/aicsimageio/tests/resources/tiled.lif")
---------------------------------------------------------------------------
UnsupportedFileFormatError Traceback (most recent call last)
Cell In[5], line 1
----> 1 BioImage("../aicsimageio/aicsimageio/tests/resources/tiled.lif")
File ~/active/cell/bioio/bioio/bio_image.py:191, in BioImage.__init__(self, image, reader, reconstruct_mosaic, fs_kwargs, **kwargs)
181 def __init__(
182 self,
183 image: biob.types.ImageLike,
(...)
187 **kwargs: Any,
188 ):
189 if reader is None:
190 # Determine reader class and create dask delayed array
--> 191 ReaderClass = BioImage.determine_reader(
192 image, fs_kwargs=fs_kwargs, **kwargs
193 )
194 else:
195 # Init reader
196 ReaderClass = reader
File ~/active/cell/bioio/bioio/bio_image.py:172, in BioImage.determine_reader(image, fs_kwargs, **kwargs)
170 image_value = str(image)
171 image_type = str(type(image))
--> 172 raise biob.exceptions.UnsupportedFileFormatError(
173 "BioImage",
174 f"{image_value} ({image_type})",
175 msg_extra=(
176 "You may need to install an extra format dependency. "
177 "See bioio README for list of some known plugins."
178 ),
179 )
UnsupportedFileFormatError: BioImage does not support the image: '../aicsimageio/aicsimageio/tests/resources/tiled.lif (<class 'str'>)'. You may need to install an extra format dependency. See bioio README for list of some known plugins.
In [6]: img = BioImage("../aicsimageio/aicsimageio/tests/resources/3d-cell-viewer.ome.tiff")
In [7]: type(img.metadata)
Out[7]: str
I put a quick PR to address item 1. https://github.com/bioio-devs/bioio/pull/19
Item number 5 is addressed here : https://github.com/bioio-devs/bioio/pull/20
Item number 2 is address here: #21
Item numbers 3 & 4 are addressed here: #22
I think this will address item number 6 #23. I did not try all the readers, but I tried ome-tiff sldy ome-zarr and tifffile which seemed problematic in your and Dan's tests
@evamaxfield @SeanLeRoy @toloudis looks like all 6 of these have been addressed! Anything else here?