-
Notifications
You must be signed in to change notification settings - Fork 378
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
magnitude parameter #145
Comments
hi, could you clarify what you mean by magnitude level? you can access standard metadata such as micron per pixel (mpp) and magnification from the openslide object if that's what you mean. |
does CLAM consider these parameters? Looking the code it seems it considers only the patch_level parameter. Am I wrong? |
correct - it does not. Our typical workflow just specifies the desired magnification level by setting the patch_level paramter. Without modifying the codebase, I believe if you have slides that are of different resolutions, and therefore require different patch_levels, you should be able to compute what the level should be for each slide in advance (e.g. by accessing the metadata), and then just passing that list of patch_levels to the script via the --process_list argument. |
I agree a better a way might be for the script to automatically parse out which patch_level to use, and give the user the option of just specifying the desired magnification level |
Hi @Bontempogianpaolo1, not sure if it's still relevant but I've implemented the functionality you were looking for as it happened I also needed it. Basically, I've created an additional method for the
This function leverages another method,
Then you should be good to go by simply adding a target_spacing argument to the
Remark: this works if
For example, all my slides were acquired with an Aperio scanner, whose pixel spacing at 40x is 0.25 µm/pixel. Hence, by passing Feel free to reach out if you have additional questions. |
There is another prerequisite. The resolution you want to get should be available at one of the levels. Some slides (e.g. in TCGA) have downsample factors [1, 4, 16, 64] for levels [0, 1, 2, 3]. So the micron per pixel (mpp) values you can get with your code for your example are [0.25, 1, 4, 16] microns per pixel. So for 0.5 mpp and a target size of your tile 256 you would need to extract a tile of 512 pixels at 0.25 mpp and then resize it down to 256. So you still need to address this in the process list. |
great, i also encouter this problem for TCGA dataset, as foundation models UNI/CONCH/Prov-Gigapath/TITAN all utilize 256 at 20X magnifcation, setting a patch level is impossible so that i have to resize~ |
I would like to ask, if I want to utilize 256 at 20X magnifcationon the TCGA dataset, how should I set the seg-level and patch-level? |
you can try this pull request, #287 (comment). It's not possible to set magnification directly in the CLAM repo, so that one possible way is to resize the image from 512 to 256 with 40X magnification following #145 (comment). Commonly, you should match the magnification with the patch level first |
In case you're interested, you can look into this repo: https://github.com/clemsgrs/hs2p it's based on CLAM preprocessing, but come with some improvements, including being able to extract patches at a spacing not naturally present in the slide. |
@zaizaiwa @iamownt @clemsgrs, I think we should just focus on resolution in microns per pixel (mpp). If I remember correctly, TCGA has slides from all four combinations:
Because of the occasional non-standard scanning, getting a patch from a 20x magnification does not guarantee that you are working at the resolution UNI was trained on. But if you get a patch at 0.5 mpp, you don't need to worry about the magnification anymore. I did not know about the hs2p repository @clemsgrs mentioned, so I added the support for UNI into TIAToolbox, where you can specify resolution in microns per pixel. Here is an example: https://github.com/TissueImageAnalytics/tiatoolbox/blob/develop/examples/11-import-foundation-models.ipynb |
Hi,
thank you for your work. It is very amazing!
Is it possible to ask the actual magnitude level of the wsi instead of the relative level of the wsi? The reason is that I'm working on a dataset on a different scale magnitude and I have the feeling that using the patch level hyperparameter doesn't guarantee the same scale on every slide. Since I really need this feature I could even help somehow.
Thank you!
The text was updated successfully, but these errors were encountered: