binli123 / dsmil-wsi

DSMIL: Dual-stream multiple instance learning networks for tumor detection in Whole Slide Image
MIT License
378 stars 88 forks source link

How to run DSMIL pipeline at different magnification #13

Open YohnGuan opened 3 years ago

YohnGuan commented 3 years ago

Hi, I have a dataset which have different magnification at level 0. Some data are at 40x and the rest are at 20x. Since they are at different resolutions, I'm trying to extract the patches and features at 20x resolution for all the WSIs for uniformity of patch magnifications.

Could you please provide more details as to how I could achieve it?

Thank you very much!

binli123 commented 3 years ago

You could try to check the openslide.PROPERTY_NAME_MPP_X property of the file via OpenSlide and grab the level with the same micron per pixel for 20x magnification. Or you can separate them manually into two folders, and for 40x slides you grab level 1 and for 20x slides you grab level 0.

saarthak-kapse commented 3 years ago

Hi,

In the deepzoom_tiler.py code, you have used "n_levels-level[-1]-1" in organize patches function at line 208. I think it will create problem for some of the files in TCGA-LUAD and TCGA-LUSC whose base magnification is 20X. From this code thus you would be extracting 10X and 2.5X when magnification is given (1, 3), Instead of extracting 20X and 5X when base level magnification is 20X.

I think this code is made for base level of 40X and there is no function to take into account the base level magnification. Can you please let me know if I am thinking it correctly or am I missing some fix you have done to incorporate 20X base magnification?

Thanks a lot!

binli123 commented 3 years ago

Hi,

In the deepzoom_tiler.py code, you have used "n_levels-level[-1]-1" in organize patches function at line 208. I think it will create problem for some of the files in TCGA-LUAD and TCGA-LUSC whose base magnification is 20X. From this code thus you would be extracting 10X and 2.5X when magnification is given (1, 3), Instead of extracting 20X and 5X when base level magnification is 20X.

I think this code is made for base level of 40X and there is no function to take into account the base level magnification. Can you please let me know if I am thinking it correctly or am I missing some fix you have done to incorporate 20X base magnification?

Thanks a lot!

Your understanding is correct. For 20x slides the current code grabs level 1 and 3 which would be 10x and 2.5x. You would have to check openslide.PROPERTY_NAME_MPP_X of each slide and grab level 0 and 2 for 20x slides (0.5 MPP) to take this into consideration.

binli123 commented 3 years ago

Hi,

In the deepzoom_tiler.py code, you have used "n_levels-level[-1]-1" in organize patches function at line 208. I think it will create problem for some of the files in TCGA-LUAD and TCGA-LUSC whose base magnification is 20X. From this code thus you would be extracting 10X and 2.5X when magnification is given (1, 3), Instead of extracting 20X and 5X when base level magnification is 20X.

I think this code is made for base level of 40X and there is no function to take into account the base level magnification. Can you please let me know if I am thinking it correctly or am I missing some fix you have done to incorporate 20X base magnification?

Thanks a lot!

I changed the way the tiler works, now it takes levels related to the specified base magnification with this base magnification as level 0. For example, to extract patches at 20x for all slides you could use python deepzoom_tiler.py -m 0 -b 20