@@ -142,37 +142,41 @@ class HH(NeuGroup):
142142 >>> plt.yticks([])
143143 >>> plt.show()
144144
145-
146- **Model Parameters**
147-
148- ============= ============== ======== ====================================
149- **Parameter** **Init Value** **Unit** **Explanation**
150- ------------- -------------- -------- ------------------------------------
151- V_th 20. mV the spike threshold.
152- C 1. ufarad capacitance.
153- E_Na 50. mV reversal potential of sodium.
154- E_K -77. mV reversal potential of potassium.
155- E_leak 54.387 mV reversal potential of unspecific.
156- g_Na 120. msiemens conductance of sodium channel.
157- g_K 36. msiemens conductance of potassium channel.
158- g_leak .03 msiemens conductance of unspecific channels.
159- ============= ============== ======== ====================================
160-
161- **Model Variables**
162-
163- ================== ================= =========================================================
164- **Variables name** **Initial Value** **Explanation**
165- ------------------ ----------------- ---------------------------------------------------------
166- V -65 Membrane potential.
167- m 0.05 gating variable of the sodium ion channel.
168- n 0.32 gating variable of the potassium ion channel.
169- h 0.60 gating variable of the sodium ion channel.
170- input 0 External and synaptic input current.
171- spike False Flag to mark whether the neuron is spiking.
172- t_last_spike -1e7 Last spike time stamp.
173- ================== ================= =========================================================
174-
175- **References**
145+ Parameters
146+ ----------
147+ size: sequence of int, int
148+ The size of the neuron group.
149+ ENa: float, JaxArray, ndarray, Initializer, callable
150+ The reversal potential of sodium. Default is 50 mV.
151+ gNa: float, JaxArray, ndarray, Initializer, callable
152+ The maximum conductance of sodium channel. Default is 120 msiemens.
153+ EK: float, JaxArray, ndarray, Initializer, callable
154+ The reversal potential of potassium. Default is -77 mV.
155+ gK: float, JaxArray, ndarray, Initializer, callable
156+ The maximum conductance of potassium channel. Default is 36 msiemens.
157+ EL: float, JaxArray, ndarray, Initializer, callable
158+ The reversal potential of learky channel. Default is -54.387 mV.
159+ gL: float, JaxArray, ndarray, Initializer, callable
160+ The conductance of learky channel. Default is 0.03 msiemens.
161+ V_th: float, JaxArray, ndarray, Initializer, callable
162+ The threshold of the membrane spike. Default is 20 mV.
163+ C: float, JaxArray, ndarray, Initializer, callable
164+ The membrane capacitance. Default is 1 ufarad.
165+ V_initializer: JaxArray, ndarray, Initializer, callable
166+ The initializer of membrane potential.
167+ m_initializer: JaxArray, ndarray, Initializer, callable
168+ The initializer of m channel.
169+ h_initializer: JaxArray, ndarray, Initializer, callable
170+ The initializer of h channel.
171+ n_initializer: JaxArray, ndarray, Initializer, callable
172+ The initializer of n channel.
173+ method: str
174+ The numerical integration method.
175+ name: str
176+ The group name.
177+
178+ References
179+ ----------
176180
177181 .. [1] Hodgkin, Alan L., and Andrew F. Huxley. "A quantitative description
178182 of membrane current and its application to conduction and excitation
@@ -214,22 +218,37 @@ def __init__(
214218 self .C = init_param (C , self .num , allow_none = False )
215219 self .V_th = init_param (V_th , self .num , allow_none = False )
216220
217- # variables
221+ # initializers
218222 check_initializer (m_initializer , 'm_initializer' , allow_none = False )
219223 check_initializer (h_initializer , 'h_initializer' , allow_none = False )
220224 check_initializer (n_initializer , 'n_initializer' , allow_none = False )
221225 check_initializer (V_initializer , 'V_initializer' , allow_none = False )
222- self .m = bm .Variable (init_param (m_initializer , (self .num ,)))
223- self .h = bm .Variable (init_param (h_initializer , (self .num ,)))
224- self .n = bm .Variable (init_param (n_initializer , (self .num ,)))
225- self .V = bm .Variable (init_param (V_initializer , (self .num ,)))
226+ self ._m_initializer = m_initializer
227+ self ._h_initializer = h_initializer
228+ self ._n_initializer = n_initializer
229+ self ._V_initializer = V_initializer
230+
231+ # variables
232+ self .m = bm .Variable (init_param (self ._m_initializer , (self .num ,)))
233+ self .h = bm .Variable (init_param (self ._h_initializer , (self .num ,)))
234+ self .n = bm .Variable (init_param (self ._n_initializer , (self .num ,)))
235+ self .V = bm .Variable (init_param (self ._V_initializer , (self .num ,)))
226236 self .input = bm .Variable (bm .zeros (self .num ))
227237 self .spike = bm .Variable (bm .zeros (self .num , dtype = bool ))
228238 self .t_last_spike = bm .Variable (bm .ones (self .num ) * - 1e7 )
229239
230240 # integral
231241 self .integral = odeint (method = method , f = self .derivative )
232242
243+ def reset (self ):
244+ self .m .value = init_param (self ._m_initializer , (self .num ,))
245+ self .h .value = init_param (self ._h_initializer , (self .num ,))
246+ self .n .value = init_param (self ._n_initializer , (self .num ,))
247+ self .V .value = init_param (self ._V_initializer , (self .num ,))
248+ self .input [:] = 0
249+ self .spike [:] = False
250+ self .t_last_spike [:] = - 1e7
251+
233252 def dm (self , m , t , V ):
234253 alpha = 0.1 * (V + 40 ) / (1 - bm .exp (- (V + 40 ) / 10 ))
235254 beta = 4.0 * bm .exp (- (V + 65 ) / 18 )
@@ -336,20 +355,8 @@ class MorrisLecar(NeuGroup):
336355 V_th 10 mV The spike threshold.
337356 ============= ============== ======== =======================================================
338357
339- **Model Variables**
340-
341- ================== ================= =========================================================
342- **Variables name** **Initial Value** **Explanation**
343- ------------------ ----------------- ---------------------------------------------------------
344- V -20 Membrane potential.
345- W 0.02 Gating variable, refers to the fraction of
346- opened K+ channels.
347- input 0 External and synaptic input current.
348- spike False Flag to mark whether the neuron is spiking.
349- t_last_spike -1e7 Last spike time stamp.
350- ================== ================= =========================================================
351-
352- **References**
358+ References
359+ ----------
353360
354361 .. [1] Meier, Stephen R., Jarrett L. Lancaster, and Joseph M. Starobin.
355362 "Bursting regimes in a reaction-diffusion system with action
@@ -398,9 +405,13 @@ def __init__(
398405 self .phi = init_param (phi , self .num , allow_none = False )
399406 self .V_th = init_param (V_th , self .num , allow_none = False )
400407
401- # vars
408+ # initializers
402409 check_initializer (V_initializer , 'V_initializer' , allow_none = False )
403410 check_initializer (W_initializer , 'W_initializer' , allow_none = False )
411+ self ._W_initializer = W_initializer
412+ self ._V_initializer = V_initializer
413+
414+ # variables
404415 self .W = bm .Variable (init_param (W_initializer , (self .num ,)))
405416 self .V = bm .Variable (init_param (V_initializer , (self .num ,)))
406417 self .input = bm .Variable (bm .zeros (self .num ))
@@ -410,6 +421,13 @@ def __init__(
410421 # integral
411422 self .integral = odeint (method = method , f = self .derivative )
412423
424+ def reset (self ):
425+ self .W .value = init_param (self ._W_initializer , (self .num ,))
426+ self .V .value = init_param (self ._V_initializer , (self .num ,))
427+ self .input .value = bm .zeros (self .num )
428+ self .spike .value = bm .zeros (self .num , dtype = bool )
429+ self .t_last_spike .value = bm .ones (self .num ) * - 1e7
430+
413431 def dV (self , V , t , W , I_ext ):
414432 M_inf = (1 / 2 ) * (1 + bm .tanh ((V - self .V1 ) / self .V2 ))
415433 I_Ca = self .g_Ca * M_inf * (V - self .V_Ca )
0 commit comments