Multiple "summed variables"

Hi,
Consider we have two population of neurons, labeled by “i” and “e”.
We can have 4 synapse object. {ii, ee, ie, ei} to connect them to each other or themselves.

    '''
    membrane_Im = I_ext + gNa*m_inf**3*h*(ENa-vm) + \
        gl*(El-vm) + gK*n**4*(EK-vm) +gSyn*s_in*(ESyn-vm): amp
    
    s_in  : 1
    ds/dt = 0.5 * (1 + tanh(0.1*vm/mV)) * (1-s)/tau_r - s/tau_d : 1
    '''


    S_ei = b2.Synapses(neuron_e,
                       neuron_i, '''
                    w : 1
                    s_in_post = w*s_pre:1 (summed)
                    ''')
    S_ei.connect('i != j', p=p_ei)
    S_ei.w = weight_ei
    # --------------------------------------------------------------#
    S_ie = b2.Synapses(neuron_i, neuron_e, '''
                    w : 1
                    s_in_post = w*s_pre:1 (summed)
                    ''' )
    S_ie.connect('i != j', p=p_ie)
    S_ie.w = weight_ie
    # --------------------------------------------------------------#
    S_ii = b2.Synapses(neuron_i, neuron_i, '''
                    w : 1
                    s_in_post = w*s_pre:1 (summed)
                    ''' )
    S_ii.connect('i != j', p=p_ii)
    S_ii.w = weight_ii

If we add the S_ii to the simulation we get the following error:

NotImplementedError: Multiple "summed variables" 
target the variable "s_in" in group "neurongroup_1". 
Use multiple variables in the target group instead.

suggest to use multiple variable in in the target group,
but I don’t know how?
GitHup

I found this in the summed variables, it should help:

neurons = NeuronGroup(1, model='''dv/dt=(gtot-v)/(10*ms) : 1
                                  gtot = gtot1 + gtot2: 1
                                  gtot1 : 1
                                  gtot2 : 1''')

for others maybe read it later I put the full code here.

This is the direct fix for the error, but I think in your original model there is another issue: excitatory and inhibitory synapses have different reversal potentials, and their currents therefore need to be separated. Your model probably should look more like:

    membrane_Im = ... + gSyn_e*s_in_e*(ESyn_e-vm)
                      + gSyn_i*s_in_i*(ESyn_i-vm) : amp
    s_in_e : 1
    s_in_i : 1

and then the respective synapses either target s_in_e_post or s_in_i_post.

1 Like

Thank you @mstimberg. :+1:

1 Like