histocartography.visualization.visualization module¶
Summary¶
Classes:
Base visualization class |
|
Base visualization class |
|
Hierarchical Cell to Tissue visualization class |
|
Instance Image Visualization. |
|
- class BaseImageVisualization(instance_style: str = 'outline', color: str = 'black', thickness: int = 1, colormap: Optional[str] = None, alpha: float = 0.5, **kwargs)[source]¶
Bases:
histocartography.pipeline.PipelineStep
Base visualization class
- __init__(instance_style: str = 'outline', color: str = 'black', thickness: int = 1, colormap: Optional[str] = None, alpha: float = 0.5, **kwargs) → None[source]¶
Base visualization class constructor
- Parameters
instance_style (str) – Defines how to represent the instances (when available). Options are ‘fill’, ‘outline’, ‘fill+outline’. Defaults to ‘outline’.
color (str) – Matplotlib named color to (fill) or (outline) the instances. Defaults to ‘black’.
thickness (int) – Thickness of the instance outline. Defaults to 1.
colormap (str) – Colormap to use to map labels to colors. Defaults to None.
alpha (float) – Blending of the background image to the instances. Defaults to 0.5.
- abstract draw_instances(canvas: numpy.ndarray, instance_map: numpy.ndarray, instance_attributes: dict)[source]¶
Abstract method that performs drawing of instances on top of the canvas
- Parameters
canvas (np.ndarray) – Background on top of which the visualization is drawn.
instance_map (np.ndarray) – Segmentation mask of instances, brinary or with individual labels for each entity.
instance_attributes (dict) – Dictionary of attributes to be applied to instances.
- class InstanceImageVisualization(instance_style: str = 'outline', color: str = 'black', thickness: int = 1, colormap: Optional[str] = None, alpha: float = 0.5, **kwargs)[source]¶
Bases:
histocartography.visualization.visualization.BaseImageVisualization
Instance Image Visualization. Generic instance visualization.
- draw_instances(canvas: numpy.ndarray, instance_map: Optional[numpy.ndarray] = None, instance_attributes: Optional[dict] = None) → <module ‘PIL.Image’ from ‘/home/travis/conda/envs/histocartography/lib/python3.7/site-packages/PIL/Image.py’>[source]¶
Drawing of instances on top of the canvas
- Parameters
canvas (np.ndarray) – Background on top of which the visualization is drawn.
instance_map (np.ndarray) – Segmentation mask of instances, brinary or with individual labels for each entity. Defaults to None.
instance_attributes (dict) – Dictionary of attributes to be applied to instances. Defaults to None.
- Returns
Canvas with visualization.
- Return type
viz_canvas (Image)
- class BaseGraphVisualization(instance_visualizer: Optional[histocartography.visualization.visualization.BaseImageVisualization] = None, min_max_color_normalize: bool = True, **kwargs)[source]¶
Bases:
histocartography.pipeline.PipelineStep
Base visualization class
- __init__(instance_visualizer: Optional[histocartography.visualization.visualization.BaseImageVisualization] = None, min_max_color_normalize: bool = True, **kwargs) → None[source]¶
Constructor
- Parameters
instance_visualizer (BaseImageVisualization) – Instance visualization object. Defaults to None.
min_max_color_normalize (bool) – If the node/edge values, eg importance scores, should be min/max normalized. Only relevant if node/edge-level colors are provided. Defaults to True.
- abstract draw_nodes(draw: <module 'PIL.ImageDraw' from '/home/travis/conda/envs/histocartography/lib/python3.7/site-packages/PIL/ImageDraw.py'>, graph: dgl.graph.DGLGraph, node_attributes: dict)[source]¶
Draw nodes on the canvas
- abstract draw_edges(draw: <module 'PIL.ImageDraw' from '/home/travis/conda/envs/histocartography/lib/python3.7/site-packages/PIL/ImageDraw.py'>, graph: dgl.graph.DGLGraph, edge_attributes: dict)[source]¶
Draw edges on the canvas
- class OverlayGraphVisualization(node_style: str = 'outline', node_color: str = 'yellow', node_radius: int = 5, edge_style: str = 'line', edge_color: str = 'blue', edge_thickness: int = 2, colormap='viridis', show_colormap=False, **kwargs)[source]¶
Bases:
histocartography.visualization.visualization.BaseGraphVisualization
- __init__(node_style: str = 'outline', node_color: str = 'yellow', node_radius: int = 5, edge_style: str = 'line', edge_color: str = 'blue', edge_thickness: int = 2, colormap='viridis', show_colormap=False, **kwargs) → None[source]¶
Overlay graph visualization class. It overlays a graph drawn with PIL on top of an image canvas using the provided instance_visualizer. Nodes outside of the canvas support willbe ignored.
- Parameters
node_style (str, optional) – Style to represent the nodes. Options are “filled”, “outline” or “filled+outline”. Defaults to “outline”.
node_color (str, optional) – Node color. Defaults to “yellow”.
node_radius (int, optional) – Node radius. Defaults to 5.
edge_style (str, optional) – Edge style. Defaults to “line”.
edge_color (str, optional) – Edge color. Defaults to “blue”.
edge_thickness (int, optional) – Edge thickness. Defaults to 2.
colormap (str, optional) – Matplotlib colormap. Defaults to “viridis”.
- graph_preprocessing(graph: dgl.graph.DGLGraph)[source]¶
preprocesses the graph (e.g., to reorganize spatially)
- draw_nodes(draw: <module 'PIL.ImageDraw' from '/home/travis/conda/envs/histocartography/lib/python3.7/site-packages/PIL/ImageDraw.py'>, graph: dgl.graph.DGLGraph, node_attributes: Optional[dict] = None)[source]¶
Draws the nodes on top of the canvas.
- class HACTVisualization(cell_visualizer: Optional[histocartography.visualization.visualization.BaseGraphVisualization] = None, tissue_visualizer: Optional[histocartography.visualization.visualization.BaseGraphVisualization] = None, **kwargs)[source]¶
Bases:
histocartography.pipeline.PipelineStep
Hierarchical Cell to Tissue visualization class
- __init__(cell_visualizer: Optional[histocartography.visualization.visualization.BaseGraphVisualization] = None, tissue_visualizer: Optional[histocartography.visualization.visualization.BaseGraphVisualization] = None, **kwargs) → None[source]¶
Constructor
- Parameters
cell_visualizer (BaseGraphVisualization) – Object to use for the cell visualization. Defaults to None.
tissue_visualizer (BaseGraphVisualization) – Object to use for the tissue visualization. Defaults to None.
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}
}