brainx-skill 1.0.12 → 1.0.14

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 (226) hide show
  1. package/README.md +30 -0
  2. package/installation/lib/bundle.js +51 -13
  3. package/installation/lib/cli.js +16 -4
  4. package/installation/lib/literature-mcp.js +536 -0
  5. package/manifest.json +4 -0
  6. package/mcp-servers/codex/README.md +82 -0
  7. package/mcp-servers/codex/UPSTREAM.md +22 -0
  8. package/mcp-servers/codex/server.mjs +142 -0
  9. package/mcp-servers/codex/skills.json +10 -0
  10. package/mcp-servers/codex/system-prompt.md +73 -0
  11. package/mcp-servers/codex/test/fixtures/fake-codex.mjs +6 -0
  12. package/mcp-servers/codex/test/server.test.mjs +99 -0
  13. package/mcp-servers/fulltext-resolver/README.md +136 -0
  14. package/mcp-servers/fulltext-resolver/REUSE.md +32 -0
  15. package/mcp-servers/fulltext-resolver/THIRD_PARTY_NOTICES.md +57 -0
  16. package/mcp-servers/fulltext-resolver/server.mjs +128 -0
  17. package/mcp-servers/fulltext-resolver/src/document.mjs +253 -0
  18. package/mcp-servers/fulltext-resolver/src/http.mjs +173 -0
  19. package/mcp-servers/fulltext-resolver/src/identifiers.mjs +123 -0
  20. package/mcp-servers/fulltext-resolver/src/model.mjs +105 -0
  21. package/mcp-servers/fulltext-resolver/src/resolver.mjs +305 -0
  22. package/mcp-servers/fulltext-resolver/src/sources/biorxiv.mjs +135 -0
  23. package/mcp-servers/fulltext-resolver/src/sources/europe-pmc.mjs +132 -0
  24. package/mcp-servers/fulltext-resolver/src/sources/openalex.mjs +165 -0
  25. package/mcp-servers/fulltext-resolver/test/document.test.mjs +82 -0
  26. package/mcp-servers/fulltext-resolver/test/resolver.test.mjs +287 -0
  27. package/mcp-servers/fulltext-resolver/test/server.test.mjs +63 -0
  28. package/mcp-servers/fulltext-resolver/test/sources.test.mjs +229 -0
  29. package/package.json +14 -10
  30. package/skills/bio-neuro-lit/SKILL.md +206 -0
  31. package/skills/bio-neuro-lit/THIRD_PARTY_NOTICES.md +34 -0
  32. package/skills/bio-neuro-lit/agents/openai.yaml +4 -0
  33. package/skills/bio-neuro-lit/references/tool-contracts.md +73 -0
  34. package/skills/bio-neuro-lit/scripts/deepxiv_fetch.py +110 -0
  35. package/skills/bio-neuro-lit/scripts/exa_search.py +190 -0
  36. package/skills/brainx-acceleration/SKILL.md +459 -0
  37. package/skills/brainx-general-guard/SKILL.md +31 -9
  38. package/skills/brainx-modeling-loop/SKILL.md +281 -0
  39. package/skills/brainx-modeling-loop/agents/openai.yaml +4 -0
  40. package/skills/brainx-modeling-loop/references/monitor-experiment.md +49 -0
  41. package/skills/brainx-modeling-loop/references/parameter-fitting-workflow/scripts/fitting_hh_neuron.py +254 -0
  42. package/skills/brainx-modeling-loop/references/parameter-fitting-workflow.md +272 -0
  43. package/skills/brainx-modeling-loop/references/run-experiment.md +179 -0
  44. package/skills/brainx-modeling-loop/references/training-workflow.md +270 -0
  45. package/skills/brainx-visualization/SKILL.md +157 -0
  46. package/skills/brainx-visualization/agents/openai.yaml +4 -0
  47. package/skills/brainx-visualization/references/interactive-and-visualization-styling.md +155 -0
  48. package/skills/brainx-visualization/references/neural-data-visualization.md +141 -0
  49. package/skills/brainx-visualization/references/statistical-and-model-visualization.md +133 -0
  50. package/skills/{braincell → package-skills/braincell}/SKILL.md +17 -6
  51. package/skills/package-skills/braincell/references/braintools/input-current.md +200 -0
  52. package/skills/package-skills/braincell/references/braintools/optimizer.md +179 -0
  53. package/skills/{braincell → package-skills/braincell}/references/multicompartment/multicompartment-cell-workflow.md +2 -2
  54. package/skills/package-skills/braincell/references/scripts/fitting_hh_neuron.py +254 -0
  55. package/skills/{brainmass → package-skills/brainmass}/references/brainstate/parameter-constraints-regularization.md +1 -1
  56. package/skills/{brainmass → package-skills/brainmass}/references/coupling-network-api.md +121 -3
  57. package/skills/{brainmass → package-skills/brainmass}/references/modellibrary.md +79 -1
  58. package/skills/package-skills/brainmass/references/parameter-sweeps-and-regime-analysis.md +188 -0
  59. package/skills/{brainmass → package-skills/brainmass}/references/visualization-analysis-api.md +6 -6
  60. package/skills/{brainpy-state → package-skills/brainpy-state}/SKILL.md +4 -3
  61. package/skills/{brainpy-state → package-skills/brainpy-state}/references/braintools/connectivity.md +1 -1
  62. package/skills/{brainpy-state → package-skills/brainpy-state}/references/braintools/input-current.md +1 -1
  63. package/skills/package-skills/brainpy-state/references/braintools/metric.md +152 -0
  64. package/skills/package-skills/brainpy-state/references/perturbation-experiment-validity.md +76 -0
  65. package/skills/{brainpy-state → package-skills/brainpy-state}/references/projection-patterns.md +1 -1
  66. package/skills/{brainstate → package-skills/brainstate}/SKILL.md +1 -0
  67. package/skills/{brainstate → package-skills/brainstate}/references/brainstate/brainstate-transformed-diagnostics.md +1 -1
  68. package/skills/{brainstate → package-skills/brainstate}/references/brainstate/parameter-constraints-regularization.md +1 -1
  69. package/skills/{brainstate → package-skills/brainstate}/references/brainstate/randomness-and-reproducibility.md +1 -1
  70. package/skills/{brainstate → package-skills/brainstate}/references/brainstate/transformation-grad-expansion.md +2 -2
  71. package/skills/{brainstate → package-skills/brainstate}/references/brainstate/transformation-vmap-expansion.md +1 -1
  72. package/skills/{brainstate → package-skills/brainstate}/references/libraries/prebuilt-layer-library.md +1 -1
  73. package/skills/package-skills/brainstate/references/paired-perturbation-execution.md +113 -0
  74. package/skills/package-skills/braintrace/SKILL.md +187 -0
  75. package/skills/package-skills/braintrace/references/Drtrl.md +133 -0
  76. package/skills/{braintrace → package-skills/braintrace}/references/ETP operators.md +31 -4
  77. package/skills/package-skills/braintrace/references/algorithm selection.md +64 -0
  78. package/skills/package-skills/braintrace/references/batching.md +140 -0
  79. package/skills/{braintrace → package-skills/braintrace}/references/compiler_internal.md +2 -2
  80. package/skills/{braintrace → package-skills/braintrace}/references/custom algorithms.md +8 -10
  81. package/skills/package-skills/braintrace/references/pp_pprop workflow.md +179 -0
  82. package/skills/{braintrace → package-skills/braintrace}/references/pre-built-braintrace-layer.md +2 -2
  83. package/skills/brainmass/references/parameter-sweeps-and-regime-analysis.md +0 -130
  84. package/skills/braintrace/SKILL.md +0 -161
  85. package/skills/braintrace/references/Drtrl.md +0 -179
  86. package/skills/braintrace/references/algorithm selection.md +0 -120
  87. package/skills/braintrace/references/batching.md +0 -150
  88. package/skills/braintrace/references/pp_pprop workflow.md +0 -196
  89. /package/skills/{braincell → package-skills/braincell}/references/area-scaled-hh-pattern.md +0 -0
  90. /package/skills/{braincell → package-skills/braincell}/references/braincell-custom-ion-channel-authoring.md +0 -0
  91. /package/skills/{brainpy-state → package-skills/braincell}/references/braintools/metric.md +0 -0
  92. /package/skills/{braincell → package-skills/braincell}/references/channel-library.md +0 -0
  93. /package/skills/{braincell → package-skills/braincell}/references/ion-library.md +0 -0
  94. /package/skills/{braincell → package-skills/braincell}/references/mixions-for-adaptation.md +0 -0
  95. /package/skills/{braincell → package-skills/braincell}/references/multicompartment/braincell-manual-morphology-construction.md +0 -0
  96. /package/skills/{braincell → package-skills/braincell}/references/multicompartment/cv-policy-reference.md +0 -0
  97. /package/skills/{braincell → package-skills/braincell}/references/multicompartment/filter-function-library.md +0 -0
  98. /package/skills/{braincell → package-skills/braincell}/references/multicompartment/morphology-io-loading-validation.md +0 -0
  99. /package/skills/{braincell → package-skills/braincell}/references/multicompartment/probe-reference.md +0 -0
  100. /package/skills/{braincell → package-skills/braincell}/references/multicompartment/topology-building-and-visualization.md +0 -0
  101. /package/skills/{braincell → package-skills/braincell}/references/scripts/calcium_channel_gating.py +0 -0
  102. /package/skills/{braincell → package-skills/braincell}/references/scripts/cell_multicompartment_reference.py +0 -0
  103. /package/skills/{braincell → package-skills/braincell}/references/scripts/channel_ablation.py +0 -0
  104. /package/skills/{braincell → package-skills/braincell}/references/scripts/fi_curve.py +0 -0
  105. /package/skills/{braincell → package-skills/braincell}/references/scripts/hh_neuron_basics.py +0 -0
  106. /package/skills/{braincell → package-skills/braincell}/references/scripts/spike_frequency_adaptation.py +0 -0
  107. /package/skills/{braincell → package-skills/braincell}/references/scripts/t_current_rebound.py +0 -0
  108. /package/skills/{braincell → package-skills/braincell}/references/scripts/thalamic_neurons.py +0 -0
  109. /package/skills/{braincell → package-skills/braincell}/references/solver-library-with-effects.md +0 -0
  110. /package/skills/{brainevent → package-skills/brainevent}/SKILL.md +0 -0
  111. /package/skills/{brainevent → package-skills/brainevent}/references/connectivity-variants.md +0 -0
  112. /package/skills/{brainevent → package-skills/brainevent}/references/custom-operators-cpu.md +0 -0
  113. /package/skills/{brainevent → package-skills/brainevent}/references/custom-operators-gpu.md +0 -0
  114. /package/skills/{brainevent → package-skills/brainevent}/references/scripts/102_EI_net_1996.py +0 -0
  115. /package/skills/{brainevent → package-skills/brainevent}/references/scripts/204_joglekar_2018_propagation.py +0 -0
  116. /package/skills/{brainevent → package-skills/brainevent}/references/scripts/coba_ei_teaching.py +0 -0
  117. /package/skills/{brainevent → package-skills/brainevent}/references/sparse-formats.md +0 -0
  118. /package/skills/{brainevent → package-skills/brainevent}/references/synaptic-plasticity.md +0 -0
  119. /package/skills/{brainmass → package-skills/brainmass}/SKILL.md +0 -0
  120. /package/skills/{brainmass → package-skills/brainmass}/references/batch-transform-acceleration.md +0 -0
  121. /package/skills/{brainmass → package-skills/brainmass}/references/brainstate/parameter-transforms-regularizers-catalog.md +0 -0
  122. /package/skills/{brainmass → package-skills/brainmass}/references/braintools/cogtask.md +0 -0
  123. /package/skills/{brainmass → package-skills/brainmass}/references/braintools/data-preprocessing.md +0 -0
  124. /package/skills/{brainmass → package-skills/brainmass}/references/braintools/metric.md +0 -0
  125. /package/skills/{brainmass → package-skills/brainmass}/references/braintools/optimizer.md +0 -0
  126. /package/skills/{brainmass → package-skills/brainmass}/references/braintools/parameter-initializer.md +0 -0
  127. /package/skills/{brainmass → package-skills/brainmass}/references/braintools/surrogate.md +0 -0
  128. /package/skills/{brainmass → package-skills/brainmass}/references/datasets-api.md +0 -0
  129. /package/skills/{brainmass → package-skills/brainmass}/references/fitting-with-objectives-api.md +0 -0
  130. /package/skills/{brainmass → package-skills/brainmass}/references/forward-observation-api.md +0 -0
  131. /package/skills/{brainmass → package-skills/brainmass}/references/horn-task-training.md +0 -0
  132. /package/skills/{brainmass → package-skills/brainmass}/references/noiseprocesses.md +0 -0
  133. /package/skills/{brainmass → package-skills/brainmass}/references/scripts/eeg-fitting-with-gradients.py +0 -0
  134. /package/skills/{brainmass → package-skills/brainmass}/references/scripts/gradient-free-fitting.py +0 -0
  135. /package/skills/{brainmass → package-skills/brainmass}/references/scripts/hopf-bifurcation-single-node.py +0 -0
  136. /package/skills/{brainmass → package-skills/brainmass}/references/scripts/horn-cognitive-task-training.py +0 -0
  137. /package/skills/{brainmass → package-skills/brainmass}/references/scripts/jansen-rit-eeg-proxy.py +0 -0
  138. /package/skills/{brainmass → package-skills/brainmass}/references/scripts/kuramoto-synchronization.py +0 -0
  139. /package/skills/{brainmass → package-skills/brainmass}/references/scripts/linear-baseline-node.py +0 -0
  140. /package/skills/{brainmass → package-skills/brainmass}/references/scripts/resting-state-meg-whole-brain-pipeline.py +0 -0
  141. /package/skills/{brainmass → package-skills/brainmass}/references/scripts/seizure-epileptor-case-study.py +0 -0
  142. /package/skills/{brainmass → package-skills/brainmass}/references/scripts/wilson-cowan-ei-dynamics.py +0 -0
  143. /package/skills/{brainmass → package-skills/brainmass}/references/scripts/wong-wang-decision-making.py +0 -0
  144. /package/skills/{brainmass → package-skills/brainmass}/references/scripts/wong-wang-dmf-resting-state.py +0 -0
  145. /package/skills/{brainmass → package-skills/brainmass}/references/simulator-input-monitor-api.md +0 -0
  146. /package/skills/{brainpy-state → package-skills/brainpy-state}/references/array-creation.md +0 -0
  147. /package/skills/{brainpy-state → package-skills/brainpy-state}/references/brain-dynamics-delay-protocol.md +0 -0
  148. /package/skills/{brainpy-state → package-skills/brainpy-state}/references/brainPy(legacy)/analysis.md +0 -0
  149. /package/skills/{brainpy-state → package-skills/brainpy-state}/references/brainPy(legacy)/brainpy legacy workflow.md +0 -0
  150. /package/skills/{brainpy-state → package-skills/brainpy-state}/references/brainPy(legacy)/built-in dynamic neuron model.md +0 -0
  151. /package/skills/{brainpy-state → package-skills/brainpy-state}/references/brainPy(legacy)/connecting neurons.md +0 -0
  152. /package/skills/{brainpy-state → package-skills/brainpy-state}/references/brainPy(legacy)/customize neuron and synpase.md +0 -0
  153. /package/skills/{brainpy-state → package-skills/brainpy-state}/references/brainPy(legacy)/infrastructure/Input generation.md +0 -0
  154. /package/skills/{brainpy-state → package-skills/brainpy-state}/references/brainPy(legacy)/infrastructure/More about simulation.md +0 -0
  155. /package/skills/{brainpy-state → package-skills/brainpy-state}/references/brainPy(legacy)/infrastructure/Multi-device array sharding.md +0 -0
  156. /package/skills/{brainpy-state → package-skills/brainpy-state}/references/brainPy(legacy)/infrastructure/Parallel experiment execution.md +0 -0
  157. /package/skills/{brainpy-state → package-skills/brainpy-state}/references/brainPy(legacy)/infrastructure/array creation and mechanics.md +0 -0
  158. /package/skills/{brainpy-state → package-skills/brainpy-state}/references/brainPy(legacy)/infrastructure/brainpy math environment setting.md +0 -0
  159. /package/skills/{brainpy-state → package-skills/brainpy-state}/references/brainPy(legacy)/infrastructure/delays.md +0 -0
  160. /package/skills/{brainpy-state → package-skills/brainpy-state}/references/brainPy(legacy)/infrastructure/object oriented transformations and control flows.md +0 -0
  161. /package/skills/{brainpy-state → package-skills/brainpy-state}/references/brainPy(legacy)/integrators.md +0 -0
  162. /package/skills/{brainpy-state → package-skills/brainpy-state}/references/brainPy(legacy)/route activity through connectivity.md +0 -0
  163. /package/skills/{brainpy-state → package-skills/brainpy-state}/references/brainPy(legacy)/synaptic projections.md +0 -0
  164. /package/skills/{brainpy-state → package-skills/brainpy-state}/references/brainPy(legacy)/synpase properties.md +0 -0
  165. /package/skills/{brainpy-state → package-skills/brainpy-state}/references/brainPy(legacy)/training/loss library.md +0 -0
  166. /package/skills/{brainpy-state → package-skills/brainpy-state}/references/brainPy(legacy)/training/optimizers.md +0 -0
  167. /package/skills/{brainpy-state → package-skills/brainpy-state}/references/brainPy(legacy)/training/parameter initializers.md +0 -0
  168. /package/skills/{brainpy-state → package-skills/brainpy-state}/references/brainPy(legacy)/training/prebuilt neural network layers.md +0 -0
  169. /package/skills/{brainpy-state → package-skills/brainpy-state}/references/brainPy(legacy)/training/surrogate gradients.md +0 -0
  170. /package/skills/{brainpy-state → package-skills/brainpy-state}/references/brainPy(legacy)/training/trainer library.md +0 -0
  171. /package/skills/{brainpy-state → package-skills/brainpy-state}/references/brainPy(legacy)/training/trainingworkflows.md +0 -0
  172. /package/skills/{brainpy-state → package-skills/brainpy-state}/references/braintools/brainstate-control-flow-patterns.md +0 -0
  173. /package/skills/{brainpy-state → package-skills/brainpy-state}/references/braintools/data-preprocessing.md +0 -0
  174. /package/skills/{brainpy-state → package-skills/brainpy-state}/references/braintools/optimizer.md +0 -0
  175. /package/skills/{brainpy-state → package-skills/brainpy-state}/references/braintools/parameter-initializer.md +0 -0
  176. /package/skills/{brainpy-state → package-skills/brainpy-state}/references/braintools/surrogate.md +0 -0
  177. /package/skills/{brainpy-state → package-skills/brainpy-state}/references/component-selection.md +0 -0
  178. /package/skills/{brainpy-state → package-skills/brainpy-state}/references/nest-compatible/devices.md +0 -0
  179. /package/skills/{brainpy-state → package-skills/brainpy-state}/references/nest-compatible/divergence-and-parity.md +0 -0
  180. /package/skills/{brainpy-state → package-skills/brainpy-state}/references/nest-compatible/integration-categories.md +0 -0
  181. /package/skills/{brainpy-state → package-skills/brainpy-state}/references/nest-compatible/model-library.md +0 -0
  182. /package/skills/{brainpy-state → package-skills/brainpy-state}/references/nest-compatible/nest-workflow.md +0 -0
  183. /package/skills/{brainpy-state → package-skills/brainpy-state}/references/nest-compatible/network-building.md +0 -0
  184. /package/skills/{brainpy-state → package-skills/brainpy-state}/references/nest-compatible/scripts/brette_et_al_2007.py +0 -0
  185. /package/skills/{brainpy-state → package-skills/brainpy-state}/references/nest-compatible/scripts/brunel_alpha.py +0 -0
  186. /package/skills/{brainpy-state → package-skills/brainpy-state}/references/nest-compatible/scripts/brunel_delta.py +0 -0
  187. /package/skills/{brainpy-state → package-skills/brainpy-state}/references/nest-compatible/scripts/clopath_synapse_spike_pairing.py +0 -0
  188. /package/skills/{brainpy-state → package-skills/brainpy-state}/references/nest-compatible/scripts/evaluate_tsodyks2_synapse.py +0 -0
  189. /package/skills/{brainpy-state → package-skills/brainpy-state}/references/nest-compatible/scripts/spatial_gaussex.py +0 -0
  190. /package/skills/{brainpy-state → package-skills/brainpy-state}/references/nest-compatible/scripts/synapsecollection.py +0 -0
  191. /package/skills/{brainpy-state → package-skills/brainpy-state}/references/nest-compatible/synapse-and-connectivity.md +0 -0
  192. /package/skills/{brainpy-state → package-skills/brainpy-state}/references/scripts/103_COBA_2005.py +0 -0
  193. /package/skills/{brainpy-state → package-skills/brainpy-state}/references/scripts/106_COBA_HH_2007.py +0 -0
  194. /package/skills/{brainpy-state → package-skills/brainpy-state}/references/scripts/107_gamma_oscillation_1996.py +0 -0
  195. /package/skills/{brainpy-state → package-skills/brainpy-state}/references/scripts/109_fast_global_oscillation.py +0 -0
  196. /package/skills/{brainpy-state → package-skills/brainpy-state}/references/scripts/201_surrogate_grad_lif_fashion_mnist.py +0 -0
  197. /package/skills/{brainpy-state → package-skills/brainpy-state}/references/scripts/sound_localization.py +0 -0
  198. /package/skills/{brainpy-state → package-skills/brainpy-state}/references/scripts/training-snn.py +0 -0
  199. /package/skills/{brainstate → package-skills/brainstate}/agents/openai.yaml +0 -0
  200. /package/skills/{brainstate → package-skills/brainstate}/references/brainstate/brainstate-control-flow-patterns.md +0 -0
  201. /package/skills/{brainstate → package-skills/brainstate}/references/brainstate/parameter-transforms-regularizers-catalog.md +0 -0
  202. /package/skills/{brainstate → package-skills/brainstate}/references/brainstate/transformation-jit-expansion.md +0 -0
  203. /package/skills/{brainstate → package-skills/brainstate}/references/collective_model_operations.md +0 -0
  204. /package/skills/{brainstate → package-skills/brainstate}/references/extension_mechanisms.md +0 -0
  205. /package/skills/{brainstate → package-skills/brainstate}/references/libraries/prebuilt-activation-library.md +0 -0
  206. /package/skills/{brainstate → package-skills/brainstate}/references/model-interop-and-migration.md +0 -0
  207. /package/skills/{brainstate → package-skills/brainstate}/references/simulation-environment.md +0 -0
  208. /package/skills/{brainstate → package-skills/brainstate}/references/size-inference-variations.md +0 -0
  209. /package/skills/{brainstate → package-skills/brainstate}/references/state-graph-operations.md +0 -0
  210. /package/skills/{brainstate → package-skills/brainstate}/references/state_collections_and_utilities.md +0 -0
  211. /package/skills/{brainstate → package-skills/brainstate}/scripts/integrator_rnn.py +0 -0
  212. /package/skills/{brainstate → package-skills/brainstate}/scripts/lif_neuron_model.py +0 -0
  213. /package/skills/{brainstate → package-skills/brainstate}/scripts/modern_cnn.py +0 -0
  214. /package/skills/{brainstate → package-skills/brainstate}/scripts/resnet.py +0 -0
  215. /package/skills/{braintrace → package-skills/braintrace}/references/custom ETP primitives.md +0 -0
  216. /package/skills/{braintrace → package-skills/braintrace}/references/customizing_primitive_transforms.md +0 -0
  217. /package/skills/{brainunit → package-skills/brainunit}/SKILL.md +0 -0
  218. /package/skills/{brainunit → package-skills/brainunit}/references/array-creation.md +0 -0
  219. /package/skills/{brainunit → package-skills/brainunit}/references/array-mechanics/functional-structural-api.md +0 -0
  220. /package/skills/{brainunit → package-skills/brainunit}/references/array-mechanics.md +0 -0
  221. /package/skills/{brainunit → package-skills/brainunit}/references/math-function-library.md +0 -0
  222. /package/skills/{brainunit → package-skills/brainunit}/references/physical-constant-library.md +0 -0
  223. /package/skills/{brainunit → package-skills/brainunit}/references/prefix-library.md +0 -0
  224. /package/skills/{brainunit → package-skills/brainunit}/references/quantity-inspection-and-conversion.md +0 -0
  225. /package/skills/{brainunit → package-skills/brainunit}/references/typing-and-runtime-validation.md +0 -0
  226. /package/skills/{brainunit → package-skills/brainunit}/references/unit-structure-and-definition.md +0 -0
