FacetsPythonCourse2008: adaptive_threshold.py

File adaptive_threshold.py, 0.6 kB (added by goodman, 7 months ago)
Line 
1 '''
2 A model with adaptive threshold (increases with each spike)
3 '''
4 from brian import *
5
6 eqs='''
7 dv/dt = -v/(10*ms) : volt
8 dvt/dt = (10*mV-vt)/(15*ms) : volt
9 '''
10
11 def myreset(P, spikes):
12     P.v[spikes]=0*mV
13     P.vt[spikes]+=3*mV
14    
15 IF = NeuronGroup(1, model=eqs,
16         reset=myreset,
17         threshold=lambda v,vt:v>=vt)
18 IF.rest()
19 PG = PoissonGroup(1, 500*Hz)
20
21 C = Connection(PG, IF, 'v')
22 C.connect_full(PG, IF, 3*mV)
23
24 Mv = StateMonitor(IF, 'v', record=True)
25 Mvt = StateMonitor(IF, 'vt', record=True)
26
27 run(100*ms)
28
29 plot(Mv.times/ms, Mv[0]/mV)
30 plot(Mvt.times/ms, Mvt[0]/mV)
31
32 show()