Skip to content

Commit ceebb00

Browse files
committed
Add SVG coordinate graph display
1 parent 3591094 commit ceebb00

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

docs/guides/coordinates.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
# that are subgroups of the Scene Zarr group.
88

99
import zarr
10+
from IPython.display import SVG, display
1011
from rich import print
1112

1213
from ome_zarr_models._v06 import Scene
@@ -22,3 +23,28 @@
2223

2324
# Here we can see that the scene metadata defines one coordinate system and
2425
# three coordinate transforms.
26+
#
27+
# The input to the first two coordinate transforms contain `path` fields.
28+
# These refer to OME-Zarr image groups stored a Zarr subgroups under the
29+
# Scene group.
30+
#
31+
# This can be verified using the `.images` property to see available images:
32+
33+
print("Images making up the scene:")
34+
print(scene.images.keys())
35+
36+
# The individual images can also contain their own coordinate transforms and systems.
37+
#
38+
# To get a better overview of the complete set of coordinate systems and transforms
39+
# we can visualize them as a graph where the nodes are systems, connected by
40+
# directed vertices (arrows) representing the transforms.
41+
#
42+
# In `ome-zarr-models` you can do this by getting a transform graph:
43+
44+
transform_graph = scene.transform_graph()
45+
print(transform_graph)
46+
47+
# To visualize,
48+
49+
svg_string = transform_graph.to_graphviz().pipe(format="svg")
50+
display(SVG(data=svg_string))

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ build-backend = "hatchling.build"
5050

5151
[dependency-groups]
5252
docs = ["ome-zarr-models[docs]"]
53-
dev = ["mypy==1.18.2", "ruff==0.13.2", "pre-commit==4.3.0"]
53+
dev = ["mypy==1.18.2", "ruff==0.13.2", "pre-commit==4.3.0", "graphviz==0.21"]
5454
test = [
5555
"pytest==8.4.2",
5656
"pytest-cov==7.0.0",

0 commit comments

Comments
 (0)