Metrics Module#
Metrics module.
- landmarker.metrics.point_error(true_landmarks, pred_landmarks, dim=None, dim_orig=None, pixel_spacing=None, padding=None, reduction='mean')[source]#
Calculates the point error between true and predicted landmarks. The point error is the mean Euclidean distance between the true and predicted landmarks. If the pixel spacing is given, the point error is calculated in mm. If the pixel spacing is not given, the point error is calculated in pixels. If the dim and dim_orig are given, the landmarks are rescaled to the original image size.
- Parameters:
true_landmarks (torch.Tensor) β true landmarks
pred_landmarks (torch.Tensor) β predicted landmarks
dim (Optional[tuple[int, ...] | torch.Tensor], optional) β image size. Defaults to None.
dim_orig (Optional[torch.Tensor], optional) β original image size. Defaults to None.
pixel_spacing (Optional[torch.Tensor], optional) β pixel spacing. Defaults to None.
padding (Optional[torch.Tensor], optional) β padding. Defaults to None.
reduction (str, optional) β reduction method. Defaults to βmeanβ. Can be βmeanβ, βnanmeanβ, or βnoneβ.
- landmarker.metrics.sdr(radius, true_landmarks, pred_landmarks, dim=None, dim_orig=None, pixel_spacing=None, padding=None, nanmean=False)[source]#
Calculates the success detection rate (SDR), which is the percentage of predicted landmarks with a point error smaller or equal than the radius.
- Parameters:
radius (Iterable | float) β radius or list of radii
true_landmarks (torch.Tensor) β true landmarks
pred_landmarks (torch.Tensor) β predicted landmarks
dim (Optional[tuple[int, ...] | torch.Tensor], optional) β image size. Defaults to None.
dim_orig (Optional[torch.Tensor], optional) β original image size. Defaults to None.
pixel_spacing (Optional[torch.Tensor], optional) β pixel spacing. Defaults to None.
padding (Optional[torch.Tensor], optional) β padding. Defaults to None.
nanmean (bool, optional) β use nanmean instead of mean. Defaults to False.
- Returns:
SDR or dictionary of SDRs for each radius
- Return type:
float | dict[float, float]