-
Notifications
You must be signed in to change notification settings - Fork 2
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
cv2 error #2
Comments
I'm assuming that you are trying to stain normalize the same image as mentioned here: If so that won't work as the TIFF image you are trying to use is just too large to be kept in memory. But if they are not, could you give me exact information regarding which format this image is stored in and what its image pixel dimensions are. OpenCV is not meant to handle such large images. However, FAST can given that the image is stored in a tiled, pyramidal format. Another problem however is that this plugin was not meant to be run on full WSIs, but rather on already extracted image patches. Patches that had for instance been extracted from QuPath. The reason why I haven't made full WSI image support, is because there are so many scenarios where the normalization could fail, but more importantly, normalization is an extremely slow operation and especially if you wish to write a full normalized WSI. Regarding catching where macenko fails and handling that is actually something I am working on in another project, and it seems to be working. What I am essentially doing is skipping patches were macenko was unable to convert, due to for instance the H and E channels not being properly represented in a given image patch. |
Thanks Andre. |
As with any algorithm applied on WSIs it is almost always necessary to apply methods in a patch-wise fashion. The same applies for stain normalization. A problem with this for this exact problem, is that it can occur patches which are not suitable for the stain normalization algorithm and which it might fail or produce strange results. If you were to apply stain normalization across the entire WSI you should observe this on some tissue types and regions.
Regarding reference image, if you are training a model for a specific task and staining (e.g., HE), you should definitely use the same reference image for all future patches and WSIs. That is the whole point of using a reference image. If you suddenly use a different one, for the same model, the colors might change too much for what the model is used to during training, and the whole point of doing "normalization" is gone - you might even get worse performance than if you did no normalization at all! Networks tend to be very sensitive to this, and that is why I most often do stain augmentation instead. But there are use cases where stain normalization has proven to be more useful, such as for mitosis detection, where I believe the task is so difficult that to properly guide the model it is necessary to normalize instead of augment, which preserves information in a standardized manner instead of potentially removing it but making the model more robust. But it can be said that there has been proposed smarter methods of performing WSI-level stain normalization, but these methods tend to be slow and/or are tricky to implement without a reference implementation, so I have not spent time on that. Regarding which reference image to use, I don't have a straight forward answer. But I would choose one that best represents the stain color you think is ideal, and at a resolution that makes sense. If you apply a method on x10 magnification, you probably want to use a reference image at the same resolution. But if I were you I would refer to a recent literature study on this exact topic to see what makes the most sense and what other people have tried. Hope it helps! When I get the time, I will try to add a way to catch faulty patches, to avoid this CLI crashing when applying it on lots of patches. I could either 1) remove the patch entirely or 2) keep the original colors. What do you prefer? Could add an option to toggle between these options. |
Thanks a lot @andreped . This is super detailed. In regard to catching faulty patches, I think adding an option to toggle between the two approaches would be a good idea. |
Hi
I was trying faststain on some tif images and ran into this error
It looks like an opencv error related to input image size. The images are around 800 MB and 1.5GB each (input and reference image).
I tried editing the _ main _.py file and including this
os.environ["OPENCV_IO_MAX_IMAGE_PIXELS"] = str(pow(pow(2,40)))
before importing cv2. This doesn't fix it unfortunately.Cheers
Pradeep
The text was updated successfully, but these errors were encountered: