FacetsPythonCourse2008: adaptive_threshold.py

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