m_MTM_W_sPNaS_sICD.py 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. from scipy import integrate
  2. from scipy.integrate import odeint
  3. import numpy as np
  4. from copy import copy
  5. Pars_MTM_W_sPNaS_sICD={
  6. 'I_app':1, #uA/cm2
  7. 'I_app_m':1, #uA/cm2
  8. 'I_app_a':1, #uA/cm2
  9. 'cof':500,#Hz
  10. 'C':1,#uF/cm2
  11. #Conductances
  12. 'g_Na':100, #mS/cm2
  13. 'g_K':200, #mS/cm2
  14. 'g_L':0.1, #mS/cm2
  15. #Activation and inactivation parameters
  16. #I_Na
  17. 'alpha_mV':54,
  18. 'beta_mV':27,
  19. 'alpha_hV':50,
  20. 'beta_hV':27,
  21. # 'alpha_h_mag':0.128,
  22. # 'alpha_h_ts':18,
  23. #I_K
  24. 'alpha_nV':52,
  25. 'beta_nV':57,
  26. #Extracellular concentrations
  27. 'Na_o':140,#mM
  28. 'K_o':15,#mM
  29. #Cell properties
  30. 'rho':4000,#check.. (cellular Area/Volume [1/cm] Vitzthum,2009)
  31. #(http://nitrolab.engr.wisc.edu/pubs/vitzthumIB09.pdf)
  32. 'remim':0.2,#Ratio ef extra to intra-cellular volume Zhang 2010,
  33. #( http://www.ncbi.nlm.nih.gov/pmc/articles/PMC2920647/ )
  34. 'P_K':0.96,
  35. 'P_Na':0.04,
  36. 'F':96484.6,#C/mol (Faraday constant)
  37. 'R':8314.4,#mJ/[mol*K] (Ideal gas constant)
  38. 'T':273.15+20,#K Temperature
  39. #Pump parameters
  40. 'I_max':40,#uA/uF... Paper Luo y Rudi 1.5!!
  41. #Simple pump parameters
  42. 'Na_sens0':20,
  43. 'Na_sens':0.1,
  44. 'parstNa':3,#Pump stoichiometry
  45. 'parstK':2,#Pump stoichiometry
  46. #Relative Timing of ionic accumulation
  47. 'r_fast_vs_ion':0.001,## Accounting for the fact the units of the change in concentrations is 1mM/S.. and the fast variables are in 1/ms
  48. #Temperature dependencies Q10s
  49. 'T0':273.15+18,
  50. 'Q10_gL':1.2,
  51. 'Q10_gNa':1.2,
  52. 'Q10_gK':1.2,
  53. 'Q10_gPump':1.2,
  54. 'Q10_n':2,
  55. 'Q10_m':2,
  56. 'Q10_h':2,
  57. #Initial conditions.. easy to manipulate from here at
  58. #the time of parameter exploration
  59. 'm_Na0':0.1,
  60. 'h_Na0':0.6,
  61. 'n_K0':0.4,
  62. 'Na_i0':10,
  63. 'K_i0':150,#Very high...(To initialize it far from the dep block)
  64. 'K_o0':8,
  65. 'V0':-60
  66. }
  67. # Mile traub model with simple pump[Na sensitive] definition
  68. class neuron_MTM_W_sPNaS_sICD():
  69. def __init__(self, p):
  70. self.s_model_tag="Traub-Miles Model with Na sensitive Pump, and temperature dependencies"
  71. self.s_model_reference=""
  72. self.p = p
  73. self.n_state_vars=7
  74. self.s_state_vars=["m_Na", "h_Na", "n_K", "Na_i",
  75. "K_i", "K_o", "V"]
  76. self.s_currents=["I_Na", "I_K", "I_1", "i_p", "I_L","I_L_K", "I_L_Na"]
  77. self.s_concentrations=["Na_i","K_i","K_o"]
  78. self.s_resting_membrane_potentials=["E_Na","E_K","E_L"]
  79. self.step_protocol=[]
  80. self.current_state=[self.p['m_Na0'],self.p['h_Na0'],self.p['n_K0'],
  81. self.p['Na_i0'],self.p['K_i0'],self.p['K_o0'],self.p['V0']]
  82. self.ode_solver="odeint"
  83. self.noisy_current=[]
  84. def resting_membrane_potentials(self,v_State_Vars):
  85. #Resting potential for each neuron
  86. m_Na, h_Na, n_K, Na_i, K_i, K_o, V = v_State_Vars
  87. E_Na=self.p['R']*self.p['T']/self.p['F']*np.log(self.p['Na_o']/Na_i)
  88. E_K=self.p['R']*self.p['T']/self.p['F']*np.log(K_o/K_i)
  89. E_L=self.p['R']*self.p['T']/self.p['F']*np.log((K_o*self.p['P_K']+
  90. self.p['Na_o']*self.p['P_Na'])/(K_i*self.p['P_K']+Na_i*self.p['P_Na']))
  91. return E_Na, E_K, E_L
  92. def neuron_currents(self,v_State_Vars,t=[],i_p_f=[]):
  93. #Resting potential for each neuron
  94. m_Na, h_Na, n_K, Na_i, K_i, K_o, V = v_State_Vars# Voltage it's always the last state variable
  95. E_Na, E_K, E_L=self.resting_membrane_potentials(v_State_Vars)
  96. #Pump
  97. if i_p_f==[]:
  98. if Na_i<=self.p['Na_sens0']/2:
  99. i_p=0
  100. if Na_i>self.p['Na_sens0']/2:
  101. temp_factor_p=self.p['Q10_gPump']**(
  102. (self.p['T']-self.p['T0'])/10)
  103. i_p=self.p['I_max']*(1/(1+np.exp(-self.p['Na_sens']*(
  104. Na_i-self.p['Na_sens0'])))-1/(1+np.exp(-self.p['Na_sens']*(
  105. -self.p['Na_sens0']/2))))*temp_factor_p
  106. else:
  107. i_p=i_p_f(t) ##Argument to force the pump to be f_i_p value
  108. # Fast Na current
  109. I_Na=self.p['g_Na']*m_Na**3*h_Na*(V-E_Na)*self.p['Q10_gNa']**(
  110. (self.p['T']-self.p['T0'])/10)
  111. #K+ delayed rectifier
  112. I_K=self.p['g_K']*n_K**4*(V-E_K)*self.p['Q10_gK']**(
  113. (self.p['T']-self.p['T0'])/10)
  114. #Leak
  115. I_L_K=self.p['g_L']*self.p['P_K']*(V-E_K)*self.p['Q10_gL']**(
  116. (self.p['T']-self.p['T0'])/10)#[uA/cm2]
  117. I_L_Na=self.p['g_L']*self.p['P_Na']*(V-E_Na)*self.p['Q10_gL']**(
  118. (self.p['T']-self.p['T0'])/10)#[uA/cm2]
  119. I_L=I_L_K+I_L_Na
  120. I_1=I_L+i_p*(self.p['parstNa']-self.p['parstK'])#[uA/cm2]
  121. return I_Na, I_K, I_1, i_p, I_L, I_L_K, I_L_Na
  122. def activation_inactivation_Dynamics(self,v_State_Vars):
  123. m_Na, h_Na, n_K, Na_i, K_i, K_o, V = v_State_Vars
  124. #Activation and inactivation variables
  125. #fast Na current
  126. alpha_m=0.32*(V+self.p['alpha_mV'])/(1-np.exp(
  127. -(V+self.p['alpha_mV'])/4))*self.p['Q10_m']**(
  128. (self.p['T']-self.p['T0'])/10)
  129. beta_m=0.28*(V+self.p['beta_mV'])/(np.exp(
  130. (V+self.p['beta_mV'])/5)-1)*self.p['Q10_m']**(
  131. (self.p['T']-self.p['T0'])/10)
  132. alpha_h=0.128*np.exp(-(V+self.p['alpha_hV'])/18)*self.p['Q10_h']**(
  133. (self.p['T']-self.p['T0'])/10)
  134. beta_h=4/(1+np.exp(-(V+self.p['beta_hV'])/5))*self.p['Q10_h']**(
  135. (self.p['T']-self.p['T0'])/10)
  136. #K+ delayed rectifier
  137. alpha_n=0.032*(V+self.p['alpha_nV'])/(1
  138. -np.exp(-(V+self.p['alpha_nV'])/5))*self.p['Q10_n']**(
  139. (self.p['T']-self.p['T0'])/10)
  140. beta_n=0.5*np.exp(-(V+self.p['beta_nV'])/40)*self.p['Q10_n']**(
  141. (self.p['T']-self.p['T0'])/10)
  142. return alpha_m, beta_m, alpha_h, beta_h, alpha_n, beta_n
  143. def neuron_changing_state(self,v_State_Vars,t,I_app,i_p_f):
  144. m_Na, h_Na, n_K, Na_i, K_i, K_o, V = v_State_Vars
  145. I_Na, I_K, I_1, i_p, I_L, I_L_K, I_L_Na=self.neuron_currents(v_State_Vars,t,i_p_f)
  146. alpha_m,beta_m,alpha_h,beta_h,alpha_n,beta_n=self.activation_inactivation_Dynamics(v_State_Vars)
  147. #Change of state variables
  148. dm_Na=alpha_m*(1-m_Na)-beta_m*m_Na
  149. dh_Na=alpha_h*(1-h_Na)-beta_h*h_Na
  150. dn_K=alpha_n*(1-n_K)-beta_n*n_K
  151. dNa_i=(self.p['rho']/self.p['F']*(
  152. -self.p['parstNa']*i_p-I_Na-I_L_Na)
  153. )*self.p['r_fast_vs_ion']
  154. dK_i=(self.p['rho']/self.p['F']*(self.p['parstK']*i_p
  155. -I_K-I_L_K))*self.p['r_fast_vs_ion']#Shut off o on..
  156. dK_o=-(dK_i)*self.p['remim']#Shut off o on..
  157. dV=1/self.p['C']*(I_app(t)-I_1-I_Na-I_K)
  158. return dm_Na, dh_Na, dn_K, dNa_i, dK_i, dK_o, dV
  159. def stimulate_neuron(self,t,c_ini,I_stim,i_p_f=[]):
  160. import copy
  161. sol= odeint(self.neuron_changing_state, c_ini,
  162. t, args=(I_stim,i_p_f))
  163. s_results=[]
  164. s_results=copy.copy(self.s_state_vars)
  165. s_results.append("t")
  166. t_prov=t[...,None]
  167. v_results=np.append(sol,t_prov,1)
  168. return s_results, v_results