Passing values into equations

17 views
Skip to first unread message

AD

unread,
Mar 16, 2020, 3:09:19 AM3/16/20
to Brian Development
Hello,

I am facing some issues while passing values into equations:

  g_L = 2*mS
  g_Ca = 4.4*mS
  g_K = 8*mS
  V_L = -60*mV
  V_Ca = 120*mV
  V_K = -84*mV
  lambda_n__max = 1.0/(15*ms)
  V_1 = -1.2*mV
  V_2 = 18*mV
  V_3 = 2*mV
  V_4 = 30*mV
  C = 20*uF
  C_calc = 0*uF
  C_min = 20*uF
  I_min = 70*uA
  alpha = 0.81*uF/uA  
  
  eqs = '''
     C_calc = C_min + (alpha*(I - I_min)**2)/I_min : farad
     C = C_calc*int(C_calc>C_min) + C_min*int(C_min>C_calc) : farad
     dv/dt = (-g_L*(v - V_L) - g_Ca*m_inf*(v - V_Ca) - g_K*n*(v - V_K) + I)/C : volt
     dn/dt = lambda_n*(n_inf - n) : 1
     m_inf = 0.5*(1 + tanh((v - V_1)/V_2)) : 1
     n_inf = 0.5*(1 + tanh((v - V_3)/V_4)) : 1
     lambda_n = lambda_n__max*cosh((v - V_3)/(2*V_4)) : 1
     I : amp
     inhibit : boolean
     v_th : 1'''

When I do this, I get an error saying V_4 could not be resolved:

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

Error encountered with object named "neurongroup_4".
Object was created here (most recent call only, full details in debug log):
  File "NewNetworkLoader.py", line 101, in init_network
    refractory = T_INHIBIT)

An error occurred when preparing an object. KeyError: 'The identifier "V_4" could not be resolved.'
(See above for original error message and traceback.)

Any idea what I am missing here?

Thanks!
AD
MML_SNN_200316.log

Marcel Stimberg

unread,
Mar 16, 2020, 4:27:46 AM3/16/20
to brian-de...@googlegroups.com

Hi,

the external constants have to be available at the point where you call the "run" function, not where you define the equation. I'm guessing that this is not the case in your script. If your code structure does not support defining the constants like this, you have two alternatives:

  1. Put the external variables into a dictionary and provide them as the "namespace" argument of the NeuronGroup or the run call (see https://brian2.readthedocs.io/en/stable/advanced/namespaces.html)
  2. Insert the values directly into the equations by using "eqs = Equations(eqs, V_1=-1.2*mV, V_2=18*mV, ...)" (see https://brian2.readthedocs.io/en/stable/user/equations.html#equation-objects)

Hope that helps, best

  Marcel


Reply all
Reply to author
Forward
0 new messages