brainstate 0.1.0.post20250420__py2.py3-none-any.whl → 0.1.0.post20250422__py2.py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. brainstate/_compatible_import.py +15 -0
  2. brainstate/_state.py +5 -4
  3. brainstate/_state_test.py +2 -1
  4. brainstate/augment/_autograd_test.py +3 -2
  5. brainstate/augment/_eval_shape.py +2 -1
  6. brainstate/augment/_mapping.py +0 -1
  7. brainstate/augment/_mapping_test.py +1 -0
  8. brainstate/compile/_ad_checkpoint.py +2 -1
  9. brainstate/compile/_conditions.py +3 -3
  10. brainstate/compile/_conditions_test.py +2 -1
  11. brainstate/compile/_error_if.py +2 -1
  12. brainstate/compile/_error_if_test.py +2 -1
  13. brainstate/compile/_jit.py +3 -2
  14. brainstate/compile/_jit_test.py +2 -1
  15. brainstate/compile/_loop_collect_return.py +2 -2
  16. brainstate/compile/_loop_collect_return_test.py +2 -1
  17. brainstate/compile/_loop_no_collection.py +1 -1
  18. brainstate/compile/_make_jaxpr.py +2 -2
  19. brainstate/compile/_make_jaxpr_test.py +2 -1
  20. brainstate/compile/_progress_bar.py +2 -1
  21. brainstate/compile/_unvmap.py +1 -2
  22. brainstate/environ.py +4 -4
  23. brainstate/environ_test.py +2 -1
  24. brainstate/functional/_activations.py +2 -1
  25. brainstate/functional/_activations_test.py +1 -1
  26. brainstate/functional/_normalization.py +2 -1
  27. brainstate/functional/_others.py +2 -1
  28. brainstate/graph/_graph_operation.py +3 -2
  29. brainstate/graph/_graph_operation_test.py +4 -3
  30. brainstate/init/_base.py +2 -1
  31. brainstate/init/_generic.py +2 -1
  32. brainstate/nn/__init__.py +4 -0
  33. brainstate/nn/_collective_ops.py +1 -0
  34. brainstate/nn/_collective_ops_test.py +0 -4
  35. brainstate/nn/_common.py +0 -1
  36. brainstate/nn/_dyn_impl/__init__.py +0 -4
  37. brainstate/nn/_dyn_impl/_dynamics_neuron.py +431 -13
  38. brainstate/nn/_dyn_impl/_dynamics_neuron_test.py +2 -1
  39. brainstate/nn/_dyn_impl/_dynamics_synapse.py +405 -103
  40. brainstate/nn/_dyn_impl/_dynamics_synapse_test.py +2 -1
  41. brainstate/nn/_dyn_impl/_inputs.py +236 -29
  42. brainstate/nn/_dyn_impl/_rate_rnns.py +238 -82
  43. brainstate/nn/_dyn_impl/_rate_rnns_test.py +2 -1
  44. brainstate/nn/_dyn_impl/_readout.py +91 -8
  45. brainstate/nn/_dyn_impl/_readout_test.py +2 -1
  46. brainstate/nn/_dynamics/_dynamics_base.py +676 -96
  47. brainstate/nn/_dynamics/_dynamics_base_test.py +2 -1
  48. brainstate/nn/_dynamics/_projection_base.py +29 -30
  49. brainstate/nn/_dynamics/_state_delay.py +3 -3
  50. brainstate/nn/_dynamics/_synouts_test.py +2 -1
  51. brainstate/nn/_elementwise/_dropout.py +3 -2
  52. brainstate/nn/_elementwise/_dropout_test.py +2 -1
  53. brainstate/nn/_elementwise/_elementwise.py +2 -1
  54. brainstate/nn/{_dyn_impl/_projection_alignpost.py → _event/__init__.py} +8 -7
  55. brainstate/nn/_event/_fixedprob_mv.py +169 -0
  56. brainstate/nn/_event/_fixedprob_mv_test.py +115 -0
  57. brainstate/nn/_event/_linear_mv.py +85 -0
  58. brainstate/nn/_event/_linear_mv_test.py +121 -0
  59. brainstate/nn/_exp_euler.py +2 -1
  60. brainstate/nn/_exp_euler_test.py +2 -1
  61. brainstate/nn/_interaction/_conv.py +2 -1
  62. brainstate/nn/_interaction/_linear.py +2 -1
  63. brainstate/nn/_interaction/_linear_test.py +2 -1
  64. brainstate/nn/_interaction/_normalizations.py +3 -2
  65. brainstate/nn/_interaction/_poolings.py +4 -3
  66. brainstate/nn/_module_test.py +2 -1
  67. brainstate/nn/metrics.py +4 -3
  68. brainstate/optim/_lr_scheduler.py +2 -1
  69. brainstate/optim/_lr_scheduler_test.py +2 -1
  70. brainstate/optim/_optax_optimizer_test.py +2 -1
  71. brainstate/optim/_sgd_optimizer.py +3 -2
  72. brainstate/random/_rand_funs.py +2 -1
  73. brainstate/random/_rand_funs_test.py +3 -2
  74. brainstate/random/_rand_seed.py +3 -2
  75. brainstate/random/_rand_seed_test.py +2 -1
  76. brainstate/random/_rand_state.py +4 -3
  77. brainstate/surrogate.py +1 -2
  78. brainstate/typing.py +4 -4
  79. brainstate/util/_caller.py +2 -1
  80. brainstate/util/_others.py +4 -4
  81. brainstate/util/_pretty_pytree.py +1 -1
  82. brainstate/util/_pretty_pytree_test.py +2 -1
  83. brainstate/util/_pretty_table.py +43 -43
  84. brainstate/util/_struct.py +2 -1
  85. brainstate/util/filter.py +0 -1
  86. {brainstate-0.1.0.post20250420.dist-info → brainstate-0.1.0.post20250422.dist-info}/METADATA +3 -3
  87. brainstate-0.1.0.post20250422.dist-info/RECORD +133 -0
  88. brainstate-0.1.0.post20250420.dist-info/RECORD +0 -129
  89. {brainstate-0.1.0.post20250420.dist-info → brainstate-0.1.0.post20250422.dist-info}/LICENSE +0 -0
  90. {brainstate-0.1.0.post20250420.dist-info → brainstate-0.1.0.post20250422.dist-info}/WHEEL +0 -0
  91. {brainstate-0.1.0.post20250420.dist-info → brainstate-0.1.0.post20250422.dist-info}/top_level.txt +0 -0
