Python 霍奇金-赫胥黎方程的高斯白噪声
在经典的Hodgkin-Huxley膜电位ODE中加入高斯白噪声 大家好 我已经找到了通过霍奇金-赫胥黎方程计算的膜电位的代码Python 霍奇金-赫胥黎方程的高斯白噪声,python,Python,在经典的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()
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')
及
我能简单地把它加到微分方程中吗
向您致以亲切的问候和衷心的感谢首先,您需要将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,))
您还可以检查我编写的代码:
首先需要将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,))
您还可以检查我编写的代码:
你好,非常感谢。我们的目标是观察噪声的幅度是否与钠离子通道的平方根成正比-你有没有找到一种方法来得到这个结果?你能更具体地说,钠离子通道的平方根是什么意思?你是说钠通道的数量还是别的什么?顺便说一句,如果你想玩噪音和其他参数,我建议使用一些数值计算,而不是使用odeint函数。您还可以检查我在github中编写的代码。要坚强!嗨,我的意思是噪音应该与钠通道数的平方根成正比——我会直接在github上给你写信。非常感谢您的盛情款待。我们的目标是观察噪声的幅度是否与钠离子通道的平方根成正比-你有没有找到一种方法来得到这个结果?你能更具体地说,钠离子通道的平方根是什么意思?你是说钠通道的数量还是别的什么?顺便说一句,如果你想玩噪音和其他参数,我建议使用一些数值计算,而不是使用odeint函数。您还可以检查我在github中编写的代码。要坚强!嗨,我的意思是噪音应该与钠通道数的平方根成正比——我会直接在github上给你写信。问候