@@ -1,6 +1,6 @@
1
1
  # BrainMass model library
2
2
 
3
- Use this reference when selecting a public BrainMass model, comparing dynamical cost, identifying its primary observable, or distinguishing variants with similar names. Return to `skills/brainmass/SKILL.md` after selection for the canonical `Simulator` workflow.
3
+ Use this reference when selecting a public BrainMass model, comparing dynamical cost, identifying its primary observable, or distinguishing variants with similar names. Return to `skills/package-skills/brainmass/SKILL.md` after selection for the canonical `Simulator` workflow.
4
4
 
5
5
  ## Inspect the public catalogue
6
6
 
@@ -74,6 +74,82 @@ assert result["output"].shape == (3000, 8)
74
74
 
75
75
  Use `JansenRitTR` only when its internal substep-to-TR behavior is explicitly required. Instantiate concrete model classes rather than shared bases such as `XY_Oscillator` or `WilsonCowanThreePopBase`.
76
76
 
77
+ ## Choose an inhibitory intervention
78
+
79
+ Match the intervention to the model's equations; similarly named inhibitory parameters do not represent the same mechanism or unit.
80
+
81
+ | API | Description |
82
+ |---|---|
83
+ | `JansenRitStep(Ai=...)` | Use for inhibitory postsynaptic gain in an alpha/EEG cortical column; `Ai` is measured in mV and scales the inhibitory-population filter, so lowering it weakens the inhibitory postsynaptic potential represented in `eeg() = E - I`. |
84
+ | `WilsonCowanStep(wEI=...)` | Use for inhibitory feedback onto the excitatory rate population; `wEI` is dimensionless I-to-E coupling and enters the excitatory equation subtractively, so lowering it weakens that coupling. |
85
+
86
+ Change only the selected inhibitory parameter in a matched causal comparison. Treat defaults and source-documented estimation ranges as context, not as evidence for a chosen intervention magnitude. Label an unsourced, outcome-tuned, or outside-range value as phenomenological and show nearby sensitivity before claiming a robust regime change.
87
+
88
+ ## Choose an Epileptor focus and input path
89
+
90
+ Use `x0` to represent autonomous regional epileptogenicity; use `x1_inp` or `x2_inp` only when the scientific intervention or network current is an input, and enable the corresponding gain explicitly.
91
+
92
+ | API | Description |
93
+ |---|---|
94
+ | `EpileptorStep(x0=...)` | Use a region-wise value to distinguish an epileptogenic focus from healthier tissue; less-negative `x0` increases epileptogenicity, while more-negative values render a region healthy. |
95
+ | `EpileptorStep(Kvf=..., Ks=...)` | Use when `x1_inp` should affect the fast `x1` subsystem and/or slow `z` recruitment path; `Kvf` scales its effect on `x1`, `Ks` scales its effect on `z`, and both default to zero. |
96
+ | `EpileptorStep(Kf=...)` | Use when `x2_inp` should affect the ultra-slow `x2` subsystem; `Kf` scales that input and defaults to zero. |
97
+ | `EpileptorStep.update(x1_inp=None, x2_inp=None)` | Use for one explicit step with population-specific coupling or external inputs; an input has no deterministic effect through a gain left at its zero default. |
98
+
99
+ ```python
100
+ import jax.numpy as jnp
101
+
102
+ epileptor = brainmass.EpileptorStep(
103
+ in_size=3,
104
+ x0=jnp.asarray([-1.6, -2.4, -2.4]),
105
+ Kvf=0.5,
106
+ Ks=0.1,
107
+ )
108
+ ```
109
+
110
+ This construction represents one autonomous focus and enables a first-channel network current to affect both fast activity and the slow permittivity path. Set only the gains required by the declared mechanism. Do not conclude that Epileptor lacks driven inputs from a trial that leaves `Kvf`, `Kf`, and `Ks` at zero.
111
+
112
+ ## Extend Wong-Wang population currents
113
+
114
+ Use stock `update()` for bounded sensory evidence; compose the public current, transfer, derivative, and integration APIs only when a mechanism adds a distinct population-specific current.
115
+
116
+ | API | Description |
117
+ |---|---|
118
+ | `WongWangStep.update(coherence=...)` | Use for one standard decision step; `coherence` is motion evidence in `[-1, 1]`, not an arbitrary current. |
119
+ | `WongWangStep.compute_inputs(coherence=..., noise_1_val=..., noise_2_val=...)` | Use when extending the current path; it combines valid coherence and actual stochastic currents and returns total population currents `I1` and `I2`. |
120
+ | `WongWangStep.phi(I)` | Use after all current-valued mechanisms are applied; it maps one nA input current to a firing rate in Hz. |
121
+ | `WongWangStep.dS1_dt(S1, r1)` | Use with the population-1 rate to preserve the model's public `S1` gating equation. |
122
+ | `WongWangStep.dS2_dt(S2, r2)` | Use with the population-2 rate to preserve the model's public `S2` gating equation. |
123
+ | `brainstate.nn.exp_euler_step(fn, state, *args)` | Use under an active `dt` context to advance each public gating derivative and return its next State value. |
124
+
125
+ ```python
126
+ import brainmass
127
+ import brainstate
128
+ import brainunit as u
129
+
130
+ model = brainmass.WongWangStep(in_size=1)
131
+ brainstate.nn.init_all_states(model)
132
+
133
+ adaptation_1 = 0.02 * u.nA
134
+ adaptation_2 = 0.0 * u.nA
135
+ with brainstate.environ.context(dt=0.1 * u.ms):
136
+ current_1, current_2 = model.compute_inputs(coherence=0.0)
137
+ rate_1 = model.phi(current_1 - adaptation_1)
138
+ rate_2 = model.phi(current_2 - adaptation_2)
139
+ model.S1.value = u.math.clip(
140
+ brainstate.nn.exp_euler_step(model.dS1_dt, model.S1.value, rate_1),
141
+ 0.0,
142
+ 1.0,
143
+ )
144
+ model.S2.value = u.math.clip(
145
+ brainstate.nn.exp_euler_step(model.dS2_dt, model.S2.value, rate_2),
146
+ 0.0,
147
+ 1.0,
148
+ )
149
+ ```
150
+
151
+ Keep actual noise in `noise_1_val` and `noise_2_val`; apply adaptation, stimulation, or another named mechanism explicitly to the returned currents. Do not force a current through out-of-range coherence or copy the model equations when these public methods preserve them.
152
+
77
153
  ## Choose Wong-Wang decision semantics
