Closed Rukhmini closed 1 year ago
Hi, @Rukhmini ! Thank you for your interest. You can find the code in
decoupling.py
inference.py
You can directly run decoupling.py
to generate heatmaps. If you have any other questions, please let me know ;)
Thank you for your response. In the "inference.py" code "prob_1M05.npy" is saved. I was trying to work with the visualization.py code where you have defined the "generate_heatmap" to save the probability heatmap for 8 classes. How do you get the prob_matrix which is one of the inputs to the function(matrix_path). I am using a different code where I have the probabilities for 8 classes from the softmax layer now I want to use your "generate_heatmap" function to save the heatmaps for 8 classes. Also, what does "prob_matrix[:,:,select_label]" contain? Can you please let me know? Thanks!
The prob_matrix
refers to heatmaps.npy
, or prob_1M05.npy
in the code, which is the probability maps numpy tensor for 8 classes. The prob_matrix
is a 3 dimensional tensor ---- prob_matrix[width of heatmaps, hight of heatmaps, classes = 8]
. So you can select the class you want to plot heatmap
with prob_matrix[:,:,select_label]
.
I am using a different code where I have the probabilities for 8 classes from the softmax layer now I want to use your "generate_heatmap" function to save the heatmaps for 8 classes.
You may check the output tensor shape.
If the shape refers to a 8-dimensional vector, the output is the patch classification result, you need to stitch together the classification results of all patches of a WSI according to the spatial distribution. Then you can get heatmaps.npy
and plot heatmaps.
If the shape refers to [width of heatmaps, hight of heatmaps, classes = 8] tensor, you can directly select the class you want to plot.
Hope this will help you : )
Thanks a lot. How do you determine the height and width of the heatmaps?
The WSI is cut into many non-overlap patches. We use classification networks to classify all of the patches and stitch them together according to their spatial location. For example, if the WSI is 20000x30000 pixels, and each patch is 100x100 pixels. Then the width of the heatmap of WSI is 20000/100 = 200, the hight of the heatmap of WSI is 30000/100 = 300. The detail can be find in methods of our paper.
m', n' is the width and height in this work. The code of this part is in here: https://github.com/Biooptics2021/PathFinder/blob/43da3deaabadd00f0338ef2de6d56dc4855da100/WSI_decoupling/inference.py#L298
Thanks, it works now :)
How do you generate the "heatmaps .npy"? Which part of the code does that?