[Brian 2] automatic creation of synapses from adjacency matrix

156 views
Skip to first unread message

luc.be...@gmail.com

unread,
Aug 3, 2015, 6:37:31 AM8/3/15
to Brian

Hello,

This query is specific to Brian v2. 

I understand that since multiple connections are possible between neurons, the notion of 'adjacency matrix' is problematic. 
However, what if I do want to initialise synapses from an existing adjacency matrix? 

In http://brian2.readthedocs.org/en/2.0b4/user/synapses.html it is indicated that it is possible to create synapses using code with the code being a boolean statement that should return True when a synapse must be created, where i is the pre and j the post synaptic neuron index. So I tried the following: 

A=randint(2,size=(4,4)) 

S.connect('A(i,j)==1')


However, I am getting the following error: 

In [11]: S.connect('A[i,j]==1')

  File "<string>", line unknown

SyntaxError: Unknown syntax: Subscript


Any idea? 

If this is not going to be possible at all, am I supposed to cycle through all entries of my adjacency matrix and create the connections one by one? 

This does not sound very efficient. Example above has only 4 neurons but I'm looking at much larger networks (N>1000)... 


Thanks, 

Luc Berthouze





Marcel Stimberg

unread,
Aug 3, 2015, 8:52:51 AM8/3/15
to brians...@googlegroups.com
Hi Luc,

expressions are only allowed to use a restricted subset of Python, indexing of arrays is not supported (there's an open issue for that, but it is a complicated issue and not something that is high on our list: https://github.com/brian-team/brian2/issues/388). For connecting synapses based on an existing structure, you'd not use string-based creation but instead you'd explicitly specify the list of source and target indices:
    A = randint(2,size=(4,4))
    rows, cols = nonzero(A)
    S.connect(rows, cols)  # or cols, rows...

Best,
  Marcel
--
http://www.facebook.com/briansimulator
https://twitter.com/briansimulator
 
New paper about Brian 2: Stimberg M, Goodman DFM, Benichoux V, Brette R (2014).Equation-oriented specification of neural models for simulations. Frontiers Neuroinf, doi: 10.3389/fninf.2014.00006.
---
You received this message because you are subscribed to the Google Groups "Brian" group.
To unsubscribe from this group and stop receiving emails from it, send an email to briansupport...@googlegroups.com.
To post to this group, send email to brians...@googlegroups.com.
Visit this group at http://groups.google.com/group/briansupport.
For more options, visit https://groups.google.com/d/optout.

luc.be...@gmail.com

unread,
Aug 3, 2015, 2:00:00 PM8/3/15
to Brian

Thanks, this is very helpful.
Luc Berthouze
Reply all
Reply to author
Forward
0 new messages