fafbseg.flywire.synapses.get_synapse_counts#

fafbseg.flywire.synapses.get_synapse_counts(x, by_neuropil=False, materialization='auto', filtered=True, min_score=None, batch_size=10, *, dataset=None, **kwargs)[source]#

Fetch synapse counts for given root IDs.

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, use fafbseg.flywire.neuron_to_segments() first.

  • by_neuropil (bool) – If True, returned DataFrame will contain a break down by neuropil.

  • 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

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

  • dataset ("public" | "production" | "sandbox", optional) – Against which FlyWire dataset to query. If None will fall back to the default dataset (see set_default_dataset()).

  • **kwargs – Keyword arguments are passed through to fafbseg.flywire.get_synapses().

Returns:

If by_neuropil=False returns counts indexed by root ID. If by_neuropil=True returns counts indexed by root ID and neuropil.

Return type:

pandas.DataFrame

See also

get_synapses()

Use this function to fetch the actual synapses.

Examples

Get synapse counts for a given root ID:

>>> from fafbseg import flywire
>>> n_syn = flywire.get_synapse_counts(720575940603231916)
Using materialization version 783.
>>> n_syn
                    pre  post
id
720575940603231916  4571   887