Brian 2--Synapses--Key error

155 views
Skip to first unread message

barre...@gmail.com

unread,
Apr 15, 2014, 7:49:10 PM4/15/14
to brians...@googlegroups.com
Yep. I'm back. :P And I have a question with Brian 2. I need help diagnosing and correcting the following error:

KeyError: 'The identifier "Theta_syn" could not be resolved.'

with the following code (note that it looks similar to that of previous posts, but I noticed that they Synapses class has changed quite a bit):

from brian2 import *

#from brian.library.ionic_currents import *


## Constants

C = 1*mfarad; I = 40*mA

E_L = -80*mvolt; E_Na = 60*mvolt; E_K = -90*mvolt

g_L = 8*siemens; g_Na = 20*siemens; g_K = 10*siemens

g_syn = 10*siemens; maxConn = 50*mA

V_half_m = -20*mvolt; V_half_n = -25*mvolt

Theta_syn = -30*mvolt; V_syn = 30*mvolt

k_m = 15*mvolt; k_n = 5*mvolt

tau = 1*second; time = 10*second

V_01 = -10*mvolt; n_01 = 0.4

V_02 = -40*mvolt; n_02 = 0.3


equs = Equations('''

n_inf_V = 1/(1 + exp((V_half_n - V)/k_n)) : 1

m_inf_V = 1/(1 + exp((V_half_m - V)/k_m)) : 1

dV/dt = (I - g_L*(V - E_L) - g_Na*m_inf_V*(V - E_Na) -\

g_K*n*(V - E_K) + I_gap)/C : volt #was mvolt

dn/dt = (n_inf_V - n)/tau : 1

I_gap : amp''') #was mamp

G = NeuronGroup(N=2, model=equs, method='exponential_Euler')

G1 = G[0:1]

G2 = G[1:2]

G1.V = V_01; G1.n = n_01

G2.V = V_02; G2.n = n_02


synEqus = ('''w : siemens #conductivity

I_syn = w*(V_syn - V_pre)/(1 + exp(-100*(V_post - Theta_syn)/volt)) :\

amp ''')


S = Synapses(G1, G2, model=synEqus)

S.connect(True)

G.I_gap=S.I_syn

S.w = g_syn


M1 = MultiStateMonitor(G1, ['V', 'n'], record=0)

M2 = MultiStateMonitor(G2, ['V', 'n'], record=0)

#M3 = StateMonitor(S, 'I_gap', record=True)

defaultclock.t = 0*second

run(time)


plt.figure(1)

xlabel('Voltage (V)')

ylabel('Response')

title('V vs. n')

plot(M1['V'][0], M1['n'][0], 'k', c='b')

plot(M2['V'][0], M2['n'][0], 'k', c='g')


plt.figure(2)

xlabel('Time (s)')

ylabel('Voltage (mV)')

plot(M1['V'].times/second, M1['V'][0]/mV, 'k', c='b')

plot(M2['V'].times/second, M2['V'][0]/mV, 'k', c='g')


#plt.figure(3)

#plot(M1['V'].times/second, M3[0]/mA, c = 'r')


show()


barre...@gmail.com

unread,
Apr 16, 2014, 2:59:57 AM4/16/14
to brians...@googlegroups.com
Check that. I didn't pay attention to the fact that Brian 2 is still in testing stages. I guess that explains the MagicError that I keep getting, lol! Now, back to something we were discussing earlier. My synaptic code was finally producing results, but meaningless results. Marcel, you said:

"You could also try to make the time step smaller."

Since the coupling equation is stiff, that just might work. But how do I do that in Brian 1?

Richard Tomsett

unread,
Apr 16, 2014, 3:41:45 AM4/16/14
to brians...@googlegroups.com
The simplest way would be to change the time-step for the defaultclock object:

defaultclock.dt = 0.01*ms

Details:

Richard


--
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.

Marcel Stimberg

unread,
Apr 16, 2014, 6:11:37 AM4/16/14
to brians...@googlegroups.com
Hi,

as you said, Brian2 is still in development, though it is in a state
where it should work for most use cases already. One area where it needs
significant improvement is error messages and documentation -- the error
message is quite misleading in your case. Setting up the link from the
synaptic to the neuronal variable has a different syntax now:
http://brian2.readthedocs.org/en/latest/user/synapses.html#summed-variables

Also, the syntax for the monitors changed (StateMonitor provides the
functionality of MultiStateMonitor):
http://brian2.readthedocs.org/en/latest/reference/brian2.monitors.statemonitor.StateMonitor.html#brian2.monitors.statemonitor.StateMonitor

If you give Brian2 another try and run into problems, please report
issues to brian-de...@googlegroups.com instead of to this list.

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