78
154
 
79
155
  Choose the decision rule from the scientific definition; thresholded firing-rate decisions and final gating dominance are not equivalent.
@@ -104,6 +180,7 @@ Open only the script that matches the selected model or scientific regime.
104
180
 
105
181
  - Choosing a complex six-State model before a cheap model establishes the regime.
106
182
  - Treating `WongWangStep` and `WongWangExcInhStep` as interchangeable.
183
+ - Passing an arbitrary current through bounded Wong-Wang `coherence` or hiding a non-noise mechanism in `noise_1_val` or `noise_2_val`.
107
184
  - Fitting a BOLD target without a suitable slow neural source and hemodynamic observation model.
108
185
  - Treating a neural-mass model as a point-neuron or cellular model.
109
186
  - Assuming the inventory from this file supersedes `list_models()` in another installed release.
@@ -111,5 +188,6 @@ Open only the script that matches the selected model or scientific regime.
111
188
  ## Official sources
112
189
 
113
190
  - `https://brainx.chaobrain.com/brainmass/reference/models.html`
191
+ - `https://brainx.chaobrain.com/brainmass/reference/generated/brainmass.WongWangStep.html`
114
192
  - `https://brainx.chaobrain.com/brainmass/reference/utilities.html`
115
193
  - `https://brainx.chaobrain.com/brainmass/howto/choose_a_model.html`
