Bayer-Group/tiffslide

Some scn test slide errors: Cannot handle data type

Closed this issue · 1 comments

ap-- commented

I found some smaller examples of scn files in openslide-testdata.
https://openslide.cs.cmu.edu/download/openslide-testdata/Leica/

I tested the Leica-1.scn file and it looks fine.

Then I tested Leica-Fluorescence-1.scn and found a new problem about PIL, which may need to open a new issue to discuss this problem. But for this file, openslide can't open it.

a=np.asarray(im2.get_thumbnail([768,768]))


Traceback (most recent call last):
  File "D:\Python\Python39\lib\site-packages\PIL\Image.py", line 2813, in fromarray
    mode, rawmode = _fromarray_typemap[typekey]
KeyError: ((1, 1, 74), '|u1')
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
  File "D:\Python\Python39\lib\site-packages\IPython\core\interactiveshell.py", line 3441, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-11-5d4126449fe6>", line 1, in <module>
    a=np.asarray(im2.get_thumbnail([768,768]))
  File "d:\github_repo\tiffslide\tiffslide\tiffslide.py", line 432, in get_thumbnail
    img = self.read_region((0, 0), level, _level_dimensions)
  File "d:\github_repo\tiffslide\tiffslide\tiffslide.py", line 392, in read_region
    return Image.fromarray(arr)
  File "D:\Python\Python39\lib\site-packages\PIL\Image.py", line 2815, in fromarray
    raise TypeError("Cannot handle this data type: %s, %s" % typekey) from e
TypeError: Cannot handle this data type: (1, 1, 74), |u1
im3=OpenSlide(r"F:\Leica-Fluorescence-1.scn")

Traceback (most recent call last):
  File "D:\Python\Python39\lib\site-packages\IPython\core\interactiveshell.py", line 3441, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-21-6061d42f300d>", line 1, in <module>
    im3=OpenSlide(r"F:\Leica-Fluorescence-1.scn")
  File "D:\Python\Python39\lib\site-packages\openslide\__init__.py", line 160, in __init__
    self._osr = lowlevel.open(filename)
  File "D:\Python\Python39\lib\site-packages\openslide\lowlevel.py", line 136, in _check_open
    raise OpenSlideError(err)
openslide.lowlevel.OpenSlideError: Can't find main image

Originally posted by @One-sixth in #22 (comment)

ap-- commented

This should be fixed via 45fd713