Programmatic access to postsynaptic target prediction data¶
In this notebook, we'll see how to use CAVEclient to access the annotations generated by the postsynaptic target classifier described in the paper Pedigo et al. 2026 - "A quantitative census of millions of postsynaptic structures in a large electron microscopy volume of mouse visual cortex".
Prerequisites:
- make sure you have installed CAVEclient (typically just
pip install caveclientoruv add caveclient). - make sure you have authenticated for the
microns65_publicdatastack. You should only have to do this once per machine.
Initialize a CAVEclient object¶
Setting the version here is important - the underlying segmentation is changing over time, so while these annotations are tracked and will still be there, they will potentially correspond to different root IDs. Much more in depth explanation is available in the MICrONS tutorials.
from caveclient import CAVEclient
version = 1718
client = CAVEclient("minnie65_public", version=version)
Query annotations for a cell's input synapses¶
# the root ID of a neuron we are interested in
# note that root IDs are updated as the segmentation changes, see the MICrONS tutorials
root_id = 864691135276234469
# this single query will pull both the synapse information and information about the
# predicted labels from the postsynaptic target classifier
annotated_post_synapses = client.materialize.tables.synapse_target_predictions_ssa_v2(
post_pt_root_id=root_id
).query(
desired_resolution=[1, 1, 1], # specify this to get data back in nm units
split_positions=True, # unpacks the synapse center point into separate x, y, z columns
)
We can have a look at some of the more important columns in the return:
annotated_post_synapses[
[
"id", # the ID of the synapse
"size", # the size of the synapse in voxels
"pre_pt_root_id", # the root ID of the presynaptic partner
"post_pt_root_id", # the root ID of the postsynaptic partner
"tag", # the predicted classifier label
"value", # the confidence of the prediction
"ctr_pt_position_x", # the center of the synapse x coordinate, in nm
"ctr_pt_position_y", # the center of the synapse y coordinate, in nm
"ctr_pt_position_z", # the center of the synapse z coordinate, in nm
]
]
Query annotations for a cell's output synapses¶
Simply changing the filter to pre_pt_root_id will now query for output synapses from this cell.
annotated_pre_synapses = client.materialize.tables.synapse_target_predictions_ssa_v2(
pre_pt_root_id=root_id
).query(
desired_resolution=[1, 1, 1], # specify this to get data back in nm units
split_positions=True, # unpacks the synapse center point into separate x, y, z columns
)
annotated_pre_synapses[
[
"id", # the ID of the synapse
"size", # the size of the synapse in voxels
"pre_pt_root_id", # the root ID of the presynaptic partner
"post_pt_root_id", # the root ID of the postsynaptic partner
"tag", # the predicted classifier label
"value", # the confidence of the prediction
"ctr_pt_position_x", # the center of the synapse x coordinate, in nm
"ctr_pt_position_y", # the center of the synapse y coordinate, in nm
"ctr_pt_position_z", # the center of the synapse z coordinate, in nm
]
]