@@ -0,0 +1,188 @@
1
+ # Parameter sweeps and regime analysis
2
+
3
+ Use this reference when mapping regimes, sensitivities, or identifiability over a fixed parameter grid. Use `Fitter` instead when the task is to minimize one target objective rather than characterize the landscape.
4
+
5
+ ## Choose sweep or fit
6
+
7
+ | Goal | Use |
8
+ |---|---|
9
+ | Visualize a bifurcation, regime boundary, sensitivity, or multiple equivalent solutions | Parameter sweep |
10
+ | Recover parameters that minimize one differentiable target | Gradient `Fitter` |
11
+ | Optimize a non-differentiable target without exhaustively mapping the grid | Gradient-free `Fitter` |
12
+
13
+ Return one scalar or fixed-shape scientific summary per grid point. Avoid retaining full trajectories unless they are required downstream.
14
+
15
+ ## Run a one-dimensional sweep
16
+
17
+ Construct the model inside the mapped function so BrainState can trace one independent simulation per parameter value.
18
+
19
+ ```python
20
+ import brainmass
21
+ import brainstate
22
+ import brainunit as u
23
+ import braintools
24
+ import jax.numpy as jnp
25
+
26
+ def amplitude_for(a):
27
+ node = brainmass.HopfStep(
28
+ in_size=1,
29
+ a=a,
30
+ w=0.3,
31
+ init_x=braintools.init.Constant(0.5),
32
+ )
33
+ result = brainmass.Simulator(node, dt=0.1 * u.ms).run(
34
+ 150.0 * u.ms,
35
+ monitors=["x"],
36
+ transient=50.0 * u.ms,
37
+ )
38
+ x = u.get_magnitude(result["x"])[:, 0]
39
+ return jnp.sqrt(jnp.mean(x**2)) * jnp.sqrt(2.0)
40
+
41
+ a_values = jnp.linspace(0.0, 1.5, 16)
42
+ amplitudes = brainstate.transform.vmap(amplitude_for)(a_values)
43
+
44
+ assert amplitudes.shape == a_values.shape
45
+ ```
46
+
47
+ The mapped function must return the same PyTree structure and leaf shapes for every point.
48
+
49
+ ## Run a two-dimensional grid
50
+
51
+ Flatten coordinate grids, map all coordinate arrays together, then reshape the fixed-shape result back to grid order.
52
+
53
+ ```python
54
+ a_grid = jnp.linspace(0.1, 1.5, 6)
55
+ w_grid = jnp.linspace(0.1, 0.6, 5)
56
+ aa, ww = jnp.meshgrid(a_grid, w_grid, indexing="ij")
57
+
58
+ def amplitude_for_pair(a, w):
59
+ node = brainmass.HopfStep(
60
+ in_size=1,
61
+ a=a,
62
+ w=w,
63
+ init_x=braintools.init.Constant(0.5),
64
+ )
65
+ result = brainmass.Simulator(node, dt=0.1 * u.ms).run(
66
+ 150.0 * u.ms,
67
+ monitors=["x"],
68
+ transient=50.0 * u.ms,
69
+ )
70
+ x = u.get_magnitude(result["x"])[:, 0]
71
+ return jnp.sqrt(jnp.mean(x**2)) * jnp.sqrt(2.0)
72
+
73
+ flat = brainstate.transform.vmap(amplitude_for_pair)(
74
+ aa.reshape(-1),
75
+ ww.reshape(-1),
76
+ )
77
+ grid = flat.reshape(aa.shape)
78
+ assert grid.shape == (6, 5)
79
+ ```
80
+
81
+ Preserve `indexing="ij"` and record axis values with the reshaped result. A heatmap without physical axis values is not a reproducible regime map.
82
+
83
+ Plot sparse coordinates as discrete cells, `scatter(x, y)`, or `plot(x, y, marker="o", linestyle="none")`. Do not assume that adding markers removes a line: `plot(..., marker="o")` still connects samples by default. Connect or interpolate only when the grid resolves behavior between adjacent coordinates or a declared interpolation model supports that inference.
84
+
85
+ ## Sweep a delayed network
86
+
87
+ Set global `dt` before `vmap` traces construction of each delayed `Network`.
88
+
89
+ ```python
90
+ brainstate.environ.set(dt=0.1 * u.ms)
91
+ connectome = brainmass.datasets.load_dataset("example_connectome")
92
+
93
+ def mean_activity_for(k):
94
+ n_region = connectome.weights.shape[0]
95
+ node = brainmass.HopfStep(
96
+ in_size=n_region,
97
+ a=0.2,
98
+ w=0.3,
99
+ init_x=braintools.init.Constant(0.3),
100
+ )
101
+ network = brainmass.Network(
102
+ node,
103
+ conn=connectome.weights,
104
+ distance=connectome.distances,
105
+ speed=10.0 * u.mm / u.ms,
106
+ coupling="diffusive",
107
+ coupled_var="x",
108
+ k=k,
109
+ )
110
+ output = brainmass.Simulator(network, dt=0.1 * u.ms).run(
111
+ 600.0 * u.ms,
112
+ monitors=lambda model: model.node.x.value,
113
+ transient=100.0 * u.ms,
114
+ )["output"]
115
+ return jnp.mean(jnp.abs(u.get_magnitude(output)))
116
+
117
+ k_values = jnp.linspace(0.0, 1.5, 8)
118
+ summary = brainstate.transform.vmap(mean_activity_for)(k_values)
119
+ assert summary.shape == k_values.shape
120
+ ```
121
+
122
+ Use FC, FCD, spectrum, amplitude, synchrony, or another domain summary when mean absolute activity does not answer the scientific question.
123
+
124
+ ## Classify time-resolved regimes
125
+
126
+ Match the temporal predicate to the claimed regime; a threshold crossing, a sustained event, and routed propagation are different outcomes.
127
+
128
+ | Claim | Required predicate |
129
+ |---|---|
130
+ | Threshold crossing | At least one sample crosses the fixed threshold; onset is the first crossing. |
131
+ | Sustained event or burst | Every sample in a fixed minimum-duration window crosses the threshold; onset is the start of the first qualifying window. |
132
+ | Routed propagation | Every required region satisfies its event predicate and the qualifying onsets follow the declared route in strict order. |
133
+
134
+ ```python
135
+ import jax
136
+ import jax.numpy as jnp
137
+
138
+ # activity has shape (time, region); minimum_steps is fixed before the sweep.
139
+ above = activity >= threshold
140
+ window_hits = jax.lax.reduce_window(
141
+ above.astype(jnp.int32),
142
+ 0,
143
+ jax.lax.add,
144
+ (minimum_steps, 1),
145
+ (1, 1),
146
+ "VALID",
147
+ )
148
+ qualifying_windows = window_hits == minimum_steps
149
+ recruited = jnp.any(qualifying_windows, axis=0)
150
+ first_start = jnp.argmax(qualifying_windows, axis=0)
151
+ onset = jnp.where(recruited, first_start + 1, jnp.nan) * dt
152
+ max_window_hits = jnp.max(window_hits, axis=0)
153
+ ```
154
+
155
+ Fix the observable, direction, threshold, minimum duration, and route before inspecting outcomes. If outcome inspection changes any part of that predicate, label the result exploratory; do not describe the rule as pre-specified. Freeze the calibrated predicate and evaluate it unchanged on independently declared conditions, trials, seeds, or a later confirmation run before making a confirmatory claim.
156
+
157
+ Apply the same disclosure to every model parameter, protocol value, grid axis, or displayed case selected after inspecting outcomes, even when the predicate stayed fixed. Record which settings were outcome-calibrated and label the result exploratory or outcome-calibrated. Show nearby sensitivity or independently declared confirmation before claiming a robust regime or confirmatory result.
158
+
159
+ Retain continuous decision evidence beside every categorical label. For the reduction above, save `max_window_hits` or its duration equivalent for every condition and region, not only the onset and an unrelated peak. Also save the exact tested reduction, observable, direction, threshold, minimum duration, and `dt` so a consumer can reconstruct the decision margin without rerunning the sweep.
160
+
161
+ Align event times with the monitor phase. When a custom step updates model State and then returns it, stacked output sample zero is observed at one `dt`, not time zero. Save post-update time as `(arange(n_steps) + 1) * dt`, compute first-window onset as `(first_start + 1) * dt`, and record that phase in result metadata. Use zero-based times only when the monitor explicitly returns pre-update State.
162
+
163
+ ## Include mechanism controls
164
+
165
+ When a regime claim attributes an outcome to a drive, coupling, intervention, or other varied mechanism, append its causal controls to the same flattened parameter arrays before the mapped call. Tag each control, run the identical model and metric path, and verify its expected outcome independently.
166
+
167
+ ```python
168
+ import numpy as np
169
+
170
+ condition_type = np.asarray(["grid"] * flat_k.size + ["no_coupling", "no_drive"])
171
+ k = jnp.concatenate([flat_k, jnp.asarray([0.0, test_k])])
172
+ drive = jnp.concatenate([flat_drive, jnp.asarray([test_drive, 0.0])])
173
+ results = brainstate.transform.vmap(run_condition)(k, drive)
174
+ ```
175
+
176
+ Append matching control values to every other mapped coordinate when the condition has additional axes such as delay. Do not run controls through a separate Python path or omit them because the positive parameter grid contains a visually local case. A local case tests a regime; zeroing the proposed mechanism tests causality.
177
+
178
+ ## Store results
179
+
180
+ Write one self-describing numeric result bundle before plotting or reporting. A figure, stdout, or value left only in memory does not retain a sweep.
181
+
182
+ Store the original grid shape and every ordered axis as dedicated named fields alongside flattened condition columns and tags so the exact mapped layout can be reconstructed. Flattened coordinates do not replace the grid shape or axis-order contract. Store continuous evidence, categorical labels, explicit units, model identity, connectivity and its direction convention, coupling kernel, non-default or mechanism-selecting parameters, protocol timing, `dt`, duration, transient, integration method, seed, predicate settings, monitor phase, and code version together. When delay retrieval varies, also record fixed buffer capacity, prehistory, and update/retrieval phase. Save full trajectories when they are required downstream; otherwise save the exact tested reduction plus every continuous boundary observable needed to audit the labels. Record code version as a repository revision when available or as an explicit script or artifact-schema version otherwise; a model name or filename is not a code version. Do not duplicate every untouched constructor default when the model identity and code version already define it.
183
+
184
+ Seed stochastic sweeps deliberately. One common seed across parameter values reduces random differences but couples their noise realization; independent seeds estimate uncertainty instead. State which design was used.
185
+
186
+ ## Official source
187
+
188
+ - `https://brainx.chaobrain.com/brainmass/howto/parameter_sweeps.html`
@@ -24,7 +24,7 @@ Strip units explicitly before a metric that operates on scale-free raw arrays. K
24
24
  |---|---|
