brainx-skill 1.0.6 → 1.0.8

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. package/README.md +9 -2
  2. package/adapters/gemini.js +7 -0
  3. package/adapters/opencode.js +7 -0
  4. package/adapters/windsurf.js +7 -0
  5. package/installation/lib/installer.js +4 -1
  6. package/manifest.json +5 -1
  7. package/package.json +7 -2
  8. package/skills/braincell/SKILL.md +182 -0
  9. package/skills/braincell/references/area-scaled-hh-pattern.md +54 -0
  10. package/skills/braincell/references/braincell-custom-ion-channel-authoring.md +210 -0
  11. package/skills/braincell/references/channel-library.md +170 -0
  12. package/skills/braincell/references/ion-library.md +154 -0
  13. package/skills/braincell/references/mixions-for-adaptation.md +81 -0
  14. package/skills/braincell/references/multicompartment/braincell-manual-morphology-construction.md +180 -0
  15. package/skills/braincell/references/multicompartment/cv-policy-reference.md +133 -0
  16. package/skills/braincell/references/multicompartment/filter-function-library.md +162 -0
  17. package/skills/braincell/references/multicompartment/morphology-io-loading-validation.md +135 -0
  18. package/skills/braincell/references/multicompartment/multicompartment-cell-workflow.md +391 -0
  19. package/skills/braincell/references/multicompartment/probe-reference.md +128 -0
  20. package/skills/braincell/references/multicompartment/topology-building-and-visualization.md +121 -0
  21. package/skills/braincell/references/scripts/calcium_channel_gating.py +66 -0
  22. package/skills/braincell/references/scripts/cell_multicompartment_reference.py +221 -0
  23. package/skills/braincell/references/scripts/channel_ablation.py +61 -0
  24. package/skills/braincell/references/scripts/fi_curve.py +68 -0
  25. package/skills/braincell/references/scripts/hh_neuron_basics.py +59 -0
  26. package/skills/braincell/references/scripts/spike_frequency_adaptation.py +75 -0
  27. package/skills/braincell/references/scripts/t_current_rebound.py +72 -0
  28. package/skills/braincell/references/scripts/thalamic_neurons.py +228 -0
  29. package/skills/braincell/references/solver-library-with-effects.md +188 -0
  30. package/skills/brainevent/SKILL.md +268 -0
  31. package/skills/brainevent/references/connectivity-variants.md +312 -0
  32. package/skills/brainevent/references/custom-operators-cpu.md +304 -0
  33. package/skills/brainevent/references/custom-operators-gpu.md +468 -0
  34. package/skills/brainevent/references/scripts/102_EI_net_1996.py +107 -0
  35. package/skills/brainevent/references/scripts/204_joglekar_2018_propagation.py +168 -0
  36. package/skills/brainevent/references/scripts/coba_ei_teaching.py +356 -0
  37. package/skills/brainevent/references/sparse-formats.md +182 -0
  38. package/skills/brainevent/references/synaptic-plasticity.md +285 -0
  39. package/skills/brainpy-state/SKILL.md +232 -0
  40. package/skills/brainpy-state/references/array-creation.md +158 -0
  41. package/skills/brainpy-state/references/brain-dynamics-delay-protocol.md +96 -0
  42. package/skills/brainpy-state/references/braintools/brainstate-control-flow-patterns.md +334 -0
  43. package/skills/brainpy-state/references/braintools/data-preprocessing.md +79 -0
  44. package/skills/brainpy-state/references/braintools/metric.md +152 -0
  45. package/skills/brainpy-state/references/braintools/optimizer.md +179 -0
  46. package/skills/brainpy-state/references/braintools/parameter-initializer.md +183 -0
  47. package/skills/brainpy-state/references/braintools/surrogate.md +147 -0
  48. package/skills/brainpy-state/references/component-selection.md +273 -0
  49. package/skills/brainpy-state/references/nest-compatible/devices.md +157 -0
  50. package/skills/brainpy-state/references/nest-compatible/divergence-and-parity.md +114 -0
  51. package/skills/brainpy-state/references/nest-compatible/integration-categories.md +41 -0
  52. package/skills/brainpy-state/references/nest-compatible/model-library.md +200 -0
  53. package/skills/brainpy-state/references/nest-compatible/nest-workflow.md +156 -0
  54. package/skills/brainpy-state/references/nest-compatible/network-building.md +264 -0
  55. package/skills/brainpy-state/references/nest-compatible/scripts/brette_et_al_2007.py +320 -0
  56. package/skills/brainpy-state/references/nest-compatible/scripts/brunel_alpha.py +108 -0
  57. package/skills/brainpy-state/references/nest-compatible/scripts/brunel_delta.py +93 -0
  58. package/skills/brainpy-state/references/nest-compatible/scripts/clopath_synapse_spike_pairing.py +171 -0
  59. package/skills/brainpy-state/references/nest-compatible/scripts/evaluate_tsodyks2_synapse.py +147 -0
  60. package/skills/brainpy-state/references/nest-compatible/scripts/spatial_gaussex.py +112 -0
  61. package/skills/brainpy-state/references/nest-compatible/scripts/synapsecollection.py +198 -0
  62. package/skills/brainpy-state/references/nest-compatible/synapse-and-connectivity.md +153 -0
  63. package/skills/brainpy-state/references/projection-patterns.md +125 -0
  64. package/skills/brainpy-state/references/scripts/103_COBA_2005.py +86 -0
  65. package/skills/brainpy-state/references/scripts/106_COBA_HH_2007.py +181 -0
  66. package/skills/brainpy-state/references/scripts/107_gamma_oscillation_1996.py +156 -0
  67. package/skills/brainpy-state/references/scripts/109_fast_global_oscillation.py +111 -0
  68. package/skills/brainpy-state/references/scripts/201_surrogate_grad_lif_fashion_mnist.py +221 -0
  69. package/skills/brainpy-state/references/scripts/training-snn.py +119 -0
  70. package/skills/brainstate/SKILL.md +1 -1
  71. package/skills/brainstate/references/brainstate/brainstate-control-flow-patterns.md +250 -399
  72. package/skills/brainstate/references/brainstate/brainstate-transformed-diagnostics.md +6 -2
  73. package/skills/brainstate/references/brainstate/parameter-constraints-regularization.md +16 -2
  74. package/skills/brainstate/references/brainstate/parameter-transforms-regularizers-catalog.md +8 -3
  75. package/skills/brainstate/references/brainstate/randomness-and-reproducibility.md +64 -143
  76. package/skills/brainstate/references/brainstate/transformation-grad-expansion.md +13 -1
  77. package/skills/brainstate/references/brainstate/transformation-jit-expansion.md +11 -1
  78. package/skills/brainstate/references/brainstate/transformation-vmap-expansion.md +35 -7
  79. package/skills/brainstate/references/collective_model_operations.md +9 -9
  80. package/skills/brainstate/references/extension_mechanisms.md +12 -1
  81. package/skills/brainstate/references/libraries/prebuilt-activation-library.md +106 -97
  82. package/skills/brainstate/references/libraries/prebuilt-layer-library.md +102 -176
  83. package/skills/brainstate/references/model-interop-and-migration.md +11 -1
  84. package/skills/brainstate/references/size-inference-variations.md +11 -0
  85. package/skills/brainstate/references/state-graph-operations.md +13 -15
  86. package/skills/brainstate/references/state_collections_and_utilities.md +12 -1
  87. package/skills/brainx-general-guard/SKILL.md +153 -0
  88. package/skills/brainx-general-guard/references/brainstate-randomness-reproducibility/advanced-randomness.md +303 -0
  89. package/skills/brainx-general-guard/references/brainstate-randomness-reproducibility/randomness-and-reproducibility.md +62 -0
  90. package/skills/brainstate/references/braintools-optimizer-reference.md +0 -133
  91. package/skills/brainstate/references/libraries/solver-library-with-effects.md +0 -85
