| 1 |
""" |
| 2 |
A model with adaptive threshold (increases with each spike) |
| 3 |
""" |
| 4 |
from brian2 import * |
| 5 |
|
| 6 |
eqs = ''' |
| 7 |
dv/dt = -v/(10*ms) : volt |
| 8 |
dvt/dt = (10*mV-vt)/(15*ms) : volt |
| 9 |
''' |
| 10 |
|
| 11 |
reset = ''' |
| 12 |
v = 0*mV |
| 13 |
vt += 3*mV |
| 14 |
''' |
| 15 |
|
| 16 |
IF = NeuronGroup(1, model=eqs, reset=reset, threshold='v>vt', |
| 17 |
method='exact') |
| 18 |
IF.vt = 10*mV |
| 19 |
PG = PoissonGroup(1, 500 * Hz) |
| 20 |
|
| 21 |
C = Synapses(PG, IF, on_pre='v += 3*mV') |
| 22 |
C.connect() |
| 23 |
|
| 24 |
Mv = StateMonitor(IF, 'v', record=True) |
| 25 |
Mvt = StateMonitor(IF, 'vt', record=True) |
| 26 |
# Record the value of v when the threshold is crossed |
| 27 |
M_crossings = SpikeMonitor(IF, variables='v') |
| 28 |
run(2*second, report='text') |
| 29 |
|
| 30 |
subplot(1, 2, 1) |
| 31 |
plot(Mv.t / ms, Mv[0].v / mV) |
| 32 |
plot(Mvt.t / ms, Mvt[0].vt / mV) |
| 33 |
ylabel('v (mV)') |
| 34 |
xlabel('t (ms)') |
| 35 |
# zoom in on the first 100ms |
| 36 |
xlim(0, 100) |
| 37 |
subplot(1, 2, 2) |
| 38 |
hist(M_crossings.v / mV, bins=np.arange(10, 20, 0.5)) |
| 39 |
xlabel('v at threshold crossing (mV)') |
| 40 |
show() |