25
25
  | `braintools.metric.functional_connectivity(signal)` | Compute pairwise correlation across regions from a `(time, regions)` trajectory. |
26
26
  | `braintools.metric.functional_connectivity_dynamics(signal, window_size, step_size)` | Slide an FC window and correlate windowed FC matrices to return an `(n_window, n_window)` FCD matrix. |
27
- | `braintools.metric.power_spectral_density(signal, dt_ms)` | Return frequencies and PSD for a one-dimensional signal; use a sampling interval in the expected raw unit. |
27
+ | `braintools.metric.power_spectral_density(signal, dt, nperseg=None, noverlap=None, freq_range=None)` | Use for a one-sided Welch PSD of a `(time,)` or `(time, channels)` signal; pass `dt` as a time `Quantity` or a float in seconds, and it returns frequencies in Hz plus PSD shaped `(frequency,)` or `(frequency, channels)`. |
28
28
  | `brainmass.objectives.fc_corr()` | Score correlation between prediction and target FC without manually recomputing the comparison logic. |
29
29
  | `brainmass.objectives.fcd_distribution(fcd_matrix, ...)` | Estimate the off-diagonal FCD value distribution used by distributional FCD objectives. |
30
30
 
@@ -103,17 +103,17 @@ Use `as_loss=True` only when the score is passed to a minimizer. A high FC score
103
103
  Use one channel at a time unless the metric explicitly accepts multichannel input.
