55 lines
1.2 KiB
Python
55 lines
1.2 KiB
Python
import numpy as np
|
|
import matplotlib.pyplot as plt
|
|
from models.LeakyIntegrateFireModel import LIFModel
|
|
|
|
|
|
# def calculate_step(current_v, tau, i_b, step_size=0.01):
|
|
# return current_v + (step_size * (-current_v + mem_res * i_b)) / tau
|
|
|
|
def function_e(x):
|
|
return (0-15) * np.e**(-x/1) + 15
|
|
|
|
# x_values = np.arange(0, 5, 0.01)
|
|
# plt.plot(x_values, [function_e(x) for x in x_values])
|
|
# plt.show()
|
|
|
|
|
|
# def function_f(i_base, tau=1, threshold=10, reset=0):
|
|
# return -1/(tau*np.log((threshold-i_base)/(reset - i_base)))
|
|
#
|
|
# x_values = np.arange(0, 20, 0.001)
|
|
# plt.plot(x_values, [function_f(x) for x in x_values])
|
|
# plt.show()
|
|
|
|
|
|
# LIF test:
|
|
# Rm = 100 MOhm, Cm = 200pF
|
|
step_size = 0.01 # ms
|
|
mem_res = 100*1000000
|
|
tau = 1
|
|
base_freq = 30
|
|
v_threshold = 10
|
|
base_input = -(- v_threshold / (np.e**(-1/(base_freq*tau))) + 1) / mem_res
|
|
|
|
stim1 = int(1000/step_size) * [base_input]
|
|
|
|
stimulus = []
|
|
stimulus.extend(stim1)
|
|
|
|
lif = LIFModel(mem_res, tau, 0, 0, stimulus, 10)
|
|
|
|
voltage, spikes_b = lif.calculate_response()
|
|
y_spikes = []
|
|
x_spikes = []
|
|
for i in range(len(spikes_b)):
|
|
if spikes_b[i]:
|
|
y_spikes.append(10.5)
|
|
x_spikes.append(i*step_size)
|
|
|
|
time = np.arange(0, 1000, step_size)
|
|
plt.plot(time, voltage)
|
|
plt.plot(x_spikes, y_spikes, 'o')
|
|
plt.show()
|
|
plt.close()
|
|
|