Help - unexpected error

99 views
Skip to first unread message

Dimitris Chatzakis

unread,
Nov 15, 2018, 3:24:01 PM11/15/18
to Brian Development
Hello guys I am trying to create a new Izhikevich simple model neuron in brian, but it creates an error that I do not undestand or know how to handle. Can anyone help please? It will be highly apreciated


MY CODE

from brian2 import *
import numpy as np
%matplotlib inline

#========================================================
#THIS CODE IS FOR CREATING AN IZHIKEVICH RESONATOR NEURON
#========================================================

start_scope()

#DECLARATION OF CONSTANTS FOR THE NEURON MODEL
C=1*pfarad
a=0.6/msecond
b=0.8*pamp/mvolt
Vreset=-45*mvolt
Vpeak=50*mvolt #arbitrary-do we need this?
Vrest=-70*mvolt  #arbitrary
Vthresh=-35*mvolt #arbitrary
k=0.7*pamp/mvolt/mvolt #arbitrary
d=-20*pamp

Imean=15.4
sigma=0.3

#Gaussian distribution of current
Iin=np.random.normal(Imean,sigma)
Iin=Iin*pamp

#EQUATIONS OF NEURON
eqs='''
dV/dt=1/C*(k*(V-Vrest)*(V-Vthresh)-u+Iin) : volt
du/dt=a*(b*(V-Vrest)-u) : amp
'''

defaultclock.dt = 0.1*ms

#creation of neuron
G=NeuronGroup(1,eqs,threshold='V=Vthresh',reset='V>Vpeak,V=Vreset',method='euler')

#TESTING
M = StateMonitor(G, 'V', record=True)

G.V = -30*mvolt # initial value

run(600*ms)

plot(M.t/ms, M.V[0])
xlabel('Time (ms)')
ylabel('V')


MY ERROR

Traceback (most recent call last):

  File "/home/tzikos/anaconda3/lib/python3.6/site-packages/IPython/core/interactiveshell.py", line 3267, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)

  File "<ipython-input-4-ad1c754ecb3c>", line 45, in <module>
    run(600*ms)

  File "/home/tzikos/anaconda3/lib/python3.6/site-packages/brian2/units/fundamentalunits.py", line 2375, in new_f
    result = f(*args, **kwds)

  File "/home/tzikos/anaconda3/lib/python3.6/site-packages/brian2/core/magic.py", line 371, in run
    namespace=namespace, profile=profile, level=2+level)

  File "/home/tzikos/anaconda3/lib/python3.6/site-packages/brian2/core/magic.py", line 231, in run
    namespace=namespace, profile=profile, level=level+1)

  File "/home/tzikos/anaconda3/lib/python3.6/site-packages/brian2/core/base.py", line 276, in device_override_decorated_function
    return func(*args, **kwds)

  File "/home/tzikos/anaconda3/lib/python3.6/site-packages/brian2/units/fundamentalunits.py", line 2375, in new_f
    result = f(*args, **kwds)

  File "/home/tzikos/anaconda3/lib/python3.6/site-packages/brian2/core/network.py", line 951, in run
    self.before_run(namespace)

  File "/home/tzikos/anaconda3/lib/python3.6/site-packages/brian2/core/base.py", line 276, in device_override_decorated_function
    return func(*args, **kwds)

  File "/home/tzikos/anaconda3/lib/python3.6/site-packages/brian2/core/network.py", line 843, in before_run
    raise brian_object_exception("An error occurred when preparing an object.", obj, ex)

  File "<string>", line unknown
BrianObjectException


I have located the problem to be at the run(600*ms ) but no one in my lab knows why this happens. If i comment it out, the rest works. Can you help please???

Unang Sunarya

unread,
Nov 15, 2018, 9:18:09 PM11/15/18
to brian-de...@googlegroups.com
First time  I also got error on these:
C=1*pfarad --------------------C=1*brian2.pfarad  

I added  brian2. before unit,  then I fixed the error of unit. I implemented it using Spyder for python,



Virus-free. www.avast.com

--

---
You received this message because you are subscribed to the Google Groups "Brian Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to brian-developm...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Virus-free. www.avast.com

Marcel Stimberg

