panoptica.utils

panoptica.metrics.assd

panoptica.metrics.assd.__surface_distances(reference, prediction, voxelspacing=None, connectivity=1)

The distances between the surface voxel of binary objects in result and their nearest partner surface voxel of a binary object in reference.

panoptica.metrics.assd._average_surface_distance(reference, prediction, voxelspacing=None, connectivity=1)
panoptica.metrics.assd._average_symmetric_surface_distance(reference, prediction, voxelspacing=None, connectivity=1, *args) float

ASSD is computed by computing the average of the bidrectionally computed ASD.

panoptica.metrics.assd._compute_instance_average_symmetric_surface_distance(ref_labels: ndarray, pred_labels: ndarray, ref_instance_idx: int | None = None, pred_instance_idx: int | None = None, voxelspacing=None, connectivity=1)
panoptica.metrics.assd._distance_transform_edt(input_array: ndarray, sampling=None, return_distances=True, return_indices=False)

panoptica.metrics.dice

panoptica.metrics.dice._compute_dice_coefficient(reference: ndarray, prediction: ndarray, *args) float

Compute the Dice coefficient between two binary masks.

The Dice coefficient measures the similarity or overlap between two binary masks. It is defined as:

Dice = (2 * intersection) / (area_mask1 + area_mask2)

Parameters:
  • reference (np.ndarray) – Reference binary mask.

  • prediction (np.ndarray) – Prediction binary mask.

Returns:

Dice coefficient between the two binary masks. A value between 0 and 1, where higher values indicate better overlap and similarity between masks.

Return type:

float

panoptica.metrics.dice._compute_instance_volumetric_dice(ref_labels: ndarray, pred_labels: ndarray, ref_instance_idx: int | None = None, pred_instance_idx: int | None = None) float

Compute the Dice coefficient between a specific pair of instances.

The Dice coefficient measures the similarity or overlap between two binary masks representing instances. It is defined as:

Dice = (2 * intersection) / (ref_area + pred_area)

Parameters:
  • ref_labels (np.ndarray) – Reference instance labels.

  • pred_labels (np.ndarray) – Prediction instance labels.

  • ref_instance_idx (int) – Index of the reference instance.

  • pred_instance_idx (int) – Index of the prediction instance.

Returns:

Dice coefficient between the specified instances. A value between 0 and 1, where higher values indicate better overlap and similarity between instances.

Return type:

float

panoptica.metrics.iou

panoptica.metrics.iou._compute_instance_iou(reference_arr: ndarray, prediction_arr: ndarray, ref_instance_idx: int | None = None, pred_instance_idx: int | None = None) float

Compute Intersection over Union (IoU) between a specific pair of reference and prediction instances.

Parameters:
  • ref_labels (np.ndarray) – Reference instance labels.

  • pred_labels (np.ndarray) – Prediction instance labels.

  • ref_instance_idx (int) – Index of the reference instance.

  • pred_instance_idx (int) – Index of the prediction instance.

Returns:

IoU between the specified instances.

Return type:

float

panoptica.metrics.iou._compute_iou(reference_arr: ndarray, prediction_arr: ndarray, *args) float

Compute Intersection over Union (IoU) between two masks.

Parameters:
  • reference (np.ndarray) – Reference mask.

  • prediction (np.ndarray) – Prediction mask.

Returns:

IoU between the two masks. A value between 0 and 1, where higher values indicate better overlap and similarity between masks.

Return type:

float