Visualize Module#
Vizualization module.
- landmarker.visualize.detection_report(true_landmarks, pred_landmarks, dim, dim_orig, pixel_spacing, padding, class_names=None, radius=[2, 2.5, 3, 4], digits=2, unit='mm', output_dict=False)[source]#
Calculate the detection report.
- Parameters:
true_landmarks (Tensor) β torch.Tensor The true landmarks, with shape (n, p, 2). n is the number of samples, p is the number of landmarks, and 2 is respectively the y and x coordinates of the landmarks.
pred_landmarks (Tensor) β torch.Tensor The predicted landmarks, with shape (n, p, 2). n is the number of samples, p is the number of landmarks, and 2 is respectively the y and x coordinates of the landmarks.
dim (tuple[int, ...] | Tensor) β tuple[int, β¦] | torch.Tensor The dimension of the image, with shape (2,). 2 is respectively the height and width of the image.
dim_orig (Tensor) β torch.Tensor The original dimension of the image, with shape (2,). 2 is respectively the height and width of the image.
pixel_spacing (Tensor) β torch.Tensor The pixel spacing of the image, with shape (2,). 2 is respectively the height and width of the image.
padding (Tensor) β torch.Tensor The padding of the image, with shape (2,). 2 is respectively the height and width of the image.
class_names (list[str] | None) β list The names of the landmarks. The default is None.
radius (list[float]) β list[float], optional The radius of the success detection rate (SDR). The default is [2, 2.5, 3, 4].
digits (int) β int, optional The number of digits to round the statistics. The default is 2.
unit (str) β str, optional The unit of distance. The default is βmmβ.
output_dict (bool) β bool, optional Whether to output the detection report as a dictionary. The default is False.
- Returns:
- dict
The detection report. Only output when output_dict is True.
- Return type:
report
- landmarker.visualize.inspection_plot(ds, idx, heatmap_generator=None, save_path=None, fig_title='Landmark Dataset Inspection Plot')[source]#
Plots the transformed image, heatmap, and original image with landmarks for the given dataset indices.
- Parameters:
ds (LandmarkDataset) β Dataset to inspect.
idx (int | Iterable[int]) β Indices of the dataset to inspect.
heatmap_generator (HeatmapGenerator, optional) β Heatmap generator to use. Defaults to None.
save_path (str, optional) β Path to save the plot to. If None, the plot is not saved. Defaults to None.
fig_title (str, optional) β Title of the figure. Defaults to βLandmark Dataset Inspection Plotβ.
- landmarker.visualize.plot_cpe(true_landmarks, pred_landmarks, dim, dim_orig, pixel_spacing, padding, class_names=None, group=True, title=None, save_path=None, stat='proportion', unit='mm', kind='ecdf')[source]#
Calculate the cumulative point-to-point error (CPE) and plot the CPE curve.
- Parameters:
y_true β numpy.ndarray The true values of the target variable, with shape (n, p, 2). n is the number of samples, p is the number of landmarks, and 2 is respectively the y and x coordinates of the landmarks.
y_pred β numpy.ndarray The predicted values of the target variable, with shape (n, p, 2). n is the number of samples, p is the number of landmarks, and 2 is respectively the y and x coordinates of the landmarks.
class_names (list[str] | None) β list The names of the landmarks. The default is None.
group (bool) β bool, optional Whether to group the CPE curves by landmarks. The default is True.
title (str | None) β str, optional The title of the plot. The default is None.
save_path (str | None) β str, optional The path to save the plot. The default is None.
stat (str) β str, optional The type of statistic to plot. The default is βproportionβ.
unit (str) β str, optional The unit of distance. The default is βmmβ.
kind (str) β str, optional The type of plot. The default is βecdfβ. Possible values are βecdfβ, βkdeβ, and βhistβ.
true_landmarks (Tensor) β
pred_landmarks (Tensor) β
dim (tuple[int, ...] | Tensor) β
dim_orig (Tensor) β
pixel_spacing (Tensor) β
padding (Tensor) β
- landmarker.visualize.prediction_inspect_plot(ds, model, idx, activation=Identity(), save_path=None, fig_title='Landmark Prediction Model Inspection Plot')[source]#
Plots the transformed image, predicted heatmap, and original image with predicted and true landmarks for the given dataset indices.
- Parameters:
ds (LandmarkDataset) β Dataset to inspect.
model (nn.Module) β Model to use for prediction.
idx (int | Sequence[int]) β Indices of the dataset to inspect.
activation (nn.Module, optional) β Activation function to use. Defaults to nn.Identity().
save_path (str, optional) β Path to save the plot to. If None, the plot is not saved. Defaults to None.
fig_title (str, optional) β Title of the figure. Defaults to βLandmark Prediction Model Inspection Plotβ.