将高斯白噪声添加到经典的 Hodgkin Huxley ODE 中以获得膜电位
大家好,
我找到了通过霍奇金赫胥黎方程评估膜电位的代码。
import matplotlib.pyplot as plt
import numpy as np
from scipy.integrate import odeint
#runtime in milliseconds
#print("Type in the runtime-interval (in milliseconds)")
#t_0 = input()
#t_1 = input()
t_0 = 0.0
t_1 = 200.0
print("The interval of runtime is:")
print(t_0, t_1)
#Potassium (alpha_n, beta_n) and Sodium (alpha_m, beta_m, alpha_h, beta_h) ion-channel rate functions
def alpha_n(V):
return (0.01*(10.0-V))/(np.exp((10.0-V)/10.0)-1.0)
def alpha_m(V):
return (0.1*(25.0-V))/(np.exp((25.0-V)/10.0)-1)
def beta_n(V):
return 0.125*np.exp(-V/80.0)
def beta_m(V):
return 4.0*np.exp(-V/18.0)
def alpha_h(V):
return 0.07*np.exp(-V/20.0)
def beta_h(V):
return (1.0)/((np.exp((30.0-V)/10.0))+1)
#mostly used parameters
#Sodium potential (mV)
V_NA = 50.0
#Potassium Potential
V_K = -77.0
#Leak Potential
V_L = -54.4
#Potassium channel conductance
g_k = 36.0
#Sodium channel conductance
g_NA = 120.0
#Leak channel conductance
g_L = 0.3
#Membrane capacitance
C = 1.0
#equally ('distributed') time values
T = np.linspace(t_0,t_1,10000)
#please input the stimulus (first of all with a fixed stimulus)
#one spike below
def stim(t):
if 0.0 < t < 1.0:
return 150.0
elif 35.0 < t < 36.0 :
return 5000.0
return 0.0
#steady - state values
def n_infty(V = 0.0):
return alpha_n(V)/(alpha_n(V)+beta_n(V))
def m_infty(V = 0.0):
return alpha_m(V)/(alpha_m(V)+beta_m(V))
def h_infty(V = 0.0):
return alpha_h(V)/(alpha_h(V)+beta_h(V))
def tau_m(V = 0.0):
return 1.0/(alpha_m(V)+beta_m(V))
def tau_n(V = 0.0):
return 1.0/(alpha_n(V)+beta_n(V))
def tau_h(V = 0.0):
return 1.0/(alpha_h(V)+beta_h(V))
#derivatives
def derivatives(x, z):
dx = np.zeros((4,))
V = x[0]
m = x[1]
n = x[2]
h = x[3]
dx[0] = (stim(z)-g_NA*np.power(m,3.0)*h*(V-V_NA)-g_k*np.power(n,4.0)*(V-V_K)-g_L*(V-V_L))/1.0
dx[1] = (m_infty(V)-m)/tau_m(V)
dx[2] = (n_infty(V)-n)/tau_n(V)
dx[3] = (h_infty(V)-h)/tau_h(V)
return dx
X = np.array([0.0,m_infty(),n_infty(),h_infty()])
V_x = odeint(derivatives,X,T)
print(V_x)
plt.plot(T,V_x)
plt.xlabel('Time in ms')
plt.ylabel('Membrane Potential in mV')
我想添加一个高斯白噪声过程 - 但我不太确定如何添加,因为我不是一个很棒的 python 用户 -
也许
noise = numpy.random.normal(mean=0.0, std=1.0, size=T)
和
dx[0] =
(stim(z)-g_NA*np.power(m,3.0)*h*(V-V_NA)-g_k*np.power(n,4.0)*(V-V_K)-g_L*(V-V_L))/1.0
+ noise
我可以简单地将其添加到微分方程中吗?
提前致以亲切的问候和非常感谢
最佳答案
首先您需要将噪声参数添加到函数中,
def derivatives(x, z,noisyInput):
您已经创建了正态分布的噪声。
noisyInput = np.ones(length)*7 + np.random.normal(0,3,length)
您只需在 dvdt 项中添加噪声项除以容量即可。
dx[0] = (noisyInput + stim(z)-g_NA*np.power(m,3.0)*h*(V-V_NA)-g_k*np.power(n,4.0)*(V-V_K)-g_L*(V-V_L))/1.0
并且您应该将噪声传递给函数。
V_x = odeint(derivatives,X,T,args=(noisyInput,))
您还可以查看我编写的代码: https://github.com/nosratullah/HodgkinHuxely
关于python - 高斯白噪声到霍奇金赫胥黎方程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56514770/