Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bioio-tiff-glob takes precedence over bioio-tifffile, but does not support the image #7

Open
TimMonko opened this issue Oct 9, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@TimMonko
Copy link

TimMonko commented Oct 9, 2024

Describe the Bug

I have an RGB image that I have been using for tests. It has been working with AICSImage, and now bioio (with bioio-tifffile). If I have bioio-tiff-glob installed, then this results in attempting to read in with bioio-tiff-glob, but the image can't be read. The RGB image in question

Expected Behavior

Either 1. bioio-tiff-glob recognizes that it does not support the image or 2. bioio-tifffile takes precedence since it is less niche in use, perhaps expecting an informed user to input bioio-tiff-glob.Reader if needed.

Reproduction

from bioio import BioImage
import bioio
import bioio_tifffile
from pathlib import Path
bioio.plugin_feasibility_report(r'./resources/RGB.tiff')

outputs this plugin matrix

{'bioio-ome-tiff': PluginSupport(supported=False, error=None),
 'bioio-imageio': PluginSupport(supported=True, error=None),
 'bioio-tiff-glob': PluginSupport(supported=True, error=None),
 'bioio-tifffile': PluginSupport(supported=True, error=None),
 'bioio-ome-zarr': PluginSupport(supported=False, error=None),
 'bioio-sldy': PluginSupport(supported=False, error=None),
 'bioio-czi': PluginSupport(supported=False, error=None),
 'bioio-dv': PluginSupport(supported=False, error=None),
 'bioio-lif': PluginSupport(supported=False, error=None),
 'bioio-nd2': PluginSupport(supported=False, error=None),
 'ArrayLike': PluginSupport(supported=False, error=None)}

this does not work (since it tries to use tiff-glob

file = Path(r'./resources/RGB.tiff')
img = BioImage(file)

error output

{
	"name": "TypeError",
	"message": "Invalid type glob_in - got type <class 'pathlib.WindowsPath'>",
	"stack": "---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[15], line 4
      1 import bioio_tifffile
      3 file = Path(r'./resources/RGB.tiff')
----> 4 img = BioImage(file)
      5 img.dims

File c:\\Users\\timmo\\mambaforge\\envs\
dev-bioio\\Lib\\site-packages\\bioio\\bio_image.py:297, in BioImage.__init__(self, image, reader, reconstruct_mosaic, use_plugin_cache, fs_kwargs, **kwargs)
    287 def __init__(
    288     self,
    289     image: biob.types.ImageLike,
   (...)
    294     **kwargs: Any,
    295 ):
    296     try:
--> 297         self._reader, self._plugin = self._get_reader(
    298             image,
    299             reader,
    300             use_plugin_cache,
    301             fs_kwargs,
    302             **kwargs,
    303         )
    304     except biob.exceptions.UnsupportedFileFormatError:
    305         # When reading from S3 if we failed trying to read
    306         # try reading as an anonymous user otherwise re-raise
    307         # the error
    308         if not str(image).startswith(\"s3://\"):

File c:\\Users\\timmo\\mambaforge\\envs\
dev-bioio\\Lib\\site-packages\\bioio\\bio_image.py:285, in BioImage._get_reader(image, reader, use_plugin_cache, fs_kwargs, **kwargs)
    281 plugin = BioImage.determine_plugin(
    282     image, fs_kwargs=fs_kwargs, use_plugin_cache=use_plugin_cache, **kwargs
    283 )
    284 ReaderClass = plugin.metadata.get_reader()
--> 285 return ReaderClass(image, fs_kwargs=fs_kwargs, **kwargs), plugin

File c:\\Users\\timmo\\mambaforge\\envs\
dev-bioio\\Lib\\site-packages\\bioio_tiff_glob\\reader.py:158, in Reader.__init__(self, glob_in, indexer, scene_glob_character, chunk_dims, dim_order, channel_names, single_file_shape, single_file_dims, fs_kwargs, **kwargs)
    156     file_series = pd.Series(glob_in)
    157 else:
--> 158     raise TypeError(f\"Invalid type glob_in - got type {type(glob_in)}\")
    160 if len(file_series) == 0:
    161     raise ValueError(\"No files found matching glob pattern\")

TypeError: Invalid type glob_in - got type <class 'pathlib.WindowsPath'>"
}

explicitly specifying bioio_tifffile.Reader works

file = Path(r'./resources/RGB.tiff')
img = BioImage(file, reader=bioio_tifffile.Reader)
img.dims

successfuly loads an RGB image

<Dimensions [T: 1, C: 1, Z: 1, Y: 1440, X: 1920, S: 3]>

Environment

  • OS Version: Windows 11
  • bioio-tiff-glob Version: [e.g. 0.5.0]
@TimMonko TimMonko added the bug Something isn't working label Oct 9, 2024
TimMonko added a commit to TimMonko/napari-bioio that referenced this issue Oct 9, 2024
@toloudis
Copy link

toloudis commented Oct 10, 2024

Thanks for reporting this.

I believe we should convert this TypeError to be the equivalent of UnsupportedFileFormatError in order to make this behave as expected.

@toloudis
Copy link

Also Reader._is_supported_image should check for a properly glob-able path.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants