论文地址:https://www.frontiersin.org/articles/10.3389/neuro.10.009.2009/full
MAT神经元模型,在我看来就是一个变动阈值一个模型,所以对于他的细胞膜电压不会有发放或者不发放的时候。
这个就是神经元细胞膜电压的变动公式,类似LIF,但是这个模型跟LIF的区别在于,它不重置,所以在这个公式里面就没有重置电势。
对比一下:
这是LIF的电势变动。
先上一下结果图:
从这个图里可以看见,是适应性阈值在碰到模型电势之后阈值往上抬,然后在按照一定规则下降,再次碰到细胞膜电势之后再阈值抬高。现在开始解释阈值变动规则。
其中ω是阈值的初始设定值,H(t)是变动值,tk是上个脉冲的发放时间,所以它是阈值是越来越小的。
指数函数的图像,已知e是大于1的数且τj是时间常数大于0。αj是权重
上代码!
import sys
import subprocess
import matplotlib.pyplot as plt
#Parameters for MAT parameters
tau = 5.0 #τm 5ms
R = 50.0 #电源电阻
E_L = -65 #静息电位
v = E_L #膜电位电势
#parameters for Adaptive Threshold 适应性阈值的参数
#修改参数把神经元改成 RS神经元、IB神经元、FS神经元以及CH神经元,下面这一种神经元是RS神经元
t_f = 0; t_ref = 20 #不应期
x = [0, 0]
tau_1 = 10; tau_2 = 200 #τ1 = 10ms τ2 = 200ms
alpha = [30,2.0]
omega = -45
#Simulation Parameters 仿真参数 dt是时间间隙
num = 0; dt = 0.1
with open("current_sample.txt", 'r') as f_cur: #读取text文件
data = list(map(float, f_cur.read().splitlines()))
print(data)
num = len(data)
print(num)
f_volt = open('voltage.txt', 'w', encoding='UTF-8')
f_sp = open('spiketime.txt', 'w', encoding='UTF-8')
y_list = [] # List of recorded voltage
v_th_list = [] # List of threshold
for i in range(num):
I_ex = data[i]
#v = (1 - 1.0/tau*dt) * v + (R/tau) * dt * I_ex
v = v + (R*I_ex - (v - E_L))/tau * dt
#Adapting Threshold
x[0] = (1 - 1.0/tau_1*dt) * x[0] #Fast $B!' (Btau_1= 10 ms
x[1] = (1 - 1.0/tau_2*dt) * x[1] #Slow: tau_2= 200 ms
v_th = omega + x[0] + x[1]
y = v
#Condition for Spike Generation (v_th: threshold, t_ref: reflactory period)
if v_th < v and t_f + t_ref < i + 1:
x[0] += alpha[0]
x[1] += alpha[1]
t_f = i + 1
f_volt.write('{:.6f} 0\n'.format(i*dt)) #Output Voltage 输出的电压
f_sp.write('{:.6f}\n'.format(t_f*dt)) #Output SpikeTime 脉冲的发放时间
y = 0
else:
f_volt.write('{:.6f} {:.6f}\n'.format(i*dt, v))
y_list.append(y)
v_th_list.append(v_th)
time = [i*dt for i in range(num)]
fig = plt.figure()
plt.plot(time, y_list, label="voltage")
plt.plot(time, v_th_list, label="threshold")
plt.xlabel("time [ms]")
plt.ylabel("voltage [mV]")
plt.legend(loc='upper left', bbox_to_anchor=(1, 1))
plt.tight_layout()
plt.show()
fig.savefig("spike.eps")
fig.savefig("spike.png")
f_volt.close()
f_sp.close()