(Brian -> Brian2) freeze argument for NeuronGroup & Matrices in Synapses.delay

49 views
Skip to first unread message

ejim...@gmail.com

unread,
Jul 23, 2018, 1:06:37 PM7/23/18
to Brian
Hello!

I am new to Brian and currently I work on converting other person's model from Brian to Brian2. I faced several problems that I cannot solve using the "Changes for Brian 1 users" guide.

The first one is the freeze argument for NeuronGroup. As I understand there is no more such argument in Brian2. I found some mentions about it only for the PoissonInput object. Could you please advice if I can just delete this argument and forget about it or I should find any workaround?

The second problem is the usage of matrices in delays for Synapses. In the model I work on the delays are given this way: delay = lambda i,j: A[i,j]*a*ms; where A is some matrix and a is some parameter. I changed it to S.delay[i,j]='A[i,j]*a*ms', but it seems that [] brackets are not accepted by Brian2 here. I is quite hard to turn the logic that lies under the matrix into a math expression, so I would like to ask if there any other ways to keep using the matrix for delay.

Sorry if any of the questions is too obvious.

Thanks in advance,

Ejved

Marcel Stimberg

unread,
Jul 24, 2018, 10:35:49 AM7/24/18
to brians...@googlegroups.com
Hi Ejved,


> The first one is the freeze argument for NeuronGroup. As I understand
> there is no more such argument in Brian2. I found some mentions about
> it only for the PoissonInput object. Could you please advice if I can
> just delete this argument and forget about it or I should find any
> workaround?

The freeze argument in NeuronGroup was just an optimisation option (it
replaced constants with their values), you can simply delete it. It was
a bit confusing in Brian 1, the freeze argument in PoissonInput actually
had a completely different meaning...

> The second problem is the usage of matrices in delays for Synapses. In
> the model I work on the delays are given this way: delay = lambda i,j:
> A[i,j]*a*ms; where A is some matrix and a is some parameter. I changed
> it to S.delay[i,j]='A[i,j]*a*ms', but it seems that [] brackets are
> not accepted by Brian2 here. I is quite hard to turn the logic that
> lies under the matrix into a math expression, so I would like to ask
> if there any other ways to keep using the matrix for delay.

In Brian 2, connections and synaptic variable are always tored in
1-dimensional arrays which has the big advantage that we can use the
same data structure for all kind of connection patterns (full, dense,
sparse, ...). String expressions can indeed not index into arrays, but
you could loop over the connections and do "S.delay[i, j] = A[i,
j]*a*ms" (i.e., without a string on the right-hand side) for every
synapse. This is quite inefficient for large arrays, though. It is
better to do a single assignment, but for this your right-hand side has
to be a 1-dimensional array that contains entries in the same order as
our Synapses data structure. Luckily, this is not very difficult:
If you have a full connection matrix (i.e. you used S.connect() or
S.connect(True)) and A stores the values with the source index as the
first, and the target index as the second dimension you can simply
flatten it:
    S.delay[:] = A.flatten()*a*ms
If your network is not fully connected, you can use the source and
target indices stored in the synapses object to get the relevant values
out of your matrix:
    S.delay[:] = A[S.i[:], S.j[:]]*a*ms

Best,
  Marcel

ejim...@gmail.com

unread,
Jul 28, 2018, 7:47:46 PM7/28/18
to Brian
Hi Marcel,

Thank you so much for such a helpful reply!

Best,
Ejved
Reply all
Reply to author
Forward
0 new messages