tumourkit.postprocessing.join_hovprob_graph.parse_centroids_probs

tumourkit.postprocessing.join_hovprob_graph.parse_centroids_probs(nuc: Dict[str, Any], logger: Logger | None = None, num_classes: int | None = 2) List[Tuple[int, int, int]]

Parses the centroids and probabilities from the Hovernet JSON nuclei dictionary.

This function takes the Hovernet JSON nuclei dictionary as input, which is obtained from the modified run_infer.py script. It extracts the centroids and probabilities from the dictionary and returns them as a list of tuples. Each tuple represents a centroid and consists of (X, Y, prob1) for binary classification or (X, Y, prob1, prob2, …, probN) for multiclass classification.

Parameters:
  • nuc (Dict[str, Any]) – The Hovernet JSON nuclei dictionary.

  • logger (Optional[Logger]) – Optional logger object to log warnings.

  • num_classes (Optional[int]) – Optional number of classes. Defaults to 2 for binary classification.

Returns:

The list of centroids with probabilities.

Return type:

List[Tuple[int, int, int]]