A way to differentiate a variable for different types of neurons

Description of problem

For the neural network, I use one neuron equation. And from the total number of neurons in the population, I single out which will be excitatory and which are inhibitory.

Is there a way to set the current within one block of equations for a neuron (the current is affected by a variable calculated within the framework of a block of equations for a neuron), so that it is taken into account only for excitatory neurons.

Something in the form neuron_eq = ''' dv/dt = g (v-E) + Iapp * (int( i <= int(0.8 * n) )) '''

I tried to set in this way and the current was saved only for the first neuron to the example of 10 (where 8 should be excitatory and 2 inhibitory neurons).

@serge25 I do not understand your problem entirely, so please forgive me if my note is out of context.

You can set any variable for any neuron if you define a variable in the equation.

For example:

gl, El = ....
taum = ... *ms
#NOTE there is no Iapp variable here!
equ="""
dv/dt = (gl*(El-v)+Iapp )/taum : 1
Iapp                           : 1
"""
n = NeuronGroup(100,equ, ....)
n.Iapp[:50] = 20
n.Iapp[50:] = -1

Hope it helps.

Thank for your answer, but this not for my case because in my equation Iapp dependence from another variable (dy/dt), which calculate with in one system with neuron equation and need to present only in excitatory population.

@serge25 It this case, you can have an additional variable within the equation, say Iexc : 1, which you can set to one in excitatory neurons and to zero in the inhibitory ones. For example, n.Iexc[:50] = 1. and n.Iexc[50:] = 0. if neurons from 0 to 50 are excitatory and the rest are inhibitory neurons. You can use this variable in the equation to turn on/off Iapp

"""
dv/dt = g (v-E) + Iapp * Iexc : 1
Iexc                          : 1
"""
1 Like

@rth Thank for your answer

I do of course agree with everything that @rth proposed, but referring to your question here:

If you define n to be the number of neurons (Brian’s standard name for that would be N, but you may as well define your own variable), then this approach should actually work. Could you give more information on what you did and what went wrong?

I don’t know why excatly but only approach of @rth is working for me in my code. But i have another question. I have dependence Isyn and Iapp from one variable which calculate in system with neuron. How to use this variable for current at neuron group and synapses?

eqs = Equations('''
dVm/dt = ((k/ms/mV)*(Vm**2 - Vm*Vr - Vm*Vt + Vr*Vt) - Um + Isyn + Iapp) / Cm : volt
dUm/dt = a*(b*(Vm - Vr) - Um) : volt/second
Isyn : volt/second
dy/dt = -y / tau + betta*HevY : 1
HevY = 1/(1 + exp(-Vm/kY)) : 1 
Iapp = I_base*(1 + alpha * y) : volt/second

''')

........

Se = Synapses(Ne, N, model= eqs_synapse, 
              on_pre=eqs_pre +'Isyn_post += w_e*(1+gamma*y)',
            method='euler')

@serge25 Is Isyn is a sum of all synaptic currents? if so, just use standard, so called, “summed variable”
BTW, if the solution works for you, don’t forget to make this thread as solved. :nerd_face:

@rth Thank your. I understand correctly that Isyn_post += w_e equivalent Isyn_post = w_e (summed). And this give us Isyn for neuron which we can modify?

@serge25, not completely. x_post += w works for dynamical variables (dx/dt in the equation part). Dynamical variables don’t need to be reset at any time step: they are updated due to dynamics.
On the other hand, summed variables don’t have dynamics Itotal : 1 it is just a constant, and therefore they need to be set to zero at each time step before summation.

dynamic summed
Equation dx/dt = .... : 1 Itot : 1
Synapses x_post += w Itot = w : 1 (summed)

It seems there is also a difference in the schedule by which dynamic variables and summed variables are updated, but I’m not sure. @mstimberg may clarify this if I’m wrong.

Indeed: summed variables are updated just before the differential equations are updated (technically, both are in the groups slot, but summed variables have order=-1). You can verify this with the scheduling_summary function. More information about scheduling can be found here: Running a simulation — Brian 2 2.5.4 documentation

1 Like