Project-MONAI / MONAI

AI Toolkit for Healthcare Imaging
https://monai.io/
Apache License 2.0
5.68k stars 1.04k forks source link

`WSIReader` support for reading by mpp or magnification #4980

Open drbeh opened 2 years ago

drbeh commented 2 years ago

In MONAI Pathology WG, we have discussed about the need for being able to read whole slide images at specific resolution (mpp or magnification) in addition to reading at a specific level. The feature request has been made by @cooperlab in cucim repo https://github.com/rapidsai/cucim/issues/389.

I have discussed with cuCIM team about this topic and the conclusion was that it may be more useful to implement this functionality in MONA rather than in cucim for few reasons:

To achieve this, the following functionalities need to be added to MOANI WSIReader:

drbeh commented 2 years ago

@cooperlab what do you think?

cooperlab commented 2 years ago

@drbeh LGTM. The guiding principles here are that developers shouldn't have to do a lot of calculations to determine what they have or what's been done to it, and to make clear what definitions like location correspond to.

NikolasSchmitz commented 11 months ago

Hi @drbeh , as discussed in the MONAI meeting last Tuesday, I will have a look at this issue. In our group we solved a similar problem and this might work here as well!

NikolasSchmitz commented 7 months ago

Hi @drbeh, sorry for the delay, but I am almost done with a first implementation. However, there are a few detailed questions I have to make sure that the function gives the desired output. Should I post them here, or should I ask them in the next monai core meeting?

drbeh commented 7 months ago

Hi @NikolasSchmitz, that is fantastic! It's best if you ask here to make sure that anyone with an answer can help and then followup in our next meeting. Thanks

NikolasSchmitz commented 7 months ago

Okay, sure! Assuming the simple and straightforward solution to this matter, we would take the image at the next lower wsi level and then downscale it to a resolution that fits the user-provided mpp value. In some cases, e.g., if the user-provided mpp is just slightly below the mpp of a certain wsi level, taking the next lower level might lead to unnecessarily compute-intensive downscaling operations. Let's say our wsi has an mpp of 1 at wsi level 1, and an mpp of 0.5 at wsi level 0. The user wants an image of the wsi that has 0.95 mpp. We would then have three options:

  1. Take the image at wsi level 0 and downscale.
  2. Take the image at wsi level 1 and upscale.
  3. Take the image at wsi level 1 without modification (e.g., with the use of tolerance criteria which the user can overwrite).

Personally, I would prefer 3. with a default value for tolerances atol and rtol. If one of the wsi levels is within the user's mpp +/- tolerance, then we can safely select the corresponding wsi level. Otherwise, we can scale down from the next larger representation of the wsi.

I attached three images showing three cases, where case 1 shows the simple and straightforward solution, and cases 2 and 3 show the above described issue without and with a tolerance range. I thought it might help to visualize the problem.

My questions are now:

  1. Is the above a fitting description of what should be implemented? What else is missing? I am pretty sure there are more edge cases we need to take care of, e.g., restricting the user-mpp to be => mpp at wsi level 0 etc.
  2. Should we prevent any form of upscaling, or should we let the user decide?

Image Image Image

cooperlab commented 6 months ago

@NikolasSchmitz my suggestion re upscaling is that users should have to opt-in to enable this. It's uncommon but I really like the option to save compute if the next highest magnification is very large.

drbeh commented 6 months ago

@NikolasSchmitz Just to summarize what we discussed about your questions:

Please do not hesitate to reach out if you have any other questions and thanks for contributing to MONAI.

NikolasSchmitz commented 6 months ago

Thanks for the helpful feedback, everyone! I will create the draft pull request in the next days and implement what we discussed.

NikolasSchmitz commented 5 months ago

This feature was added in #7574