pymaid.get_partners

pymaid.get_partners(x, threshold=1, min_size=2, filt=[], min_confidence=1, directions=['incoming', 'outgoing', 'gapjunctions', 'attachments'], remote_instance=None)[source]

Retrieve partners connected by synapses, gap junctions or attachments.

Note

This function treats multiple fragments with the same skeleton ID (e.g. from splits into axon & dendrites) as a single neuron when fetching data from the server. For “fragmented” connectivity use cn_table_from_connectors() instead.

Parameters:
  • x

    Neurons for which to retrieve partners. Can be either:

    1. list of skeleton ID(s) (int or str)

    2. list of neuron name(s) (str, exact match)

    3. an annotation: e.g. ‘annotation:PN right’

    4. CatmaidNeuron or CatmaidNeuronList object

  • threshold (int, optional) – Minimum # of links (synapses/gap-junctions/etc).

  • min_size (int, optional) – Minimum node count of partner (default=2 to hide single-node partners).

  • filt (list of str, optional) – Filters partners for neuron names (must be exact) or skeleton_ids.

  • min_confidence (int | None, optional) – If set, edges with lower confidence will be ignored. Applied before threshold.

  • directions ('incoming' | 'outgoing' | 'gapjunctions' | 'attachments', optional) – Use to restrict to either up- or downstream partners.

  • remote_instance (CatmaidInstance, optional) – If not passed directly, will try using global.

Returns:

DataFrame in which each row represents a neuron and the number of synapses with the query neurons:

  neuron_name  skeleton_id    num_nodes    relation    total  skid1  skid2 ...
0   name1         skid1      node_count1   upstream    n_syn  n_syn  ...
1   name2         skid2      node_count2  downstream   n_syn  n_syn  ..
2   name3         skid3      node_count3  gapjunction  n_syn  n_syn  .
...

relation can be 'upstream' (incoming), 'downstream' (outgoing), 'attachment' or 'gapjunction' (gap junction).

Return type:

pandas.DataFrame

Warning

By default, will exclude single node partners! Set min_size=1 to return ALL partners including placeholder nodes.

Notes

Partners can show up multiple times if they are e.g. pre- AND postsynaptic!

Examples

>>> example_skids = [16, 201, 150, 20]
>>> cn = pymaid.get_partners(example_skids)
>>> # Get only upstream partners
>>> subset = cn[ cn.relation == 'upstream' ]
>>> # Get partners with more than e.g. 5 synapses across all neurons
>>> subset2 = cn[ cn[example_skids].sum(axis=1) > 5 ]
>>> # Combine above conditions (watch parentheses!)
>>> subset3 = cn[(cn.relation=='upstream') &
...              (cn[example_skids].sum(axis=1) > 5)]

See also

adjacency_matrix()

Use if you need an adjacency matrix instead of a table.

get_partners_in_volume()

Use if you only want connectivity within a given volume.

filter_connectivity()

Use to restrict connector table to given part of a neuron or a volume.

cn_table_from_connectors()

Returns “fragmented” connectivity. Use e.g. if you are working with multiple fragments from the same neuron.