Tracking synapses¶
import time
from caveclient import CAVEclient
from paleo import (
get_initial_graph,
get_root_level2_edits,
get_nucleus_supervoxel,
get_node_aliases,
)
root_id = 864691135639556411
client = CAVEclient("minnie65_public", version=1078)
Collect edit history information¶
edits = get_root_level2_edits(root_id, client)
initial_graph = get_initial_graph(root_id, client)
nuc_supervoxel_id = get_nucleus_supervoxel(root_id, client)
anchor_nodes = get_node_aliases(nuc_supervoxel_id, client, stop_layer=2)
Apply edit history¶
from paleo import apply_edit_sequence
nodes_by_state = apply_edit_sequence(
initial_graph,
edits,
anchor_nodes,
return_graphs=False,
include_initial=True,
verbose=True,
)
nodes_by_state[9028]
Get synapses, map to state history¶
from paleo import get_mutable_synapses
currtime = time.time()
pre_synapses = get_mutable_synapses(root_id, edits, client, verbose=True, sides="pre")
print(f"{time.time() - currtime:.3f} seconds elapsed.")
from paleo import map_synapses_to_sequence
pre_synapses_by_state = map_synapses_to_sequence(
pre_synapses, nodes_by_state, side="pre"
)
pre_synapses_by_state[9028]
pre_synapses_by_state[87490]
Plot number of synapses over time¶
n_synapses = [len(s) for s in pre_synapses_by_state.values()]
import seaborn as sns
import matplotlib.pyplot as plt
sns.set_context("talk")
fig, ax = plt.subplots()
sns.lineplot(x=range(len(n_synapses)), y=n_synapses, ax=ax)
ax.set_xlabel("State")
ax.set_ylabel("Number of pre-synapses")