为经典的霍奇金·赫x黎ODE增加高斯白噪声以提高膜电位
嗨,
我已经找到了通过霍奇金·赫x黎方程评估膜电位的代码。
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
我可以简单地将其添加到微分方程中吗?
亲切的问候,并在此先感谢
答案 0 :(得分: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