-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathelif_neuron_impl.py
78 lines (55 loc) · 1.38 KB
/
elif_neuron_impl.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
from matplotlib import pyplot as plt
import numpy as np
from neuron import h
from neuron.units import ms
h.load_file('stdrun.hoc')
from nrn_impl import eLIFNeuron
''' Create the neuron '''
params = {
"C_m": 100.,
"g_L": 9.,
"E_0": -62.5,
"I_e": 0.,
"E_u": -58.5,
"V_th": -59.,
"alpha": 1.,
"E_d": -40.,
"E_f": -62.,
"t_ref": 2.,
"epsilon_0": 0.5,
"epsilon_c": 0.18,
"delta": 0.01,
"V_reset": -62.,
"tau_e": 200.,
}
neuron = eLIFNeuron(params)
''' Record and stimulate '''
t_vec = h.Vector().record(h._ref_t)
v_vec = h.Vector().record(neuron._seg._ref_v)
e_vec = h.Vector().record(neuron._model._ref_epsilon)
# current clamps
num_steps = 10
iclamps = []
times = [i*11000 for i in range(num_steps)]
amps = [i for i in np.linspace(0, 120, num_steps)]
for t, I in zip(times, amps):
i = h.IClamp(0.5, sec=neuron._sec)
i.delay = t # ms
i.dur = 1000. # ms
i.amp = I
iclamps.append(i)
''' Run and plot '''
h.finitialize(-61.)
neuron.epsilon = 0.32
h.continuerun((times[-1] + 10000) * ms)
t_vec /= 1000.
fig, (ax1, ax2) = plt.subplots(2, sharex=True)
pos = (np.array(v_vec) >= neuron.V_th)*(np.array(e_vec) >= neuron.epsilon_c)
v_vec = np.array(v_vec)
v_vec[pos] = -10.
ax1.plot(t_vec, v_vec, label="nrn")
ax2.plot(t_vec, e_vec)
ax1.set_ylabel("V (mV)")
ax2.set_ylabel("epsilon")
ax2.set_xlabel("time (s)")
plt.show()