@@ -36,6 +36,25 @@ __all__ = [
36
36
  class Synapse(Dynamics):
37
37
  """
38
38
  Base class for synapse dynamics.
39
+
40
+ This class serves as the foundation for all synapse models in the library,
41
+ providing a common interface for implementing various types of synaptic
42
+ connectivity and transmission mechanisms.
43
+
44
+ Synapses are responsible for modeling the transmission of signals between
45
+ neurons, including temporal dynamics, plasticity, and neurotransmitter effects.
46
+ All specific synapse implementations (like Expon, Alpha, AMPA, etc.) should
47
+ inherit from this class.
48
+
49
+ See Also
50
+ --------
51
+ Expon : Simple first-order exponential decay synapse model
52
+ Alpha : Alpha function synapse model
53
+ DualExpon : Dual exponential synapse model
54
+ STP : Synapse with short-term plasticity
55
+ STD : Synapse with short-term depression
56
+ AMPA : AMPA receptor synapse model
57
+ GABAa : GABAa receptor synapse model
39
58
  """
40
59
  __module__ = 'brainstate.nn'
41
60
 
@@ -44,9 +63,41 @@ class Expon(Synapse, AlignPost):
44
63
  r"""
45
64
  Exponential decay synapse model.
46
65
 
47
- Args:
48
- tau: float. The time constant of decay. [ms]
49
- %s
66
+ This class implements a simple first-order exponential decay synapse model where
67
+ the synaptic conductance g decays exponentially with time constant tau:
68
+
69
+ $$
70
+ dg/dt = -g/\tau + \text{input}
71
+ $$
72
+
73
+ The model is widely used for basic synaptic transmission modeling.
74
+
75
+ Parameters
76
+ ----------
77
+ in_size : Size
78
+ Size of the input.
79
+ name : str, optional
80
+ Name of the synapse instance.
81
+ tau : ArrayLike, default=8.0*u.ms
82
+ Time constant of decay in milliseconds.
83
+ g_initializer : ArrayLike or Callable, default=init.ZeroInit(unit=u.mS)
84
+ Initial value or initializer for synaptic conductance.
85
+
86
+ Attributes
87
+ ----------
88
+ g : HiddenState
89
+ Synaptic conductance state variable.
90
+ tau : Parameter
91
+ Time constant of decay.
92
+
93
+ Notes
94
+ -----
95
+ The implementation uses an exponential Euler integration method.
96
+ The output of this synapse is the conductance value.
97
+
98
+ This class inherits from :py:class:`AlignPost`, which means it can be used in projection patterns
99
+ where synaptic variables are aligned with post-synaptic neurons, enabling event-driven
100
+ computation and more efficient handling of sparse connectivity patterns.
50
101
  """
51
102
  __module__ = 'brainstate.nn'
52
103
 
@@ -77,6 +128,62 @@ class Expon(Synapse, AlignPost):
77
128
 
78
129
 
79
130
  class DualExpon(Synapse, AlignPost):
131
+ r"""
132
+ Dual exponential synapse model.
133
+
134
+ This class implements a synapse model with separate rise and decay time constants,
135
+ which produces a more biologically realistic conductance waveform than a single
136
+ exponential model. The model is characterized by the differential equation system:
137
+
138
+ dg_rise/dt = -g_rise/tau_rise
139
+ dg_decay/dt = -g_decay/tau_decay
140
+ g = a * (g_decay - g_rise)
141
+
142
+ where $a$ is a normalization factor that ensures the peak conductance reaches
143
+ the desired amplitude.
144
+
145
+ Parameters
146
+ ----------
147
+ in_size : Size
148
+ Size of the input.
149
+ name : str, optional
150
+ Name of the synapse instance.
151
+ tau_decay : ArrayLike, default=10.0*u.ms
152
+ Time constant of decay in milliseconds.
153
+ tau_rise : ArrayLike, default=1.0*u.ms
154
+ Time constant of rise in milliseconds.
155
+ A : ArrayLike, optional
156
+ Amplitude scaling factor. If None, a scaling factor is automatically
157
+ calculated to normalize the peak amplitude.
158
+ g_initializer : ArrayLike or Callable, default=init.ZeroInit(unit=u.mS)
159
+ Initial value or initializer for synaptic conductance.
160
+
161
+ Attributes
162
+ ----------
163
+ g_rise : HiddenState
164
+ Rise component of synaptic conductance.
165
+ g_decay : HiddenState
166
+ Decay component of synaptic conductance.
167
+ tau_rise : Parameter
168
+ Time constant of rise phase.
169
+ tau_decay : Parameter
170
+ Time constant of decay phase.
171
+ a : Parameter
172
+ Normalization factor calculated from tau_rise, tau_decay, and A.
173
+
174
+ Notes
175
+ -----
176
+ The dual exponential model produces a conductance waveform that is more
177
+ physiologically realistic than a simple exponential decay, with a finite
178
+ rise time followed by a slower decay.
179
+
180
+ The implementation uses an exponential Euler integration method.
181
+ The output of this synapse is the normalized difference between decay and rise components.
182
+
183
+ This class inherits from :py:class:`AlignPost`, which means it can be used in projection patterns
184
+ where synaptic variables are aligned with post-synaptic neurons, enabling event-driven
185
+ computation and more efficient handling of sparse connectivity patterns.
186
+ """
80
187
  __module__ = 'brainstate.nn'
81
188
 
82
189
  def __init__(
@@ -127,6 +234,45 @@ class DualExpon(Synapse, AlignPost):
127
234
 
128
235
 
129
236
  class Alpha(Synapse):
237
+ r"""
238
+ Alpha synapse model.
239
+
240
+ This class implements the alpha function synapse model, which produces
241
+ a smooth, biologically realistic synaptic conductance waveform.
242
+ The model is characterized by the differential equation system:
243
+
244
+ dh/dt = -h/tau
245
+ dg/dt = -g/tau + h/tau
246
+
247
+ This produces a response that rises and then falls with a characteristic
248
+ time constant $\tau$, with peak amplitude occurring at time $t = \tau$.
249
+
250
+ Parameters
251
+ ----------
252
+ in_size : Size
253
+ Size of the input.
254
+ name : str, optional
255
+ Name of the synapse instance.
256
+ tau : ArrayLike, default=8.0*u.ms
257
+ Time constant of the alpha function in milliseconds.
258
+ g_initializer : ArrayLike or Callable, default=init.ZeroInit(unit=u.mS)
259
+ Initial value or initializer for synaptic conductance.
260
+
261
+ Attributes
262
+ ----------
263
+ g : HiddenState
264
+ Synaptic conductance state variable.
265
+ h : HiddenState
266
+ Auxiliary state variable for implementing the alpha function.
267
+ tau : Parameter
268
+ Time constant of the alpha function.
269
+
270
+ Notes
271
+ -----
272
+ The alpha function is defined as g(t) = (t/tau) * exp(1-t/tau) for t ≥ 0.
273
+ This implementation uses an exponential Euler integration method.
274
+ The output of this synapse is the conductance value.
275
+ """
130
276
  __module__ = 'brainstate.nn'
131
277
 
132
278
  def __init__(
@@ -160,15 +306,71 @@ class Alpha(Synapse):
160
306
 
161
307
 
162
308
  class STP(Synapse):
163
- r"""Synaptic output with short-term plasticity.
164
-
165
- %s
166
-
167
- Args:
168
- tau_f: float, ArrayType, Callable. The time constant of short-term facilitation.
169
- tau_d: float, ArrayType, Callable. The time constant of short-term depression.
170
- U: float, ArrayType, Callable. The fraction of resources used per action potential.
171
- %s
309
+ r"""
310
+ Synapse with short-term plasticity.
311
+
312
+ This class implements a synapse model with short-term plasticity (STP), which captures
313
+ activity-dependent changes in synaptic efficacy that occur over milliseconds to seconds.
314
+ The model simultaneously accounts for both short-term facilitation and depression
315
+ based on the formulation by Tsodyks & Markram (1998).
316
+
317
+ The model is characterized by the following equations:
318
+
319
+ $$
320
+ \frac{du}{dt} = -\frac{u}{\tau_f} + U \cdot (1 - u) \cdot \delta(t - t_{spike})
321
+ $$
322
+
323
+ $$
324
+ \frac{dx}{dt} = \frac{1 - x}{\tau_d} - u \cdot x \cdot \delta(t - t_{spike})
325
+ $$
326
+
327
+ $$
328
+ g_{syn} = u \cdot x
329
+ $$
330
+
331
+ where:
332
+ - $u$ represents the utilization of synaptic efficacy (facilitation variable)
333
+ - $x$ represents the available synaptic resources (depression variable)
334
+ - $\tau_f$ is the facilitation time constant
335
+ - $\tau_d$ is the depression time constant
336
+ - $U$ is the baseline utilization parameter
337
+ - $\delta(t - t_{spike})$ is the Dirac delta function representing presynaptic spikes
338
+ - $g_{syn}$ is the effective synaptic conductance
339
+
340
+ Parameters
341
+ ----------
342
+ in_size : Size
343
+ Size of the input.
344
+ name : str, optional
345
+ Name of the synapse instance.
346
+ U : ArrayLike, default=0.15
347
+ Baseline utilization parameter (fraction of resources used per action potential).
348
+ tau_f : ArrayLike, default=1500.*u.ms
349
+ Time constant of short-term facilitation in milliseconds.
350
+ tau_d : ArrayLike, default=200.*u.ms
351
+ Time constant of short-term depression (recovery of synaptic resources) in milliseconds.
352
+
353
+ Attributes
354
+ ----------
355
+ u : HiddenState
356
+ Utilization of synaptic efficacy (facilitation variable).
357
+ x : HiddenState
358
+ Available synaptic resources (depression variable).
359
+
360
+ Notes
361
+ -----
362
+ - Larger values of tau_f produce stronger facilitation effects.
363
+ - Larger values of tau_d lead to slower recovery from depression.
364
+ - The parameter U controls the initial release probability.
365
+ - The effective synaptic strength is the product of u and x.
366
+
367
+ References
368
+ ----------
369
+ .. [1] Tsodyks, M. V., & Markram, H. (1997). The neural code between neocortical
370
+ pyramidal neurons depends on neurotransmitter release probability.
371
+ Proceedings of the National Academy of Sciences, 94(2), 719-723.
372
+ .. [2] Tsodyks, M., Pawelzik, K., & Markram, H. (1998). Neural networks with dynamic
373
+ synapses. Neural computation, 10(4), 821-835.
172
374
  """
173
375
  __module__ = 'brainstate.nn'
174
376
 
@@ -217,14 +419,59 @@ class STP(Synapse):
217
419
 
218
420
 
219
421
  class STD(Synapse):
220
- r"""Synaptic output with short-term depression.
221
-
222
- %s
223
-
224
- Args:
225
- tau: float, ArrayType, Callable. The time constant of recovery of the synaptic vesicles.
226
- U: float, ArrayType, Callable. The fraction of resources used per action potential.
227
- %s
422
+ r"""
423
+ Synapse with short-term depression.
424
+
425
+ This class implements a synapse model with short-term depression (STD), which captures
426
+ activity-dependent reduction in synaptic efficacy, typically caused by depletion of
427
+ neurotransmitter vesicles following repeated stimulation.
428
+
429
+ The model is characterized by the following equation:
430
+
431
+ $$
432
+ \frac{dx}{dt} = \frac{1 - x}{\tau} - U \cdot x \cdot \delta(t - t_{spike})
433
+ $$
434
+
435
+ $$
436
+ g_{syn} = x
437
+ $$
438
+
439
+ where:
440
+ - $x$ represents the available synaptic resources (depression variable)
441
+ - $\tau$ is the depression recovery time constant
442
+ - $U$ is the utilization parameter (fraction of resources depleted per spike)
443
+ - $\delta(t - t_{spike})$ is the Dirac delta function representing presynaptic spikes
444
+ - $g_{syn}$ is the effective synaptic conductance
445
+
446
+ Parameters
447
+ ----------
448
+ in_size : Size
449
+ Size of the input.
450
+ name : str, optional
451
+ Name of the synapse instance.
452
+ tau : ArrayLike, default=200.*u.ms
453
+ Time constant governing recovery of synaptic resources in milliseconds.
454
+ U : ArrayLike, default=0.07
455
+ Utilization parameter (fraction of resources used per action potential).
456
+
457
+ Attributes
458
+ ----------
459
+ x : HiddenState
460
+ Available synaptic resources (depression variable).
461
+
462
+ Notes
463
+ -----
464
+ - Larger values of tau lead to slower recovery from depression.
465
+ - Larger values of U cause stronger depression with each spike.
466
+ - This model is a simplified version of the STP model that only includes depression.
467
+
468
+ References
469
+ ----------
470
+ .. [1] Abbott, L. F., Varela, J. A., Sen, K., & Nelson, S. B. (1997). Synaptic
471
+ depression and cortical gain control. Science, 275(5297), 220-224.
472
+ .. [2] Tsodyks, M. V., & Markram, H. (1997). The neural code between neocortical
473
+ pyramidal neurons depends on neurotransmitter release probability.
474
+ Proceedings of the National Academy of Sciences, 94(2), 719-723.
228
475
  """
229
476
  __module__ = 'brainstate.nn'
230
477
 
@@ -261,57 +508,76 @@ class STD(Synapse):
261
508
 
262
509
 
263
510
  class AMPA(Synapse):
264
- r"""AMPA synapse model.
265
-
266
- **Model Descriptions**
267
-
268
- AMPA receptor is an ionotropic receptor, which is an ion channel.
269
- When it is bound by neurotransmitters, it will immediately open the
270
- ion channel, causing the change of membrane potential of postsynaptic neurons.
271
-
272
- A classical model is to use the Markov process to model ion channel switch.
273
- Here :math:`g` represents the probability of channel opening, :math:`1-g`
274
- represents the probability of ion channel closing, and :math:`\alpha` and
275
- :math:`\beta` are the transition probability. Because neurotransmitters can
276
- open ion channels, the transfer probability from :math:`1-g` to :math:`g`
277
- is affected by the concentration of neurotransmitters. We denote the concentration
278
- of neurotransmitters as :math:`[T]` and get the following Markov process.
279
-
280
- .. image:: ../../_static/synapse_markov.png
281
- :align: center
282
-
283
- We obtained the following formula when describing the process by a differential equation.
284
-
285
- .. math::
286
-
287
- \frac{ds}{dt} =\alpha[T](1-g)-\beta g
288
-
289
- where :math:`\alpha [T]` denotes the transition probability from state :math:`(1-g)`
290
- to state :math:`(g)`; and :math:`\beta` represents the transition probability of
291
- the other direction. :math:`\alpha` is the binding constant. :math:`\beta` is the
292
- unbinding constant. :math:`[T]` is the neurotransmitter concentration, and
293
- has the duration of 0.5 ms.
294
-
295
- Moreover, the post-synaptic current on the post-synaptic neuron is formulated as
296
-
297
- .. math::
298
-
299
- I_{syn} = g_{max} g (V-E)
300
-
301
- where :math:`g_{max}` is the maximum conductance, and `E` is the reverse potential.
302
-
303
- This module can be used with interface ``brainpy.dyn.ProjAlignPreMg2``, as shown in the following example:
304
-
305
- .. [1] Vijayan S, Kopell N J. Thalamic model of awake alpha oscillations
306
- and implications for stimulus processing[J]. Proceedings of the
307
- National Academy of Sciences, 2012, 109(45): 18553-18558.
308
-
309
- Args:
310
- alpha: float, ArrayType, Callable. Binding constant. [ms^-1 mM^-1]
311
- beta: float, ArrayType, Callable. Unbinding constant. [ms^-1 mM^-1]
312
- T: float, ArrayType, Callable. Transmitter concentration when synapse is triggered by
313
- a pre-synaptic spike. Default 0.5 [mM].
314
- T_dur: float, ArrayType, Callable. Transmitter concentration duration time after being triggered. Default 1 [ms]
511
+ r"""AMPA receptor synapse model.
512
+
513
+ This class implements a kinetic model of AMPA (α-amino-3-hydroxy-5-methyl-4-isoxazolepropionic acid)
514
+ receptor-mediated synaptic transmission. AMPA receptors are ionotropic glutamate receptors that mediate
515
+ fast excitatory synaptic transmission in the central nervous system.
516
+
517
+ The model uses a Markov process approach to describe the state transitions of AMPA receptors
518
+ between closed and open states, governed by neurotransmitter binding:
519
+
520
+ $$
521
+ \frac{dg}{dt} = \alpha [T] (1-g) - \beta g
522
+ $$
523
+
524
+ $$
525
+ I_{syn} = g_{max} \cdot g \cdot (V - E)
526
+ $$
527
+
528
+ where:
529
+ - $g$ represents the fraction of receptors in the open state
530
+ - $\alpha$ is the binding rate constant [ms^-1 mM^-1]
531
+ - $\beta$ is the unbinding rate constant [ms^-1]
532
+ - $[T]$ is the neurotransmitter concentration [mM]
533
+ - $I_{syn}$ is the resulting synaptic current
534
+ - $g_{max}$ is the maximum conductance
535
+ - $V$ is the membrane potential
536
+ - $E$ is the reversal potential
537
+
538
+ The neurotransmitter concentration $[T]$ follows a square pulse of amplitude T and
539
+ duration T_dur after each presynaptic spike.
540
+
541
+ Parameters
542
+ ----------
543
+ in_size : Size
544
+ Size of the input.
545
+ name : str, optional
546
+ Name of the synapse instance.
547
+ alpha : ArrayLike, default=0.98/(u.ms*u.mM)
548
+ Binding rate constant [ms^-1 mM^-1].
549
+ beta : ArrayLike, default=0.18/u.ms
550
+ Unbinding rate constant [ms^-1].
551
+ T : ArrayLike, default=0.5*u.mM
552
+ Peak neurotransmitter concentration when released [mM].
553
+ T_dur : ArrayLike, default=0.5*u.ms
554
+ Duration of neurotransmitter presence in the synaptic cleft [ms].
555
+ g_initializer : ArrayLike or Callable, default=init.ZeroInit()
556
+ Initial value or initializer for the synaptic conductance.
557
+
558
+ Attributes
559
+ ----------
560
+ g : HiddenState
561
+ Fraction of receptors in the open state.
562
+ spike_arrival_time : ShortTermState
563
+ Time of the most recent presynaptic spike.
564
+
565
+ Notes
566
+ -----
567
+ - The model captures the fast-rising and relatively fast-decaying excitatory currents
568
+ characteristic of AMPA receptor-mediated transmission.
569
+ - The time course of the synaptic conductance is determined by both the binding and
570
+ unbinding rate constants and the duration of transmitter presence.
571
+ - This implementation uses an exponential Euler integration method.
572
+
573
+ References
574
+ ----------
575
+ .. [1] Destexhe, A., Mainen, Z. F., & Sejnowski, T. J. (1994). Synthesis of models for
576
+ excitable membranes, synaptic transmission and neuromodulation using a common
577
+ kinetic formalism. Journal of computational neuroscience, 1(3), 195-230.
578
+ .. [2] Vijayan, S., & Kopell, N. J. (2012). Thalamic model of awake alpha oscillations
579
+ and implications for stimulus processing. Proceedings of the National Academy
580
+ of Sciences, 109(45), 18553-18558.
315
581
  """
316
582
 
317
583
  def __init__(
@@ -353,38 +619,74 @@ class AMPA(Synapse):
353
619
 
354
620
 
355
621
  class GABAa(AMPA):
356
- r"""GABAa synapse model.
357
-
358
- **Model Descriptions**
359
-
360
- GABAa synapse model has the same equation with the `AMPA synapse <./brainmodels.synapses.AMPA.rst>`_,
361
-
362
- .. math::
363
-
364
- \frac{d g}{d t}&=\alpha[T](1-g) - \beta g \\
365
- I_{syn}&= - g_{max} g (V - E)
366
-
367
- but with the difference of:
368
-
369
- - Reversal potential of synapse :math:`E` is usually low, typically -80. mV
370
- - Activating rate constant :math:`\alpha=0.53`
371
- - De-activating rate constant :math:`\beta=0.18`
372
- - Transmitter concentration :math:`[T]=1\,\mu ho(\mu S)` when synapse is
373
- triggered by a pre-synaptic spike, with the duration of 1. ms.
374
-
375
- This module can be used with interface ``brainpy.dyn.ProjAlignPreMg2``, as shown in the following example:
376
-
377
- .. [1] Destexhe, Alain, and Denis Paré. "Impact of network activity
378
- on the integrative properties of neocortical pyramidal neurons
379
- in vivo." Journal of neurophysiology 81.4 (1999): 1531-1547.
380
-
381
- Args:
382
- alpha: float, ArrayType, Callable. Binding constant. Default 0.062
383
- beta: float, ArrayType, Callable. Unbinding constant. Default 3.57
384
- T: float, ArrayType, Callable. Transmitter concentration when synapse is triggered by
385
- a pre-synaptic spike.. Default 1 [mM].
386
- T_dur: float, ArrayType, Callable. Transmitter concentration duration time
387
- after being triggered. Default 1 [ms]
622
+ r"""GABAa receptor synapse model.
623
+
624
+ This class implements a kinetic model of GABAa (gamma-aminobutyric acid type A)
625
+ receptor-mediated synaptic transmission. GABAa receptors are ionotropic chloride channels
626
+ that mediate fast inhibitory synaptic transmission in the central nervous system.
627
+
628
+ The model uses the same Markov process approach as the AMPA model but with different
629
+ kinetic parameters appropriate for GABAa receptors:
630
+
631
+ $$
632
+ \frac{dg}{dt} = \alpha [T] (1-g) - \beta g
633
+ $$
634
+
635
+ $$
636
+ I_{syn} = - g_{max} \cdot g \cdot (V - E)
637
+ $$
638
+
639
+ where:
640
+ - $g$ represents the fraction of receptors in the open state
641
+ - $\alpha$ is the binding rate constant [ms^-1 mM^-1], typically slower than AMPA
642
+ - $\beta$ is the unbinding rate constant [ms^-1]
643
+ - $[T]$ is the neurotransmitter (GABA) concentration [mM]
644
+ - $I_{syn}$ is the resulting synaptic current (note the negative sign indicating inhibition)
645
+ - $g_{max}$ is the maximum conductance
646
+ - $V$ is the membrane potential
647
+ - $E$ is the reversal potential (typically around -80 mV for chloride)
648
+
649
+ The neurotransmitter concentration $[T]$ follows a square pulse of amplitude T and
650
+ duration T_dur after each presynaptic spike.
651
+
652
+ Parameters
653
+ ----------
654
+ in_size : Size
655
+ Size of the input.
656
+ name : str, optional
657
+ Name of the synapse instance.
658
+ alpha : ArrayLike, default=0.53/(u.ms*u.mM)
659
+ Binding rate constant [ms^-1 mM^-1]. Typically slower than AMPA receptors.
660
+ beta : ArrayLike, default=0.18/u.ms
661
+ Unbinding rate constant [ms^-1].
662
+ T : ArrayLike, default=1.0*u.mM
663
+ Peak neurotransmitter concentration when released [mM]. Higher than AMPA.
664
+ T_dur : ArrayLike, default=1.0*u.ms
665
+ Duration of neurotransmitter presence in the synaptic cleft [ms]. Longer than AMPA.
666
+ g_initializer : ArrayLike or Callable, default=init.ZeroInit()
667
+ Initial value or initializer for the synaptic conductance.
668
+
669
+ Attributes
670
+ ----------
671
+ Inherits all attributes from AMPA class.
672
+
673
+ Notes
674
+ -----
675
+ - GABAa receptors typically produce slower-rising and longer-lasting currents compared to AMPA receptors.
676
+ - The inhibitory nature of GABAa receptors is reflected in the convention of using a negative sign in the
677
+ synaptic current equation.
678
+ - The reversal potential for GABAa receptors is typically around -80 mV (due to chloride), making them
679
+ inhibitory for neurons with resting potentials more positive than this value.
680
+ - This model does not include desensitization, which can be significant for prolonged GABA exposure.
681
+
682
+ References
683
+ ----------
684
+ .. [1] Destexhe, A., Mainen, Z. F., & Sejnowski, T. J. (1994). Synthesis of models for
685
+ excitable membranes, synaptic transmission and neuromodulation using a common
686
+ kinetic formalism. Journal of computational neuroscience, 1(3), 195-230.
687
+ .. [2] Destexhe, A., & Paré, D. (1999). Impact of network activity on the integrative
688
+ properties of neocortical pyramidal neurons in vivo. Journal of neurophysiology,
689
+ 81(4), 1531-1547.
388
690
  """
389
691
 
390
692
  def __init__(
@@ -15,10 +15,11 @@
15
15
 
16
16
  from __future__ import annotations
17
17
 
18
+ import unittest
19
+
18
20
  import brainunit as u
19
21
  import jax.numpy as jnp
20
22
  import pytest
21
- import unittest
22
23
 
23
24
  import brainstate as bst
24
25
  from brainstate.nn import Expon, STP, STD