AllenCellModeling / napari-aicsimageio

Multiple file format reading directly into napari using pure Python
GNU General Public License v3.0
33 stars 9 forks source link

Error when opening multi-file OME.TIF (from micro-manager) #39

Closed haesleinhuepf closed 2 years ago

haesleinhuepf commented 2 years ago

Description

Hi all,

after a fresh napari-aicsimagio installation and restarting napari, I see an error in Plugins > Plugin Errors. Edit: Correction! This error happens after drag & drop an OME.TIF (the first of a series of 4GB files) file that was saved by MicroManager.

Do I have to install something else or a different version of something?

==================== Errors for plugin 'aicsimageio-in-memory' ====================

napari version: 0.4.12
plugin package: napari-aicsimageio
version: 0.4.1
module: 

ERROR #1: Error in plugin 'aicsimageio-in-memory', hook 'napari_get_reader': a bytes-like object is required, not 'str' 

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
~/opt/anaconda3/envs/bio_39/lib/python3.9/site-packages/napari/plugins/io.py in read_data_with_plugins(path='/Users/haase/Downloads/S1_ZF_DIBAC_H2B_Cherry_488_561_tseries_1_MMStack_Default.ome.tif', plugin=None)
    133         try:
--> 134             layer_data = reader(path)  # try to read data
        layer_data = None
        reader = None
        path = '/Users/haase/Downloads/S1_ZF_DIBAC_H2B_Cherry_488_561_tseries_1_MMStack_Default.ome.tif'
    135             if layer_data:

~/opt/anaconda3/envs/bio_39/lib/python3.9/site-packages/napari_aicsimageio/core.py in reader_function(path='/Users/haase/Downloads/S1_ZF_DIBAC_H2B_Cherry_488_561_tseries_1_MMStack_Default.ome.tif', in_memory=True)
    212     else:
--> 213         data = _get_full_image_data(img, in_memory=in_memory)
        data = undefined
        global _get_full_image_data = 
        img = 
        in_memory = True
    214         meta = _get_meta(data, img)

~/opt/anaconda3/envs/bio_39/lib/python3.9/site-packages/napari_aicsimageio/core.py in _get_full_image_data(img=, in_memory=True)
     37 ) -> xr.DataArray:
---> 38     if DimensionNames.MosaicTile in img.reader.dims.order:
        global DimensionNames.MosaicTile = 'M'
        img.reader.dims.order = undefined
     39         try:

~/opt/anaconda3/envs/bio_39/lib/python3.9/site-packages/aicsimageio/readers/reader.py in dims(self=)
    513         return self._dims
