-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathexample_graph_init.py
More file actions
68 lines (52 loc) · 1.78 KB
/
Copy pathexample_graph_init.py
File metadata and controls
68 lines (52 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
"""Example script to test and demonstrate the neuromaps_nhp graph functionality.
Covers:
- Loads the graph and prints a summary
- Inspects nodes and species
- Finding paths between spaces
- Plotting full, surface-only, and volume-only graphs
Usage:
python examples/example_graph_init.py
"""
from pathlib import Path
from neuromaps_prime.graph import NeuromapsGraph
from neuromaps_prime.plotting import plot_graph
graph = NeuromapsGraph()
# Brief summary of graph
print(graph)
print(graph.utils.get_graph_info())
# All registered spaces
print("Nodes:", list(graph.nodes(data=False)))
# Print species of each node
for node in graph.nodes(data=False):
print(f"Node: {node}")
print(f" Species: {graph.get_node_data(node).species}")
# Find and print paths between two nodes for different edge types
source, target = "CIVETNMT", "Yerkes19"
vol_path = graph.find_path(source, target, edge_type="volume_to_volume")
print(f"Volume path {source} -> {target}: {vol_path}")
surf_path = graph.find_path(source, target, edge_type="surface_to_surface")
print(f"Surface path {source} -> {target}: {surf_path}")
# Plot full graph with both surface and volume transforms combined
plot_graph(
graph,
graph_type="combined",
layout="kamada_kawai",
figsize=(14, 10),
save_path=Path("examples/neuromaps_graph.png"),
)
# Plot only surface transforms
surface_subgraph = graph.utils.get_subgraph("surface_to_surface")
plot_graph(
surface_subgraph,
graph_type="surface",
layout="kamada_kawai",
save_path=Path("examples/neuromaps_surface.png"),
)
# Plot only volume transforms
volume_subgraph = graph.utils.get_subgraph("volume_to_volume")
plot_graph(
volume_subgraph,
graph_type="volume",
layout="kamada_kawai",
save_path=Path("examples/neuromaps_volume.png"),
)