Visualizing CT scans
torchmil.visualize.slices_to_canvas(slices_list, slice_size)
Given a list of images of CT scan slices, return a canvas with all the slices.
Parameters:
-
slices_list(list[ndarray]) –List of images of CT scan slices. Each image is a numpy array with shape
(slice_size, slice_size, 3). -
slice_size(int) –Size of the slices.
Returns:
-
canvas(ndarray) –Canvas with all the slices. It has shape
(slice_size, bag_len*slice_size, 3).
torchmil.visualize.draw_slices_contour(canvas, slice_size, contour_prop=0.05)
Given a canvas with CT scan slices already drawn, draw a contour around each slice.
Parameters:
-
canvas(ndarray) –Canvas with all the slices. It has shape
(slice_size, bag_len*slice_size, 3). -
slice_size(int) –Size of the slices.
-
contour_prop(float, default:0.05) –Proportion of the slice size that the contour will cover.
Returns:
-
canvas(ndarray) –Canvas with the contours drawn. It has shape
(slice_size, bag_len*slice_size, 3).
torchmil.visualize.draw_heatmap_ctscan(canvas, values, slice_size, 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 CT scan slices already drawn, draw a heatmap on top of the slices.
This heatmap is defined by values, which should be normalized between 0 and 1.
Parameters:
-
canvas(ndarray) –Canvas with all the slices. It has shape
(slice_size, bag_len*slice_size, 3). -
values(ndarray) –List of values to draw the heatmap. Each value should be normalized between 0 and 1.
-
slice_size(int) –Size of the slices.
-
alpha(float, default:0.5) –Alpha value for blending the heatmap with the canvas.
-
max_color(ndarray, default:array([0.8392156862745098, 0.15294117647058825, 0.1568627450980392])) –Color for the maximum value in the heatmap.
-
min_color(ndarray, default:array([0.17254901960784313, 0.6274509803921569, 0.17254901960784313])) –Color for the minimum value in the heatmap.
Returns:
-
canvas(ndarray) –Canvas with the heatmap drawn. It has shape
(slice_size, bag_len*slice_size, 3).