Visualization
Different visualization methods are available in pathology-image-features to represent properties a object might have as well as to see the order of processes in a pipeline more clearly.
Graphviz Integration
graphviz is used for generating visualizations containing labeled nodes and edges, making it useful for visualizing triples from a graph. To view the serialization of a term in pathology-image-features, you can use the “graphviz” method of any class.
from pathology_image_features.ontology import PIFO
Person = PIFO.to_python('http://schema.org/Person')
software_developer_role = PIFO.to_python('http://purl.obolibrary.org/obo/PIFO_0000055')
person_instance = Person(
label = "Sam",
has_role = software_developer_role()
)
person_instance.graphviz(filepath = "./tests/output/person_graph.gv")
Specific Entity Visualization
In addition to visualizing entity’s properties and relations to other entities, you may also be interested in visualizing the underlying data that is represented by a term. For example, custom visualization methods may be added in order to highlight which parts of an input item are considered in a specific type of transformation or quantification.
These methods may be accessed through the “visualize” method of any class. For those where a specific visualization is not implemented, a blank axis will be returned with the label/name of the class for that item.
import matplotlib.pyplot as plt
from pathology_image_features.ontology import PIFO
path_to_annotations = "./tests/data/histology_annotations.json"
annotations = histomics_to_geojson(read_histomics(path_to_annotations))
path_to_image = "./tests/data/histology_image.svs"
annotated_image_data_set = PIFO.to_python(
"http://purl.obolibrary.org/obo/PIFO_0000002"
)
test_annotated_image_data_set = annotated_image_data_set.construct(
image_data_set_kwargs={"filepath": path_to_image},
annotations_kwargs=[{"spatial": ann} for ann in annotations],
)
fig, ax = plt.subplots()
axis = test_annotated_image_data_set.visualize()
plt.savefig("./tests/data/annotated_data_visualization.png")