tumourkit.postprocessing.join_hovprob_graph.add_probability

tumourkit.postprocessing.join_hovprob_graph.add_probability(graph: DataFrame, hov_json: Dict[str, Any], logger: Logger | None = None, num_classes: int | None = 2, enable_background: bool | None = False) DataFrame

Adds probability information from the Hovernet JSON nuclei dictionary to the graph DataFrame.

This function extracts the type probabilities from the Hovernet JSON nuclei dictionary (hov_json) and adds them as columns to the graph DataFrame. The join between the graph DataFrame and the hov_json dictionary is based on the ‘id’ field.

Parameters:
  • graph (pd.DataFrame) – The graph DataFrame containing the nodes.

  • hov_json (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.

  • enable_background (Optional[bool]) – If True, extra cells are included. They are represented with a value of 1 in the column background.

Returns:

The updated graph DataFrame with probability information.

Return type:

pd.DataFrame