Visualizing WSIs
torchmil.visualize.patches_to_canvas(patches_list, row_array, column_array, patch_size)
Given a list of WSI patches and their corresponding row and column indices, return a canvas with all the patches.
Parameters:
-
patches_list
(list
) –List of WSI patches. Each patch is a numpy array with shape
(patch_size, patch_size, 3)
. -
row_array
(ndarray
) –Array with the row indices of the patches.
-
column_array
(ndarray
) –Array with the column indices of the patches.
-
patch_size
(int
) –Size of the patches.
Returns:
-
canvas
(ndarray
) –Canvas with all the patches. It has shape
(max_row*patch_size, max_column*patch_size, 3)
.
torchmil.visualize.draw_patches_contour(canvas, row_array, column_array, patch_size, contour_prop=0.05)
Given a canvas with WSI patches already drawn, draw a contour around each patch.
Parameters:
-
canvas
(ndarray
) –Canvas with all the patches. It has shape
(max_row*patch_size, max_column*patch_size, 3)
. -
row_array
(ndarray
) –Array with the row indices of the patches.
-
column_array
(ndarray
) –Array with the column indices of the patches.
-
patch_size
(int
) –Size of the patches.
-
contour_prop
(float
, default:0.05
) –Proportion of the patch size that the contour will cover.
Returns:
-
canvas
(ndarray
) –Canvas with the contours drawn. It has shape
(max_row*patch_size, max_column*patch_size, 3)
.
torchmil.visualize.draw_heatmap_wsi(canvas, values, patch_size, row_array, col_array, alpha=0.5, max_color=np.array([0.8392156862745098, 0.15294117647058825, 0.1568627450980392]), min_color=np.array([0.17254901960784313, 0.6274509803921569, 0.17254901960784313]))
Given a canvas with WSI patches already drawn, draw a heatmap on top of the patches.
This heatmap is defined by values
, which should be normalized between 0 and 1.
Parameters:
-
canvas
(ndarray
) –Canvas with all the patches. It has shape
(max_row*patch_size, max_column*patch_size, 3)
. -
values
(ndarray
) –Array with the values of the heatmap.
-
patch_size
(int
) –Size of the patches.
-
row_array
(ndarray
) –Array with the row indices of the patches.
-
col_array
(ndarray
) –Array with the column indices of the patches.
-
alpha
(float
, default:0.5
) –Alpha value of the heatmap.
-
max_color
(ndarray
, default:array([0.8392156862745098, 0.15294117647058825, 0.1568627450980392])
) –Color of the highest value of the heatmap.
-
min_color
(ndarray
, default:array([0.17254901960784313, 0.6274509803921569, 0.17254901960784313])
) –Color of the lowest value of the heatmap.
Returns:
-
canvas
(ndarray
) –Canvas with the heatmap drawn. It has shape
(max_row*patch_size, max_column*patch_size, 3)
.