-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfhn_sample.py
More file actions
34 lines (25 loc) · 790 Bytes
/
fhn_sample.py
File metadata and controls
34 lines (25 loc) · 790 Bytes
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
from spine import FitzHughNagumo
import numpy as np
import matplotlib.pyplot as plt
if __name__ == '__main__':
# init experimental time and time-step
time = 100
dt = 0.1
# create Hodgkin-Huxley Neuron
neu = FitzHughNagumo(time, dt)
# Input data (sin curve)
input_data = np.sin(0.2 * np.arange(0, time, dt))
input_data = np.where(input_data > 0, 0.8, 0.1)
v, u = neu.calc_v(input_data)
# plot
x = np.arange(0, time, dt)
plt.subplot(2, 1, 1)
plt.title('FitzHugh-Nagumo Neuron model Simulation')
plt.plot(x, input_data)
plt.ylabel('input')
plt.subplot(2, 1, 2)
plt.plot(x, v, label='v: recovery variable')
plt.plot(x, u, label='u: membrane potential')
plt.xlabel('time [ms]')
plt.legend()
plt.show()