brainx-skill 1.0.14 → 1.0.16

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 (171) hide show
  1. package/README.md +17 -1
  2. package/manifest.json +1 -1
  3. package/mcp-servers/codex/skills.json +1 -1
  4. package/package.json +1 -1
  5. package/skills/bio-neuro-lit/SKILL.md +4 -2
  6. package/skills/bio-neuro-lit/references/required-supplements.md +27 -0
  7. package/skills/brainx-acceleration/SKILL.md +30 -437
  8. package/skills/brainx-acceleration/references/audit-and-rewrite-patterns.md +326 -0
  9. package/skills/brainx-general-guard/SKILL.md +24 -8
  10. package/skills/brainx-install/SKILL.md +3 -3
  11. package/skills/brainx-install/references/compatibility-and-release-matching.md +28 -20
  12. package/skills/brainx-install/references/uninstall-and-cleanup.md +11 -4
  13. package/skills/brainx-modeling-loop/SKILL.md +143 -36
  14. package/skills/brainx-modeling-loop/agents/openai.yaml +2 -2
  15. package/skills/brainx-modeling-loop/references/mechanism-comparison.md +62 -0
  16. package/skills/brainx-modeling-loop/references/multiscale-coupling.md +16 -0
  17. package/skills/brainx-modeling-loop/references/paper-reproduction.md +42 -0
  18. package/skills/brainx-modeling-loop/references/parameter-fitting-workflow.md +14 -14
  19. package/skills/brainx-modeling-loop/references/run-experiment.md +1 -1
  20. package/skills/brainx-modeling-loop/references/training-workflow.md +10 -8
  21. package/skills/brainx-visualization/SKILL.md +6 -2
  22. package/skills/brainx-visualization/references/neural-data-visualization.md +1 -1
  23. package/skills/brainx-visualization/references/statistical-and-model-visualization.md +1 -1
  24. package/skills/package-skills/braincell/SKILL.md +23 -14
  25. package/skills/package-skills/braincell/references/braintools/input-current.md +1 -1
  26. package/skills/package-skills/braincell/references/braintools/metric.md +72 -46
  27. package/skills/package-skills/braincell/references/mixions-for-adaptation.md +1 -1
  28. package/skills/package-skills/braincell/references/multicompartment/braincell-manual-morphology-construction.md +1 -1
  29. package/skills/package-skills/braincell/references/multicompartment/cv-policy-reference.md +1 -1
  30. package/skills/package-skills/braincell/references/multicompartment/filter-function-library.md +3 -3
  31. package/skills/package-skills/braincell/references/multicompartment/morphology-io-loading-validation.md +1 -1
  32. package/skills/package-skills/braincell/references/multicompartment/multicompartment-cell-workflow.md +31 -43
  33. package/skills/package-skills/braincell/references/multicompartment/network-workflow.md +49 -0
  34. package/skills/package-skills/braincell/references/multicompartment/probe-reference.md +26 -114
  35. package/skills/package-skills/braincell/references/multicompartment/topology-building-and-visualization.md +40 -28
  36. package/skills/package-skills/braincell/references/scripts/cell_multicompartment_reference.py +13 -17
  37. package/skills/package-skills/brainevent/SKILL.md +0 -3
  38. package/skills/package-skills/brainevent/references/synaptic-plasticity.md +1 -1
  39. package/skills/package-skills/brainmass/SKILL.md +5 -3
  40. package/skills/package-skills/brainmass/references/brainstate/parameter-constraints-regularization.md +9 -7
  41. package/skills/package-skills/brainmass/references/brainstate/parameter-transforms-regularizers-catalog.md +4 -4
  42. package/skills/package-skills/brainmass/references/braintools/data-preprocessing.md +15 -7
  43. package/skills/package-skills/brainmass/references/braintools/metric.md +72 -46
  44. package/skills/package-skills/brainmass/references/coupling-network-api.md +3 -1
  45. package/skills/package-skills/brainmass/references/fitting-with-objectives-api.md +6 -6
  46. package/skills/package-skills/brainmass/references/horn-task-training.md +9 -9
  47. package/skills/package-skills/brainmass/references/modellibrary.md +12 -10
  48. package/skills/package-skills/brainmass/references/scripts/resting-state-meg-whole-brain-pipeline.py +5 -3
  49. package/skills/package-skills/brainmass/references/scripts/wilson-cowan-ei-dynamics.py +10 -6
  50. package/skills/package-skills/brainmass/references/simulator-input-monitor-api.md +3 -1
  51. package/skills/package-skills/brainmass/references/visualization-analysis-api.md +17 -9
  52. package/skills/package-skills/brainspike/SKILL.md +201 -0
  53. package/skills/package-skills/brainspike/references/braintools/connectivity.md +40 -0
  54. package/skills/package-skills/brainspike/references/braintools/data-preprocessing.md +39 -0
  55. package/skills/package-skills/brainspike/references/braintools/input-current.md +55 -0
  56. package/skills/package-skills/brainspike/references/braintools/metric.md +36 -0
  57. package/skills/package-skills/brainspike/references/braintools/optimizer.md +50 -0
  58. package/skills/package-skills/brainspike/references/braintools/parameter-initializer.md +43 -0
  59. package/skills/package-skills/brainspike/references/braintools/surrogate.md +40 -0
  60. package/skills/package-skills/brainspike/references/migration-boundary.md +38 -0
  61. package/skills/package-skills/brainspike/references/model-and-readout-selection.md +41 -0
  62. package/skills/package-skills/brainspike/references/multirate-coupling.md +31 -0
  63. package/skills/package-skills/brainspike/references/multiscale-composition.md +28 -0
  64. package/skills/package-skills/brainspike/references/native-composition.md +52 -0
  65. package/skills/package-skills/brainspike/references/native-delays.md +34 -0
  66. package/skills/package-skills/brainspike/references/native-projections.md +43 -0
  67. package/skills/package-skills/brainspike/references/native-training.md +36 -0
  68. package/skills/package-skills/{brainpy-state → brainspike}/references/nest-compatible/devices.md +33 -33
  69. package/skills/package-skills/{brainpy-state → brainspike}/references/nest-compatible/divergence-and-parity.md +15 -15
  70. package/skills/package-skills/{brainpy-state → brainspike}/references/nest-compatible/integration-categories.md +1 -1
  71. package/skills/package-skills/brainspike/references/nest-compatible/model-library.md +200 -0
  72. package/skills/package-skills/brainspike/references/nest-compatible/network-building.md +276 -0
  73. package/skills/package-skills/{brainpy-state → brainspike}/references/nest-compatible/scripts/brette_et_al_2007.py +23 -26
  74. package/skills/package-skills/{brainpy-state → brainspike}/references/nest-compatible/scripts/brunel_alpha.py +18 -21
  75. package/skills/package-skills/{brainpy-state → brainspike}/references/nest-compatible/scripts/brunel_delta.py +16 -19
  76. package/skills/package-skills/{brainpy-state → brainspike}/references/nest-compatible/scripts/clopath_synapse_spike_pairing.py +11 -12
  77. package/skills/package-skills/{brainpy-state → brainspike}/references/nest-compatible/scripts/evaluate_tsodyks2_synapse.py +10 -11
  78. package/skills/package-skills/{brainpy-state → brainspike}/references/nest-compatible/scripts/spatial_gaussex.py +18 -18
  79. package/skills/package-skills/{brainpy-state → brainspike}/references/nest-compatible/scripts/synapsecollection.py +26 -29
  80. package/skills/package-skills/brainspike/references/nest-compatible/synapse-and-connectivity.md +166 -0
  81. package/skills/package-skills/brainspike/references/nest-delay-boundaries.md +31 -0
  82. package/skills/package-skills/brainspike/references/nonlinear-state-sharing.md +26 -0
  83. package/skills/package-skills/{brainpy-state → brainspike}/references/perturbation-experiment-validity.md +2 -2
  84. package/skills/package-skills/brainspike/references/simulator-training.md +61 -0
  85. package/skills/package-skills/brainspike/references/temporal-task-training.md +36 -0
  86. package/skills/package-skills/brainspike/scripts/advanced_native_patterns.py +76 -0
  87. package/skills/package-skills/brainspike/scripts/delay_workflow.py +44 -0
  88. package/skills/package-skills/brainspike/scripts/delayed_cue_training.py +78 -0
  89. package/skills/package-skills/brainspike/scripts/lif_smoke.py +31 -0
  90. package/skills/package-skills/brainspike/scripts/multiscale_workflow.py +35 -0
  91. package/skills/package-skills/brainspike/scripts/native_ei_network.py +47 -0
  92. package/skills/package-skills/brainspike/scripts/native_workflows.py +77 -0
  93. package/skills/package-skills/brainspike/scripts/nest_boundary_workflows.py +108 -0
  94. package/skills/package-skills/brainspike/scripts/train_native_snn.py +65 -0
  95. package/skills/package-skills/brainspike/scripts/train_nest_simulator.py +69 -0
  96. package/skills/package-skills/brainspike/scripts/train_nest_simulator_two_weights.py +220 -0
  97. package/skills/package-skills/brainstate/SKILL.md +16 -21
  98. package/skills/package-skills/brainstate/references/brainstate/brainstate-control-flow-patterns.md +1 -138
  99. package/skills/package-skills/brainstate/references/brainstate/brainstate-transformed-diagnostics.md +1 -1
  100. package/skills/package-skills/brainstate/references/brainstate/delay-buffers.md +45 -0
  101. package/skills/package-skills/brainstate/references/brainstate/parameter-constraints-regularization.md +9 -7
  102. package/skills/package-skills/brainstate/references/brainstate/parameter-transforms-regularizers-catalog.md +4 -4
  103. package/skills/package-skills/brainstate/references/brainstate/randomness-and-reproducibility.md +6 -4
  104. package/skills/package-skills/brainstate/references/brainstate/transformation-grad-expansion.md +4 -4
  105. package/skills/package-skills/brainstate/references/brainstate/transformation-vmap-expansion.md +1 -1
  106. package/skills/package-skills/brainstate/references/braintools-optimizer-reference.md +16 -0
  107. package/skills/package-skills/brainstate/references/libraries/prebuilt-layer-library.md +1 -1
  108. package/skills/package-skills/brainstate/references/simulation-environment.md +5 -5
  109. package/skills/package-skills/braintrace/SKILL.md +17 -38
  110. package/skills/package-skills/braintrace/references/Drtrl.md +9 -26
  111. package/skills/package-skills/braintrace/references/algorithm selection.md +7 -12
  112. package/skills/package-skills/braintrace/references/batching.md +15 -35
  113. package/skills/package-skills/braintrace/references/compiler_internal.md +1 -1
  114. package/skills/package-skills/braintrace/references/custom algorithms.md +1 -2
  115. package/skills/package-skills/braintrace/references/customizing_primitive_transforms.md +26 -15
  116. package/skills/package-skills/braintrace/references/pp_pprop workflow.md +5 -139
  117. package/skills/package-skills/brainunit/SKILL.md +7 -2
  118. package/skills/package-skills/brainunit/references/array-mechanics/functional-structural-api.md +1 -1
  119. package/skills/package-skills/brainunit/references/math-function-library.md +2 -2
  120. package/skills/package-skills/brainunit/references/typing-and-runtime-validation.md +5 -2
  121. package/skills/package-skills/brainevent/references/scripts/102_EI_net_1996.py +0 -107
  122. package/skills/package-skills/brainevent/references/scripts/204_joglekar_2018_propagation.py +0 -168
  123. package/skills/package-skills/brainevent/references/scripts/coba_ei_teaching.py +0 -356
  124. package/skills/package-skills/brainpy-state/SKILL.md +0 -247
  125. package/skills/package-skills/brainpy-state/references/array-creation.md +0 -158
  126. package/skills/package-skills/brainpy-state/references/brain-dynamics-delay-protocol.md +0 -147
  127. package/skills/package-skills/brainpy-state/references/brainPy(legacy)/analysis.md +0 -150
  128. package/skills/package-skills/brainpy-state/references/brainPy(legacy)/brainpy legacy workflow.md +0 -373
  129. package/skills/package-skills/brainpy-state/references/brainPy(legacy)/built-in dynamic neuron model.md +0 -150
  130. package/skills/package-skills/brainpy-state/references/brainPy(legacy)/connecting neurons.md +0 -175
  131. package/skills/package-skills/brainpy-state/references/brainPy(legacy)/customize neuron and synpase.md +0 -286
  132. package/skills/package-skills/brainpy-state/references/brainPy(legacy)/infrastructure/Input generation.md +0 -111
  133. package/skills/package-skills/brainpy-state/references/brainPy(legacy)/infrastructure/More about simulation.md +0 -163
  134. package/skills/package-skills/brainpy-state/references/brainPy(legacy)/infrastructure/Multi-device array sharding.md +0 -113
  135. package/skills/package-skills/brainpy-state/references/brainPy(legacy)/infrastructure/Parallel experiment execution.md +0 -136
  136. package/skills/package-skills/brainpy-state/references/brainPy(legacy)/infrastructure/array creation and mechanics.md +0 -222
  137. package/skills/package-skills/brainpy-state/references/brainPy(legacy)/infrastructure/brainpy math environment setting.md +0 -123
  138. package/skills/package-skills/brainpy-state/references/brainPy(legacy)/infrastructure/delays.md +0 -107
  139. package/skills/package-skills/brainpy-state/references/brainPy(legacy)/infrastructure/object oriented transformations and control flows.md +0 -185
  140. package/skills/package-skills/brainpy-state/references/brainPy(legacy)/integrators.md +0 -181
  141. package/skills/package-skills/brainpy-state/references/brainPy(legacy)/route activity through connectivity.md +0 -102
  142. package/skills/package-skills/brainpy-state/references/brainPy(legacy)/synaptic projections.md +0 -147
  143. package/skills/package-skills/brainpy-state/references/brainPy(legacy)/synpase properties.md +0 -159
  144. package/skills/package-skills/brainpy-state/references/brainPy(legacy)/training/loss library.md +0 -127
  145. package/skills/package-skills/brainpy-state/references/brainPy(legacy)/training/optimizers.md +0 -167
  146. package/skills/package-skills/brainpy-state/references/brainPy(legacy)/training/parameter initializers.md +0 -107
  147. package/skills/package-skills/brainpy-state/references/brainPy(legacy)/training/prebuilt neural network layers.md +0 -186
  148. package/skills/package-skills/brainpy-state/references/brainPy(legacy)/training/surrogate gradients.md +0 -104
  149. package/skills/package-skills/brainpy-state/references/brainPy(legacy)/training/trainer library.md +0 -89
  150. package/skills/package-skills/brainpy-state/references/brainPy(legacy)/training/trainingworkflows.md +0 -253
  151. package/skills/package-skills/brainpy-state/references/braintools/brainstate-control-flow-patterns.md +0 -334
  152. package/skills/package-skills/brainpy-state/references/braintools/connectivity.md +0 -206
  153. package/skills/package-skills/brainpy-state/references/braintools/data-preprocessing.md +0 -79
  154. package/skills/package-skills/brainpy-state/references/braintools/input-current.md +0 -199
  155. package/skills/package-skills/brainpy-state/references/braintools/metric.md +0 -152
  156. package/skills/package-skills/brainpy-state/references/braintools/optimizer.md +0 -179
  157. package/skills/package-skills/brainpy-state/references/braintools/parameter-initializer.md +0 -183
  158. package/skills/package-skills/brainpy-state/references/braintools/surrogate.md +0 -147
  159. package/skills/package-skills/brainpy-state/references/component-selection.md +0 -288
  160. package/skills/package-skills/brainpy-state/references/nest-compatible/model-library.md +0 -200
  161. package/skills/package-skills/brainpy-state/references/nest-compatible/nest-workflow.md +0 -156
  162. package/skills/package-skills/brainpy-state/references/nest-compatible/network-building.md +0 -264
  163. package/skills/package-skills/brainpy-state/references/nest-compatible/synapse-and-connectivity.md +0 -153
  164. package/skills/package-skills/brainpy-state/references/projection-patterns.md +0 -127
  165. package/skills/package-skills/brainpy-state/references/scripts/103_COBA_2005.py +0 -86
  166. package/skills/package-skills/brainpy-state/references/scripts/106_COBA_HH_2007.py +0 -181
  167. package/skills/package-skills/brainpy-state/references/scripts/107_gamma_oscillation_1996.py +0 -156
  168. package/skills/package-skills/brainpy-state/references/scripts/109_fast_global_oscillation.py +0 -111
  169. package/skills/package-skills/brainpy-state/references/scripts/201_surrogate_grad_lif_fashion_mnist.py +0 -221
  170. package/skills/package-skills/brainpy-state/references/scripts/sound_localization.py +0 -240
  171. package/skills/package-skills/brainpy-state/references/scripts/training-snn.py +0 -119