unread,
Nov 16, 2018, 8:40:17 AM11/16/18
to brian-de...@googlegroups.com
Hi,

you are getting this unhelpful error message because you are running the
code from a jupyter notebook, and this interacted badly with syntax
errors in the code (it has been fixed in Brian's source code recently,
but that fix is not yet part of a release:
https://github.com/brian-team/brian2/issues/964).

If you run your script with python, you get a syntax error complaining
about your threshold condition "V=Vthresh" -- this has to be a logical
condition and not an assignment. Your reset statement is not valid,
either. Statements have to be variable assignments (e.g. "V=reset") and
not conditions (e.g. "V>Vpeak").

For the Izhikevich model this should be normally something like
threshold="V>Vpeak", reset="V=Vreset; u += d".

Best,

  Marcel


Dimitris Chatzakis

unread,
Nov 16, 2018, 8:42:33 AM11/16/18
to brian-de...@googlegroups.com
Thanks everyone. The problem was in the logical syntax. I fixed it. Thanks a bunch again.

--

---
You received this message because you are subscribed to a topic in the Google Groups "Brian Development" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/brian-development/dnaZ4i2USxE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to brian-developm...@googlegroups.com.

Maryam Idea

unread,
Jan 16, 2022, 1:29:27 PM1/16/22
to Brian Development

Hi , excuseme ,i get same error for run
may you help me to fix it and explain how can i fix my error

Rajeswari Yerraguntla ee21d015

unread,
Nov 21, 2022, 8:52:37 AM11/21/22
to Brian Development
parse exception.png
Hi , iam also getting same error.. can some one help me..

Marcel Stimberg

unread,
Nov 21, 2022, 9:04:04 AM11/21/22
to Brian Development
Hi,
please note that this mailing list/google group is no longer used, please ask questions at the discourse forum instead:

That said, there are two issues here: the first is that you are getting an unhelpful error message. I think this indicates that you are using a very old version of Brian (something older than 2.2.1?), the error message should be more helpful with newer versions (if not, please let me know!). But the main issue–and the reason that you are getting an error in the first place–is an incorrect definition of your "reset": Instead of "reset = 'vm'", you need to use "reset = 'vm=v_reset'", i.e. you need to define what should happen to the vm variable after a spike.

Best,
  Marcel

Rajeswari Yerraguntla ee21d015

unread,
Nov 21, 2022, 9:04:54 AM11/21/22
to Brian Development
yes thanks a lot.. it got rectified

Rajeswari Yerraguntla ee21d015

unread,
Nov 21, 2022, 9:07:50 AM11/21/22
to Brian Development
can you provide link for tutorial on brian.. It can be reading material or youtube lecture series.. thanks in advance

Marcel Stimberg

unread,
Nov 21, 2022, 9:10:46 AM11/21/22
to brian-de...@googlegroups.com

Our website at https://briansimulator.org has several links, e.g. you can find the tutorials here: https://brian2.readthedocs.io/en/stable/resources/tutorials/index.html

Our youtube channel (https://www.youtube.com/channel/UCvRrNQaL_y58ZjWbmekbFvQ) has quite a long "introduction to Brian" video that goes through some of the tutorial material as well.

Best,

  Marcel

You received this message because you are subscribed to the Google Groups "Brian Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to brian-developm...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/brian-development/8f4e4cad-0743-4cb5-b40e-e263aadd9b66n%40googlegroups.com.

Rajeswari Yerraguntla ee21d015

unread,
Nov 21, 2022, 10:19:32 PM11/21/22
to Brian Development
thanks  a lot.

Rajeswari Yerraguntla ee21d015

unread,
Nov 22, 2022, 7:06:40 AM11/22/22
to Brian Development
how to update threshold voltage after each spike?
please provide syntax and where to keep it?

Marcel Stimberg

unread,
Nov 23, 2022, 4:18:09 AM11/23/22
to brian-de...@googlegroups.com

Hi,

the documentation has an example with an adaptive threshold: https://brian2.readthedocs.io/en/stable/examples/adaptive_threshold.html

But as I said earlier, please ask future questions at https://brian.discourse.group

Best,

  Marcel

Reply all
Reply to author
Forward
0 new messages