This notebook demonstrates different ways to retrieve connector information.


In [1]:
import pymaid

print('Last run with Pymaid version', pymaid.__version__)


/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/vispy/visuals/isocurve.py:22: UserWarning:

VisPy is not yet compatible with matplotlib 2.2+

Last run with Pymaid version 0.76

In [4]:
# Create Catmaid instance
rm = pymaid.CatmaidInstance('server_url', 'api_token', 'http_user', 'http_password')


INFO  : Global CATMAID instance set. (pymaid.fetch)

Multiple ways lead to Rome

There are several API endpoints in CATMAID that allow you to fetch connector data. Which one to use is depending ultimately on what information you want. The examples below are rather simply and many of the function used let you pass parameters to further restrict your search. Please check out their documentation on readthedocs or use e.g. help(pymaid.get_connectors).

A) The most simple way to get connectors is to just get the 3D skeleton of a neuron and look at its connector table:

In [3]:
n = pymaid.get_neuron(2333007)
n.connectors.head()



Out[3]:
treenode_id connector_id relation x y z
0 17856950 17856949 0 504626 173115 80240
1 8413738 8413736 1 416875 182721 91560
2 7746386 7746388 0 618244 186376 86600
3 6345213 6345207 1 433553 180556 80200
4 7713470 7713473 1 597588 166641 45960

The connector table contains all the data necessary for plotting: position, type (relation: 0 = presynaptic, 1 = postsynaptic, 2 = gap_junction; see also help(pymaid.get_neuron)) and the treenode of this neuron it is connected to. It has, however, no information about tags, creator or edition/creation times.

B) If you need more detailed information, you can use another API endpoint to get a richer connector table:

In [4]:
# Retrieve all types of connectors for a single neuron
cn_table = pymaid.get_connectors(2333007)
print('Connectors retrieved: %i' % cn_table.shape[0] )


Connectors retrieved: 10933

In [5]:
cn_table.head()


Out[5]:
connector_id x y z confidence editor_id creation_time edition_time tags type creator
0 1567478 438621.0 171214.0 116360.0 5 37 2015-08-10 15:01:57.195320 2016-12-07 02:19:05.726210 None synaptic gillisz
1 1567508 438165.0 166824.0 118440.0 5 37 2015-08-10 15:02:43.946600 2016-12-07 02:20:27.909150 None synaptic gillisz
2 1567512 438239.0 166823.0 118480.0 5 37 2015-08-10 15:03:02.143370 2016-12-07 02:20:30.199940 None synaptic gillisz
3 1567532 438650.0 166954.0 118600.0 5 37 2015-08-10 15:03:19.324150 2016-12-07 02:20:34.093350 None synaptic gillisz
4 1567542 438552.0 166713.0 118800.0 5 37 2015-08-10 15:03:41.516370 2016-12-07 02:20:40.630300 None synaptic gillisz

This table gives you more detailed information. But what if you need even more details?

C) Get a detailed connector table:

In [6]:
cn_details = pymaid.get_connector_details( n )
cn_details.head()


INFO  : Data for 10933 of 10933 unique connector IDs retrieved (pymaid.fetch)

Out[6]:
connector_id presynaptic_to postsynaptic_to presynaptic_to_node postsynaptic_to_node
0 1567478 248997 [206619, 2333007] 1567477 [1567066, 8035764]
1 1567508 13302 [206619, 2333007] 1567507 [1567509, 7950137]
2 1567512 206619 [13302, 2333007] 1567513 [1567515, 1567514]
3 1567532 206619 [249039, 2333007] 1566736 [1567538, 1567534]
4 1567542 249046 [206619, 2333007] 1567541 [1566733, 7950723]

This connector table now give you information about which neurons/treenodes are pre- and postsynaptic to a given connector.

C) Get the connectors that connect two (sets of) neurons

In [7]:
cn_between = pymaid.get_connectors_between( 2049139, n )
cn_between.head()


Out[7]:
connector_id connector_loc treenode1_id source_neuron confidence1 creator1 treenode1_loc treenode2_id target_neuron confidence2 creator2 treenode2_loc
0 7045130 [415801.0, 168624.0, 101800.0] 7045135 2049139 5 schlegelp [415767.0, 168382.0, 101800.0] 7045122 2333007 5 schlegelp [415843.0, 168740.0, 101800.0]
1 7639717 [421988.0, 168403.0, 90560.0] 7639719 2049139 5 schlegelp [421561.0, 167992.0, 90560.0] 7639716 2333007 5 schlegelp [422224.0, 168399.0, 90560.0]
2 7649270 [416946.0, 169359.0, 92000.0] 7649273 2049139 5 schlegelp [416831.0, 169595.0, 92000.0] 7649269 2333007 5 schlegelp [416986.0, 169417.0, 92080.0]