Closed kayarre closed 2 years ago
large_image usually just uses the openslide library to read svs files (though it could also use libtiff in certain instances).
I notice that all of the problem areas appear to be at the edges, which makes me wonder if there is some bug related to that with your specific image.
Does this happen on multiple svs files, or just this one? For instance there are a variety of svs files here that are know to work correctly: https://data.kitware.com/#item/57b345d28d777f126827dc25 . If those work, but your svs doesn't, can you share the problem svs? If those don't work, then I'd expect there is some issue with library installation.
Have you used Girder? If so, does the svs show properly in the item view? (Girder isn't required; it is just another way to check on what is happening).
For confirmation, I just tried your exact getRegion example with a local svs file and I don't see the problem on large_image master with libraries installed from large_image_wheels.
thank you so much @manthey. I would be happy to share the image in question, should I attached here or somewhere else?
I am not sure how to use girder, I am kinda lost on figuring our how to deploy the HistomicsTk thing with the web interface.
When open the image with openslide, there are only 4 levels, same with qupath, but with large_image it there are 10 levels.
Multi-resolution files often store a subset of possible levels. large_image will optionally synthesize the "missing" levels, and reports that total possible levels. For instance, an image that has all expected levels, a tile from each level covers exactly four tiles (2x2) from the next higher resolution level. Some images skip a level, so a tile in one level covers sixteen or sixtyfour tiles from the next higher resolution level.
If the file is large, it would be best to share somewhere other than here. I can send a one-time-upload link to one of our data services if that is useful (send me an email).
Hi @manthey , I'm having the same problem as @kayarre . I had this happen when using the getRegion
method, the tileIterator
method, and the getThumbnail
method. They all use getRegion
though, so I assume that's the culprit.
I also tested this with one of the .svs files in the folder you shared (i.e. TCGA-02-0010-01Z-00-DX4.07de2e55-a8fe-40ee-9e98-bcb78050b9f7.svs), but it produces the same result.
However, it doesn't happen at all magnification levels. Here I include two iterators using different magnification levels, along with a heatmap of the mean pixel value for each tile converted to grayscale.
tileIterator(scale=dict(magnification=2.5),
tile_size=dict(width=64, height=64),
tile_overlap=dict(x=7, y=7))
Here is the image:
When using a magnification of 20 I don't get the 0-values. For the following iterator:
tileIterator(scale=dict(magnification=20),
tile_size=dict(width=512, height=512),
tile_overlap=dict(x=56, y=56))
I get this heatmap:
I'm trouble reproducing this, which means I'm doing something different that either @kayarre or @frank. Using TCGA-02-0010-01Z-00-DX4.07de2e55-a8fe-40ee-9e98-bcb78050b9f7.svs, if I do:
import large_image
import numpy as np
ts = large_image.getTileSource('TCGA-02-0010-01Z-00-DX4.07de2e55-a8fe-40ee-9e98-bcb78050b9f7.svs')
ti = ts.tileIterator(scale=dict(magnification=2.5), tile_size=dict(width=64, height=64), tile_overlap=dict(x=7, y=7))
print([np.mean(t['tile'][:, :, :3]) for t in ti])
I don't see any zero values.
I'm missing something about how you are doing this.
Hi @manthey , I think that depends on the fact that you're printing the mean pixel brightness. The 0-value areas are divided into squares, themselves divided by narrow 1 or 2 pixel wide strips of pixels that are not 0-valued.
Here's a piece of code to reproduce the issue and more easily see where the 0-valued areas are:
import large_image
import numpy as np
import matplotlib.pyplot as plt
ts = large_image.getTileSource('TCGA-02-0010-01Z-00-DX4.07de2e55-a8fe-40ee-9e98-bcb78050b9f7.svs')
thumb, _ = ts.getThumbnail(width=1000, height=1000, format=large_image.tilesource.TILE_FORMAT_NUMPY)
plt.imshow(thumb)
plt.show()
ti = ts.tileIterator(scale=dict(magnification=2.5), tile_size=dict(width=64, height=64), tile_overlap=dict(x=7, y=7))
print([np.min(np.mean(t['tile'][:, :, :3], axis=2)) for t in ti])
Hi @manthey, I had a look at this a week ago or so and tested it on another machine. It seems that it doesn't have to do with large_image, but instead with openslide. And it's not an error. I'm just running Ubuntu 19 while compatibility is guaranteed only up until Ubuntu 18.04 I believe. I think you can close the issue.
@frank thank you for looking into this more in depth. I am using Ubuntu 18.04 and osx. I need to revisit this using your code to see if it gives me the same issues.
@kayarre What's your conclusion on osx? I'm experiencing the same issue currently
I haven't take the time to check it recently.
On Tue, Apr 21, 2020 at 3:47 AM Yoni Schirris notifications@github.com wrote:
@kayarre https://github.com/kayarre What's your conclusion on osx? I'm experiencing the same issue currently
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/girder/large_image/issues/392#issuecomment-617043752, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACE44VKIU5HRZ6SFBMFJXCLRNVMQZANCNFSM4JIB4ZJA .
-- Kurt Sansom
I'm closing this as unable to reliably reproduce it. Please reopen or file a new issue if you can provide a reasonably small example that can show the problem.
I am using large_image with matplotlib to interactively record rectangles that match the size of the highest resolution tile based on a lower resolution tile. However when I use GetRegion at the lower magnification the returned image has blank pixels.
The input format is .svs and I am outputting to numpy for visualization in matplotlib.
im_low_res, er = image.getRegion( scale=image.getMagnificationForLevel(level=2), format=large_image.tilesource.TILE_FORMAT_NUMPY )
Here is a screen shot of what I am seeing
I also plotted just the first three components of RGBA,
When I open in QuPath the metadata says its a rgb file and not cmyk/rgba. could that explain it ? maybe it's not reading it in the proper format?
I was also able to open the image directly with openslide-python and get a thumbnail without the missing values. when converted to numpy in openslide, it returns an rgb array that is correctly populated..
Is there some kind of encoding step that might be missing.