Synapses: creating intermediary variables in the equation makes trouble when building the dependency graph- error 'The static variables are referring to each other' (which does not happen when equations are inserted in the NeuronGroup class)

53 views
Skip to first unread message

lal...@hotmail.fr

unread,
Dec 3, 2012, 3:09:35 PM12/3/12
to brians...@googlegroups.com
Hi all,

I am trying to use the new Synapses class with clock-driven update. During my trials, I often find that the error 'The static variables are referring to each other', while my dependency graph does not seem to have cycles.

The simplest example I could find is when intermediary variables are added (computing independently two variables a and b, and writing c=a+b, instead of building directly c). Such intermediary variables are not problematic at all in equations that are fed into the NeuronGroup class, which should have the same requirements as the Synapses class for the equations definition if I understood well.

Here is the example code. To get the mistake, the indicated lines should be commented:

from brian import *

# ######################################################################################
# Defining neuron/synapse model parameters
# ######################################################################################

V_t = -50 * mV
V_r = -55 * mV

V_L = -70 * mV
C_m = 0.5 * nF
g_m = 25 * nS

V_E= 0 * mV
w = 2.1
inc = 1

tau_AMPA = 2 * ms
g_AMPA = 0.104 * nS


g_NMDA = 0.327 * nS
tau_NMDA_rise = 2 * ms
tau_NMDA_decay = 100 * ms
inv_alpha = 2 * ms
C_Mg2_times_constant = (1/3.57)
factor_in_exp_NMDA=0.062 * (mvolt**(-1))



# ######################################################################################
# Defining neuron model equation
# ######################################################################################

eqs = '''

dV/dt = (-1/C_m)*((g_m)*(V-V_L) + I_tot) : volt
I_tot : amp

'''

# ######################################################################################
# Defining synapse model equation
# ######################################################################################

# the following code, with intermediary variables, does not work: Gives the error raise ReferenceError, "The static variables are referring to each other"
eqs_syn = '''
I_T=I_AMPA+I_NMDA : amp

I_NMDA=(g_NMDA*(V_post-V_E)*w*s_NMDA)/(1+C_Mg2_times_constant*(exp(-V_post*factor_in_exp_NMDA))) : amp

ds_NMDA/dt=-(1/tau_NMDA_decay)*s_NMDA+(1/inv_alpha)*x*(1-s_NMDA) : 1
dx/dt=-(1/tau_NMDA_rise)*x : 1

I_AMPA=s_AMPA*w*g_AMPA*(V_post-V_E) : amp
ds_AMPA/dt=(-1/tau_AMPA)*s_AMPA : 1
'''

# the following code, without intermediary variables, works ; the 8 following lines should be commented to get the error message
eqs_syn = '''
I_T=s_AMPA*w*g_AMPA*(V_post-V_E)+(g_NMDA*w*(V_post-V_E)*w*s_NMDA)/(1+C_Mg2_times_constant*(exp(-V_post*factor_in_exp_NMDA))) : amp

ds_NMDA/dt=-(1/tau_NMDA_decay)*s_NMDA+(1/inv_alpha)*x*(1-s_NMDA) : 1
dx/dt=-(1/tau_NMDA_rise)*x : 1

ds_AMPA/dt=(-1/tau_AMPA)*s_AMPA : 1
'''


# ######################################################################################
# Creating the post-synaptic neuron
# ######################################################################################

neuron_post = NeuronGroup(1,model=eqs, threshold=V_t, reset=V_r)


# ######################################################################################
# Creating the pre-synaptic stimulation
# ######################################################################################

spiketimes=[(0,15*ms)]

inputs=SpikeGeneratorGroup(1,spiketimes)


# ######################################################################################
# Creating the synaptic connection between presynaptic input and post-synaptic neurons
# ######################################################################################

mix_Syn=Synapses(inputs, neuron_post, model = eqs_syn, pre='''x+=inc
                                                              s_AMPA+=inc''')
neuron_post.I_tot=mix_Syn.I_T

mix_Syn[0,0]=True

mix_Syn.delay= 0.5 * ms

# ######################################################################################
# Setting the initial values
# ######################################################################################

neuron_post.V = V_L

mix_Syn.I_T[0,0]=0
mix_Syn.s_NMDA[0,0]=0
mix_Syn.x[0,0]=0
mix_Syn.s_AMPA[0,0]=0

#with the code that does not work, we would also have:
#mix_Syn.I_NMDA[0,0]=0
#mix_Syn.I_AMPA[0,0]=0

# ######################################################################################
# Running
# ######################################################################################

run(1500 * ms)


Thanks for any help, I am currently stuck with this...


Laureline

Marcel Stimberg

unread,
Dec 3, 2012, 4:51:13 PM12/3/12
to brians...@googlegroups.com, lal...@hotmail.fr
Hi Laureline,
> I am trying to use the new Synapses class with clock-driven update.
> During my trials, I often find that the error 'The static variables
> are referring to each other', while my dependency graph does not seem
> to have cycles.
thanks for the bug report. It turned out this was quite a small error in
the Synapses code (using a list of identifiers instead of a set). If you
don't mind running the newest Brian version from trunk: a fix should be
in revision 3663 (http://neuralensemble.org/trac/brian/changeset/3663).

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