笔记:
IZH模型python实现练习图, 蓝色线是输入【10mA】, 绿色是U随时间的变化,V是膜电压随时间的变化。
各变量的含义:
# a 恢复变量U的时间尺度,a越小,恢复的越慢
# b 恢复变量U依赖膜电位V的阈值下随机波动的敏感程度
# c 发放脉冲后,V的复位值 mV
# d 发放买抽,U的复位值
# V 膜电位
# U 恢复变量,用来代替生理模型中激活的K离子电流和失活的Na离子电流,实现对膜电位V的负反馈
把下面代码粘贴到Jupyter Notebook 运行即可得到上面的六种模型,
import random
import matplotlib.pyplot as plt
def floatRange(startInt, stopInt, stepInt, precision):
f = []
for x in range(startInt, stopInt, stepInt):
f.append(x/(10**precision))
return f
# a 恢复变量U的时间尺度,a越小,恢复的越慢
# b 恢复变量U依赖膜电位V的阈值下随机波动的敏感程度
# c 发放脉冲后,V的复位值 mV
# d 发放买抽,U的复位值
# V 膜电位
# U 恢复变量,用来代替生理模型中激活的K离子电流和失活的Na离子电流,实现对膜电位V的负反馈
def plotIZH(a, b, c, d, V, U, tSpan, tRange, I, title):
x = []
yI = []
yV = []
yU = []
for t in tRange:
# 下面5行是实现,其他都是工具代码,和IZH模型无关
V = V + tSpan * ( 0.04 * V**2 + 5 * V + 140 - U + I )
U = U + tSpan * ( a * ( b * V - U) )
if V >= 30: # 大于等于30mV
V = c
U = U + d
x.append(t)
yI.append(I)
yV.append(V)
yU.append(U)
plt.plot(x, yI, label = 'I')
plt.plot(x, yV, label = 'V')
plt.plot(x, yU, label = 'U')
plt.rcParams['font.sans-serif']=['SimHei'] #中文显示问题
plt.rcParams['axes.unicode_minus'] = False
plt.xlabel('时间')
plt.ylabel('电压/mV,电流/mA')
plt.legend()
plt.title("{0}n{1};{2};{3};{4}".format(title,a,b,c,d))
plt.show()
#--------------------------------
U = 0
tSpan = 0.6
tRange = floatRange(0, 2000, 6, 1) # 生成 [0.0, 0.6, 1.2, 1.8, 2.4, 3.0, 3.6, .... 198.0, 198.6, 199.2, 199.8]的序列
I = 10
plotIZH(0.02, 0.2, -65, 8, -65, U, tSpan, tRange, I, "RegularSpiking")
plotIZH(0.02, 0.2, -55, 4, -55, U, tSpan, tRange, I, "Intrinsically Bursting")
plotIZH(0.02, 0.2, -50, 2, -50, U, tSpan, tRange, I, "Chattering")
plotIZH(0.1, 0.2, -65, 2, -65, U, tSpan, tRange, I, "Fast Spiking")
plotIZH(0.02, 0.25, -65, 2, -65, U, tSpan, tRange, I, "Low-Threshold Spiking")
plotIZH(0.1, 0.2, -65, 2, -65, U, tSpan, tRange, I, "Last Spiking")
除了核心计算外,应该还有其他点需要注意,生成的图像不太稳定。
//TODO 待研究透了再更新文章。



