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โ.