104
104
 
105
105
  ```python
106
- record_dt_ms = float(
107
- (result["ts"][1] - result["ts"][0]).to(u.ms).mantissa
108
- )
106
+ record_dt = result["ts"][1] - result["ts"][0]
109
107
  frequencies, power = braintools.metric.power_spectral_density(
110
108
  signal[:, 0],
111
- record_dt_ms,
109
+ record_dt,
112
110
  )
113
111
  assert frequencies.shape == power.shape
114
112
  ```
115
113
 
116
- Convert cycles per millisecond to hertz only when the metric's returned frequency convention requires it. Do not infer a sampling frequency from the number of samples alone.
114
+ The returned frequencies are in hertz. A plain numeric `dt` is always interpreted in seconds; do not pass a value expressed in milliseconds without its unit. Use the difference between recorded timestamps because `sample_every` can make it differ from the integration step.
115
+
116
+ Freeze a signal-amplitude or in-band-power floor before inspecting condition outcomes. Report the dominant frequency as undefined below that floor: `argmax` always selects a bin even when the trace contains no scientifically identifiable oscillation. Choose `nperseg` deliberately when the default resolution cannot distinguish the claimed frequency band.
117
117
 
118
118
  ## Common failures
119
119
 
@@ -160,7 +160,7 @@ assert post_voltage.shape == (2000, 10)
160
160
  assert conductance.shape == (2000, 10)