@@ -1,264 +0,0 @@
1
- # Network building
2
-
3
- Use this reference when the canonical `Simulator` workflow needs lifecycle control, `NodeView` composition, `SimulationResult`, `SynapseCollection`, projection or connection-rule lookup, declarative `Network`/`Builder` APIs, or spatially structured populations and connectivity.
4
-
5
- ## Network construction
6
-
7
- Use these APIs to choose the declarative or imperative network surface and create its populations, devices, and connections.
8
-
9
- | API | Use when | Important result |
10
- |---|---|---|
11
- | `bp.Simulator(*, dt)` | Use for the NEST-flavored create/connect/run workflow. | Owns the graph, timestep, rollout State, recording, and result construction. |
12
- | `bp.network.Network(*args, **kwargs)` | Use when subclassing the lower-level network base and registering populations, projections, and devices as attributes. | `update()` walks immediate children in projection-first, then dynamics order. |
13
- | `bp.network.Builder(*args, **kwargs)` | Use for the imperative variant of `Network`. | `add()` registers named modules and `connect()` registers projections. |
14
- | `sim.create(model_cls, size=1, *, params=None, positions=None, **kw)` | Use to instantiate a population or device. | Returns a `NodeView`; spatial `positions` attach coordinates. |
15
- | `sim.connect(pre, post, *, rule=bp.all_to_all, weight=None, delay=None, comm="dense", receptor_type=None, synapse=None, vt=None, allow_autapses=True, allow_multapses=True, seed=None)` | Use to create a projection, attach a source, or register a recorder. | Returns a projection handle, a list for multi-segment fan-out, or `None` for taps/injectors. |
16
-
17
- ## Simulation execution
18
-
19
- Use these methods to choose whether a run starts from fresh State or continues a persistent biological timeline.
20
-
21
- | API | Use when | Important result |
22
- |---|---|---|
23
- | `sim.simulate(duration, *, dt=None)` | Use for an independent run. | Reinitializes all State, starts at time zero, and returns `SimulationResult`. |
24
- | `sim.cont(duration, *, dt=None)` | Use to continue biological time across host-controlled windows. | Preserves State and returns a window result with absolute times. |
25
- | `sim.reset_rollout(*, dt=None)` | Use before restarting a persistent `cont()` workflow. | Reinitializes all State and resets accumulated time and step index to zero. |
26
-
27
- Do not interchange `simulate()` and `cont()` casually. Use `simulate()` for independent trials; use `cont()` only when State and biological time must persist across windows.
28
-
29
- ## NodeView composition
30
-
31
- Use `NodeView` composition when one connection or recording operation must address a full population, a slice, or several preserved population segments.
32
-
33
- | Operation | Use |
34
- |---|---|
35
- | `left + right` | Concatenate views while preserving segment boundaries, such as `exc + inh` for a common target. |
36
- | `view[start:stop]` | Slice one population segment for recording or partial connectivity. |
37
- | `bp.network.NodeView.of(population)` | Build a full-population view over an existing population. |
38
- | `view.segments` | Inspect the population-and-local-index segments when an API needs the concrete underlying population. |
39
-
40
- Source and target indices reported by connectivity inspection are population-local. Do not reinterpret them as NEST global node IDs.
41
-
42
- ## Connection-rule lookup
43
-
44
- Pass rule objects to `Simulator.connect()`; let the rule select edges and the synapse spec select edge behavior.
45
-
46
- | Rule helper | Choose when |
47
- |---|---|
48
- | `bp.all_to_all` | Every source-target pair must exist. |
49
- | `bp.one_to_one` | Source `i` must connect to target `i`. |
50
- | `bp.fixed_indegree(k)` | Every target must receive exactly `k` incoming edges. |
51
- | `bp.fixed_total_number(n)` | Exactly `n` edges must be drawn over the source-target grid. |
52
- | `bp.pairwise_bernoulli(p)` | Every possible pair must receive an independent Bernoulli draw. |
53
- | `bp.explicit_edges(pre_idx, post_idx)` | The exact source and target edge-index arrays are already known. |
54
- | `bp.third_factor_bernoulli_with_pool(p=..., pool_size=..., pool_type=...)` | A tripartite pre-post-third-factor network needs Bernoulli pairing with an astrocyte pool. |
55
-
56
- Use `seed` to reproduce one BrainPy-State realization, `allow_autapses` and `allow_multapses` to control self and repeated edges, and `comm="sparse"` for memory-light event communication.
57
-
58
- ## Projection-class lookup
59
-
60
- For standard construction, pass a rule or synapse spec to `Simulator.connect()` and inspect the returned handle. Use the classes below when reading API behavior or extending the network layer.
61
-
62
- | Projection class | Represents |
63
- |---|---|
64
- | `bp.network.OneToOneProj(*args, **kwargs)` | Edge `(i, i)` for every paired index. |
65
- | `bp.network.AllToAllProj(*args, **kwargs)` | Full all-to-all connectivity. |
66
- | `bp.network.PairwiseBernoulliProj(*args, **kwargs)` | Independent Bernoulli sampling for every source-target pair. |
67
- | `bp.network.SymmetricPairwiseBernoulliProj(*args, **kwargs)` | Symmetric Bernoulli connectivity where an edge implies its reverse. |
68
- | `bp.network.FixedIndegreeProj(*args, **kwargs)` | Exactly `k` incoming edges per postsynaptic neuron. |
69
- | `bp.network.FixedOutdegreeProj(*args, **kwargs)` | Exactly `k` outgoing edges per presynaptic neuron. |
70
- | `bp.network.FixedTotalNumberProj(*args, **kwargs)` | Exactly `n` edges over the full source-target grid. |
71
- | `bp.network.PairwisePoissonProj(*args, **kwargs)` | A Poisson-distributed edge multiplicity for each source-target pair. |
72
- | `bp.network.EventProjection(*args, **kwargs)` | Delayed, weighted static event transmission. |
73
- | `bp.network.EventPlasticProj(*args, **kwargs)` | Event-driven plastic transmission. |
74
- | `bp.network.VoltageCoupledPlasticProj(*args, **kwargs)` | Plasticity coupled to postsynaptic voltage State. |
75
-
76
- ## Canonical sparse E/I construction
77
-
78
- Use `NodeView` algebra and a seeded fixed-indegree rule to express Brunel-style wiring without materializing a dense edge list.
79
-
80
- ```python
81
- import brainunit as u
82
- from brainpy import state as bp
83
-
84
- sim = bp.Simulator(dt=0.1 * u.ms)
85
- params = {
86
- "C_m": 1.0 * u.pF,
87
- "tau_m": 20.0 * u.ms,
88
- "t_ref": 2.0 * u.ms,
89
- "E_L": 0.0 * u.mV,
90
- "V_reset": 0.0 * u.mV,
91
- "V_th": 20.0 * u.mV,
92
- }
93
- exc = sim.create(bp.iaf_psc_delta, 400, params=params)
94
- inh = sim.create(bp.iaf_psc_delta, 100, params=params)
95
- all_neurons = exc + inh
96
-
97
- sim.connect(
98
- exc,
99
- all_neurons,
100
- rule=bp.fixed_indegree(40),
101
- weight=0.1 * u.mV,
102
- delay=1.5 * u.ms,
103
- comm="sparse",
104
- allow_multapses=True,
105
- seed=1,
106
- )
107
- sim.connect(
108
- inh,
109
- all_neurons,
110
- rule=bp.fixed_indegree(10),
111
- weight=-0.5 * u.mV,
112
- delay=1.5 * u.ms,
113
- comm="sparse",
114
- allow_multapses=True,
115
- seed=2,
116
- )
117
- ```
118
-
119
- **Invariant:** Delta-neuron weights are voltage jumps in `mV`. Do not reuse current weights from an alpha- or exponential-PSC network.
120
-
121
- ## Result readback
122
-
123
- Use these APIs after simulation to read the common time axis, spike observables, analog traces, or registered plastic-weight trajectories.
124
-
125
- | API | Use |
126
- |---|---|
127
- | `result.times` | Read the common time axis. |
128
- | `result.spikes(node)` | Read a per-step spike matrix. |
129
- | `result.rate(node)` | Read the mean population firing rate. |
130
- | `result.trace(recorder, recordable="V_m")` | Read a registered analog trace. |
131
- | `sim.record_weight(proj)` | Register the returned plastic projection for per-step weight capture. |
132
- | `result.weight_trace(proj)` | Read the registered `(n_steps, n_edges)` weight trajectory. |
133
-
134
- ## Realized-connection inspection
135
-
136
- Use these APIs after construction to obtain a lazy view over realized edges and read or update supported live connection attributes.
137
-
138
- | API | Use |
139
- |---|---|
140
- | `sim.get_connections(source=None, target=None, synapse=None)` | Obtain a filtered, lazy `SynapseCollection` over realized edges. |
141
- | `connections.get(key)` | Read live `source`, `target`, `weight`, or `delay` values. |
142
- | `connections.set(key, value)` | Write supported static weight or delay values; plastic and homogeneous constraints can reject the write. |
143
-
144
- ## Spatial layouts
145
-
146
- Use these constructors to build concrete or deferred 2-D/3-D node positions.
147
-
148
- | Constructor | Use when |
149
- |---|---|
150
- | `bp.spatial.Layer(coords, ndim, shape=None, extent=None, center=None, sampler=None)` | Use when constructing a layer directly from coordinates or a sampler. |
151
- | `bp.spatial.grid(shape, extent=None, center=None)` | Use a regular cell-centered lattice. |
152
- | `bp.spatial.free(positions, extent=None, num_dimensions=None)` | Use explicit or sampled free positions. |
153
-
154
- ## Spatial position expressions
155
-
156
- Use these expression roots when a kernel depends on absolute, source, or target coordinates.
157
-
158
- | API | Use when |
159
- |---|---|
160
- | `bp.spatial.pos` | Use `.x`, `.y`, or `.z` for the current position expression. |
161
- | `bp.spatial.source_pos` | Use `.x`, `.y`, or `.z` for source-coordinate expressions. |
162
- | `bp.spatial.target_pos` | Use `.x`, `.y`, or `.z` for target-coordinate expressions. |
163
-
164
- ## Spatial distance and displacement
165
-
166
- Use these APIs to compute pairwise geometric relationships between source and target nodes or layers.
167
-
168
- | API | Use when |
169
- |---|---|
170
- | `bp.spatial.displacement(pre_pos, post_pos)` | Use the vector displacement `post - pre`. |
171
- | `bp.spatial.pairwise_distance(pre_pos, post_pos)` | Use pairwise Euclidean distance between coordinate arrays. |
172
- | `bp.spatial.Distance(layer_a, layer_b)` | Use a reusable distance expression between two layers. |
173
-
174
- ## Spatial probability kernels
175
-
176
- Use these constructors to map distance or displacement to connection probability.
177
-
178
- | Constructor | Use when |
179
- |---|---|
180
- | `bp.spatial.gaussian(x=bp.spatial.distance, mean=0.0, std=1.0)` | Use a Gaussian probability profile. |
181
- | `bp.spatial.exponential(x=bp.spatial.distance, beta=1.0)` | Use an exponential probability profile. |
182
- | `bp.spatial.gamma(x=bp.spatial.distance, kappa=1.0, theta=1.0)` | Use a gamma probability profile. |
183
- | `bp.spatial.gabor(x=None, y=None, theta=0.0, gamma=1.0, std=1.0, lam=1.0, psi=0.0)` | Use a rectified Gabor profile over 2-D displacement. |
184
- | `bp.spatial.gaussian2D(x=None, y=None, mean_x=0.0, mean_y=0.0, std_x=1.0, std_y=1.0, rho=0.0)` | Use a correlated bivariate-Gaussian profile. |
185
-
186
- ## Spatial masks
187
-
188
- Use these constructors to restrict candidate targets to a 2-D or 3-D region.
189
-
190
- | Constructor | Use when |
191
- |---|---|
192
- | `bp.spatial.circular(radius)` | Use a circular 2-D cutoff. |
193
- | `bp.spatial.spherical(radius)` | Use a spherical 3-D cutoff. |
194
- | `bp.spatial.box(lower_left, upper_right)` | Use an axis-aligned 2-D or 3-D box. |
195
- | `bp.spatial.rectangular(lower_left, upper_right, azimuth_angle=0.0)` | Use a rotated 2-D rectangle. |
196
- | `bp.spatial.doughnut(inner_radius, outer_radius)` | Use a 2-D annulus. |
197
- | `bp.spatial.elliptical(major_axis, minor_axis, azimuth_angle=0.0, anchor=None)` | Use a rotated 2-D ellipse. |
198
- | `bp.spatial.ellipsoidal(major_axis, minor_axis, polar_axis, azimuth_angle=0.0, polar_angle=0.0, anchor=None)` | Use a rotated 3-D ellipsoid. |
199
-
200
- ## Spatial connection rules
201
-
202
- Use these constructors to combine a probability law with an optional mask before passing the rule to `Simulator.connect()`.
203
-
204
- | Constructor | Use when |
205
- |---|---|
206
- | `bp.spatial.SpatialConnRule(p, mask=None, allow_autapses=True, _pre_pos=None, _post_pos=None)` | Use the concrete spatial rule type when positions are already bound. |
207
- | `bp.spatial.spatial_pairwise_bernoulli(p, mask=None, allow_autapses=True)` | Use the public distance-dependent pairwise-Bernoulli builder. |
208
-
209
- ## Spatial node selection and introspection
210
-
211
- Use these APIs to select nodes by geometry or inspect realized spatial targets.
212
-
213
- | API | Use when |
214
- |---|---|
215
- | `bp.spatial.center_element(layer)` | Use the node nearest the layer centroid. |
216
- | `bp.spatial.nearest_element(layer, locations, find_all=False)` | Use the node nearest each query location. |
217
- | `bp.spatial.select_nodes_by_mask(layer, anchor, mask)` | Use local indices inside a mask anchored at a position. |
218
- | `bp.spatial.target_nodes(sim, source, target)` | Use realized target indices for each source. |
219
- | `bp.spatial.target_positions(sim, source, target)` | Use coordinates of each source node's realized targets. |
220
-
221
- ## Spatial export and visualization
222
-
223
- Use these APIs to export layer data or visualize positions, realized edges, and probability fields.
224
-
225
- | API | Use when |
226
- |---|---|
227
- | `bp.spatial.dump_layer_nodes(sim, pop, outname)` | Use to write local node indices and coordinates. |
228
- | `bp.spatial.dump_layer_connections(sim, source, target, outname)` | Use to write realized edges, weights, delays, and displacement. |
229
- | `bp.spatial.plot_layer(layer, fig=None, nodecolor="b", nodesize=20)` | Use to plot layer positions. |
230
- | `bp.spatial.plot_targets(sim, src_node, target, fig=None, src_color="red", src_size=50, tgt_color="b", tgt_size=20)` | Use to highlight one source node's realized targets. |
231
- | `bp.spatial.plot_sources(sim, source, tgt_node, fig=None, src_color="b", src_size=20, tgt_color="red", tgt_size=50)` | Use to highlight one target node's realized sources. |
232
- | `bp.spatial.plot_probability_parameter(kernel, mask=None, extent=(-0.5, 0.5, -0.5, 0.5), shape=(100, 100), fig=None, cmap="Greys")` | Use to plot a 2-D probability field. |
233
-
234
- ## Spatial workflow
235
-
236
- Use the same `Simulator.create()` and `Simulator.connect()` lifecycle after selecting the layout, kernel, mask, and spatial rule.
237
-
238
- ```python
239
- positions = bp.spatial.grid([4, 3], extent=[2.0, 1.5])
240
- source = sim.create(bp.iaf_psc_alpha, positions=positions)
241
- target = sim.create(bp.iaf_psc_alpha, positions=positions)
242
-
243
- rule = bp.spatial.spatial_pairwise_bernoulli(
244
- p=bp.spatial.gaussian(bp.spatial.distance, std=0.5),
245
- mask=bp.spatial.circular(3.0),
246
- )
247
- sim.connect(
248
- source,
249
- target,
250
- rule=rule,
251
- weight=1.0 * u.pA,
252
- delay=1.0 * u.ms,
253
- seed=0,
254
- )
255
- ```
256
-
257
- Spatial random draws differ between NEST and JAX even when the probability law matches. Validate the empirical probability-versus-distance curve distributionally, not edge by edge.
258
-
259
- ## Official sources
260
-
261
- - https://brainx.chaobrain.com/brainpy-state/nest-style/tutorials/03-connect-network.html
262
- - https://brainx.chaobrain.com/brainpy-state/apis/nest-network.html
263
- - https://brainx.chaobrain.com/brainpy-state/apis/nest-spatial.html
264
- - https://brainx.chaobrain.com/brainpy-state/nest-style/spatial.html
@@ -1,153 +0,0 @@
1
- # Synapse and connectivity
2
-
3
- Use this reference when selecting a NEST-compatible synapse or plasticity rule, choosing canonical connectivity, constructing a unitful synapse spec, or reading and writing realized edges. Use `references/nest-compatible/network-building.md` for the complete connection-rule and projection-class map, and `references/nest-compatible/divergence-and-parity.md` for STDP parameter relocation and numerical bands.
4
-
5
- ## Connection rules
6
-
7
- Use these APIs to choose realized source-target pairs; choose the synapse spec separately to define what each realized edge does.
8
-
9
- | API | Use when |
10
- |---|---|
11
- | `bp.all_to_all` | Use when every source must connect to every target, including the default generator fan-out. |
12
- | `bp.one_to_one` | Use when source `i` must connect to target `i`; source and target views must have equal-size pairings. |
13
- | `bp.fixed_indegree(k)` | Use when every target must receive exactly `k` randomly drawn presynaptic edges. |
14
- | `bp.spatial.spatial_pairwise_bernoulli(p, mask=None, allow_autapses=True)` | Use when connection probability or eligibility depends on distance. |
15
-
16
- Set `seed` to reproduce a BrainPy-State random realization. For `fixed_indegree`, set `allow_multapses=True` to match NEST's default and use `comm="sparse"` for large event fan-in. Open `references/nest-compatible/network-building.md` for the remaining rule constructors.
17
-
18
- ## Static synapses
19
-
20
- Use these constructors when edge weights do not change through activity-dependent learning.
21
-
22
- | Constructor | Use when |
23
- |---|---|
24
- | `bp.static_synapse(*args, **kwargs)` | Use the default fixed-weight, fixed-delay synapse spec. |
25
- | `bp.static_synapse_hom_w(*args, **kwargs)` | Use one homogeneous weight shared across all realized connections. |
26
- | `bp.bernoulli_synapse(*args, **kwargs)` | Use fixed structural edges with stochastic Bernoulli transmission. |
27
- | `bp.cont_delay_synapse(*args, **kwargs)` | Use a continuous sub-timestep delay. |
28
-
29
- Pass `synapse=None` to `Simulator.connect()` for the ordinary static event path; instantiate a static spec only when its specialized behavior is required.
30
-
31
- ## Gap junctions and special connections
32
-
33
- Use these constructors for electrical, diffusion, rate, or astrocyte slow-inward-current coupling rather than ordinary static spike transmission.
34
-
35
- | Constructor | Use when |
36
- |---|---|
37
- | `bp.gap_junction(*args, **kwargs)` | Use electrical synaptic coupling with a compatible gap-junction neuron. |
38
- | `bp.diffusion_connection(*args, **kwargs)` | Use the NEST-compatible diffusion connection. |
39
- | `bp.rate_connection_instantaneous(*args, **kwargs)` | Use rate coupling without a connection delay. |
40
- | `bp.rate_connection_delayed(*args, **kwargs)` | Use delayed rate coupling. |
41
- | `bp.sic_connection(*args, **kwargs)` | Use astrocyte-to-neuron slow inward current coupling. |
42
-
43
- ## Short-term plasticity
44
-
45
- Use these constructors for transient, reversible efficacy changes on the timescale of individual spikes.
46
-
47
- | Constructor | Use when |
48
- |---|---|
49
- | `bp.tsodyks_synapse(*args, **kwargs)` | Use the Tsodyks-Uziel-Markram short-term-plasticity rule. |
50
- | `bp.tsodyks_synapse_hom(*args, **kwargs)` | Use the homogeneous shared-parameter Tsodyks form. |
51
- | `bp.tsodyks2_synapse(*args, **kwargs)` | Use the two-variable Tsodyks form. |
52
- | `bp.quantal_stp_synapse(*args, **kwargs)` | Use the quantal/binomial short-term-plasticity form. |
53
-
54
- ## Spike-timing-dependent plasticity
55
-
56
- Use these constructors for long-term weight changes driven by pre-post spike timing; select the pairing, weight-dependence, triplet, hardware, or dopamine rule explicitly.
57
-
58
- | Constructor | Use when |
59
- |---|---|
60
- | `bp.stdp_synapse(*args, **kwargs)` | Use pair-based STDP. |
61
- | `bp.stdp_synapse_hom(*args, **kwargs)` | Use pair-based STDP with homogeneous shared parameters. |
62
- | `bp.stdp_pl_synapse_hom(*args, **kwargs)` | Use power-law STDP. |
63
- | `bp.stdp_facetshw_synapse_hom(*args, **kwargs)` | Use the FACETS/BrainScaleS hardware-emulating rule. |
64
- | `bp.stdp_nn_pre_centered_synapse(*args, **kwargs)` | Use presynaptic-centered nearest-neighbour pairing. |
65
- | `bp.stdp_nn_restr_synapse(*args, **kwargs)` | Use restricted symmetric nearest-neighbour pairing. |
66
- | `bp.stdp_nn_symm_synapse(*args, **kwargs)` | Use symmetric nearest-neighbour pairing. |
67
- | `bp.stdp_triplet_synapse(*args, **kwargs)` | Use triplet STDP. |
68
- | `bp.stdp_dopamine_synapse(*args, **kwargs)` | Use dopamine-modulated STDP with a `volume_transmitter`. |
69
-
70
- Open `references/nest-compatible/divergence-and-parity.md` before porting `tau_minus`, Clopath parameters, dopamine State, or a nearest-neighbour pairing rule.
71
-
72
- ## Voltage-based and specialized learning
73
-
74
- Use these constructors when the weight update depends on voltage trajectories, dendritic prediction, inhibitory timing, or the Hill-Tononi vesicle pool.
75
-
76
- | Constructor | Use when |
77
- |---|---|
78
- | `bp.clopath_synapse(*args, **kwargs)` | Use voltage-based Clopath plasticity with a compatible `_clopath` neuron. |
79
- | `bp.jonke_synapse(*args, **kwargs)` | Use exponential weight-dependence STDP. |
80
- | `bp.urbanczik_synapse(*args, **kwargs)` | Use dendritic prediction-error plasticity with `pp_cond_exp_mc_urbanczik`. |
81
- | `bp.vogels_sprekeler_synapse(*args, **kwargs)` | Use symmetric inhibitory plasticity. |
82
- | `bp.ht_synapse(*args, **kwargs)` | Use Hill-Tononi vesicle-pool depression. |
83
-
84
- ## Synapse specification
85
-
86
- Use these `Simulator.connect()` arguments to attach a selected rule to realized edges.
87
-
88
- | Argument | Use |
89
- |---|---|
90
- | `weight=<quantity>` | Use signed current such as `pA` for current-based event input; use voltage such as `mV` for the instantaneous jump of `iaf_psc_delta`. |
91
- | `delay=<time quantity>` | Use for a homogeneous axonal delay. |
92
- | `weight=[...] * unit` | Use for a multi-channel generator with one signed weight per channel. |
93
- | `seed=<int>` | Use to reproduce the BrainPy-State random edge realization. |
94
- | `allow_multapses=<bool>` | Use to permit or forbid repeated source-target edges under a random rule. |
95
- | `comm="dense"` or `comm="sparse"` | Use to select the communication backend without changing the rule. |
96
- | `synapse=<spec>` | Use to attach any constructor from the synapse families above. |
97
-
98
- ```python
99
- projection = sim.connect(
100
- exc,
101
- exc + inh,
102
- rule=bp.fixed_indegree(80),
103
- weight=0.1 * u.pA,
104
- delay=1.5 * u.ms,
105
- seed=1,
106
- allow_multapses=True,
107
- comm="sparse",
108
- )
109
- ```
110
-
111
- **Invariant:** Do not copy one weight unit across neuron families. `iaf_psc_delta` consumes a voltage jump, while canonical alpha- and exponential-current events consume current.
112
-
113
- ## Plastic connection workflow
114
-
115
- Use `synapse=` when the edge needs State or behavior beyond static weight and delay.
116
-
117
- ```python
118
- plasticity = bp.tsodyks2_synapse(
119
- weight=250.0 * u.pA,
120
- U=0.67,
121
- tau_rec=450.0 * u.ms,
122
- tau_fac=0.0 * u.ms,
123
- )
124
- projection = sim.connect(spike_source, post, synapse=plasticity)
125
- ```
126
-
127
- **Invariant:** A BrainPy-State `spike_generator` can drive a plastic edge directly. Do not add a `parrot_neuron` solely because the NEST version required one.
128
-
129
- ## Realized-connectivity inspection
130
-
131
- Use these methods after construction to inspect or update the live edges selected by the rule.
132
-
133
- | API | Use when |
134
- |---|---|
135
- | `sim.get_connections(source=None, target=None, synapse=None)` | Use to obtain an empty or populated lazy `SynapseCollection` filtered by source, target, or synapse name. |
136
- | `connections.get(key)` | Use one key to read live `source`, `target`, `weight`, or `delay`, or a sequence to return several attributes as a dictionary; weights and delays retain units. |
137
- | `connections.set(key, value)` | Use to write supported static `weight` or `delay` values; homogeneous, plastic, and other weight-evolving projections can reject the write. |
138
-
139
- ```python
140
- connections = sim.get_connections(source=exc, target=inh)
141
- edge_data = connections.get(["source", "target", "weight", "delay"])
142
-
143
- assert edge_data["source"].shape == edge_data["target"].shape
144
- assert edge_data["weight"].shape == edge_data["source"].shape
145
- ```
146
-
147
- `SynapseCollection` re-reads live weights and delays, so a collection created before simulation reflects later plastic changes. Source and target indices are population-local, not global NEST node IDs.
148
-
149
- ## Official sources
150
-
151
- - https://brainx.chaobrain.com/brainpy-state/apis/nest-synapses.html
152
- - https://brainx.chaobrain.com/brainpy-state/apis/nest-plasticity.html
153
- - https://brainx.chaobrain.com/brainpy-state/nest-style/connectivity.html
@@ -1,127 +0,0 @@
1
- # Projection patterns
2
-
3
- Use this reference after selecting neuron, synapse, output, and communication semantics. Choose alignment from synapse linearity and reuse direction before choosing the class or functional API form.
4
-
5
- ## Projection anatomy
6
-
7
- Every native chemical projection separates four roles:
8
-
9
- | Role | Decision |
10
- |---|---|
11
- | `comm` | Choose how presynaptic values are weighted and mapped to postsynaptic values. Use event operators for sparse binary spikes and dense linear operators for dense continuous values. |
12
- | `syn` | Choose temporal filtering and determine whether its dynamics satisfy AlignPost's linear exponential condition. |
13
- | `out` | Choose conductance-based, current-based, or voltage-blocked conversion into postsynaptic current. |
14
- | `post` | Supply the receiving neuron population; projections accumulate input into it before its update. |
15
-
16
- Call each chemical projection before `post(...)` in the step. Read the presynaptic spike from the previous completed update, route it through the projection, then update the source and target populations.
17
-
18
- Subclass `brainpy.state.Projection` only when the concrete projections cannot express the required lifecycle. Register communication, dynamics, and output Modules as attributes and preserve the postsynaptic current/delta-input contract.
19
-
20
- ## Alignment decision
21
-
22
- Choose alignment from synapse linearity and trace reuse; use a filter-free or electrical projection only when the connection does not require aligned chemical-synapse State.
23
-
24
- ### Linear convergent fan-in
25
-
26
- Use this family for exponential-family linear synapses when many sources converge on a target and exact State should scale with the postsynaptic dimension.
27
-
28
- | API | Use when |
29
- |---|---|
30
- | `brainpy.state.AlignPostProj(*modules, comm=..., syn=..., out=..., post=..., label=None, delay=None)` | Use the direct push form when the caller supplies presynaptic events at update time; it stores exact synaptic State with memory proportional to `N_post`. |
31
- | `brainpy.state.align_post_projection(*spike_generator, comm=..., syn=..., out=..., post=..., stp=None)` | Use the builder form when presynaptic extraction or short-term plasticity belongs to projection construction. |
32
-
33
- ### Nonlinear or reusable fan-out
34
-
35
- Use this family for nonlinear receptor kinetics or when one source population fans out to several targets and outgoing parameters are homogeneous per source.
36
-
37
- | API | Use when |
38
- |---|---|
39
- | `brainpy.state.align_pre_projection(*spike_generator, syn=..., comm=..., out=..., post=..., stp=None)` | Use when exact synaptic traces should live on and be reusable from the presynaptic dimension, with memory proportional to `N_pre`. |
40
-
41
- ### Filter-free chemical projections
42
-
43
- Use this family when communication should deposit continuous current or an instantaneous event without temporal synapse dynamics.
44
-
45
- | API | Use when |
46
- |---|---|
47
- | `brainpy.state.CurrentProj(*prefetch, comm=..., out=..., post=..., delay=None)` | Use when continuous input requires communication and output conversion before current is deposited into `post`. |
48
- | `brainpy.state.DeltaProj(*prefetch, comm=..., post=..., label=None)` | Use when an event should produce an instantaneous target increment without temporal synapse State. |
49
-
50
- ### Electrical coupling
51
-
52
- Use this family when voltage differences should drive reciprocal or directed gap-junction current rather than a chemical synapse.
53
-
54
- | API | Use when |
55
- |---|---|
56
- | `brainpy.state.SymmetryGapJunction(couples, states, conn, weight, param_type=brainstate.ParamState)` | Use when the same conductance applies reciprocally in both coupling directions. |
57
- | `brainpy.state.AsymmetryGapJunction(pre, pre_state, post, post_state, conn, weight, param_type=brainstate.ParamState)` | Use when the two coupling directions require distinct conductances. |
58
-
59
- AlignPre and AlignPost are exact only under their stated conditions. They change State ownership and memory, not the intended dynamics.
60
-
61
- ## AlignPost API forms
62
-
63
- Use `AlignPostProj` for the direct push form:
64
-
65
- ```python
66
- proj = brainpy.state.AlignPostProj(
67
- comm=brainstate.nn.EventFixedProb(
68
- n_pre,
69
- n_post,
70
- conn_num=0.1,
71
- conn_weight=0.5 * u.mS,
72
- ),
73
- syn=brainpy.state.Expon.desc(n_post, tau=5.0 * u.ms),
74
- out=brainpy.state.COBA.desc(E=0.0 * u.mV),
75
- post=post,
76
- )
77
-
78
- proj(pre.get_spike() != 0.0)
79
- ```
80
-
81
- Use the functional builder when presynaptic extraction or short-term plasticity belongs to projection construction. Open `references/component-selection.md` for the canonical `stp=STP.desc(...)` composition.
82
-
83
- Do not pass both a pulled presynaptic source and a second explicit spike array at update time.
84
-
85
- When `syn` and `out` are matching `.desc(...)` objects, compatible AlignPost projections targeting the same population can merge and share the postsynaptic synapse/output instances. When `syn` is a concrete synapse instance, pass a concrete output instance as well; that pair is not merged.
86
-
87
- ## AlignPre form
88
-
89
- Use the function `align_pre_projection`; there is no AlignPre projection class:
90
-
91
- ```python
92
- proj = brainpy.state.align_pre_projection(
93
- pre,
94
- syn=brainpy.state.AMPA(n_pre),
95
- comm=brainstate.nn.Linear(
96
- n_pre,
97
- n_post,
98
- w_init=braintools.init.KaimingNormal(unit=u.mS),
99
- b_init=None,
100
- ),
101
- out=brainpy.state.COBA(E=0.0 * u.mV),
102
- post=post,
103
- )
104
- ```
105
-
106
- Use AlignPre only when synaptic parameters are homogeneous for the outgoing synapses represented by each presynaptic trace. If connection-specific nonlinear kinetics are required, the shared-trace premise does not hold.
107
-
108
- ## Delayed projections
109
-
110
- Choose projection alignment before adding a delay. Open `references/brain-dynamics-delay-protocol.md` when selecting direct `delay=` versus delayed prefetch, applying scalar or per-presynaptic delays, preserving the fixed-`dt` buffer invariant, or separating BrainPy projection delays from general BrainState delay buffers.
111
-
112
- ## Communication boundary
113
-
114
- Use `brainstate.nn.EventFixedProb` for the canonical probabilistic sparse-spike connection shown in BrainPy-State tutorials. Open `skills/package-skills/brainevent/SKILL.md` when the decision involves `EventLinear`, fixed-number event connectivity, sparse formats, plasticity operators, custom kernels, or dense-to-event performance conversion.
115
-
116
- Open `references/scripts/103_COBA_2005.py` for a complete E/I COBA projection workflow. Open `references/scripts/109_fast_global_oscillation.py` when the projection uses `DeltaProj` with delayed recurrent input.
117
-
118
- Open `references/scripts/sound_localization.py` when independent conditions require a mapped bank of heterogeneous integer event taps feeding BrainEvent fixed-fan-out communication and coincidence detectors.
119
-
120
- ## Official sources
121
-
122
- - `https://brainx.chaobrain.com/brainpy-state/concepts/model-anatomy.html`
123
- - `https://brainx.chaobrain.com/brainpy-state/concepts/alignpre-alignpost.html`
124
- - `https://brainx.chaobrain.com/brainpy-state/brainpy-style/tutorials/02-synapse-and-projection.html`
125
- - `https://brainx.chaobrain.com/brainpy-state/brainpy-style/howto/sim-short-term-plasticity.html`
126
- - `https://brainx.chaobrain.com/brainpy-state/brainpy-style/howto/sim-delays.html`
127
- - `https://brainx.chaobrain.com/brainpy-state/apis/brainpy-projections.html`
@@ -1,86 +0,0 @@
1
- # Copyright 2024 BrainX Ecosystem Limited. All Rights Reserved.
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # http://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
- # ==============================================================================
15
-
16
- #
17
- # Implementation of the paper:
18
- #
19
- # - Brette, R., Rudolph, M., Carnevale, T., Hines, M., Beeman, D., Bower, J. M., et al. (2007),
20
- # Simulation of networks of spiking neurons: a review of tools and strategies., J. Comput. Neurosci., 23, 3, 349–98
21
- #
22
- # which is based on the balanced network proposed by:
23
- #
24
- # - Vogels, T. P. and Abbott, L. F. (2005), Signal propagation and logic gating in networks of integrate-and-fire neurons., J. Neurosci., 25, 46, 10786–95
25
- #
26
-
27
-
28
- import brainunit as u
29
- import matplotlib.pyplot as plt
30
-
31
- import brainpy
32
- import brainstate
33
- import braintools
34
-
35
-
36
- class EINet(brainstate.nn.Module):
37
- def __init__(self):
38
- super().__init__()
39
- self.n_exc = 3200
40
- self.n_inh = 800
41
- self.num = self.n_exc + self.n_inh
42
- self.N = brainpy.state.LIFRef(
43
- self.num, V_rest=-60. * u.mV, V_th=-50. * u.mV, V_reset=-60. * u.mV,
44
- tau=20. * u.ms, tau_ref=5. * u.ms,
45
- V_initializer=braintools.init.Normal(-55., 2., unit=u.mV)
46
- )
47
- self.E = brainpy.state.AlignPostProj(
48
- comm=brainstate.nn.EventFixedProb(self.n_exc, self.num, conn_num=0.02, conn_weight=0.6 * u.mS),
49
- syn=brainpy.state.Expon.desc(self.num, tau=5. * u.ms),
50
- out=brainpy.state.COBA.desc(E=0. * u.mV),
51
- post=self.N
52
- )
53
- self.I = brainpy.state.AlignPostProj(
54
- comm=brainstate.nn.EventFixedProb(self.n_inh, self.num, conn_num=0.02, conn_weight=6.7 * u.mS),
55
- syn=brainpy.state.Expon.desc(self.num, tau=10. * u.ms),
56
- out=brainpy.state.COBA.desc(E=-80. * u.mV),
57
- post=self.N
58
- )
59
-
60
- def update(self, t, inp):
61
- with brainstate.environ.context(t=t):
62
- spk = self.N.get_spike() != 0.
63
- self.E(spk[:self.n_exc])
64
- self.I(spk[self.n_exc:])
65
- self.N(inp)
66
- return self.N.get_spike()
67
-
68
-
69
- # network
70
- net = EINet()
71
- brainstate.nn.init_all_states(net)
72
-
73
- # simulation
74
- with brainstate.environ.context(dt=0.1 * u.ms):
75
- times = u.math.arange(0. * u.ms, 1000. * u.ms, brainstate.environ.get_dt())
76
- spikes = brainstate.transform.for_loop(
77
- lambda t: net.update(t, 20. * u.mA), times,
78
- pbar=brainstate.transform.ProgressBar(10)
79
- )
80
-
81
- # visualization
82
- t_indices, n_indices = u.math.where(spikes)
83
- plt.scatter(times[t_indices], n_indices, s=1)
84
- plt.xlabel('Time (ms)')
85
- plt.ylabel('Neuron index')
86
- plt.show()