--> 514 
        global get_image_dask_data = undefined
        self = 
        global dimension_order_out = undefined
        global Optional = typing.Optional
        global str = undefined
        global kwargs = undefined
        global Any = typing.Any
        global da.Array = 
    515     def get_image_dask_data(

~/opt/anaconda3/envs/bio_39/lib/python3.9/site-packages/aicsimageio/readers/reader.py in xarray_dask_data(self=)
    340         return self._xarray_dask_data
--> 341 
        global property = undefined
    342     @property

~/opt/anaconda3/envs/bio_39/lib/python3.9/site-packages/aicsimageio/readers/ome_tiff_reader.py in _read_delayed(self=)
    333         """
--> 334         return metadata_utils.physical_pixel_sizes(
        global metadata_utils.physical_pixel_sizes = undefined
        self.metadata = undefined
        self.current_scene_index = 0
    335             self.metadata, self.current_scene_index

~/opt/anaconda3/envs/bio_39/lib/python3.9/site-packages/aicsimageio/readers/tiff_reader.py in _get_tiff_tags(self=, tiff=)
    173 
--> 174         # Create dict of tag and value
        global tags = undefined
        global Dict = typing.Dict
        global int = undefined
        global str = undefined
    175         tags: Dict[int, str] = {}

~/opt/anaconda3/envs/bio_39/lib/python3.9/site-packages/tifffile/tifffile.py in __get__(self=, instance=, owner=)
   1075         try:
-> 1076             value = self.func(instance)
        value = undefined
        self.func = 
        instance = 
   1077         except AttributeError as exc:

~/opt/anaconda3/envs/bio_39/lib/python3.9/site-packages/tifffile/tifffile.py in series(self=)
   3458         ):
-> 3459             if getattr(self, 'is_' + name, False):
        global getattr = undefined
        self = 
        name = 'shaped'
   3460                 series = getattr(self, '_series_' + name)()

~/opt/anaconda3/envs/bio_39/lib/python3.9/site-packages/tifffile/tifffile.py in __getattr__(self=, name='is_shaped')
   4917                 return False
-> 4918             value = bool(getattr(self.pages[0], name))
        value = undefined
        global bool = undefined
        global getattr = undefined
        self.pages = 
        name = 'is_shaped'
   4919             setattr(self, name, value)

~/opt/anaconda3/envs/bio_39/lib/python3.9/site-packages/tifffile/tifffile.py in __get__(self=, instance=, owner=)
   1075         try:
-> 1076             value = self.func(instance)
        value = undefined
        self.func = 
        instance = 
   1077         except AttributeError as exc:

~/opt/anaconda3/envs/bio_39/lib/python3.9/site-packages/tifffile/tifffile.py in is_shaped(self=)
   7495         for description in (self.description, self.description1):
-> 7496             if not description or '"mibi.' in description:
        description = b'\x82\x00\x7f\x00x\x00z\x00}\x00\x80\x00}\x00t\x00{\x00|\x00r\x00\x86\x00\x7f\x00u\x00\x7f\x00|\x00r\x00~\x00\x81\x00z\x00|\x00x\x00n\x00\x84\x00\x7f\x00u\x00y\x00q\x00u\x00\x84\x00x\x00x\x00|\x00|\x00\x7f\x00\x81\x00{\x00w\x00p\x00\x7f\x00\x7f\x00\x81\x00z\x00y\x00v\x00x\x00s\x00q\x00{'
   7497                 return None

TypeError: a bytes-like object is required, not 'str'

The above exception was the direct cause of the following exception:

PluginCallError                           Traceback (most recent call last)
PluginCallError: Error in plugin 'aicsimageio-in-memory', hook 'napari_get_reader': a bytes-like object is required, not 'str'
================================================================================

Expected Behavior

What did you expect to happen instead?

Reproduction

A minimal example that exhibits the behavior.

Environment

That's my napari info:

napari: 0.4.12
Platform: macOS-12.1-x86_64-i386-64bit
System: MacOS 12.1
Python: 3.9.9 | packaged by conda-forge | (main, Dec 20 2021, 02:41:37) [Clang 11.1.0 ]
Qt: 5.15.2
PyQt5: 5.15.6
NumPy: 1.21.5
SciPy: 1.7.3
Dask: 2021.11.2
VisPy: 0.9.4

OpenGL:
- GL version: 2.1 Metal - 76.3
- MAX_TEXTURE_SIZE: 16384

Screens:
- screen 1: resolution 1800x1169, scale 2.0

Plugins:
- Measurements (Plot profile): 0.2.0
- Measurements (skimage regionprops): 0.2.5
- Search (Plugin): 0.1.2
- Segmentation (split/merge): 0.1.3
- Utilities (skimage regionprops): 0.2.5
- Visualization(B/C): 0.1.5
- aicsimageio-in-memory: 0.4.1
- aicsimageio-out-of-memory: 0.4.1
- clEsperanto: 0.12.0
- console: 0.0.4
- llsz_napari: 0.0.1
- napari-accelerated-pixel-and-object-classification: 0.6.2
- napari-allencell-segmenter: 1.1.3
- napari-clusters-plotter: 0.2.1
- napari-crop: 0.1.3
- napari-curtain: 0.1.0
- napari-folder-browser: 0.1.2
- napari-layer-details-display: 0.1.0
- napari-mouse-controls: 0.1.2
- napari-pyfast-image-processing: 0.0.1
- napari-script-editor: 0.2.5
- napari-segment-blobs-and-things-with-membranes: 0.2.14
- napari-simpleitk-image-processing: 0.1.4
- napari-tabu: 0.1.4
- napari-time-slicer: 0.4.0
- napari-tools-menu: 0.1.8
- napari-workflow-inspector: 0.1.3
- napari-workflow-optimizer: 0.0.1
- napari-workflows: 0.1.1
- natari: 0.2.6
- ome-types: 0.2.9
- scikit-image: 0.4.12
- svg: 0.1.5
evamaxfield commented 2 years ago

Hey @haesleinhuepf! I think this may actually be a tifffile error? The stack trace shows the error as arriving from tifffile:

~/opt/anaconda3/envs/bio_39/lib/python3.9/site-packages/tifffile/tifffile.py in is_shaped(self=)
   7495         for description in (self.description, self.description1):
-> 7496             if not description or '"mibi.' in description:
        description = b'\x82\x00\x7f\x00x\x00z\x00}\x00\x80\x00}\x00t\x00{\x00|\x00r\x00\x86\x00\x7f\x00u\x00\x7f\x00|\x00r\x00~\x00\x81\x00z\x00|\x00x\x00n\x00\x84\x00\x7f\x00u\x00y\x00q\x00u\x00\x84\x00x\x00x\x00|\x00|\x00\x7f\x00\x81\x00{\x00w\x00p\x00\x7f\x00\x7f\x00\x81\x00z\x00y\x00v\x00x\x00s\x00q\x00{'
   7497                 return None
haesleinhuepf commented 2 years ago

Alright. I should try with napari 0.4.13 where I can select napari-aicsimagio to open the file. Ok. thanks for the feedback! I'm closing this as it's obviously the wrong place :-)

tlambert03 commented 2 years ago

also answered in thread, but what I was trying to suggest you try here was the bioformats reader, not the default Tiff reader, so will be curious to hear whether that works for you

evamaxfield commented 2 years ago

^ I think to do that you would need to install bioformats_jar into the same env and then try again