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

Use the correct Leica image series. #22

Merged
merged 5 commits into from
Mar 22, 2022
Merged

Conversation

One-sixth
Copy link
Contributor

Fix #21

@ap--
Copy link
Collaborator

ap-- commented Mar 21, 2022

Hi @One-sixth!

Thank you so much for your contribution ❤️ I'll review the PR right away!

Copy link
Collaborator

@ap-- ap-- left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you implement these two changes that would be great.

We should also add tests with an scn file, but I haven't found a relatively small one yet. Do you have a good resource for a small scn file?

tiffslide/tiffslide.py Outdated Show resolved Hide resolved
tiffslide/tiffslide.py Outdated Show resolved Hide resolved
@One-sixth
Copy link
Contributor Author

If you implement these two changes that would be great.

We should also add tests with an scn file, but I haven't found a relatively small one yet. Do you have a good resource for a small scn file?

Modified.
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

@ap--
Copy link
Collaborator

ap-- commented Mar 22, 2022

Modified. 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.

Nice. Yes this looks like another bug. Let's open a new issue for it.

Copy link
Collaborator

@ap-- ap-- left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, this small change and then we'll merge and release a new version. Thank you so much for your contribution!

tiffslide/tiffslide.py Outdated Show resolved Hide resolved
tiffslide/tiffslide.py Outdated Show resolved Hide resolved
tiffslide/tiffslide.py Outdated Show resolved Hide resolved
tiffslide/tiffslide.py Outdated Show resolved Hide resolved
tiffslide/tiffslide.py Outdated Show resolved Hide resolved
@One-sixth
Copy link
Contributor Author

Modified.

@ap-- ap-- merged commit 769ea95 into Bayer-Group:main Mar 22, 2022
@ap--
Copy link
Collaborator

ap-- commented Mar 22, 2022

Thanks again ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Two series in a scn tiff image, but only first series are used.
2 participants