fafbseg.flywire.synapses.get_synapses¶
- fafbseg.flywire.synapses.get_synapses(x, pre=True, post=True, attach=True, filtered=True, min_score=None, transmitters=False, neuropils=False, clean=True, materialization='auto', batch_size=10, *, dataset=None, progress=True)[source]¶
Fetch Buhmann et al. (2019) synapses for given neuron(s).
- Parameters:
x (int | list of int | Neuron/List | NeuronCriteria) – Either a FlyWire segment ID (i.e. root ID), a list thereof or a Neuron/List. For neurons, the
.id
is assumed to be the root ID. If you have a neuron (in FlyWire space) but don’t know its ID, usefafbseg.flywire.neuron_to_segments()
first.pre (bool) – Whether to fetch presynapses for the given neurons.
post (bool) – Whether to fetch postsynapses for the given neurons.
transmitters (bool) – Whether to also load per-synapse neurotransmitter predictions from Eckstein et al. (2020).
neuropils (bool) – Whether to add a column indicating which neuropil a synapse is in.
attach (bool) – If True and
x
is Neuron/List, the synapses will be added as.connectors
table. For TreeNeurons (skeletons), the synapses will be mapped to the closest node. Note that the function will still return the full synapse table.filtered (bool) – Whether to use the filtered synapse table. Briefly, this filter removes redundant and low confidence (<= 50 cleft score) synapses. See also https://tinyurl.com/4j9v7t86 (links to CAVE website).
min_score (int) – Minimum “cleft score”. Buhmann et al. used a threshold of 30 in their paper. However, for FlyWire analyses that threshold was raised to 50 (see also filtered).
clean (bool) –
If True, we will perform some clean up of the connectivity compared with the raw synapse information. Currently, we:
- drop autapses - drop synapses from/to background (id 0) - drop synapses that are >10um from the skeleton (only if ``attach=True``)
batch_size (int) – Number of IDs to query per batch. Too large batches might lead to truncated tables: currently individual queries can not return more than 500_000 rows and you will see a warning if that limit is exceeded.
materialization (int | str, optional) –
- Which materialization to query:
’auto’ (default) tries to find the most recent materialization version at which all the query IDs existed
’latest’ uses the latest materialized table
’live’ queries against the live data - this will be much slower!
pass an integer (e.g. 447) to use a specific materialization version
dataset ("public" | "production" | "sandbox", optional) – Against which FlyWire dataset to query. If
None
will fall back to the default dataset (seeset_default_dataset()
).
- Returns:
Note that each synapse (or rather synaptic connection) will show up only once. Depending on the query neurons (x), a given row might represent a presynapse for one and a postsynapse for another neuron.
- Return type:
pandas.DataFrame
See also
get_connectivity()
Use this function to fetch the edges between neurons instead of individual synapses.
Examples
Fetch synapses for a given root ID:
>>> from fafbseg import flywire >>> syn = flywire.get_synapses(720575940603231916) Using materialization version 783. >>> syn.head() pre post cleft_score pre_x pre_y pre_z post_x post_y post_z id 0 720575940631406673 720575940603231916 60 434336 218108 28240 434340 218204 28240 3535576 1 720575940608044501 720575940603231916 136 429180 212316 51520 429244 212136 51520 15712693 2 720575940627777265 720575940603231916 142 440272 215372 35240 440152 215392 35200 29684635 3 720575940606227890 720575940603231916 147 429932 224436 41120 429968 224584 41120 111586446 4 720575940627777265 720575940603231916 146 423856 216648 51280 423844 216528 51240 15689207
Skeletonize a neuron and attach its synapses:
>>> from fafbseg import flywire >>> sk = flywire.get_skeletons(720575940603231916) >>> _ = flywire.get_synapses(sk, attach=True) Using materialization version 783. >>> sk.connectors.head() connector_id x y z cleft_score partner_id type node_id 0 0 356304 146840 145120 145 720575940627592977 pre 217 1 1 344456 164324 162440 153 720575940537249676 pre 5 2 2 373200 149464 162440 52 720575940599849357 pre 390 3 3 355220 156784 151000 144 720575940537605841 pre 171 4 4 346320 154520 151720 142 720575940635161060 pre 30