mahmoodlab / CLAM

Data-efficient and weakly supervised computational pathology on whole slide images - Nature Biomedical Engineering
http://clam.mahmoodlab.org
GNU General Public License v3.0
1.02k stars 340 forks source link

How to downsample from 40x to 20x using create_patches_fp when level 1 is 4 #163

Closed maduc7 closed 1 year ago

maduc7 commented 1 year ago

Hi, I found two related issues about my question: #147 and #162 but I did not understand how to do it.

I want all my slides at the magnification at 20x. I have some slides at 40x magnification. One solution is to take the level 1 when it is 2 but for most of them it is 4. This would lead to 10x instead of 20x. As far as I understood the solution would be to downsample the level 0 by 2 but I could not figure out how to do that using create_patches_fp.py. I found it in create_patches.py but this method takes way too much memory and somehow the custom_downsample parameter was removed.

Thanks

maduc7 commented 1 year ago

Okay I found a solution. If anyone is facing the same issue I did the following for each slide: When creating the patches in create_patches_fp.py:

MohammedHAlali commented 1 year ago
  • if level 1 is 2 take level 1, if level 1 is 4

Could you please explain this sentence a little bit more? What do you mean by "level 1 is 2", and "level 1 is 4"?

Thank you

maduc7 commented 1 year ago

For each level in the pyramid you have an associated downsample level. This associated downsample level can be found in the class WholeSlideImage.py: self.level_downsamples = self._assertLevelDownsamples() For the level 1 you can access it via: level_downsamples[1][0] and check whether this is equal to 2 or 4. Meaning whether the slides at level 1 has been downsampled by 2 or by 4.

Hope this makes more sense

ShiCrazy commented 1 year ago

Maybe you have noticed that there are parameters called "custom_downsample" and "target_patch_size" in extract_features_fp.py? You can change either one if you need.

ljhOfGithub commented 11 months ago

How can I get the original magnification?I don't know TCGA-BRCA is at 40x or 20x.

maduc7 commented 11 months ago

When you open a slide with openslide, some properties are also loaded and one of them is the magnification: wsi = openslide.open_slide(path_to_wsi) magnification = wsi.properties["openslide.objective-power"]

maojy0914 commented 2 weeks ago

some slides in TCGA don't have magnification information as follows: image