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.11k stars 362 forks source link

Multi-scale patching #119

Closed yuechen9 closed 2 years ago

yuechen9 commented 2 years ago

I am also trying to work on different magnifications, such as 5x,10x,20x.

Just to check for 40x WSI file:

Thanks

the model training command looks reasonable. So TCGA slides are typically 40X at --level 0. If you want 20x for 256 x 256 patches, you should patch at --level 0, --patch_size 512, --step_size 512, and then when extracting features run --custom_downsample 2, which will downsize the patches by a factor of 2. If you didn't do this then you're most likely training at 40x. The fact that you seem to be getting somewhat worse performance might suggest for this task, 20x should work better.

Thanks for clarifying this.

I did patch at level 0 but the patch size was 265 as well as the step size.

So your suggestion is :

  • repeat the experiment using 512 patch & step-size.
  • repeat the feature extraction using a custom_downsample=2

I want to mention that I have 97% AUC on the 75% of the training, still not like the one in the CLAM paper(98) given that my dataset is bigger. I assume that I should get closer to CLAM AUC or better!

Again many thanks for the explanation. Omnia

Originally posted by @Legendddd in https://github.com/mahmoodlab/CLAM/issues/115#issuecomment-1087652098

fedshyvana commented 2 years ago

it depends on what pyramid levels are available in your 40x wsi file. e.g. is it 40x, 20x, 10x, 5x, ..., or maybe 40x, 10x, 2.5x, ...?

If it's the latter then yes your command looks right.

yuechen9 commented 2 years ago

Thank you for your reply, I will check pyramid levels first.

yuechen9 commented 2 years ago

I found that this depends on scanner, For Hamamatsu (output wsi in .ndpi) downsample: level 0 = 1, level 1 = 2, level 2=4 and so on, each level x2 for level 0 is x40, level 1 will be x20 and so on.

For aperio(output wsi in .svs) downsample: level 0 = 1, level 1 = 4, level 2=64 and so on, each level x4 for level 0 is x40, level 1 will be x10 and so on.

gexinh commented 2 years ago

Sorry to reopen this issue! I am facing the same problem and thus I am curious about how to check pyramid levels you mentioned above. My dataset is TCGA, downloaded as .svs format, and is preprocessed via CLAM which uses the default value of patch level, i.e., "--patch_level: which downsample pyramid level to extract patches from (default is 0, the highest available resolution)".

If the .svs data is x40 at level 0, dose it mean that my TCGA dataset preprocessed by CLAM is x40 magnificantion? If so, it would contradict to the description of CLAM's paper, which TCGA is at x20 magnification. Therefore, should I modify the 'patch level' to get a x20 magnification for TCGA?

I found that this depends on scanner, For Hamamatsu (output wsi in .ndpi) downsample: level 0 = 1, level 1 = 2, level 2=4 and so on, each level x2 for level 0 is x40, level 1 will be x20 and so on.

For aperio(output wsi in .svs) downsample: level 0 = 1, level 1 = 4, level 2=64 and so on, each level x4 for level 0 is x40, level 1 will be x10 and so on.

yuechen9 commented 2 years ago

Sorry to reopen this issue! I am facing the same problem and thus I am curious about how to check pyramid levels you mentioned above. My dataset is TCGA, downloaded as .svs format, and is preprocessed via CLAM which uses the default value of patch level, i.e., "--patch_level: which downsample pyramid level to extract patches from (default is 0, the highest available resolution)".

If the .svs data is x40 at level 0, dose it mean that my TCGA dataset preprocessed by CLAM is x40 magnificantion? If so, it would contradict to the description of CLAM's paper, which TCGA is at x20 magnification. Therefore, should I modify the 'patch level' to get a x20 magnification for TCGA?

I found that this depends on scanner, For Hamamatsu (output wsi in .ndpi) downsample: level 0 = 1, level 1 = 2, level 2=4 and so on, each level x2 for level 0 is x40, level 1 will be x20 and so on. For aperio(output wsi in .svs) downsample: level 0 = 1, level 1 = 4, level 2=64 and so on, each level x4 for level 0 is x40, level 1 will be x10 and so on.

I checked pyramid levels using openslide package, read in then check the info. You will get something like this:

aperio.AppMag': '40' which indicates highest resolution 40x 'openslide.level-count': '4', in total 4 levels 'openslide.level[0].downsample': '1', level 0 is 40/1 'openslide.level[1].downsample': '4.0000683838614091', level 1 is 40/4 'openslide.level[2].downsample': '16.001974108624321', level 2 is 40/16 'openslide.level[3].downsample': '32.006867359118147', level 3 is 40/32

FYI, TCGA contains both x20 and x40 WSIs, but majority of diagnostic slide should be 40x. You need to check image pyramids first.

Hope this answers your question.