161
161
  ```
162
162
 
163
- Open `references/braintools/connectivity.md` first when geometry, distance, degree, modules, or another named topology determines which neuron pairs connect; generate the topology before choosing its BrainEvent representation. Open `references/projection-patterns.md` before implementing recurrent excitation, mutual inhibition, or other spike-driven connectivity; it owns AlignPre versus AlignPost, communication, delays, direct/delta input, short-term plasticity, and electrical coupling. Open `skills/brainevent/references/scripts/coba_ei_teaching.py` when a BrainPy network should use BrainEvent for efficient event-driven communication; it keeps BrainPy neuron and synapse dynamics while replacing the communication step with `BinaryArray @ connectivity` over fixed-degree, CSR, or dense storage.
163
+ Open `references/braintools/connectivity.md` first when geometry, distance, degree, modules, or another named topology determines which neuron pairs connect; generate the topology before choosing its BrainEvent representation. Open `references/projection-patterns.md` before implementing recurrent excitation, mutual inhibition, or other spike-driven connectivity; it owns AlignPre versus AlignPost, communication, delays, direct/delta input, short-term plasticity, and electrical coupling. Open `skills/package-skills/brainevent/references/scripts/coba_ei_teaching.py` when a BrainPy network should use BrainEvent for efficient event-driven communication; it keeps BrainPy neuron and synapse dynamics while replacing the communication step with `BinaryArray @ connectivity` over fixed-degree, CSR, or dense storage.
164
164
 
165
165
  ### 3. Train a spiking network
166
166
 
@@ -228,10 +228,11 @@ Open only the smallest reference that owns the decision.
228
228
  | `references/braintools/input-current.md` | Generating or composing direct unit-aware current sections, pulses, waveforms, or stochastic processes |
229
229
  | `references/component-selection.md` | Choosing a neuron, synapse, synaptic output, plasticity model, input generator, or readout from the documented native API families |
230
230
  | `references/projection-patterns.md` | Choosing projection alignment or API form, adding delays or short-term plasticity, using direct/delta projections, or adding gap junctions |
231
+ | `references/perturbation-experiment-validity.md` | Estimating baseline tuning or features before matched point-neuron perturbations, calibrating delivered target dose, or deciding whether activity and analysis support justify a formal causal run |
231
232
  | `references/nest-compatible/nest-workflow.md` | Using NEST/PyNEST model names, `Simulator`, devices, connection rules, spatial networks, parity, porting, or the bundled NEST-compatible full scripts |
232
233
  | `references/brainPy(legacy)/brainpy legacy workflow.md` | Use as the only first-level legacy entry when existing legacy `brainpy` has no BrainUnit, unit-aware, or BrainTrace code and the user explicitly requests it; this workflow routes all second-level legacy references |
233
- | `skills/brainevent/SKILL.md` | Selecting sparse event representations, connectivity formats, event operators, plasticity kernels, or custom kernels |
234
- | `skills/brainevent/references/scripts/coba_ei_teaching.py` | Learning how to incorporate efficient BrainEvent communication into a complete BrainPy COBA E/I network while preserving BrainPy dynamics and BrainState execution |
234
+ | `skills/package-skills/brainevent/SKILL.md` | Selecting sparse event representations, connectivity formats, event operators, plasticity kernels, or custom kernels |
235
+ | `skills/package-skills/brainevent/references/scripts/coba_ei_teaching.py` | Learning how to incorporate efficient BrainEvent communication into a complete BrainPy COBA E/I network while preserving BrainPy dynamics and BrainState execution |
235
236
 
236
237
 
237
238
  ## Application script examples
@@ -137,7 +137,7 @@ matching value permutation separately. If the topology has no generated
137
137
  weights, supply an intentional scalar or edge-aligned weight array before
138
138
  constructing `CSR`.
139
139
 
140
- Open `skills/brainevent/references/sparse-formats.md` when choosing among CSR,
140
+ Open `skills/package-skills/brainevent/references/sparse-formats.md` when choosing among CSR,
141
141
  CSC, dense, generated, or fixed-degree event representations after topology is
142
142
  defined.
143
143
 
@@ -115,7 +115,7 @@ Do not reconstruct the same sections with comparisons against `t` inside
115
115
  `step`. For a mapped parameter sweep that shares this protocol, keep the
116
116
  per-step current sample unmapped (`in_axes=None`) while mapping the independent
117
117
  condition parameters and dynamical State. Open
118
- `skills/brainstate/references/brainstate/transformation-vmap-expansion.md` for
118
+ `skills/package-skills/brainstate/references/brainstate/transformation-vmap-expansion.md` for
119
119
  the mapped-State contract.
120
120
 
121
121
  ## Basic currents
@@ -0,0 +1,152 @@
1
+ # Braintools metrics
2
+
3
+ Use this reference to select supervised losses and neuroscience metrics for
4
+ classification, regression, spike trains, local field potentials, correlation,
5
+ connectivity, and pairwise comparison. Verify input orientation, units, and
6
+ reduction before treating any returned array as a scalar objective.
7
+
8
+ ## Choose a metric family
9
+
10
+ | Task | Use | Important constraint |
11
+ |---|---|---|
12
+ | Independent binary or multilabel classification | Sigmoid binary cross entropy or focal loss | Logits and labels must have broadcast-compatible class structure. |
13
+ | 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 | Set `reduction` rather than assuming a scalar result. |
15
+ | Spike timing | Victor-Purpura or van Rossum distance | Inputs are spike-time trains, not dense spike matrices. |
16
+ | 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 | Pass the sample interval as `dt`, not sampling frequency as `fs`. |
18
+ | Functional connectivity | Correlation and connectivity functions | Time series use `(num_time, num_signals)`. |
19
+
20
+ ## Classification losses
21
+
22
+ | API | Description |
23
+ |---|---|
24
+ | `sigmoid_binary_cross_entropy(logits, labels)` | Use for independent binary classes; returns element-wise sigmoid cross entropy. |
25
+ | `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. Validate every label yourself. |
27
+ | `hinge_loss(...)` | Use for binary margin classification. |
28
+ | `perceptron_loss(...)` | Use for the binary perceptron objective. |
29
+ | `multiclass_hinge_loss(...)` | Use for a multiclass margin objective. |
30
+ | `multiclass_perceptron_loss(...)` | Use for a multiclass perceptron objective. |
31
+ | `poly_loss_cross_entropy(...)` | Use when the specified method requires PolyLoss cross entropy. |
32
+ | `kl_divergence(...)` | Compare probability distributions. |
33
+ | `kl_divergence_with_log_targets(...)` | Use when predictions and targets are already in log space. |
34
+ | `convex_kl_divergence(...)` | Use when the convex KL variant is required. |
35
+ | `ctc_loss(...)` | Use for sequence alignment without frame-level labels. |
36
+ | `ctc_loss_with_forward_probs(...)` | Use when the CTC forward probabilities are also needed. |
37
+ | `sigmoid_focal_loss(...)` | Use for class imbalance among independent binary targets. |
38
+ | `nll_loss(...)` | Use with log-probability classification outputs. |
39
+
40
+ ```python
41
+ import jax.numpy as jnp
42
+ from braintools.metric import (
43
+ softmax_cross_entropy_with_integer_labels,
44
+ )
45
+
46
+ logits = jnp.array([
47
+ [2.0, 1.0, 0.1],
48
+ [0.5, 2.5, 0.3],
49
+ ])
50
+ labels = jnp.array([0, 1])
51
+
52
+ per_example = softmax_cross_entropy_with_integer_labels(logits, labels)
53
+ loss = jnp.mean(per_example)
54
+ assert loss.ndim == 0
55
+ ```
56
+
57
+ **Critical exception:** JAX gather silently clamps out-of-range integer labels
58
+ in `softmax_cross_entropy_with_integer_labels`. Validate
59
+ `0 <= labels < logits.shape[-1]`; the function does not raise for invalid
60
+ labels.
61
+
62
+ ## Regression and pairwise metrics
63
+
64
+ | API | Description |
65
+ |---|---|
66
+ | `squared_error(predictions, targets=None, axis=None, reduction='none')` | Use for element-wise squared error; choose `mean` or another supported reduction explicitly when a scalar is required. |
67
+ | `absolute_error(...)` | Use for element-wise absolute error. |
68
+ | `l1_loss(...)` | Use for mean absolute-error behavior according to its axis/reduction options. |
69
+ | `l2_loss(...)` | Use for squared L2 loss. |
70
+ | `l2_norm(...)` | Return the L2 norm of prediction error. |
71
+ | `safe_norm(...)` | Use when a differentiable lower bound must prevent an unstable zero norm. |
72
+ | `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. |
73
+ | `log_cosh(...)` | Use for a smooth robust regression loss. |
74
+ | `cosine_similarity(...)` | Compare vector direction. |
75
+ | `cosine_distance(...)` | Return the corresponding cosine distance. |
76
+ | `pairwise_cosine_similarity(X, Y, ...)` | Return all pairwise cosine similarities between sample sets. |
77
+ | `pairwise_cosine_distance(X, Y, ...)` | Return all pairwise cosine distances between sample sets. |
78
+
79
+ Do not conflate element-wise loss with final optimization reduction. Preserve
80
+ batch and time axes until the scientific loss definition determines how to
81
+ reduce them.
82
+
83
+ ## Correlation and functional connectivity
84
+
85
+ | API | Description |
86
+ |---|---|
87
+ | `cross_correlation(spikes, bin, dt)` | Calculate a cross-correlation synchrony index from a time-major spike matrix. |
88
+ | `voltage_fluctuation(voltages)` | Estimate synchrony from population voltage variance. |
89
+ | `matrix_correlation(a, b)` | Correlate upper-triangular entries of two square matrices. |
90
+ | `weighted_correlation(x, y, weights)` | Compute weighted Pearson correlation for two one-dimensional series. |
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)` | Compare sliding-window connectivity matrices to produce functional-connectivity dynamics. |
93
+
94
+ ## Spike-train metrics
95
+
96
+ | API | Description |
97
+ |---|---|
98
+ | `raster_plot(spikes, times)` | Extract neuron indices and spike times from a dense spike matrix; this is a metric/data helper, not the visualization API. |
99
+ | `firing_rate(spikes, width, dt=None)` | Average across neurons and smooth population rate with a rectangular window of physical width. |
100
+ | `victor_purpura_distance(spike_times_1, spike_times_2, cost_factor=1.0)` | Measure edit cost from insertions, deletions, and temporal shifts. |
101
+ | `van_rossum_distance(spike_times_1, spike_times_2, tau=...)` | Compare exponentially filtered spike trains. |
102
+ | `spike_train_synchrony(spikes, window_size, dt=None)` | Compute SPIKE-style synchronization on a population matrix. |
103
+ | `burst_synchrony_index(spikes, dt=None, ...)` | Measure co-occurring burst events. |
104
+ | `phase_locking_value(spikes, reference_freq, dt=None, ...)` | Measure spike phase locking to a reference oscillation. |
105
+ | `spike_time_tiling_coefficient(spikes, dt=None, tau=...)` | Compute STTC within a temporal tolerance. |
106
+ | `correlation_index(spikes, window_size, dt=None)` | Compute a windowed spike-train correlation index. |
107
+
108
+ ```python
109
+ import brainunit as u
110
+ from braintools.metric import firing_rate, spike_train_synchrony
111
+
112
+ # Shape: (num_time, num_neurons)
113
+ rate = firing_rate(spikes, width=10 * u.ms, dt=1 * u.ms)
114
+ synchrony = spike_train_synchrony(
115
+ spikes,
116
+ window_size=5 * u.ms,
117
+ dt=1 * u.ms,
118
+ )
119
+ ```
120
+
121
+ Keep dense spike matrices and lists of spike times distinct. Distance metrics
122
+ consume event times; population rate and synchrony metrics consume matrices.
123
+
124
+ ## Local field potential analysis
125
+
126
+ | API | Description |
127
+ |---|---|
128
+ | `unitary_LFP(times, spikes, neuron_type, seed=None, ...)` | Construct unitary LFP contributions from spikes; use the documented `'exc'` or `'inh'` neuron type. |
129
+ | `power_spectral_density(lfp, dt, nperseg=None, noverlap=None, freq_range=None)` | Return one-sided Welch frequencies and PSD. |
130
+ | `coherence_analysis(signal1, signal2, dt, ...)` | Return frequency-resolved magnitude-squared coherence. |
131
+ | `phase_amplitude_coupling(lfp, dt, phase_freq_range, amplitude_freq_range, ...)` | Return Tort modulation index plus phase-bin details. |
132
+ | `theta_gamma_coupling(lfp, dt, ...)` | Return theta-gamma coupling using standard bands. |
133
+ | `current_source_density(lfp, electrode_spacing, axis=0, ...)` | Estimate laminar CSD along the electrode axis. |
134
+ | `spectral_entropy(lfp, dt, ...)` | Return normalized spectral entropy. |
135
+ | `lfp_phase_coherence(lfp, dt, freq_band, ...)` | Compute pairwise phase coherence across channels. |
136
+
137
+ `power_spectral_density(..., freq_range=...)` uses boolean-mask indexing and
138
+ therefore has a data-dependent output length; that path is not JIT-compatible.
139
+ Compute the full spectrum inside JIT and filter outside when compilation is
140
+ required.
141
+
142
+ ## Structured, ranking, and smoothing losses
143
+
144
+ | API | Description |
145
+ |---|---|
146
+ | `make_fenchel_young_loss(max_fun)` | Build a Fenchel-Young loss. `max_fun` must map one score vector to a scalar because it is vectorized with signature `(n)->()`. |
147
+ | `ranking_softmax_loss(scores, labels, ...)` | Use for list-wise learning-to-rank objectives. |
148
+ | `smooth_labels(labels, alpha=...)` | Apply label smoothing to one-hot targets. |
149
+
150
+ ## Official source
151
+
152
+ - `https://brainx.chaobrain.com/braintools/apis/metric.html`
@@ -0,0 +1,76 @@
1
+ # Validate perturbation experiments before scaling
2
+
3
+ Open this reference when a point-neuron experiment estimates tuning or other
4
+ baseline features and then compares matched control and intervention trials. It
5
+ settles which scientific-validity gates must pass before a full causal mapping
6
+ run and how to calibrate intervention delivery without tuning the requested
7
+ outcome.
8
+
9
+ ## Separate model validity from the tested result
10
+
11
+ Freeze the hypothesis tests only after establishing that the model produces
12
+ observable baseline responses and that the intervention reaches its declared
13
+ target. Use pilot data only for these protocol checks. Do not inspect downstream
14
+ influence signs, distance profiles, feature effects, or other requested outcomes
15
+ while choosing the operating regime or intervention strength.
16
+
17
+ | Gate | Required evidence before a formal run |
18
+ |---|---|
19
+ | Baseline operating regime | Report population and subgroup firing-rate distributions, silent fractions, and trial-count windows; reject a regime whose response statistic is almost always zero or saturated. |
20
+ | Stimulus identifiability | Show that repeated unperturbed trials yield non-degenerate response vectors, adequate reliability or dynamic range, and enough supported preferences or feature values for the planned comparisons. |
21
+ | Analysis support | Construct the exact planned eligibility filters and bins on pilot data; report finite-value, unique-value, bin, target, and effective-cluster counts, and reject empty or tie-dominated contrasts. |
22
+ | Intervention delivery | Measure the paired target-neuron response in the declared dose window and compare it with the stated protocol tolerance or cited benchmark. |
23
+ | Causal pairing | Verify identical initial State and external inputs before intervention onset and zero pre-intervention response mismatches. |
24
+
25
+ Define numerical acceptance rules from the scientific question, cited protocol,
26
+ measurement resolution, and planned estimator before running the pilot. Do not
27
+ invent universal firing-rate or bin-count thresholds. Preserve the rules and all
28
+ failed gate results in the run artifacts.
29
+
30
+ ## Calibrate only the delivered intervention
31
+
32
+ When the stimulus waveform is an implementation proxy for a published
33
+ intervention, select its amplitude using target-neuron dose alone. Use a small,
34
+ predeclared candidate grid or monotone search, run matched pilot trials, and
35
+ choose according to the predeclared dose tolerance. Record every candidate,
36
+ trial count, measured target increment, uncertainty, and selection rule.
37
+
38
+ Do not select amplitude from non-target influence, suppression, feature
39
+ specificity, distance dependence, or any other reproduction outcome. If no
40
+ candidate satisfies the target-dose rule without invalidating the baseline
41
+ regime, classify the protocol as invalid and stop.
42
+
43
+ Generate each pilot's unit-aware waveform once and pass it through the same
44
+ BrainPy-State neuron and projection path used by the formal run. Measure the
45
+ executed spike increment; a requested current or pulse count is not the delivered
46
+ biological dose.
47
+
48
+ ## Freeze and scale
49
+
50
+ After all gates pass, freeze model parameters, randomization rules, target
51
+ selection, intervention, eligibility filters, estimators, uncertainty method,
52
+ and success criteria. Then start a new immutable formal run and allow its result
53
+ to be positive, negative, or inconclusive.
54
+
55
+ Keep the pilot and formal artifacts distinct. A failed pilot is protocol
56
+ development evidence, not a scientific non-reproduction. A completed formal run
57
+ with adequate observability and support may legitimately fail every requested
58
+ hypothesis.
59
+
60
+ Open `skills/package-skills/brainstate/references/paired-perturbation-execution.md` for exact
61
+ State branching, fixed-shape batching, resource gates, and execution-status
62
+ classification. Open `references/braintools/input-current.md` when constructing
63
+ the unit-aware intervention waveform.
64
+
65
+ ## Boundaries and common failures
66
+
67
+ - Treating a successfully executed but nearly silent network as an informative
68
+ null experiment.
69
+ - Estimating preferences by `argmax` when most response vectors are tied at
70
+ zero, then interpreting the tie-broken labels as tuning.
71
+ - Plotting nominal quantile bins without reporting empty bins, tied values, or
72
+ effective target counts.
73
+ - Matching the requested current waveform but failing to measure the added
74
+ target spikes or other delivered dose.
75
+ - Adjusting connectivity or intervention strength after seeing the sign of a
76
+ downstream influence statistic.
@@ -111,7 +111,7 @@ Choose projection alignment before adding a delay. Open `references/brain-dynami
111
111
 
112
112
  ## Communication boundary
113
113
 
114
- Use `brainstate.nn.EventFixedProb` for the canonical probabilistic sparse-spike connection shown in BrainPy-State tutorials. Open `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.
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
115
 
