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

Urgent: Facing issues with the Level-Dimensions in Leica .scn Images #48

Closed
hitesha14 opened this issue Apr 15, 2019 · 7 comments
Closed

Comments

@hitesha14
Copy link

hello @bgilbert , @jaharkes

Context

Issue type (bug report or feature request): Bug
Operating system ( Windows ): Windows 8.1 and also Tried on Linux Server Machine (ppc64le)
Platform (64-bit):
OpenSlide Python version - 1.1.1:
OpenSlide version - 3.4.1
Slide format - .scn (Leica SCN Images)

Details

I am facing issues regarding the Whole Slide Image for Leica .scn images. Whenever I use the slide.level_dimensions and slide.properties functions from the openslide python package to get information about the dimensions and the overall information about the slide properties, it gives incorrect information about the level dimensions. The information doesn't seem to match the information from the image.

My code details to reproduce to issue are:

import openslide
slide = openslide.OpenSlide('./nims-002.scn')
print("Level count: %d" % slide.level_count)
print("Level dimensions: " + str(slide.level_dimensions))
print("Properties: " + str(slide.properties))
print("Dimensions: " + str(slide.dimensions))

I am hereby attaching the details of 2 Whole Slide Image and their information from the slide.level_dimension and slide.properties function and those extracted from actual Whole Slide Images. The width and height at each and every level dont seem to match to the original scn image at all. As a result I get tiles with huge y-coordinates and few tiles that are completely black. For two different Whole Slide Images, slide.level_dimensions and slide.properties function gives same level values and same dimensions. How is it possible when both of them have different values of the levels and different dimensions all together?

Request you to kindly inspect the issue and let me know about it, as I am unable to proceed with my research.

a2
nims-002.txt

a4
nims-004.txt

Regards,
Hitesha

@jaharkes
Copy link
Member

Not too familiar with Leica, but my assumption is that the low level image data is the full size of what the scanner is capable of and within that space, in the case of nims-002.scn, there is a 62656x38816 sized image at the offset (8884,38525) according to the openslide.bounds- properties. It looks like width and height may be swapped between the tool you're using and the properties openslide extracted from the slide.

The levels you are seeing in the original image include interpolated levels which are probably created by downsampling from a higher level. The actual levels that openslide sees in the slide are,

openslide level 0 == scn base
openslide level 1 == scn level 2
openslide level 2 == scn level 4
openslide level 3 == scn level 6
openslide level 4 == not shown in scn tool

@hitesha14
Copy link
Author

Issue Regarding Levels Extraction of Leica .scn Images

Hello @jaharkes , @bgilbert, @agoode

I see your point. But even then openslide level 1 == scn level 2, openslide level 2 == scn level 4. The numeric values of height and width do not seem to match among them at all even if we assume they are swapped. The interpolated levels which you have mentioned, can you please elaborate on it a bit?
.
I request you to kindly go through the nims-002 and nims-004.txt document once again . The original question remains unanswered ie For two different Whole Slide Images (original images) openslide slide.level_dimensions and slide.properties function gives same level values and same dimensions. How is it possible when both of them have different values of the levels and different dimensions all together?

Also the number of levels mentioned in openslide about the orginal image seems to be wrong. It shows 5 levels when one of the images have 6 levels.

As a result I get tiles with huge y-coordinates(out of range) and few tiles that are completely black. I am attaching the nims-002 and nims-004.txt documents once again.

Request you to go through the document, images and suggest a feasible solution. If it could be fixed so that any other users would not face similar issues. Its very crucial for us to get acurate values of the levels since we are dealing with medical images.

Thanks in Advance

nims-002.txt
nims-004.txt

@jaharkes
Copy link
Member

I believe I did answer your question, so I'll repeat my answer with some more detail.

The actual dimensions of the whole slide image match those of what the scanner is capable of scanning, 153470x53130, and as a result every file will report the same dimensions and pyramid levels in openslide.

Because the scanned slide did not cover the whole scannable area, there is a smaller region of interest which can be found from the openslide.bounds-* properties. The area outside of that region are not actually black, but fully transparent and you are interpreting those tiles as black.

Also openslide only reports actual levels stored in the file which are 1x, ~4x, ~16x, ~64x, and ~256x. The reason why they are not rounded to 4, 16, 64, and 256 is because the highest resolution (1x) in one or both dimensions is not a multiple of any of these so either something has to be added or clipped at the edges, or there is non-linear scaling going on. All other levels reported by the other software you are using are generated from these base levels that are stored in the whole slide image, probably by just scaling the one-higher level down by 2.

The lowest resolution image that the slide contains (256x) would result in a corresponding region of interest of only 271x159 which is probably too small for a meaningful thumbnail which is probably why the thumbnail in the other software is listed at 542x319 (128x).

@hitesha14
Copy link
Author

Hello @jaharkes, @agoode, @bgilbert

I think you completely missed out on one if the points I mentioned. Let me reiterate it again.

I request you to kindly go through the nims-002 and nims-004.txt document once again . The original question remains unanswered ie For two different Whole Slide Images (original images) openslide slide.level_dimensions and slide.properties function gives same level values (width and height) and same dimensions. How is it possible when both of the images have different values (width and height) of the levels and different dimensions all together when I open the original images in Aperio Imagescope Software? You could crosscheck the information about the image (attached above) and the nims-002 and nims-004.txt text documents.

There is a lot of discrepanies with regards to the values retrived by the Openslide , two entirely different images with different levels have same values when extracted using Openslide. Please go through the documents carefully to notice it.

Also the number of levels retrieved by openslide about the orginal image seems to be wrong. It shows 5 levels when one of the images have 6 levels. I have used Aperio ImageScope to open the Images and Inspect them.

Also I would request @bgilbert , @agoode to look into this issue. If any suggestions could be given. What is workaround for such issue?

Regards,
Hitesha

@jaharkes
Copy link
Member

You clearly are not reading my response. Reread my previous reponse until you understand what it says. It explains exactly your issues, why every slide scanned on the same scanner will report the same dimensions for every layer in the pyramid and why the number of levels are different from what the imagescope software is reporting.

For nims-002 the declared region of interest at level 0, is 62656x38816, when you apply the scale factor for level 1 (divide by 3.99989...) as stored in the slide you get 15664x9704, level 2 as stored in the slide scales to 3916x2426 (i.e. divide by 15.99899..), level 3 in the slide is 979x607, level 4 as stored in the slide is 245x152. All other levels that imagescope is reported are computed off of these levels and it isn't showing or using the 256x down scaled level.

There is no issue and no workarounds are needed.

@bgilbert
Copy link
Member

OpenSlide exposes the coordinate plane and image levels as they are encoded in the image file, without conversion or interpolation. On Leica slides, there will only be pixels in part of the image area, but you can use the openslide.bounds-* properties to determine where they are.

As to the extra image levels: could you post the output of running tiffinfo on your sample slides?

@jaharkes
Copy link
Member

Without further feedback, I'm closing this issue.

Feel free to reopen if there is something in the tiffinfo output.

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

No branches or pull requests

3 participants