fafbseg.flywire.synapses.get_transmitter_predictions¶
- fafbseg.flywire.synapses.get_transmitter_predictions(x, single_pred=False, weighted=True, materialization='auto', filtered=True, neuropils=None, batch_size=10, *, dataset=None, **kwargs)[source]¶
Fetch neurotransmitter predictions for neurons.
Based on Eckstein et al. (2020). The per-synapse predictions are collapsed into per-neuron prediction by calculating the average confidence for each neurotransmitter across all synapses weighted by the “cleft score”. Bottom line: higher confidence synapses have more weight than low confidence synapses.
- 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.single_pred (bool) – Whether to only return the highest probability transmitter for each neuron.
weighted (bool) – If True, will weight predictions based on confidence: higher cleft score = more weight.
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).
neuropils (str | list of str, optional) – Provide neuropil (e.g.
'AL_R'
) or list thereof (e.g.['AL_R', 'AL_L']
) to filter predictions to these ROIs. Prefix neuropil with a tilde (e.g.~AL_R
) to exclude it.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 (seeset_default_dataset()
).**kwargs – Keyword arguments are passed through to
fafbseg.flywire.get_synapses()
.
- Returns:
pandas.DataFrame – If single_pred=False: returns a dataframe with all per-transmitter confidences for each query neuron.
dict – If single_pred=True: returns dictionary with (top_transmitter, confidence) named tuple for each query neuron.
Examples
>>> from fafbseg import flywire
Get per-transmitter predictions for a single neuron:
>>> flywire.get_transmitter_predictions(720575940603231916) Using materialization version 783. root_id 720575940603231916 gaba 0.011677 acetylcholine 0.938961 glutamate 0.017902 octopamine 0.012861 serotonin 0.012467 dopamine 0.006132
Return only the most likely transmitter:
>>> flywire.get_transmitter_predictions(720575940603231916, single_pred=True) Using materialization version 783. {720575940603231916: prediction(transmitter='acetylcholine', probability=0.9389612897479809)}