brainx-skill 1.0.15 → 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.
- package/README.md +17 -1
- package/manifest.json +1 -1
- package/mcp-servers/codex/skills.json +1 -1
- package/package.json +1 -1
- package/skills/bio-neuro-lit/SKILL.md +4 -2
- package/skills/bio-neuro-lit/references/required-supplements.md +27 -0
- package/skills/brainx-acceleration/SKILL.md +30 -437
- package/skills/brainx-acceleration/references/audit-and-rewrite-patterns.md +326 -0
- package/skills/brainx-general-guard/SKILL.md +24 -8
- package/skills/brainx-install/SKILL.md +3 -3
- package/skills/brainx-install/references/compatibility-and-release-matching.md +28 -20
- package/skills/brainx-install/references/uninstall-and-cleanup.md +11 -4
- package/skills/brainx-modeling-loop/SKILL.md +117 -36
- package/skills/brainx-modeling-loop/agents/openai.yaml +2 -2
- package/skills/brainx-modeling-loop/references/mechanism-comparison.md +62 -0
- package/skills/brainx-modeling-loop/references/multiscale-coupling.md +16 -0
- package/skills/brainx-modeling-loop/references/paper-reproduction.md +42 -0
- package/skills/brainx-modeling-loop/references/parameter-fitting-workflow.md +14 -14
- package/skills/brainx-modeling-loop/references/run-experiment.md +1 -1
- package/skills/brainx-modeling-loop/references/training-workflow.md +10 -8
- package/skills/brainx-visualization/SKILL.md +6 -2
- package/skills/brainx-visualization/references/neural-data-visualization.md +1 -1
- package/skills/brainx-visualization/references/statistical-and-model-visualization.md +1 -1
- package/skills/package-skills/braincell/SKILL.md +23 -14
- package/skills/package-skills/braincell/references/braintools/input-current.md +1 -1
- package/skills/package-skills/braincell/references/braintools/metric.md +72 -46
- package/skills/package-skills/braincell/references/mixions-for-adaptation.md +1 -1
- package/skills/package-skills/braincell/references/multicompartment/braincell-manual-morphology-construction.md +1 -1
- package/skills/package-skills/braincell/references/multicompartment/cv-policy-reference.md +1 -1
- package/skills/package-skills/braincell/references/multicompartment/filter-function-library.md +3 -3
- package/skills/package-skills/braincell/references/multicompartment/morphology-io-loading-validation.md +1 -1
- package/skills/package-skills/braincell/references/multicompartment/multicompartment-cell-workflow.md +31 -43
- package/skills/package-skills/braincell/references/multicompartment/network-workflow.md +49 -0
- package/skills/package-skills/braincell/references/multicompartment/probe-reference.md +26 -114
- package/skills/package-skills/braincell/references/multicompartment/topology-building-and-visualization.md +40 -28
- package/skills/package-skills/braincell/references/scripts/cell_multicompartment_reference.py +13 -17
- package/skills/package-skills/brainevent/SKILL.md +0 -3
- package/skills/package-skills/brainevent/references/synaptic-plasticity.md +1 -1
- package/skills/package-skills/brainmass/SKILL.md +5 -3
- package/skills/package-skills/brainmass/references/brainstate/parameter-constraints-regularization.md +9 -7
- package/skills/package-skills/brainmass/references/brainstate/parameter-transforms-regularizers-catalog.md +4 -4
- package/skills/package-skills/brainmass/references/braintools/data-preprocessing.md +15 -7
- package/skills/package-skills/brainmass/references/braintools/metric.md +72 -46
- package/skills/package-skills/brainmass/references/coupling-network-api.md +3 -1
- package/skills/package-skills/brainmass/references/fitting-with-objectives-api.md +6 -6
- package/skills/package-skills/brainmass/references/horn-task-training.md +9 -9
- package/skills/package-skills/brainmass/references/modellibrary.md +12 -10
- package/skills/package-skills/brainmass/references/scripts/resting-state-meg-whole-brain-pipeline.py +5 -3
- package/skills/package-skills/brainmass/references/scripts/wilson-cowan-ei-dynamics.py +10 -6
- package/skills/package-skills/brainmass/references/simulator-input-monitor-api.md +3 -1
- package/skills/package-skills/brainmass/references/visualization-analysis-api.md +17 -9
- package/skills/package-skills/brainspike/SKILL.md +201 -0
- package/skills/package-skills/brainspike/references/braintools/connectivity.md +40 -0
- package/skills/package-skills/brainspike/references/braintools/data-preprocessing.md +39 -0
- package/skills/package-skills/brainspike/references/braintools/input-current.md +55 -0
- package/skills/package-skills/brainspike/references/braintools/metric.md +36 -0
- package/skills/package-skills/brainspike/references/braintools/optimizer.md +50 -0
- package/skills/package-skills/brainspike/references/braintools/parameter-initializer.md +43 -0
- package/skills/package-skills/brainspike/references/braintools/surrogate.md +40 -0
- package/skills/package-skills/brainspike/references/migration-boundary.md +38 -0
- package/skills/package-skills/brainspike/references/model-and-readout-selection.md +41 -0
- package/skills/package-skills/brainspike/references/multirate-coupling.md +31 -0
- package/skills/package-skills/brainspike/references/multiscale-composition.md +28 -0
- package/skills/package-skills/brainspike/references/native-composition.md +52 -0
- package/skills/package-skills/brainspike/references/native-delays.md +34 -0
- package/skills/package-skills/brainspike/references/native-projections.md +43 -0
- package/skills/package-skills/brainspike/references/native-training.md +36 -0
- package/skills/package-skills/{brainpy-state → brainspike}/references/nest-compatible/devices.md +33 -33
- package/skills/package-skills/{brainpy-state → brainspike}/references/nest-compatible/divergence-and-parity.md +15 -15
- package/skills/package-skills/{brainpy-state → brainspike}/references/nest-compatible/integration-categories.md +1 -1
- package/skills/package-skills/brainspike/references/nest-compatible/model-library.md +200 -0
- package/skills/package-skills/brainspike/references/nest-compatible/network-building.md +276 -0
- package/skills/package-skills/{brainpy-state → brainspike}/references/nest-compatible/scripts/brette_et_al_2007.py +23 -26
- package/skills/package-skills/{brainpy-state → brainspike}/references/nest-compatible/scripts/brunel_alpha.py +18 -21
- package/skills/package-skills/{brainpy-state → brainspike}/references/nest-compatible/scripts/brunel_delta.py +16 -19
- package/skills/package-skills/{brainpy-state → brainspike}/references/nest-compatible/scripts/clopath_synapse_spike_pairing.py +11 -12
- package/skills/package-skills/{brainpy-state → brainspike}/references/nest-compatible/scripts/evaluate_tsodyks2_synapse.py +10 -11
- package/skills/package-skills/{brainpy-state → brainspike}/references/nest-compatible/scripts/spatial_gaussex.py +18 -18
- package/skills/package-skills/{brainpy-state → brainspike}/references/nest-compatible/scripts/synapsecollection.py +26 -29
- package/skills/package-skills/brainspike/references/nest-compatible/synapse-and-connectivity.md +166 -0
- package/skills/package-skills/brainspike/references/nest-delay-boundaries.md +31 -0
- package/skills/package-skills/brainspike/references/nonlinear-state-sharing.md +26 -0
- package/skills/package-skills/{brainpy-state → brainspike}/references/perturbation-experiment-validity.md +2 -2
- package/skills/package-skills/brainspike/references/simulator-training.md +61 -0
- package/skills/package-skills/brainspike/references/temporal-task-training.md +36 -0
- package/skills/package-skills/brainspike/scripts/advanced_native_patterns.py +76 -0
- package/skills/package-skills/brainspike/scripts/delay_workflow.py +44 -0
- package/skills/package-skills/brainspike/scripts/delayed_cue_training.py +78 -0
- package/skills/package-skills/brainspike/scripts/lif_smoke.py +31 -0
- package/skills/package-skills/brainspike/scripts/multiscale_workflow.py +35 -0
- package/skills/package-skills/brainspike/scripts/native_ei_network.py +47 -0
- package/skills/package-skills/brainspike/scripts/native_workflows.py +77 -0
- package/skills/package-skills/brainspike/scripts/nest_boundary_workflows.py +108 -0
- package/skills/package-skills/brainspike/scripts/train_native_snn.py +65 -0
- package/skills/package-skills/brainspike/scripts/train_nest_simulator.py +69 -0
- package/skills/package-skills/brainspike/scripts/train_nest_simulator_two_weights.py +220 -0
- package/skills/package-skills/brainstate/SKILL.md +16 -21
- package/skills/package-skills/brainstate/references/brainstate/brainstate-control-flow-patterns.md +1 -138
- package/skills/package-skills/brainstate/references/brainstate/brainstate-transformed-diagnostics.md +1 -1
- package/skills/package-skills/brainstate/references/brainstate/delay-buffers.md +45 -0
- package/skills/package-skills/brainstate/references/brainstate/parameter-constraints-regularization.md +9 -7
- package/skills/package-skills/brainstate/references/brainstate/parameter-transforms-regularizers-catalog.md +4 -4
- package/skills/package-skills/brainstate/references/brainstate/randomness-and-reproducibility.md +6 -4
- package/skills/package-skills/brainstate/references/brainstate/transformation-grad-expansion.md +4 -4
- package/skills/package-skills/brainstate/references/brainstate/transformation-vmap-expansion.md +1 -1
- package/skills/package-skills/brainstate/references/braintools-optimizer-reference.md +16 -0
- package/skills/package-skills/brainstate/references/libraries/prebuilt-layer-library.md +1 -1
- package/skills/package-skills/brainstate/references/simulation-environment.md +5 -5
- package/skills/package-skills/braintrace/SKILL.md +17 -38
- package/skills/package-skills/braintrace/references/Drtrl.md +9 -26
- package/skills/package-skills/braintrace/references/algorithm selection.md +7 -12
- package/skills/package-skills/braintrace/references/batching.md +15 -35
- package/skills/package-skills/braintrace/references/compiler_internal.md +1 -1
- package/skills/package-skills/braintrace/references/custom algorithms.md +1 -2
- package/skills/package-skills/braintrace/references/customizing_primitive_transforms.md +26 -15
- package/skills/package-skills/braintrace/references/pp_pprop workflow.md +5 -139
- package/skills/package-skills/brainunit/SKILL.md +7 -2
- package/skills/package-skills/brainunit/references/array-mechanics/functional-structural-api.md +1 -1
- package/skills/package-skills/brainunit/references/math-function-library.md +2 -2
- package/skills/package-skills/brainunit/references/typing-and-runtime-validation.md +5 -2
- package/skills/package-skills/brainevent/references/scripts/102_EI_net_1996.py +0 -107
- package/skills/package-skills/brainevent/references/scripts/204_joglekar_2018_propagation.py +0 -168
- package/skills/package-skills/brainevent/references/scripts/coba_ei_teaching.py +0 -356
- package/skills/package-skills/brainpy-state/SKILL.md +0 -247
- package/skills/package-skills/brainpy-state/references/array-creation.md +0 -158
- package/skills/package-skills/brainpy-state/references/brain-dynamics-delay-protocol.md +0 -147
- package/skills/package-skills/brainpy-state/references/brainPy(legacy)/analysis.md +0 -150
- package/skills/package-skills/brainpy-state/references/brainPy(legacy)/brainpy legacy workflow.md +0 -373
- package/skills/package-skills/brainpy-state/references/brainPy(legacy)/built-in dynamic neuron model.md +0 -150
- package/skills/package-skills/brainpy-state/references/brainPy(legacy)/connecting neurons.md +0 -175
- package/skills/package-skills/brainpy-state/references/brainPy(legacy)/customize neuron and synpase.md +0 -286
- package/skills/package-skills/brainpy-state/references/brainPy(legacy)/infrastructure/Input generation.md +0 -111
- package/skills/package-skills/brainpy-state/references/brainPy(legacy)/infrastructure/More about simulation.md +0 -163
- package/skills/package-skills/brainpy-state/references/brainPy(legacy)/infrastructure/Multi-device array sharding.md +0 -113
- package/skills/package-skills/brainpy-state/references/brainPy(legacy)/infrastructure/Parallel experiment execution.md +0 -136
- package/skills/package-skills/brainpy-state/references/brainPy(legacy)/infrastructure/array creation and mechanics.md +0 -222
- package/skills/package-skills/brainpy-state/references/brainPy(legacy)/infrastructure/brainpy math environment setting.md +0 -123
- package/skills/package-skills/brainpy-state/references/brainPy(legacy)/infrastructure/delays.md +0 -107
- package/skills/package-skills/brainpy-state/references/brainPy(legacy)/infrastructure/object oriented transformations and control flows.md +0 -185
- package/skills/package-skills/brainpy-state/references/brainPy(legacy)/integrators.md +0 -181
- package/skills/package-skills/brainpy-state/references/brainPy(legacy)/route activity through connectivity.md +0 -102
- package/skills/package-skills/brainpy-state/references/brainPy(legacy)/synaptic projections.md +0 -147
- package/skills/package-skills/brainpy-state/references/brainPy(legacy)/synpase properties.md +0 -159
- package/skills/package-skills/brainpy-state/references/brainPy(legacy)/training/loss library.md +0 -127
- package/skills/package-skills/brainpy-state/references/brainPy(legacy)/training/optimizers.md +0 -167
- package/skills/package-skills/brainpy-state/references/brainPy(legacy)/training/parameter initializers.md +0 -107
- package/skills/package-skills/brainpy-state/references/brainPy(legacy)/training/prebuilt neural network layers.md +0 -186
- package/skills/package-skills/brainpy-state/references/brainPy(legacy)/training/surrogate gradients.md +0 -104
- package/skills/package-skills/brainpy-state/references/brainPy(legacy)/training/trainer library.md +0 -89
- package/skills/package-skills/brainpy-state/references/brainPy(legacy)/training/trainingworkflows.md +0 -253
- package/skills/package-skills/brainpy-state/references/braintools/brainstate-control-flow-patterns.md +0 -334
- package/skills/package-skills/brainpy-state/references/braintools/connectivity.md +0 -206
- package/skills/package-skills/brainpy-state/references/braintools/data-preprocessing.md +0 -79
- package/skills/package-skills/brainpy-state/references/braintools/input-current.md +0 -199
- package/skills/package-skills/brainpy-state/references/braintools/metric.md +0 -152
- package/skills/package-skills/brainpy-state/references/braintools/optimizer.md +0 -179
- package/skills/package-skills/brainpy-state/references/braintools/parameter-initializer.md +0 -183
- package/skills/package-skills/brainpy-state/references/braintools/surrogate.md +0 -147
- package/skills/package-skills/brainpy-state/references/component-selection.md +0 -288
- package/skills/package-skills/brainpy-state/references/nest-compatible/model-library.md +0 -200
- package/skills/package-skills/brainpy-state/references/nest-compatible/nest-workflow.md +0 -156
- package/skills/package-skills/brainpy-state/references/nest-compatible/network-building.md +0 -264
- package/skills/package-skills/brainpy-state/references/nest-compatible/synapse-and-connectivity.md +0 -153
- package/skills/package-skills/brainpy-state/references/projection-patterns.md +0 -127
- package/skills/package-skills/brainpy-state/references/scripts/103_COBA_2005.py +0 -86
- package/skills/package-skills/brainpy-state/references/scripts/106_COBA_HH_2007.py +0 -181
- package/skills/package-skills/brainpy-state/references/scripts/107_gamma_oscillation_1996.py +0 -156
- package/skills/package-skills/brainpy-state/references/scripts/109_fast_global_oscillation.py +0 -111
- package/skills/package-skills/brainpy-state/references/scripts/201_surrogate_grad_lif_fashion_mnist.py +0 -221
- package/skills/package-skills/brainpy-state/references/scripts/sound_localization.py +0 -240
- package/skills/package-skills/brainpy-state/references/scripts/training-snn.py +0 -119
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
Use this reference to inspect distributions and assumptions, compare groups, explore associations, diagnose regression, and evaluate classification or learning behavior. Plot the sampling structure that supports the scientific claim; a visual summary does not replace the statistical analysis.
|
|
6
6
|
|
|
7
|
-
Route BrainMass-owned FC/FCD, spectral, or dynamical summaries to `
|
|
7
|
+
Route BrainMass-owned FC/FCD, spectral, or dynamical summaries to `brainmass` → `references/visualization-analysis-api.md` before plotting them here.
|
|
8
8
|
|
|
9
9
|
## Choose the statistical family
|
|
10
10
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: braincell
|
|
3
|
-
description: Use for cell modeling with conductance-based or Hodgkin-Huxley ions, channels, compartments, or morphology. Use alone for cell studies or together with
|
|
3
|
+
description: Use for cell modeling with conductance-based or Hodgkin-Huxley ions, channels, compartments, or morphology. Use alone for cell studies or together with BrainSpike and/or BrainMass when cellular mechanisms participate in a multiscale model.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# BrainCell
|
|
@@ -13,7 +13,7 @@ Use BrainCell for cellular biophysics at either of its two supported spatial sca
|
|
|
13
13
|
- Use `Cell` when soma, dendrite, axon, branch geometry, spatial channel distribution, or location-specific stimulation and recording affect the result.
|
|
14
14
|
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
Use `braincell.Network` when events must reach synapses placed on detailed cells. Open `brainspike` → `SKILL.md` for point-neuron networks.
|
|
17
17
|
|
|
18
18
|
## Underlying principle of BrainCell
|
|
19
19
|
|
|
@@ -34,7 +34,8 @@ Keep network wiring, projections, and network training outside this skill. Open
|
|
|
34
34
|
| `braincell.ion` | Choose sodium, potassium, and calcium ion models and their reversal-potential or concentration dynamics. |
|
|
35
35
|
| `braincell.channel` | Choose built-in membrane-channel dynamics for calcium, HCN, leak, potassium, potassium-calcium, and sodium currents. |
|
|
36
36
|
| `braincell.synapse` | Choose built-in AMPA, GABAa, and NMDA Markov synapse models. |
|
|
37
|
-
| `braincell.mech` | Declare what a multicompartment `Cell` installs: cable properties, density ions and channels, point mechanisms
|
|
37
|
+
| `braincell.mech` | Declare what a multicompartment `Cell` installs: cable properties, density ions and channels, and point mechanisms. |
|
|
38
|
+
| `braincell.observe` | Select State, currents, or mechanism fields for named recordings. |
|
|
38
39
|
| `braincell.filter` | Build regions for `paint()` and locsets for `place()`, including composed spatial selections. |
|
|
39
40
|
| `braincell.io` | Load, validate, checkpoint, and retrieve morphologies from supported file formats and NeuroMorpho.Org. |
|
|
40
41
|
| `braincell.quad` | Define differential-equation modules and choose, inspect, or register numerical integrators. |
|
|
@@ -113,7 +114,7 @@ Open `references/braintools/input-current.md` when generating timed sections, pu
|
|
|
113
114
|
|
|
114
115
|
## Build and run a multicompartment cell
|
|
115
116
|
|
|
116
|
-
A `Cell` lowers morphology
|
|
117
|
+
A `Cell` lowers morphology and declarative mechanisms into coupled control-volume State. The voltage layout is `pop_size + (n_cv,)` before any separate trial batch axis, including a leading size-one population axis for one cell.
|
|
117
118
|
|
|
118
119
|
| API | Description |
|
|
119
120
|
|---|---|
|
|
@@ -121,19 +122,25 @@ A `Cell` lowers morphology, spatial selectors, and declarative mechanisms into c
|
|
|
121
122
|
| `braincell.Cell(morpho, cv_policy=..., solver=...)` | Use when spatial structure matters; it clones the morphology, applies a CV policy, and owns distinct declaration and initialized runtime phases. |
|
|
122
123
|
| `braincell.CVPolicy` | Use to control spatial resolution; it divides branches into isopotential control volumes, trading accuracy against State size and computation. |
|
|
123
124
|
| `cell.paint(region, *mechanisms)` | Use for cable properties and density mechanisms; it records declarations over a cable region and returns the cell for chaining. |
|
|
124
|
-
| `cell.place(locset, *mechanisms)` | Use for clamps
|
|
125
|
-
| `cell.
|
|
126
|
-
| `cell.
|
|
125
|
+
| `cell.place(locset, *mechanisms)` | Use for clamps and other point mechanisms at selected locations; it returns the cell for chaining. |
|
|
126
|
+
| `cell.loc(locset).record(name, observable)` | Use before initialization to sample a named observable at the selected locations, such as `braincell.observe.state("v")` for membrane voltage. |
|
|
127
|
+
| `cell.init_state()` | Use after declaring mechanisms and recordings to allocate runtime State explicitly. It raises if the cell is already initialized. |
|
|
128
|
+
| `cell.run(dt=..., duration=...)` | Use for a standalone cell. It initializes on first use and returns named recording blocks in `result.samples`. |
|
|
127
129
|
| `cell.reset_state()` / `cell.reset()` | Use `reset_state()` to reseed State while remaining initialized; use `reset()` to discard runtime State and return to the declaration phase before changing `paint()` or `place()` rules. |
|
|
128
130
|
|
|
129
131
|
```python
|
|
130
132
|
import braincell
|
|
131
133
|
import braincell.mech as mech
|
|
132
134
|
import brainunit as u
|
|
133
|
-
from braincell.filter import AllRegion, RootLocation,
|
|
135
|
+
from braincell.filter import AllRegion, RootLocation, branch_in
|
|
134
136
|
|
|
135
137
|
|
|
136
|
-
|
|
138
|
+
soma = braincell.Branch.from_points(
|
|
139
|
+
points=[[0.0, 0.0, 0.0], [20.0, 0.0, 0.0]] * u.um,
|
|
140
|
+
radii=[5.0, 5.0] * u.um,
|
|
141
|
+
type="soma",
|
|
142
|
+
)
|
|
143
|
+
morphology = braincell.Morphology.from_root(soma, name="soma")
|
|
137
144
|
cell = braincell.Cell(
|
|
138
145
|
morphology,
|
|
139
146
|
cv_policy=braincell.CVPerBranch(cv_per_branch=2),
|
|
@@ -154,25 +161,26 @@ cell.paint(
|
|
|
154
161
|
mech.Channel("Na_HH1952", g_max=120.0 * u.mS / u.cm**2),
|
|
155
162
|
mech.Channel("K_HH1952", g_max=36.0 * u.mS / u.cm**2),
|
|
156
163
|
)
|
|
164
|
+
soma_midpoint = RootLocation(x=0.5)
|
|
157
165
|
cell.place(
|
|
158
|
-
|
|
166
|
+
soma_midpoint,
|
|
159
167
|
mech.CurrentClamp(
|
|
160
168
|
delay=20.0 * u.ms,
|
|
161
169
|
durations=60.0 * u.ms,
|
|
162
170
|
amplitudes=0.2 * u.nA,
|
|
163
171
|
),
|
|
164
172
|
)
|
|
165
|
-
cell.
|
|
173
|
+
cell.loc(soma_midpoint).record("soma_v", braincell.observe.state("v"))
|
|
166
174
|
|
|
167
175
|
cell.init_state()
|
|
168
176
|
result = cell.run(dt=0.1 * u.ms, duration=100.0 * u.ms)
|
|
169
177
|
|
|
170
|
-
assert "
|
|
178
|
+
assert result.samples["soma_v"].values.shape == (1000, 1)
|
|
171
179
|
```
|
|
172
180
|
|
|
173
|
-
Use `paint()`
|
|
181
|
+
Use regions for `paint()` and locsets for `place()`. Declare mechanisms and recordings before `init_state()`. Call `reset()` before changing a declaration on an initialized cell.
|
|
174
182
|
|
|
175
|
-
Open `references/multicompartment/multicompartment-cell-workflow.md` for the complete advanced morphology-to-simulation path. Let that workflow select the exclusive morphology, filter, CV-policy,
|
|
183
|
+
Open `references/multicompartment/multicompartment-cell-workflow.md` for the complete advanced morphology-to-simulation path. Let that workflow select the exclusive morphology, filter, CV-policy, recording, or topology reference.
|
|
176
184
|
|
|
177
185
|
## Reference routing
|
|
178
186
|
|
|
@@ -190,4 +198,5 @@ Open only the smallest reference that owns the non-canonical decision.
|
|
|
190
198
|
| `references/ion-library.md` | Choosing fixed, Nernst-initialized, or dynamic ions and their concentration behavior. |
|
|
191
199
|
| `references/mixions-for-adaptation.md` | Adding calcium-dependent adaptation, AHP/KCa currents, rebound, dynamic calcium, or multi-ion channel dependencies. |
|
|
192
200
|
| `references/multicompartment/multicompartment-cell-workflow.md` | Extending the canonical `Morphology -> Cell -> paint/place -> run` path and selecting the exclusive multicompartment references. |
|
|
201
|
+
| `references/multicompartment/network-workflow.md` | Connecting event sources to spatially placed synapses on detailed cells, managing the network lifecycle, or reading population results. |
|
|
193
202
|
| `references/solver-library-with-effects.md` | Comparing registered integrators, stability, accuracy, and solver-dependent trace effects. |
|
|
@@ -116,7 +116,7 @@ Do not reconstruct the same sections with comparisons against `t` inside
|
|
|
116
116
|
`step`. For a mapped parameter sweep that shares this protocol, keep the
|
|
117
117
|
per-step current sample unmapped (`in_axes=None`) while mapping the independent
|
|
118
118
|
condition parameters and dynamical State. Open
|
|
119
|
-
`
|
|
119
|
+
`brainstate` → `references/brainstate/transformation-vmap-expansion.md` for
|
|
120
120
|
the mapped-State contract.
|
|
121
121
|
|
|
122
122
|
## Basic currents
|
|
@@ -1,36 +1,40 @@
|
|
|
1
|
-
#
|
|
1
|
+
# BrainTools losses and analysis
|
|
2
2
|
|
|
3
3
|
Use this reference to select supervised losses and neuroscience metrics for
|
|
4
4
|
classification, regression, spike trains, local field potentials, correlation,
|
|
5
5
|
connectivity, and pairwise comparison. Verify input orientation, units, and
|
|
6
6
|
reduction before treating any returned array as a scalar objective.
|
|
7
7
|
|
|
8
|
+
Use `braintools.metric` for training losses and vector comparisons. Use
|
|
9
|
+
`braintools.analysis` for neuroscience analysis. The analysis examples require
|
|
10
|
+
BrainTools 0.4.0 or newer.
|
|
11
|
+
|
|
8
12
|
## Choose a metric family
|
|
9
13
|
|
|
10
14
|
| Task | Use | Important constraint |
|
|
11
15
|
|---|---|---|
|
|
12
16
|
| Independent binary or multilabel classification | Sigmoid binary cross entropy or focal loss | Logits and labels must have broadcast-compatible class structure. |
|
|
13
17
|
| Mutually exclusive classes | Softmax cross entropy | Choose one-hot/probability labels or the integer-label variant explicitly. |
|
|
14
|
-
| Continuous fitting | Squared, absolute, Huber, log-cosh, or cosine losses |
|
|
18
|
+
| Continuous fitting | Squared, absolute, Huber, log-cosh, or cosine losses | Check the function-specific reduction and reduce explicitly when a scalar is required. |
|
|
15
19
|
| Spike timing | Victor-Purpura or van Rossum distance | Inputs are spike-time trains, not dense spike matrices. |
|
|
16
20
|
| Population spiking | Firing-rate and synchrony metrics | Dense spike matrices are time-major unless the API says otherwise. |
|
|
17
|
-
| LFP spectrum or coupling | PSD, coherence, PAC, CSD, entropy, or phase coherence |
|
|
21
|
+
| LFP spectrum or coupling | PSD, coherence, PAC, CSD, entropy, or phase coherence | For spectral routines with `dt`, pass the sample interval. CSD takes electrode spacing. |
|
|
18
22
|
| Functional connectivity | Correlation and connectivity functions | Time series use `(num_time, num_signals)`. |
|
|
19
23
|
|
|
20
|
-
## Classification losses
|
|
24
|
+
## Classification losses (`braintools.metric`)
|
|
21
25
|
|
|
22
26
|
| API | Description |
|
|
23
27
|
|---|---|
|
|
24
28
|
| `sigmoid_binary_cross_entropy(logits, labels)` | Use for independent binary classes; returns element-wise sigmoid cross entropy. |
|
|
25
29
|
| `softmax_cross_entropy(logits, labels)` | Use for mutually exclusive classes represented by one-hot or probability labels. |
|
|
26
|
-
| `softmax_cross_entropy_with_integer_labels(logits, labels)` | Use the more direct integer-index form for mutually exclusive classes.
|
|
30
|
+
| `softmax_cross_entropy_with_integer_labels(logits, labels)` | Use the more direct integer-index form for mutually exclusive classes. |
|
|
27
31
|
| `hinge_loss(...)` | Use for binary margin classification. |
|
|
28
32
|
| `perceptron_loss(...)` | Use for the binary perceptron objective. |
|
|
29
33
|
| `multiclass_hinge_loss(...)` | Use for a multiclass margin objective. |
|
|
30
34
|
| `multiclass_perceptron_loss(...)` | Use for a multiclass perceptron objective. |
|
|
31
35
|
| `poly_loss_cross_entropy(...)` | Use when the specified method requires PolyLoss cross entropy. |
|
|
32
|
-
| `kl_divergence(
|
|
33
|
-
| `kl_divergence_with_log_targets(...)` | Use when
|
|
36
|
+
| `kl_divergence(log_predictions, targets)` | Compare target probabilities with predicted log probabilities. |
|
|
37
|
+
| `kl_divergence_with_log_targets(...)` | Use when both predicted and target probabilities are supplied in log space. |
|
|
34
38
|
| `convex_kl_divergence(...)` | Use when the convex KL variant is required. |
|
|
35
39
|
| `ctc_loss(...)` | Use for sequence alignment without frame-level labels. |
|
|
36
40
|
| `ctc_loss_with_forward_probs(...)` | Use when the CTC forward probabilities are also needed. |
|
|
@@ -54,19 +58,18 @@ loss = jnp.mean(per_example)
|
|
|
54
58
|
assert loss.ndim == 0
|
|
55
59
|
```
|
|
56
60
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
`
|
|
60
|
-
labels.
|
|
61
|
+
Validate integer labels against `0 <= labels < logits.shape[-1]` before
|
|
62
|
+
computing the loss. Invalid indices can select a different class or return
|
|
63
|
+
`NaN` without raising.
|
|
61
64
|
|
|
62
|
-
## Regression and pairwise metrics
|
|
65
|
+
## Regression and pairwise metrics (`braintools.metric`)
|
|
63
66
|
|
|
64
67
|
| API | Description |
|
|
65
68
|
|---|---|
|
|
66
|
-
| `squared_error(predictions, targets=None, axis=None, reduction='none')` | Use for element-wise squared error; choose `mean`
|
|
69
|
+
| `squared_error(predictions, targets=None, axis=None, reduction='none')` | Use for element-wise squared error. Targets must match prediction shape; choose `reduction="mean"` for a scalar MSE with `axis=None`. |
|
|
67
70
|
| `absolute_error(...)` | Use for element-wise absolute error. |
|
|
68
|
-
| `l1_loss(
|
|
69
|
-
| `l2_loss(...)` | Use for squared
|
|
71
|
+
| `l1_loss(logits, targets, reduction="mean")` | Average absolute error over non-batch axes first; use `reduction="none"` to keep one value per sample. |
|
|
72
|
+
| `l2_loss(...)` | Use for half the squared error. |
|
|
70
73
|
| `l2_norm(...)` | Return the L2 norm of prediction error. |
|
|
71
74
|
| `safe_norm(...)` | Use when a differentiable lower bound must prevent an unstable zero norm. |
|
|
72
75
|
| `huber_loss(predictions, targets=None, delta=1.0, axis=None, reduction='none')` | Use for quadratic small residuals and linear large residuals; tune `delta` in target units. |
|
|
@@ -80,38 +83,42 @@ Do not conflate element-wise loss with final optimization reduction. Preserve
|
|
|
80
83
|
batch and time axes until the scientific loss definition determines how to
|
|
81
84
|
reduce them.
|
|
82
85
|
|
|
83
|
-
## Correlation and functional connectivity
|
|
86
|
+
## Correlation and functional connectivity (`braintools.analysis`)
|
|
84
87
|
|
|
85
88
|
| API | Description |
|
|
86
89
|
|---|---|
|
|
87
|
-
| `cross_correlation(spikes, bin, dt)` | Calculate a cross-correlation synchrony index from a time-major spike matrix. |
|
|
88
|
-
| `voltage_fluctuation(
|
|
89
|
-
| `matrix_correlation(
|
|
90
|
-
| `weighted_correlation(x, y,
|
|
91
|
-
| `functional_connectivity(activities)` | Return the pairwise Pearson correlation matrix for `(num_time, num_signals)` data; NaNs are replaced with zero. |
|
|
92
|
-
| `functional_connectivity_dynamics(activities, window_size, step_size)` |
|
|
90
|
+
| `spike.cross_correlation(spikes, bin, dt=None, ...)` | Calculate a cross-correlation synchrony index from a time-major spike matrix. |
|
|
91
|
+
| `population.voltage_fluctuation(potentials, ...)` | Estimate synchrony from population voltage variance. |
|
|
92
|
+
| `stats.matrix_correlation(x, y)` | Correlate the strict upper triangles of two matching connectivity matrices. |
|
|
93
|
+
| `stats.weighted_correlation(x, y, w)` | Compute weighted Pearson correlation for two one-dimensional series. |
|
|
94
|
+
| `population.functional_connectivity(activities)` | Return the pairwise Pearson correlation matrix for `(num_time, num_signals)` data; NaNs are replaced with zero. |
|
|
95
|
+
| `population.functional_connectivity_dynamics(activities, window_size, step_size)` | Correlate the strict upper triangles of windowed FC matrices. Specify window size and step in samples. |
|
|
93
96
|
|
|
94
97
|
## Spike-train metrics
|
|
95
98
|
|
|
99
|
+
Pass physical time quantities on BrainTools 0.4. Bare `dt` values are in
|
|
100
|
+
seconds for `firing_rate`, `phase_locking_value`, and spectral functions.
|
|
101
|
+
Most other spike-matrix routines use milliseconds.
|
|
102
|
+
|
|
96
103
|
| API | Description |
|
|
97
104
|
|---|---|
|
|
98
|
-
| `
|
|
99
|
-
| `
|
|
100
|
-
| `
|
|
101
|
-
| `
|
|
102
|
-
| `
|
|
103
|
-
| `
|
|
104
|
-
| `
|
|
105
|
-
| `
|
|
106
|
-
| `correlation_index(spikes, window_size, dt=None)` | Compute a windowed spike-train correlation index. |
|
|
105
|
+
| `spike.firing_rate(spikes, width, dt=None)` | Return a time series of population rate in Hz. Pass physical time quantities for `width` and `dt` to make units explicit. |
|
|
106
|
+
| `spike.victor_purpura_distance(spike_times_1, spike_times_2, cost_factor=1.0)` | Measure edit cost from insertions, deletions, and temporal shifts. |
|
|
107
|
+
| `spike.van_rossum_distance(spike_times_1, spike_times_2, tau=1.0, t_max=None)` | Compare exponentially filtered spike trains. |
|
|
108
|
+
| `spike.spike_train_synchrony(spike_matrix, window_size, dt=None)` | Average pairwise spike coincidences within a time window. Silent-neuron pairs are omitted; check activity before interpreting the score. |
|
|
109
|
+
| `spike.burst_synchrony_index(spike_matrix, burst_threshold=3, max_isi=100.0, dt=None)` | Measure co-occurring burst events. |
|
|
110
|
+
| `spike.phase_locking_value(spike_matrix, reference_freq, dt=None)` | Measure spike phase locking at a specified reference frequency; this score does not give a signed phase lag. |
|
|
111
|
+
| `spike.spike_time_tiling_coefficient(spike_matrix, dt=None, tau=5.0)` | Compute STTC within a temporal tolerance. |
|
|
112
|
+
| `spike.correlation_index(spike_matrix, window_size, dt=None)` | Compute a windowed spike-train correlation index. |
|
|
107
113
|
|
|
108
114
|
```python
|
|
109
115
|
import brainunit as u
|
|
110
|
-
|
|
116
|
+
import braintools
|
|
117
|
+
import jax.numpy as jnp
|
|
111
118
|
|
|
112
|
-
|
|
113
|
-
rate = firing_rate(spikes, width=10 * u.ms, dt=1 * u.ms)
|
|
114
|
-
synchrony = spike_train_synchrony(
|
|
119
|
+
spikes = jnp.zeros((200, 5)).at[50:53, :].set(1.0)
|
|
120
|
+
rate = braintools.analysis.spike.firing_rate(spikes, width=10 * u.ms, dt=1 * u.ms)
|
|
121
|
+
synchrony = braintools.analysis.spike.spike_train_synchrony(
|
|
115
122
|
spikes,
|
|
116
123
|
window_size=5 * u.ms,
|
|
117
124
|
dt=1 * u.ms,
|
|
@@ -120,26 +127,40 @@ synchrony = spike_train_synchrony(
|
|
|
120
127
|
|
|
121
128
|
Keep dense spike matrices and lists of spike times distinct. Distance metrics
|
|
122
129
|
consume event times; population rate and synchrony metrics consume matrices.
|
|
130
|
+
Use [`braintools.spike.SpikeTrains.from_dense`](https://brainx.chaobrain.com/braintools/apis/generated/braintools.spike.SpikeTrains.html#braintools.spike.SpikeTrains.from_dense)
|
|
131
|
+
to convert a regularly sampled matrix to spike trains; use
|
|
132
|
+
[`braintools.visualize.spike_raster`](https://brainx.chaobrain.com/braintools/apis/generated/braintools.visualize.spike_raster.html)
|
|
133
|
+
to draw a raster.
|
|
123
134
|
|
|
124
135
|
## Local field potential analysis
|
|
125
136
|
|
|
126
137
|
| API | Description |
|
|
127
138
|
|---|---|
|
|
128
|
-
| `unitary_LFP(times, spikes,
|
|
129
|
-
| `power_spectral_density(lfp, dt, nperseg=None, noverlap=None, freq_range=None)` | Return one-sided Welch frequencies and PSD. |
|
|
130
|
-
| `
|
|
131
|
-
| `
|
|
132
|
-
| `
|
|
133
|
-
| `
|
|
134
|
-
| `
|
|
135
|
-
| `
|
|
139
|
+
| `field.unitary_LFP(times, spikes, spike_type, ...)` | Construct unitary LFP contributions from spikes. Supply times in milliseconds and choose `'exc'` or `'inh'`. |
|
|
140
|
+
| `spectral.power_spectral_density(lfp, dt, nperseg=None, noverlap=None, freq_range=None)` | Return one-sided Welch frequencies in Hz and PSD for `(time,)` or `(time, channels)` input. |
|
|
141
|
+
| `spectral.spectrogram(x, dt, nperseg, noverlap=None, window='hann', detrend='constant')` | Use when segment spectra or explicit window/detrending controls are required; returns frequencies, segment centers and PSD shaped `(frequency, segment, ...)`. |
|
|
142
|
+
| `spectral.coherence_analysis(lfp1, lfp2, dt, ...)` | Return frequency-resolved magnitude-squared coherence. |
|
|
143
|
+
| `spectral.phase_amplitude_coupling(lfp, dt, phase_freq_range, amplitude_freq_range, ...)` | Return Tort modulation index plus phase-bin details. |
|
|
144
|
+
| `spectral.theta_gamma_coupling(lfp, dt)` | Return theta-gamma coupling using standard bands. |
|
|
145
|
+
| `field.current_source_density(lfp_laminar, electrode_spacing, conductivity=1.0, axis=-1)` | Estimate laminar CSD using electrode spacing. Set `axis` explicitly when electrodes are not on the last axis. |
|
|
146
|
+
| `spectral.spectral_entropy(lfp, dt, ...)` | Return normalized spectral entropy. |
|
|
147
|
+
| `spectral.lfp_phase_coherence(lfp_signals, dt, freq_band=(8, 12))` | Compute pairwise phase coherence across channels. |
|
|
148
|
+
|
|
149
|
+
Use `power_spectral_density` when its estimator defaults match the protocol.
|
|
150
|
+
For a fixed Welch estimator requiring explicit window and detrending controls,
|
|
151
|
+
use [`spectral.spectrogram`](https://brainx.chaobrain.com/braintools/apis/generated/braintools.analysis.spectral.spectrogram.html)
|
|
152
|
+
and take `u.math.mean(segment_psd, axis=1)` over segments. Set `noverlap`
|
|
153
|
+
explicitly: its default is `nperseg // 8`, not 50%. `window='hann'` selects
|
|
154
|
+
a periodic Hann window; `detrend='constant'` removes each segment's mean.
|
|
155
|
+
For a Quantity signal with unit `U`, the segment PSD and its mean retain
|
|
156
|
+
`U**2 / Hz`. Preserve the frozen estimator when comparing implementations.
|
|
136
157
|
|
|
137
158
|
`power_spectral_density(..., freq_range=...)` uses boolean-mask indexing and
|
|
138
159
|
therefore has a data-dependent output length; that path is not JIT-compatible.
|
|
139
160
|
Compute the full spectrum inside JIT and filter outside when compilation is
|
|
140
161
|
required.
|
|
141
162
|
|
|
142
|
-
## Structured, ranking, and smoothing losses
|
|
163
|
+
## Structured, ranking, and smoothing losses (`braintools.metric`)
|
|
143
164
|
|
|
144
165
|
| API | Description |
|
|
145
166
|
|---|---|
|
|
@@ -147,6 +168,11 @@ required.
|
|
|
147
168
|
| `ranking_softmax_loss(scores, labels, ...)` | Use for list-wise learning-to-rank objectives. |
|
|
148
169
|
| `smooth_labels(labels, alpha=...)` | Apply label smoothing to one-hot targets. |
|
|
149
170
|
|
|
150
|
-
## Official
|
|
171
|
+
## Official sources
|
|
172
|
+
|
|
173
|
+
Open the [analysis API](https://brainx.chaobrain.com/braintools/apis/analysis.html)
|
|
174
|
+
for PSTH, interspike-interval statistics, or band power. Open the
|
|
175
|
+
[fitting API](https://brainx.chaobrain.com/braintools/apis/fit.html) when firing
|
|
176
|
+
rate, PSD, or FC is a fitting objective.
|
|
151
177
|
|
|
152
|
-
-
|
|
178
|
+
- [Training losses and deprecated alias routing](https://brainx.chaobrain.com/braintools/apis/metric.html)
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Use this reference when adding a calcium-activated potassium current, calcium-dependent afterhyperpolarization, spike-frequency adaptation, or a thalamic/rebound variant that needs dynamic calcium plus a K/Ca mixed current.
|
|
4
4
|
|
|
5
|
-
In single-compartment models, use the class pattern below directly. In multicompartment `Cell` work, use this reference for ion/channel composition choices, but keep morphology, targeting, `paint`, `place`, CV policy, clamps, and
|
|
5
|
+
In single-compartment models, use the class pattern below directly. In multicompartment `Cell` work, use this reference for ion/channel composition choices, but keep morphology, targeting, `paint`, `place`, CV policy, clamps, and recordings in `references/multicompartment/multicompartment-cell-workflow.md`.
|
|
6
6
|
|
|
7
7
|
## Rule
|
|
8
8
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# BrainCell manual morphology construction
|
|
2
2
|
|
|
3
|
-
Use this reference after opening `references/multicompartment/multicompartment-cell-workflow.md` when no existing reconstruction should be loaded and the task requires explicit branch geometry, anatomical types, or parent-child topology. Return to the workflow before choosing CVs, mechanisms,
|
|
3
|
+
Use this reference after opening `references/multicompartment/multicompartment-cell-workflow.md` when no existing reconstruction should be loaded and the task requires explicit branch geometry, anatomical types, or parent-child topology. Return to the workflow before choosing CVs, mechanisms, recordings, or a solver.
|
|
4
4
|
|
|
5
5
|
## Mental model
|
|
6
6
|
|
|
@@ -114,7 +114,7 @@ Treat CV policy as a numerical assumption, not a visualization preference.
|
|
|
114
114
|
1. Choose a policy from the spatial question and inspect `cell.n_cv` and `cell.cvs`.
|
|
115
115
|
2. Run the scientific protocol with fixed morphology, mechanisms, stimulus, solver, and `dt`.
|
|
116
116
|
3. Refine only the CV policy: increase `cv_per_branch`, reduce `max_cv_len`, or reduce `d_lambda`.
|
|
117
|
-
4. Compare the relevant traces, spike timing, peaks, attenuation, or other spatial observable at the same
|
|
117
|
+
4. Compare the relevant traces, spike timing, peaks, attenuation, or other spatial observable at the same recording locations.
|
|
118
118
|
5. Accept the coarser policy only when the observable remains within the task's stated tolerance.
|
|
119
119
|
|
|
120
120
|
Do not change `dt`, solver, and CV policy in the same convergence comparison. A stable CV count does not establish time-step or solver convergence.
|
package/skills/package-skills/braincell/references/multicompartment/filter-function-library.md
CHANGED
|
@@ -70,7 +70,7 @@ Overlapping slices are normalized in the materialized mask. Inspect `morphology.
|
|
|
70
70
|
|
|
71
71
|
## Locset selectors
|
|
72
72
|
|
|
73
|
-
Use locsets for clamps,
|
|
73
|
+
Use locsets for clamps, synapses, and spatial recording views.
|
|
74
74
|
|
|
75
75
|
| API | Use when | Important behavior and result |
|
|
76
76
|
|---|---|---|
|
|
@@ -125,11 +125,11 @@ cell.paint(
|
|
|
125
125
|
E=-65.0 * u.mV,
|
|
126
126
|
),
|
|
127
127
|
)
|
|
128
|
-
cell.
|
|
128
|
+
cell.loc(terminal_sites).record("terminal_v", braincell.observe.state("v"))
|
|
129
129
|
cell.init_state()
|
|
130
130
|
```
|
|
131
131
|
|
|
132
|
-
Use a region
|
|
132
|
+
Use a region for `paint()` and a locset for `place()` or `cell.loc()`. A selector that resolves correctly against `Morphology` can still map unexpectedly after discretization. Open `references/multicompartment/topology-building-and-visualization.md` to inspect CV ownership and runtime placement.
|
|
133
133
|
|
|
134
134
|
## Exported but unavailable selectors
|
|
135
135
|
|
|
@@ -79,7 +79,7 @@ from braincell.io import NeuroMlReader
|
|
|
79
79
|
morphology = NeuroMlReader().read("neuron.cell.nml")
|
|
80
80
|
```
|
|
81
81
|
|
|
82
|
-
Declare ions, channels, clamps,
|
|
82
|
+
Declare ions, channels, clamps, recordings, and network structure separately. BrainCell does not import those NeuroML2 definitions automatically.
|
|
83
83
|
|
|
84
84
|
### NeuroMorpho.Org
|
|
85
85
|
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
## Purpose and boundary
|
|
4
4
|
|
|
5
|
-
Use this reference when a BrainCell simulation depends on geometry, axial current, regional biophysics, or location-specific stimulation and recording.
|
|
5
|
+
Use this reference when a BrainCell simulation depends on geometry, axial current, regional biophysics, or location-specific stimulation and recording. Use `SingleCompartment` for isopotential cells. Keep independent cells on the population axis and resolve compartments through the morphology and CV policy.
|
|
6
6
|
|
|
7
7
|
## Underlying principle of BrainCell multicompartment cells
|
|
8
8
|
|
|
9
9
|
`braincell.filter` expressions represent spatial targets. Regions select cable for `paint()`; locsets select points for `place()`.
|
|
10
10
|
|
|
11
|
-
`braincell.mech` declarations represent cellular biophysics and point processes. Paint cable properties, ions, and channels over regions
|
|
11
|
+
`braincell.mech` declarations represent cellular biophysics and point processes. Paint cable properties, ions, and channels over regions. Place clamps and synapses at locsets. Declare recordings on the cell or a spatial view.
|
|
12
12
|
|
|
13
13
|
## Workflow map
|
|
14
14
|
|
|
@@ -133,7 +133,7 @@ for cv in cell.cvs[:3]:
|
|
|
133
133
|
|
|
134
134
|
Validate every policy by refining it and comparing the target observable. Resolve cable properties before `DLambda`; split capacitance or axial-resistivity changes at branch boundaries.
|
|
135
135
|
|
|
136
|
-
Open `references/multicompartment/cv-policy-reference.md` for by-type or composite policies,
|
|
136
|
+
Open `references/multicompartment/cv-policy-reference.md` for by-type or composite policies, recording-site mapping, and convergence.
|
|
137
137
|
|
|
138
138
|
## Declare distributed biophysics
|
|
139
139
|
|
|
@@ -174,9 +174,9 @@ BrainCell area-scales capacitance and conductance densities during lowering; kee
|
|
|
174
174
|
|
|
175
175
|
Open `references/multicompartment/filter-function-library.md` for composed or geometry-based regions, `references/ion-library.md` or `references/channel-library.md` for non-canonical mechanisms, and `references/mixions-for-adaptation.md` for calcium-dependent or multi-ion coupling.
|
|
176
176
|
|
|
177
|
-
## Place stimuli and
|
|
177
|
+
## Place stimuli and declare recordings
|
|
178
178
|
|
|
179
|
-
|
|
179
|
+
Place current clamps at locsets. Register observables on a selected view before initialization.
|
|
180
180
|
|
|
181
181
|
| API | Description |
|
|
182
182
|
|---|---|
|
|
@@ -184,9 +184,7 @@ Point declarations define where current enters and what the simulation exposes;
|
|
|
184
184
|
| `braincell.filter.at(branch, position)` | Use for one named branch position; the branch argument identifies a branch, not an anatomical type. |
|
|
185
185
|
| `braincell.filter.Terminals()` | Use when a point declaration must resolve at every terminal tip. |
|
|
186
186
|
| `braincell.mech.CurrentClamp(...)` | Use for piecewise current injection; declare delay, durations, and amplitudes with time and current units. Currents from clamps at the same runtime point add. |
|
|
187
|
-
| `
|
|
188
|
-
| `braincell.mech.MechanismProbe(mechanism=..., field=...)` | Use to record a real runtime State field on a named channel or ion; do not request a static parameter or derived property. |
|
|
189
|
-
| `braincell.mech.CurrentProbe(...)` | Use to record one mechanism current or the total current owned by a named ion. |
|
|
187
|
+
| `cell.loc(locset).record(name, observable)` | Use to record over the CVs selected by a locset. Select membrane voltage with `braincell.observe.state("v")`. |
|
|
190
188
|
| `cell.place(locset, *point_mechanisms)` | Use only in DECLARING; it records point declarations at every resolved location and returns the cell for chaining. |
|
|
191
189
|
|
|
192
190
|
```python
|
|
@@ -202,12 +200,10 @@ cell.place(
|
|
|
202
200
|
amplitudes=0.2 * u.nA,
|
|
203
201
|
),
|
|
204
202
|
)
|
|
205
|
-
cell.
|
|
203
|
+
cell.loc(soma_midpoint).record("soma_v", braincell.observe.state("v"))
|
|
206
204
|
```
|
|
207
205
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
Open `references/multicompartment/filter-function-library.md` for composed locsets and `references/multicompartment/probe-reference.md` for probe selection or missing and ambiguous keys.
|
|
206
|
+
Open `references/multicompartment/filter-function-library.md` for composed locsets and `references/multicompartment/probe-reference.md` for observable selection, sample schedules, result schemas, or legacy probe migration.
|
|
211
207
|
|
|
212
208
|
## Initialize and inspect the lowered runtime
|
|
213
209
|
|
|
@@ -215,35 +211,32 @@ Open `references/multicompartment/filter-function-library.md` for composed locse
|
|
|
215
211
|
|
|
216
212
|
| API | Description |
|
|
217
213
|
|---|---|
|
|
218
|
-
| `cell.init_state(batch_size=None)` | Use after
|
|
214
|
+
| `cell.init_state(batch_size=None)` | Use after declaring mechanisms and recordings. It lowers declarations, allocates evolving model State, and raises if the cell is already initialized. |
|
|
219
215
|
| `cell.node_tree` | Use after initialization to inspect the point-and-edge execution topology derived from the CV tree. |
|
|
220
216
|
| `cell.layouts` | Use after initialization to inspect each lowered mechanism layout, including its kind, target, active count, source CVs, and runtime point indices. |
|
|
221
|
-
| `cell.sample_probe(name)` | Use after initialization to read the current value of one probe by its resolved name. |
|
|
222
|
-
| `cell.sample_probes()` | Use after initialization to read all current probe values and discover the exact probe-key surface. |
|
|
223
217
|
|
|
224
218
|
```python
|
|
225
219
|
cell.init_state()
|
|
226
220
|
|
|
227
|
-
|
|
228
|
-
print("probe keys:", sorted(samples))
|
|
221
|
+
assert cell.V.value.shape == cell.pop_size + (cell.n_cv,)
|
|
229
222
|
print("runtime nodes:", len(cell.node_tree.nodes))
|
|
230
223
|
for layout in cell.layouts:
|
|
231
224
|
print(layout.kind, layout.target, layout.n_active)
|
|
232
225
|
```
|
|
233
226
|
|
|
234
|
-
Inspect `cell.cvs` before initialization
|
|
227
|
+
Inspect `cell.cvs` before initialization and runtime voltage and mechanism layouts afterward. In BrainCell 0.2.0 the unbatched voltage has population axes followed by the CV axis, even for a singleton population.
|
|
235
228
|
|
|
236
229
|
Open `references/multicompartment/topology-building-and-visualization.md` to visualize CV, branch, node, or placement topology; open `references/multicompartment/probe-reference.md` for sampling failures.
|
|
237
230
|
|
|
238
231
|
## Run and interpret the result
|
|
239
232
|
|
|
240
|
-
`run()` advances the
|
|
233
|
+
`run()` advances from the current cell time. Each recording block carries the times for its own sample schedule.
|
|
241
234
|
|
|
242
235
|
| API | Description |
|
|
243
236
|
|---|---|
|
|
244
|
-
| `cell.run(dt=..., duration=...)` | Use with positive time quantities
|
|
237
|
+
| `cell.run(dt=..., duration=...)` | Use with positive time quantities and a duration divisible by `dt`. It initializes a standalone cell on first use. |
|
|
245
238
|
| `braincell.RunResult.time` | Use as the unit-aware `(n_steps,)` time axis spanning `[start_t, start_t + duration)`. |
|
|
246
|
-
| `braincell.RunResult.
|
|
239
|
+
| `braincell.RunResult.samples` | Look up a named recording block and use its `time`, `values`, and `schema` together. |
|
|
247
240
|
| `cell.current_time` | Use after a run to inspect the endpoint from which the next `run()` call will continue. |
|
|
248
241
|
| `Quantity.to_decimal(unit)` | Use only at plotting, serialization, or external-library boundaries to obtain values in an explicit compatible unit. |
|
|
249
242
|
|
|
@@ -253,12 +246,10 @@ result = cell.run(
|
|
|
253
246
|
duration=100.0 * u.ms,
|
|
254
247
|
)
|
|
255
248
|
|
|
256
|
-
|
|
257
|
-
voltage
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
times_ms = result.time.to_decimal(u.ms)
|
|
261
|
-
voltage_mV = voltage.to_decimal(u.mV)
|
|
249
|
+
voltage = result.samples["soma_v"]
|
|
250
|
+
assert voltage.values.shape == (voltage.time.size, 1)
|
|
251
|
+
times_ms = voltage.time.to_decimal(u.ms)
|
|
252
|
+
voltage_mV = voltage.values[:, 0].to_decimal(u.mV)
|
|
262
253
|
```
|
|
263
254
|
|
|
264
255
|
Keep quantities unit-aware and convert only at external boundaries. Validate `dt` by comparing the target observable at `dt / 2`.
|
|
@@ -267,7 +258,7 @@ Open `references/solver-library-with-effects.md` for cable-solver choice or meth
|
|
|
267
258
|
|
|
268
259
|
## Canonical end-to-end workflow
|
|
269
260
|
|
|
270
|
-
This current-clamp pattern uses an explicit passive baseline, `DLambda` with staggered integration, somatic active channels, runtime target checks, and one voltage
|
|
261
|
+
This current-clamp pattern uses an explicit passive baseline, `DLambda` with staggered integration, somatic active channels, runtime target checks, and one voltage recording. Supply a valid SWC file containing a soma at `neuron.swc`.
|
|
271
262
|
|
|
272
263
|
```python
|
|
273
264
|
import braincell
|
|
@@ -331,7 +322,7 @@ cell.place(
|
|
|
331
322
|
amplitudes=0.2 * u.nA,
|
|
332
323
|
),
|
|
333
324
|
)
|
|
334
|
-
cell.
|
|
325
|
+
cell.loc(soma_midpoint).record("soma_v", braincell.observe.state("v"))
|
|
335
326
|
|
|
336
327
|
# 5. Inspect the final spatial layout before allocating runtime State.
|
|
337
328
|
print("n_cv:", cell.n_cv)
|
|
@@ -340,25 +331,21 @@ for cv in cell.cvs[:3]:
|
|
|
340
331
|
|
|
341
332
|
# 6. Lower declarations, verify resolved targets, and run.
|
|
342
333
|
cell.init_state()
|
|
343
|
-
|
|
344
|
-
assert len(initial_samples) == 1
|
|
345
|
-
voltage_key = next(iter(initial_samples))
|
|
346
|
-
assert voltage_key.endswith("_v")
|
|
334
|
+
assert cell.V.value.shape == (1, cell.n_cv)
|
|
347
335
|
|
|
348
336
|
for layout in cell.layouts:
|
|
349
337
|
print(layout.kind, layout.target, layout.n_active)
|
|
350
338
|
|
|
351
339
|
result = cell.run(dt=0.05 * u.ms, duration=100.0 * u.ms)
|
|
352
|
-
voltage = result.
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
voltage_mV = voltage.to_decimal(u.mV)
|
|
340
|
+
voltage = result.samples["soma_v"]
|
|
341
|
+
assert voltage.values.shape == (voltage.time.size, 1)
|
|
342
|
+
times_ms = voltage.time.to_decimal(u.ms)
|
|
343
|
+
voltage_mV = voltage.values[:, 0].to_decimal(u.mV)
|
|
357
344
|
```
|
|
358
345
|
|
|
359
346
|
Replace the example morphology, mechanisms, stimulus, readout, `dt`, and CV policy, then validate the target observable under numerical refinement.
|
|
360
347
|
|
|
361
|
-
Open `references/scripts/cell_multicompartment_reference.py` for the full tutorial with CV, node-tree, layout, policy, and plotting inspection.
|
|
348
|
+
Open `references/scripts/cell_multicompartment_reference.py` for the full tutorial with CV, node-tree, layout, policy, and plotting inspection. Pass the path to a soma-and-dendrite SWC as the script's first argument.
|
|
362
349
|
|
|
363
350
|
## Reset, continue, or revise
|
|
364
351
|
|
|
@@ -368,20 +355,21 @@ Use continuation, State reset, declaration reset, or a new cell according to wha
|
|
|
368
355
|
|---|---|---|
|
|
369
356
|
| Continue the same trajectory | Call `cell.run(...)` again. | The next run starts at `cell.current_time`; the cell is not reinitialized. |
|
|
370
357
|
| Repeat the same declaration from reset State | Call `cell.reset_state()`, then `cell.run(...)`. | The cell remains INITIALIZED while voltage, spike, time, and mechanism State are reseeded through their reset hooks. |
|
|
371
|
-
| Change
|
|
358
|
+
| Change the declaration | Call `cell.reset()` to reopen declaration before adding mechanisms or recordings. Build a fresh cell when replacing an existing recording name. | Runtime State is discarded. Existing declarations are retained. |
|
|
372
359
|
| Compare CV policies or independent numerical trials | Construct separate cells from one model-building function. | Each comparison has independent declarations, runtime State, and time. |
|
|
373
360
|
|
|
374
361
|
## Reference routing
|
|
375
362
|
|
|
376
|
-
Open the smallest child for the next decision
|
|
363
|
+
Open the smallest child for the next decision.
|
|
377
364
|
|
|
378
365
|
| Reference | Open when |
|
|
379
366
|
|---|---|
|
|
380
367
|
| `references/multicompartment/morphology-io-loading-validation.md` | Loading SWC, ASC, NeuroML2, NeuroMorpho.Org, or checkpoint data; configuring validation; or checking loaded geometry. |
|
|
381
368
|
| `references/multicompartment/braincell-manual-morphology-construction.md` | Constructing branches, points, radii, types, and parent-child topology without an existing morphology file. |
|
|
382
369
|
| `references/multicompartment/filter-function-library.md` | Selecting or composing non-canonical regions and locsets for `paint()` and `place()`. |
|
|
383
|
-
| `references/multicompartment/cv-policy-reference.md` | Selecting advanced CV policies or evaluating spatial resolution, cost,
|
|
384
|
-
| `references/multicompartment/probe-reference.md` | Selecting
|
|
370
|
+
| `references/multicompartment/cv-policy-reference.md` | Selecting advanced CV policies or evaluating spatial resolution, cost, recording-site mapping, and convergence. |
|
|
371
|
+
| `references/multicompartment/probe-reference.md` | Selecting voltage, mechanism State, or current, checking sampling schedules and result rows, or migrating legacy probes. |
|
|
372
|
+
| `references/multicompartment/network-workflow.md` | Delivering events to spatially placed synapses, registering populations, or running and resetting connected cells. |
|
|
385
373
|
| `references/multicompartment/topology-building-and-visualization.md` | Inspecting and visualizing morphology, branch, CV, node, region, locset, or runtime topology. |
|
|
386
374
|
| `references/ion-library.md` | Choosing fixed, Nernst, or dynamic ion declarations and concentration behavior. |
|
|
387
375
|
| `references/channel-library.md` | Choosing registered sodium, potassium, calcium, leak, HCN, or mixed-ion density channels. |
|