histocartography.preprocessing.graph_builders module

This module handles all the graph building

Summary

Classes:

BaseGraphBuilder

Base interface class for graph building.

KNNGraphBuilder

k-Nearest Neighbors Graph class for graph building.

RAGGraphBuilder

Super-pixel Graphs class for graph building.

Functions:

two_hop_neighborhood

Increases the connectivity of a given graph by an additional hop

two_hop_neighborhood(graph: dgl.graph.DGLGraph)dgl.graph.DGLGraph[source]

Increases the connectivity of a given graph by an additional hop

Parameters

graph (dgl.DGLGraph) – Input graph

Returns

Output graph

Return type

dgl.DGLGraph

class BaseGraphBuilder(nr_annotation_classes: int = 5, annotation_background_class: Optional[int] = None, add_loc_feats: bool = False, **kwargs: Any)[source]

Bases: histocartography.pipeline.PipelineStep

Base interface class for graph building.

__init__(nr_annotation_classes: int = 5, annotation_background_class: Optional[int] = None, add_loc_feats: bool = False, **kwargs: Any)None[source]

Base Graph Builder constructor. :param nr_annotation_classes: Number of classes in annotation. Used only if setting node labels. :type nr_annotation_classes: int :param annotation_background_class: Background class label in annotation. Used only if setting node labels. :type annotation_background_class: int :param add_loc_feats: Flag to include location-based features (ie normalized centroids)

in node feature representation. Defaults to False.

precompute(link_path: Union[None, str, pathlib.Path] = None, precompute_path: Union[None, str, pathlib.Path] = None)None[source]

Precompute all necessary information :param link_path: Path to link to. Defaults to None. :type link_path: Union[None, str, Path], optional :param precompute_path: Path to save precomputation outputs. Defaults to None. :type precompute_path: Union[None, str, Path], optional

class RAGGraphBuilder(kernel_size: int = 3, hops: int = 1, **kwargs)[source]

Bases: histocartography.preprocessing.graph_builders.BaseGraphBuilder

Super-pixel Graphs class for graph building.

__init__(kernel_size: int = 3, hops: int = 1, **kwargs)None[source]

Create a graph builder that uses a provided kernel size to detect connectivity :param kernel_size: Size of the kernel to detect connectivity. Defaults to 5. :type kernel_size: int, optional

class KNNGraphBuilder(k: int = 5, thresh: Optional[int] = None, **kwargs)[source]

Bases: histocartography.preprocessing.graph_builders.BaseGraphBuilder

k-Nearest Neighbors Graph class for graph building.

__init__(k: int = 5, thresh: Optional[int] = None, **kwargs)None[source]

Create a graph builder that uses the (thresholded) kNN algorithm to define the graph topology.

Parameters
  • k (int, optional) – Number of neighbors. Defaults to 5.

  • thresh (int, optional) – Maximum allowed distance between 2 nodes. Defaults to None (no thresholding).

Reference

If you use histocartography in your projects, please cite the following:

@inproceedings{pati2021,
    title = {Hierarchical Graph Representations for Digital Pathology},
    author = {Pushpak Pati, Guillaume Jaume, Antonio Foncubierta, Florinda Feroce, Anna Maria Anniciello, Giosuè Scognamiglio, Nadia Brancati, Maryse Fiche, Estelle Dubruc, Daniel Riccio, Maurizio Di Bonito, Giuseppe De Pietro, Gerardo Botti, Jean-Philippe Thiran, Maria Frucci, Orcun Goksel, Maria Gabrani},
    booktitle = {https://arxiv.org/pdf/2102.11057},
    year = {2021}
}