models.py 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. import brian2 as br
  2. from brian2 import umetre, ufarad, cm, siemens, mV, msiemens, nS, ms
  3. # Hodgkin Huxley model from Brian2 documentation
  4. # The model
  5. area = 20000 * umetre ** 2
  6. hodgkin_huxley_params = {
  7. "Cm": 1 * ufarad * cm ** -2 * area,
  8. "gl": 5e-5 * siemens * cm ** -2 * area,
  9. "El": -65 * mV,
  10. "EK": -90 * mV,
  11. "ENa": 50 * mV,
  12. "g_na": 100 * msiemens * cm ** -2 * area,
  13. "g_kd": 30 * msiemens * cm ** -2 * area,
  14. "VT": -63 * mV
  15. }
  16. hodgkin_huxley_eqs = br.Equations('''
  17. dv/dt = (gl*(El-v) - g_na*(m*m*m)*h*(v-ENa) - g_kd*(n*n*n*n)*(v-EK) + I + ih)/Cm : volt
  18. dm/dt = 0.32*(mV**-1)*(13.*mV-v+VT)/
  19. (exp((13.*mV-v+VT)/(4.*mV))-1.)/ms*(1-m)-0.28*(mV**-1)*(v-VT-40.*mV)/
  20. (exp((v-VT-40.*mV)/(5.*mV))-1.)/ms*m : 1
  21. dn/dt = 0.032*(mV**-1)*(15.*mV-v+VT)/
  22. (exp((15.*mV-v+VT)/(5.*mV))-1.)/ms*(1.-n)-.5*exp((10.*mV-v+VT)/(40.*mV))/ms*n : 1
  23. dh/dt = 0.128*exp((17.*mV-v+VT)/(18.*mV))/ms*(1.-h)-4./(1+exp((40.*mV-v+VT)/(5.*mV)))/ms*h : 1
  24. I : amp
  25. ''')
  26. hodgkin_huxley_cond_synapse_weak_noise_eqs = br.Equations('''
  27. dv/dt = (gl*(El-v) - g_na*(m*m*m)*h*(v-ENa) - g_kd*(n*n*n*n)*(v-EK) + I + ih - g_syn*(v-E_i))/Cm + sigma_noise*sqrt(1./tau_noise)*xi : volt
  28. dm/dt = 0.32*(mV**-1)*(13.*mV-v+VT)/
  29. (exp((13.*mV-v+VT)/(4.*mV))-1.)/ms*(1-m)-0.28*(mV**-1)*(v-VT-40.*mV)/
  30. (exp((v-VT-40.*mV)/(5.*mV))-1.)/ms*m : 1
  31. dn/dt = 0.032*(mV**-1)*(15.*mV-v+VT)/
  32. (exp((15.*mV-v+VT)/(5.*mV))-1.)/ms*(1.-n)-.5*exp((10.*mV-v+VT)/(40.*mV))/ms*n : 1
  33. dh/dt = 0.128*exp((17.*mV-v+VT)/(18.*mV))/ms*(1.-h)-4./(1+exp((40.*mV-v+VT)/(5.*mV)))/ms*h : 1
  34. I : amp
  35. g_syn: siemens
  36. ''')
  37. hodgkin_huxley_with_external_input_eqs = br.Equations('''
  38. dv/dt = (gl*(El-v) - g_na*(m*m*m)*h*(v-ENa) - g_kd*(n*n*n*n)*(v-EK) + I + ih)/Cm
  39. : volt
  40. dm/dt = 0.32*(mV**-1)*(13.*mV-v+VT)/
  41. (exp((13.*mV-v+VT)/(4.*mV))-1.)/ms*(1-m)-0.28*(mV**-1)*(v-VT-40.*mV)/
  42. (exp((v-VT-40.*mV)/(5.*mV))-1.)/ms*m : 1
  43. dn/dt = 0.032*(mV**-1)*(15.*mV-v+VT)/
  44. (exp((15.*mV-v+VT)/(5.*mV))-1.)/ms*(1.-n)-.5*exp((10.*mV-v+VT)/(40.*mV))/ms*n : 1
  45. dh/dt = 0.128*exp((17.*mV-v+VT)/(18.*mV))/ms*(1.-h)-4./(1+exp((40.*mV-v+VT)/(5.*mV)))/ms*h : 1
  46. I = I_ext_const + stimulus(t) : amp (constant over dt)
  47. I_ext_const : amp
  48. ''')
  49. hodgkin_huxley_eqs_with_synaptic_conductance = br.Equations('''
  50. dv/dt = (gl*(El-v) - g_na*(m*m*m)*h*(v-ENa) - g_kd*(n*n*n*n)*(v-EK) + I + ih - g_syn*(v-E_i))/Cm : volt
  51. dm/dt = 0.32*(mV**-1)*(13.*mV-v+VT)/
  52. (exp((13.*mV-v+VT)/(4.*mV))-1.)/ms*(1-m)-0.28*(mV**-1)*(v-VT-40.*mV)/
  53. (exp((v-VT-40.*mV)/(5.*mV))-1.)/ms*m : 1
  54. dn/dt = 0.032*(mV**-1)*(15.*mV-v+VT)/
  55. (exp((15.*mV-v+VT)/(5.*mV))-1.)/ms*(1.-n)-.5*exp((10.*mV-v+VT)/(40.*mV))/ms*n : 1
  56. dh/dt = 0.128*exp((17.*mV-v+VT)/(18.*mV))/ms*(1.-h)-4./(1+exp((40.*mV-v+VT)/(5.*mV)))/ms*h : 1
  57. I : amp
  58. g_syn: siemens
  59. ''')
  60. # # First H-current from Izhikevich p. 48
  61. # ghbar = 40. * nS #Other values would be 0.5, 2, 3.5, 20 depending on neuron type (Rothman, Manis)
  62. # Eh = -43*mV
  63. # V_half_h = -75.0
  64. # k_h = -5.5
  65. # V_max_h = -75.
  66. # sigma_h = 15.
  67. # C_amp_h = 1000.
  68. # C_base_h = 100.
  69. # eqs_ih = """
  70. # ih = ghbar*r*(Eh-v) : amp
  71. # dr/dt= (rinf-r)/rtau : 1
  72. # rinf = 1. / (1+exp((V_half_h - v/mV) / k_h)) : 1
  73. # rtau = (C_base_h + C_amp_h * exp(-(V_max_h-v/mV)**2./sigma_h**2)) * ms : second
  74. # """
  75. # Second H-current from Izhikevich p. 48
  76. # eqs_ih = """
  77. # ih = ghbar*r*(Eh-v) : amp
  78. # dr/dt=(rinf-r)/rtau : 1
  79. # rinf = 1. / (1+exp((v/mV + 90.) / 7.)) : 1
  80. # # rtau = ((100000. / (237.*exp((v/mV+60.) / 12.) + 17.*exp(-(v/mV+60.) / 14.))) + 25.)*ms : second
  81. # rtau = 0.01*(100. + 1000. * exp(-(-76.-v/mV)**2./15.**2)) * ms : second #From Izhikevich
  82. # """
  83. ih_params = {
  84. "ghbar": 40. * nS, # Other values would be 0.5, 2, 3.5, 20 depending on neuron type (Rothman, Manis)
  85. "Eh": -1. * mV,
  86. "V_half_h": -95.0,
  87. "k_h": -5.5,
  88. "V_max_h": -75.,
  89. "sigma_h": 20.,
  90. "C_amp_h": 50.,
  91. "C_base_h": 10.,
  92. }
  93. eqs_ih = """
  94. ih = ghbar*r*(Eh-v) : amp
  95. dr/dt= (rinf-r)/rtau : 1
  96. rinf = 1. / (1+exp((V_half_h - v/mV) / k_h)) : 1
  97. rtau = 0.1*(C_base_h + C_amp_h * exp(-(V_max_h-v/mV)**2./sigma_h**2)) * ms : second
  98. """
  99. lif_eqs = """
  100. dv/dt =1.0/tau* (-v + u_ext) :volt (unless refractory)
  101. u_ext = u_ext_const : volt
  102. """
  103. lif_params = {
  104. "tau": 7 * ms,
  105. "v_threshold": -40 * mV,
  106. "v_reset": -60 * mV,
  107. "tau_refractory": 0.0 * ms,
  108. "u_ext_const": -50 * mV
  109. }
  110. lif_options = {
  111. "threshold": "v>v_threshold",
  112. "reset": "v=v_reset",
  113. "refractory": "tau_refractory",
  114. 'method': 'euler'
  115. }
  116. delta_synapse_model = 'synaptic_strength: volt'
  117. delta_synapse_on_pre = 'v+=synaptic_strength'
  118. delta_synapse_param = {}
  119. exponential_synapse = """
  120. dg/dt = -g/tau_syn : siemens (clock-driven)
  121. g_syn_post = g :siemens (summed)
  122. synaptic_strength : siemens
  123. """
  124. exponential_synapse_on_pre = "g+=synaptic_strength"
  125. exponential_synapse_params = {
  126. "tau_syn": 1 * ms
  127. }
  128. noise_params = {
  129. 'sigma_noise': 1.0 * mV,
  130. 'tau_noise': 10. * ms
  131. }