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]