@@ -1,133 +0,0 @@
1
- # Braintools optimizer selection reference
2
-
3
- Use this reference to select a `braintools.optim` optimizer, learning-rate scheduler, Optax bridge, or external optimizer wrapper. It is a selection adapter, not a BrainState training-loop guide: return to `skills/brainstate/SKILL.md` for the canonical State-aware training structure. Advanced full-training workflows are outside the supplied router.
4
-
5
- **Source URL:** https://brainx.chaobrain.com/braintools/optim/index.html
6
-
7
- ## Route from the official optimization index
8
-
9
- The index states: "Optimization guides highlight practical solvers for tuning models and experiments. Compare gradient-free Nevergrad strategies with SciPy-based routines and learn when to apply each."
10
-
11
- Use its five routes as follows, without importing their unshown details into this reference:
12
-
13
- | Official index route | Selection cue available on the index |
14
- |---|---|
15
- | Tutorial 1: `NevergradOptimizer` Tutorial | Gradient-free Nevergrad strategy |
16
- | Tutorial 2: `ScipyOptimizer` Tutorial | SciPy-based routine |
17
- | Tutorial 3: Getting Started with `optax` Optimizers | Optax optimizer route |
18
- | Tutorial 4: Learning Rate Scheduling Strategies | Learning-rate scheduler selection |
19
- | Tutorial 5: Advanced Optimizers and Techniques | Optimizer choices beyond the basic route |
20
-
21
- **Source URL:** https://brainx.chaobrain.com/braintools/optim/index.html
22
-
23
- ## Optimizer and state types
24
-
25
- The index exposes the `braintools.optim` module and lists `Optimizer`, `OptaxOptimizer`, and `OptimState` before its concrete optimizer classes. For class selection, preserve the module and symbol names exactly:
26
-
27
- ```python
28
- import braintools.optim
29
-
30
- optimizer_type = braintools.optim.Adam
31
- ```
32
-
33
- Concrete optimizer classes, in index order:
34
-
35
- - `SGD`
36
- - `Momentum`
37
- - `MomentumNesterov`
38
- - `Adam`
39
- - `AdamW`
40
- - `Adagrad`
41
- - `Adadelta`
42
- - `RMSprop`
43
- - `Adamax`
44
- - `Nadam`
45
- - `RAdam`
46
- - `Lamb`
47
- - `Lars`
48
- - `Lookahead`
49
- - `Yogi`
50
- - `LBFGS`
51
- - `Rprop`
52
- - `Adafactor`
53
- - `AdaBelief`
54
- - `Lion`
55
- - `SM3`
56
- - `Novograd`
57
- - `Fromage`
58
- - `SOFO`
59
- - `SOFOScan`
60
-
61
- The index does not provide constructor signatures, update semantics, or comparative algorithm guidance. Select the requested class here; do not infer arguments or substitute a training workflow from this catalog.
62
-
63
- **Source URL:** https://brainx.chaobrain.com/braintools/optim/index.html
64
-
65
- ## Learning-rate schedulers
66
-
67
- The scheduler base and concrete scheduler symbols are listed together. Select the exact class first, then return to the main BrainState skill for the surrounding canonical training structure.
68
-
69
- ```python
70
- import braintools.optim
71
-
72
- scheduler_type = braintools.optim.ExponentialDecayLR
73
- ```
74
-
75
- Scheduler classes, in index order:
76
-
77
- - `LRScheduler`
78
- - `StepLR`
79
- - `MultiStepLR`
80
- - `ConstantLR`
81
- - `LinearLR`
82
- - `ExponentialLR`
83
- - `PolynomialLR`
84
- - `ExponentialDecayLR`
85
- - `CosineAnnealingLR`
86
- - `CosineAnnealingWarmRestarts`
87
- - `WarmupCosineSchedule`
88
- - `CyclicLR`
89
- - `OneCycleLR`
90
- - `ReduceLROnPlateau`
91
- - `WarmupScheduler`
92
- - `PiecewiseConstantSchedule`
93
- - `ChainedScheduler`
94
- - `SequentialLR`
95
-
96
- **Source URL:** https://brainx.chaobrain.com/braintools/optim/index.html
97
-
98
- ## Optax bridge
99
-
100
- The index pairs a "Getting Started with `optax` Optimizers" route with the exported `OptaxOptimizer` symbol. Select that bridge only when the task explicitly calls for the Optax route through Braintools:
101
-
102
- ```python
103
- import braintools.optim
104
-
105
- optax_bridge_type = braintools.optim.OptaxOptimizer
106
- ```
107
-
108
- The index gives no adapter constructor or Optax transformation example, so this reference does not invent one.
109
-
110
- **Source URL:** https://brainx.chaobrain.com/braintools/optim/index.html
111
-
112
- ## Scipy and nevergrad wrappers
113
-
114
- The index distinguishes "gradient-free Nevergrad strategies" from "SciPy-based routines" and lists the wrapper symbols `NevergradOptimizer` and `ScipyOptimizer`.
115
-
116
- ```python
117
- import braintools.optim
118
-
119
- gradient_free_wrapper_type = braintools.optim.NevergradOptimizer
120
- scipy_wrapper_type = braintools.optim.ScipyOptimizer
121
- ```
122
-
123
- - Select `NevergradOptimizer` for the index's gradient-free Nevergrad route.
124
- - Select `ScipyOptimizer` for the index's SciPy-based route.
125
- - Do not assume that either wrapper follows the ordinary BrainState gradient-step interface; the index does not state their call contracts.
126
-
127
- **Source URL:** https://brainx.chaobrain.com/braintools/optim/index.html
128
-
129
- ## Integration boundary
130
-
131
- After choosing a symbol, route back to the main BrainState skill for its canonical State-aware training structure. Advanced full-training workflows remain outside this supplied router. Training operations are deliberately not repeated here because the optimization index supplies names and routes, not the BrainState training structure.
132
-
133
- **Source URL:** https://brainx.chaobrain.com/braintools/optim/index.html
@@ -1,85 +0,0 @@
1
- # Braincell solver library with effects
2
-
3
- ## Purpose
4
-
5
- Catalog BrainCell integration and solver choices with their expected modeling consequences.
6
-
7
- ## Source pages
8
-
9
- * https://brainx.chaobrain.com/braincell/concepts/integration.html
10
- * https://brainx.chaobrain.com/braincell/apis/integration.html
11
- * https://brainx.chaobrain.com/braincell/examples/integration_methods.html
12
-
13
- ## Core model
14
-
15
- * `DiffEqState` is a state variable that carries its derivative.
16
- * `DiffEqModule` exposes a right-hand side over integrable states.
17
- * Cells implement this protocol, so solvers can advance them without user code touching the protocol in ordinary modeling.
18
- * `braincell.quad` holds a registry of solvers selectable by name.
19
- * `get_integrator` resolves an integrator from a string or callable; `register_integrator` adds a function to the global registry; `all_integrators` exposes registered names.
20
-
21
- ## Solver families
22
-
23
- | Family | Names / APIs | Use |
24
- | --- | --- | --- |
25
- | Exponential Euler | `exp_euler`, `ind_exp_euler`, `exp_exp_euler` | Good default family for HH-style gating; stable at practical point-neuron step sizes. |
26
- | Explicit Runge-Kutta | `euler`, `midpoint`, `rk2`, `rk3`, `rk4`, `heun2`, `heun3`, `ssprk3`, `ralston2`, `ralston3`, `ralston4` | Useful for comparisons and non-stiff problems; may need tiny time steps for stiff HH dynamics. |
27
- | Implicit | `backward_euler`, `implicit_euler`, `implicit_exp_euler`, `implicit_rk4` | Use when implicit stepping is required; inspect official API and examples first. |
28
- | Composite / cable | `cn_exp_euler`, `cn_rk4`, `splitting`, `staggered`, `dhs_voltage` | Designed for multicompartment/cable coupling; delegate geometry tasks to `skills/braincell/SKILL.md`, which selects its multicompartment parent. |
29
-
30
- List available names at runtime:
31
-
32
- ```python
33
- import braincell.quad as quad
34
-
35
- sorted(quad.all_integrators)
36
- ```
37
-
38
- ## Single-compartment defaults
39
-
40
- * Use `exp_euler` for high-precision single-cell HH traces and electrophysiology-style examples.
41
- * Use `ind_exp_euler` for large vectorized point-neuron or network simulations when speed matters.
42
- * Use `rk4` when the user asks for classical Runge-Kutta comparison or explicitly requests it.
43
- * Treat method-dependent waveform changes as numerical artifacts until proven otherwise.
44
-
45
- ## Solver effects from official hh comparison
46
-
47
- The official integration-methods example compares `exp_euler` and `ind_exp_euler` on HH dynamics:
48
-
49
- * `exp_euler` produces smoother curves and more accurately fits tightly coupled gating variables and membrane potential.
50
- * `ind_exp_euler` updates state variables independently, can deviate slightly during rapid changes, and is faster for large-scale simulations.
51
- * For high-precision single-cell simulations, prefer `exp_euler`.
52
- * For large-scale network simulations with thousands of neurons, prefer `ind_exp_euler` when the approximation is acceptable.
53
-
54
- ## Usage pattern
55
-
56
- ```python
57
- class HH(braincell.SingleCompartment):
58
- def __init__(self, size, solver="exp_euler"):
59
- super().__init__(size, V_th=20. * u.mV, solver=solver)
60
- self.na = braincell.ion.SodiumFixed(size, E=50. * u.mV)
61
- self.na.add(INa=braincell.channel.Na_HH1952(size))
62
- self.k = braincell.ion.PotassiumFixed(size, E=-77. * u.mV)
63
- self.k.add(IK=braincell.channel.K_HH1952(size))
64
- self.IL = braincell.channel.IL(size, E=-54.387 * u.mV, g_max=0.03 * (u.mS / u.cm ** 2))
65
-
66
- hh_exp = HH(1, solver="exp_euler")
67
- hh_ind = HH(1, solver="ind_exp_euler")
68
- ```
69
-
70
- Always keep `dt` explicit in a BrainState environment context:
71
-
72
- ```python
73
- with brainstate.environ.context(dt=0.01 * u.ms):
74
- times = u.math.arange(0. * u.ms, 100. * u.ms, brainstate.environ.get_dt())
75
- vs, spikes = brainstate.transform.for_loop(step, times)
76
- ```
77
-
78
- ## Common mistakes -> fix
79
-
80
- * Choosing solver blindly -> name the solver and why it fits the task.
81
- * Using too-large `dt` -> reduce `dt` before blaming model biology.
82
- * Treating solver differences as biological findings -> compare methods and report as numerical effects.
83
- * Using `rk4` as the default for stiff HH gating -> prefer exponential-Euler variants unless comparison requires RK.
84
- * Using cable/composite solvers in a point-neuron task -> only use them when morphology/cable coupling exists.
85
- * Forgetting units on `dt` -> use `0.01 * u.ms`, not `0.01`.