116
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
117
 
@@ -352,6 +352,7 @@ Route by the outcome the task needs, then open only the smallest reference that
352
352
  | `references/state-graph-operations.md` | Splitting, transforming, checkpointing, or reconstructing Module graphs while preserving sharing and cycles |
353
353
  | `references/state_collections_and_utilities.md` | Filtering, freezing, flattening, configuring, or inspecting supporting mappings without graph identity |
354
354
  | `references/collective_model_operations.md` | Initializing, resetting, restoring, or invoking methods across a Module graph, including vmapped lifecycle operations |
355
+ | `references/paired-perturbation-execution.md` | Running matched baseline-perturbation simulations with exact causal branching, fixed-shape chunks, progressive resource gates, and explicit execution-versus-science outcome classification |
355
356
 
356
357
  ### Simulation environment
357
358
 
@@ -1,6 +1,6 @@
1
1
  # BrainState transformed diagnostics
2
2
 
3
- Use this reference after `skills/brainstate/SKILL.md` when runtime values, State
3
+ Use this reference after `skills/package-skills/brainstate/SKILL.md` when runtime values, State
4
4
  updates, or failures must be inspected from transformed BrainState code. The
5
5
  skill owns the core transformation model; this reference only adds diagnostics
6
6
  that execute after tracing or turn value-dependent failures into data or
@@ -1,6 +1,6 @@
1
1
  # BrainState constrained and regularized parameters
2
2
 
3
- Use this reference after `skills/brainstate/SKILL.md` has selected
3
+ Use this reference after `skills/package-skills/brainstate/SKILL.md` has selected
4
4
  `brainstate.nn.Param` for a value that needs a valid-domain transform, a
5
5
  regularization penalty, a modeling prior, or fixed parameter-like storage. It
6
6
  owns the operational workflow and common patterns. Open