fafbseg.flywire.synapses.get_connectivity#

fafbseg.flywire.synapses.get_connectivity(x, clean=True, style='simple', upstream=True, downstream=True, proofread_only=False, transmitters=False, neuropils=None, filtered=True, min_score=None, batch_size=30, materialization='auto', *, progress=True, dataset=None)[source]#

Fetch Buhmann et al. (2019) connectivity for given neuron(s).

Notes

As of May 2023, CAVE provides “views” of materialized tables. This includes a view with neuron edges (as opposed to individual synaptic connections) which can be much faster to query. We will automatically use use the view _if_:

  1. filtered=True (default is False)

  2. min_score=None or min_score=50

  3. neuropils=None (default is None)

  4. mat!=’live’ (default is “auto” which can end up as “live”)

Parameters:
  • x (int | list of int | Neuron/List | NeuronCriteria) – Either a FlyWire 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, use fafbseg.flywire.neuron_to_segments() first.

  • 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)
    

  • style ("simple" | "catmaid") – Style of the returned table.

  • upstream (bool) – Whether to fetch upstream connectivity of `x.

  • downstream (bool) – Whether to fetch downstream connectivity of `x.

  • proofread_only (bool) – Whether to filter out root IDs that have not been proofread. Query IDs (i.e. x) will never be excluded regardless of proofreading status!

  • transmitters (bool) – If True, will attach the best guess for the transmitter for a given connection based on the predictions in Eckstein et al (2020). IMPORTANT: the predictions are based solely on the connections retrieved as part of this query which likely represent only a fraction of each neuron’s total synapses. As such the predictions need to be taken with a grain of salt - in particular for weak connections! To get the “full” predictions see fafbseg.flywire.predict_transmitter().

  • neuropils (bool | str | list of str, optional) – If True, will return edges broken down by neuropils. You can also provide neuropil (e.g. 'AL_R') or list thereof (e.g. ['AL_R', 'AL_L']) to filter connectivity to these ROIs. Prefix neuropil with a tilde (e.g. ~AL_R) to exclude it.

  • 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).

  • 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 200_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 the query IDs co-exist

    • ’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 (see set_default_dataset()).

Returns:

Connectivity table.

Return type:

pd.DataFrame

See also

get_adjacency()

Use this function to fetch connections between two sets of neurons.

Examples

Get connections from/to given root ID(s):

>>> from fafbseg import flywire
>>> edges = flywire.get_connectivity(720575940603231916)
Using materialization version 783.
>>> edges.head()
                pre                post  weight
0  720575940635945919  720575940603231916      83
1  720575940620541349  720575940603231916      58
2  720575940603231916  720575940629163931      50
3  720575940603231916  720575940635945919      46
4  720575940603231916  720575940646122804      42