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
@@ -0,0 +1,141 @@
1
+ # Neural data visualization
2
+
3
+ ## Purpose and boundary
4
+
5
+ Use this reference for general neural events, activity, connectivity, low-dimensional dynamics, stimulus response, topology, and spatial 3D data. Preserve the active BrainX package's variable meanings, units, ordering, and recording interval.
6
+
7
+ Route BrainCell morphology, compartments, runtime nodes, selector placement, or mechanism values directly to `skills/package-skills/braincell/references/multicompartment/topology-building-and-visualization.md`. Route BrainMass-owned trajectories, phase portraits, connectivity, FC/FCD, or spectra directly to `skills/package-skills/brainmass/references/visualization-analysis-api.md`.
8
+
9
+ ## Choose the neural family
10
+
11
+ Select the figure from the data contract and question, not from visual familiarity.
12
+
13
+ | Data contract or question | Use | Preserve |
14
+ |---|---|---|
15
+ | Selected time-series columns aligned to timestamps | `line_plot(ts, val_matrix, ...)` | Time-major orientation, selected column identities, timestamps, and units. |
16
+ | Flat spike times plus matching neuron IDs, or one spike-time sequence per neuron | `spike_raster(...)` | Event times, neuron identity, filtering ranges, and time unit. |
17
+ | Dense `(time, neuron)` binary or event matrix with timestamps | `raster_plot(ts, sp_matrix, ...)` | Time-major orientation and exact timestamp vector. |
18
+ | Time-major neural activity or an aggregate rate | `population_activity(...)` | Recorded interval, aggregation method, window, and selected neurons. |
19
+ | Spike timing distribution | `isi_distribution(...)` or `spike_histogram(...)` | Whether the quantity is inter-spike interval or event count per time bin. |
20
+ | Spatial firing | `firing_rate_map(...)` | Position-to-rate mapping, grid geometry, interpolation, and rate unit. |
21
+ | Directed weights | `connectivity_matrix(...)` | Rows as presynaptic sources, columns as postsynaptic targets, labels, and normalization. |
22
+ | State evolution | `neural_trajectory(...)` or `phase_portrait(...)` | Time-major samples, selected coordinates, transient rule, and direction of time. |
23
+ | Structural relationships | `network_topology(...)` | Adjacency direction, layout meaning, and declared node or edge encodings. |
24
+ | Ordered stimulus and response | `tuning_curve(...)` | Stimulus order and unit, response unit, repeats, error meaning, and fit family. |
25
+ | Physical depth, mesh, volume, or three-coordinate geometry | Matching 3D helper | Coordinates, camera, thresholds, color normalization, and comparison view. |
26
+
27
+ Do not convert flat events to a dense matrix merely to plot them. Do not use 3D when a 2D projection answers the same question without occlusion.
28
+
29
+ ## Visualize spikes and population activity
30
+
31
+ Spike helpers preserve either event-list or dense-matrix representations; population helpers reduce only along the declared neuron axis.
32
+
33
+ | API | Description |
34
+ |---|---|
35
+ | `line_plot(ts, val_matrix, plot_ids=None, ...)` | Use for selected columns of a time-by-value matrix aligned to `ts`. Preserve the meaning and unit of every selected column. |
36
+ | `spike_raster(spike_times, neuron_ids=None, ...)` | Use for flat event arrays with equal lengths or a sequence of per-neuron spike trains. Filter with explicit time or neuron ranges and receive a Matplotlib axes. |
37
+ | `raster_plot(ts, sp_matrix, ...)` | Use for dense `(time, neuron)` spikes aligned to `ts`. Do not pass flat spike-time events. |
38
+ | `population_activity(data, time=None, dt=None, method='mean', window_size=None, ...)` | Use for `(time, neurons)` activity or a one-dimensional aggregate. Prefer the recorded `time`; use `dt` only when it is the actual recorded interval. |
39
+ | `isi_distribution(spike_times, bins=50, max_isi=None, log_scale=False, ...)` | Use for sorted spike times or a list of sorted per-neuron spike-time arrays; it computes successive intervals. Use a per-neuron list to avoid intervals across neuron boundaries, and enable log scale when bin counts span orders of magnitude. |
40
+ | `spike_histogram(spike_times, bins=50, bin_size=None, density=False, ...)` | Use for event counts or density across time. Treat bin count or `bin_size` as a declared temporal-resolution choice. |
41
+ | `firing_rate_map(rates, positions=None, grid_size=None, interpolation='bilinear', ...)` | Use for position-rate pairs or an already shaped map. Declare interpolation and do not imply unsampled spatial resolution. |
42
+
43
+ ```python
44
+ import matplotlib.pyplot as plt
45
+ import braintools.visualize as btvis
46
+
47
+
48
+ assert spike_times.shape == neuron_ids.shape
49
+ assert activity.shape[0] == time.size
50
+
51
+ fig, axes = plt.subplots(2, 1, figsize=(7, 5), sharex=True)
52
+ btvis.spike_raster(spike_times, neuron_ids, ax=axes[0])
53
+ btvis.population_activity(activity, time=time, ax=axes[1])
54
+ axes[0].set_ylabel("neuron index")
55
+ axes[1].set(xlabel="time (ms)", ylabel="mean activity")
56
+ fig.tight_layout()
57
+ ```
58
+
59
+ Compare the raster and population trace against raw event counts in at least one known window. When smoothing population activity, retain the unsmoothed series and record the window or kernel.
60
+
61
+ ## Visualize connectivity and dynamics
62
+
63
+ Matrix, trajectory, topology, and tuning figures answer different questions even when derived from the same model.
64
+
65
+ | API | Description |
66
+ |---|---|
67
+ | `connectivity_matrix(weights, pre_labels=None, post_labels=None, center_zero=True, ...)` | Use for source-by-target weights. Center a diverging colormap at zero only when zero is the meaningful neutral value; keep one normalization across comparisons. |
68
+ | `neural_trajectory(data, dims=None, time_color=True, ...)` | Use for `(time, features)` trajectories in two or three selected coordinates. Time coloring and start/end markers expose direction. |
69
+ | `phase_portrait(x, y=None, dx=None, dy=None, trajectory=True, vector_field=False, ...)` | Use for a two-variable trajectory, vector field, or both. Match vector-field and trajectory coordinates, scales, and units. |
70
+ | `network_topology(adjacency, positions=None, layout='spring', ...)` | Use for graph structure. Choose a layout for a declared structural question and state what node size, node color, edge width, and edge color encode. |
71
+ | `tuning_curve(stimulus, response, bins=20, error_bars=True, fit_curve=None, ...)` | Use for response versus ordered stimulus. Use error bars only when repeats define their statistic and use a fit only when its family is scientifically justified. |
72
+
73
+ ```python
74
+ import matplotlib.pyplot as plt
75
+ import braintools.visualize as btvis
76
+
77
+
78
+ assert trajectory.ndim == 2 # (time, features)
79
+ fig, axes = plt.subplots(1, 2, figsize=(8, 3.5))
80
+ btvis.neural_trajectory(trajectory, dims=(0, 1), time_color=True, ax=axes[0])
81
+ btvis.phase_portrait(trajectory[:, :2], trajectory=True, ax=axes[1])
82
+ axes[0].set(xlabel="state 1", ylabel="state 2")
83
+ axes[1].set(xlabel="state 1", ylabel="state 2")
84
+ fig.tight_layout()
85
+ ```
86
+
87
+ For repeated conditions, keep coordinates, transient removal, start/end encoding, scales, matrix ordering, network positions, and tuning-curve bins fixed. A force-directed layout is not a biological coordinate system.
88
+
89
+ ## Use 3D only for geometric evidence
90
+
91
+ Three-dimensional views are justified when depth, surfaces, volumes, electrodes, or three-coordinate trajectories are part of the question.
92
+
93
+ | API | Description |
94
+ |---|---|
95
+ | `neural_network_3d(layer_sizes, weights=None, activations=None, ...)` | Use for layered architecture and optional weights or activations, not anatomical morphology. |
96
+ | `brain_surface_3d(vertices, faces, values=None, ...)` | Use for a triangular surface mesh and optional vertex values. Validate vertex-face indexing and value alignment. |
97
+ | `connectivity_3d(source_positions, target_positions, connections, ...)` | Use for connections between two 3D point sets. Declare thresholding and edge-strength encoding. |
98
+ | `trajectory_3d(trajectory, time_colors=True, ...)` | Use for `(time, 3)` trajectories. Preserve direction with time color or start/end markers. |
99
+ | `volume_rendering(volume, threshold=None, ...)` | Use for a 3D scalar volume. Declare voxel geometry, threshold, alpha, and normalization. |
100
+ | `electrode_array_3d(electrode_positions, signals=None, ...)` | Use for electrode coordinates and optional aligned signals. Preserve coordinate frame and signal scaling. |
101
+ | `dendrite_tree_3d(segments, diameters=None, ...)` | Use only for generic segment geometry. Use the BrainCell route when segments represent BrainCell morphology or runtime nodes. |
102
+ | `phase_space_3d(x, y, z, time_colors=True, ...)` | Use for three declared dynamical variables. Keep their coordinate meanings and scales explicit. |
103
+
104
+ ```python
105
+ import matplotlib.pyplot as plt
106
+ import braintools.visualize as btvis
107
+
108
+
109
+ assert trajectory_xyz.shape[1] == 3
110
+ fig = plt.figure(figsize=(6, 5))
111
+ ax = fig.add_subplot(111, projection="3d")
112
+ btvis.trajectory_3d(trajectory_xyz, time_colors=True, ax=ax)
113
+ ax.set(xlabel="state 1", ylabel="state 2", zlabel="state 3")
114
+ ```
115
+
116
+ Fix the camera, axis limits, coordinate scaling, threshold, transparency, and color normalization before comparing conditions. Supply a 2D projection when occlusion could hide the relevant structure.
117
+
118
+ ## Preserve comparison integrity
119
+
120
+ - Keep time bases, units, neuron and region order, matrix orientation, bins, smoothing, and aggregation fixed across comparable panels.
121
+ - Show raw observations when feasible. Do not let a smoothed population curve, fitted tuning curve, or topology layout stand in for the underlying data.
122
+ - Use a sequential colormap for nonnegative magnitude, a diverging colormap around a meaningful neutral value, and a cyclic colormap for phase.
123
+ - Label every colorbar with the encoded quantity and unit. State the meaning of node, edge, marker, and line encodings.
124
+ - Subsample dense trajectories or edges only by a declared rule. Preserve full data for numerical checks.
125
+ - Verify known events, extrema, connection directions, and start/end states against the source arrays.
126
+
127
+ ## Common failures
128
+
129
+ - Time and neuron axes are swapped because shape was treated as meaning.
130
+ - Simulation `dt` is used after monitor subsampling changed the recording interval.
131
+ - Connectivity rows and columns are reversed, or matrices use different orderings across conditions.
132
+ - A diverging colormap is centered at zero when zero has no scientific role.
133
+ - Raster bins, smoothing windows, tuning bins, network layouts, or 3D thresholds change across a comparison.
134
+ - Network positions, trajectory coordinates, or interpolated maps imply biological geometry that the data do not contain.
135
+ - A generic dendrite view duplicates BrainCell-owned morphology visualization.
136
+
137
+ ## Tutorial sources
138
+
139
+ - [Neural data visualization](https://brainx.chaobrain.com/braintools/visualize/01_neural_data_visualization.html)
140
+ - [Advanced neural plots](https://brainx.chaobrain.com/braintools/visualize/02_advanced_neural_plots.html)
141
+ - [3D visualization](https://brainx.chaobrain.com/braintools/visualize/06_3d_visualization.html)
@@ -0,0 +1,133 @@
1
+ # Statistical and model visualization
2
+
3
+ ## Purpose and boundary
4
+
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
+
7
+ Route BrainMass-owned FC/FCD, spectral, or dynamical summaries to `skills/package-skills/brainmass/references/visualization-analysis-api.md` before plotting them here.
8
+
9
+ ## Choose the statistical family
10
+
11
+ Inspect distributions and assumptions before selecting a test or reporting a model score.
12
+
13
+ | Question | Use | Required context |
14
+ |---|---|---|
15
+ | What is the shape, spread, or tail behavior? | `distribution_plot(...)` | Sampling unit, `n`, binning or density settings, exclusions, and units. |
16
+ | Is a theoretical distribution plausible? | `qq_plot(...)` | Named reference distribution and whether deviations matter to the planned inference. |
17
+ | How do groups differ? | `box_plot(...)` or `violin_plot(...)` plus raw observations | Independent or paired structure, group sizes, center, spread, uncertainty, and effect size. |
18
+ | Which variables associate? | `correlation_matrix(...)` or `scatter_matrix(...)` | Variable orientation, method, missing-data rule, ordering, and multiple-comparison plan. |
19
+ | Is a relationship fitted adequately? | `regression_plot(...)` plus `residual_plot(...)` | Model family, train/held-out split, confidence meaning, residual definition, and units. |
20
+ | Which classification errors occur? | `confusion_matrix(...)` | Class order, counts versus normalization, prevalence, and decision threshold. |
21
+ | How does a binary ranker perform by threshold? | `roc_curve(...)` or `precision_recall_curve(...)` | Positive class, score direction, prevalence, operating costs, and held-out predictions. |
22
+ | Is performance data-limited, high-variance, or biased? | `learning_curve(...)` | Train sizes or steps, fold dimension, scoring metric, and held-out protocol. |
23
+
24
+ Do not infer causality from correlation. Do not use statistical significance as a substitute for effect size or practical importance.
25
+
26
+ ## Inspect distributions and groups
27
+
28
+ Distribution and group figures expose data shape and sampling structure; show raw observations when feasible.
29
+
30
+ | API | Description |
31
+ |---|---|
32
+ | `distribution_plot(data, labels=None, plot_type='hist', bins=30, density=True, fit_normal=False, ...)` | Use for one or more distributions. Choose histogram, density, or both deliberately; treat binning and density estimation as declared transformations. |
33
+ | `qq_plot(data, distribution='norm', ...)` | Use to compare empirical and theoretical quantiles. Interpret systematic deviations, not visual proximity alone. |
34
+ | `box_plot(data, labels=None, showmeans=True, ...)` | Use for robust grouped summaries. Overlay raw observations when their count permits and state whether groups are paired. |
35
+ | `violin_plot(data, labels=None, showmeans=True, showmedians=True, ...)` | Use when distribution shape matters and sample size supports density estimation. Do not imply precision from a small-sample violin. |
36
+
37
+ ```python
38
+ import matplotlib.pyplot as plt
39
+ import braintools.visualize as btvis
40
+
41
+
42
+ fig, axes = plt.subplots(1, 2, figsize=(7, 3.2))
43
+ btvis.distribution_plot(residuals, plot_type="hist", bins=30, ax=axes[0])
44
+ btvis.qq_plot(residuals, distribution="norm", ax=axes[1])
45
+ axes[0].set_xlabel("residual (mV)")
46
+ fig.tight_layout()
47
+ ```
48
+
49
+ Report the sampling unit, `n`, center, spread, uncertainty definition, and effect size beside the plot. Correct multiple comparisons and preserve paired observations rather than plotting paired data as independent groups.
50
+
51
+ ## Inspect association and regression
52
+
53
+ Association plots reveal structure; residual plots test whether a fitted relationship leaves systematic error.
54
+
55
+ | API | Description |
56
+ |---|---|
57
+ | `correlation_matrix(data, labels=None, method='pearson', ...)` | Use for pairwise associations with `(observations, variables)` data. Align labels to the variable axis and keep their order fixed. |
58
+ | `scatter_matrix(data, labels=None, diagonal='hist', ...)` | Use for pairwise multivariate inspection with ordinary `(observations, variables)` data. It returns a Matplotlib figure; reduce variables or sample density when unreadable. |
59
+ | `regression_plot(x, y, fit_line=True, confidence_interval=True, ...)` | Use for observations and an optional linear fit. A confidence band is not a prediction interval and the helper does not justify the model family. |
60
+ | `residual_plot(y_true, y_pred, ...)` | Use for aligned truth and prediction arrays. It computes residuals against predictions; preserve target units and observation order. |
61
+
62
+ ```python
63
+ import matplotlib.pyplot as plt
64
+ import braintools.visualize as btvis
65
+
66
+
67
+ assert y_true.shape == y_pred.shape
68
+ limits = [min(y_true.min(), y_pred.min()), max(y_true.max(), y_pred.max())]
69
+ fig, axes = plt.subplots(1, 2, figsize=(7, 3.2))
70
+ axes[0].scatter(y_true, y_pred, alpha=0.6)
71
+ axes[0].plot(limits, limits, "k--", linewidth=1)
72
+ btvis.residual_plot(y_true, y_pred, ax=axes[1])
73
+ axes[0].set(xlabel="observed (Hz)", ylabel="predicted (Hz)")
74
+ fig.tight_layout()
75
+ ```
76
+
77
+ Inspect residual center, trend, changing spread, tails, and outliers. Keep train and held-out residuals separate. Use a 1:1 line for observed-versus-predicted comparisons; a fitted regression line answers a different question.
78
+
79
+ ## Evaluate classification and learning
80
+
81
+ Model-evaluation figures consume held-out labels, scores, predictions, or fold-wise learning results; never substitute training predictions unless the figure is explicitly diagnostic.
82
+
83
+ | API | Description |
84
+ |---|---|
85
+ | `confusion_matrix(y_true, y_pred, labels=None, normalize=None, ...)` | Use counts for workload and error totals. Use `normalize='true'` for per-true-class recall proportions or `normalize='pred'` for per-predicted-class composition; state the normalization. |
86
+ | `roc_curve(y_true, y_scores, ...)` | Use for binary ranking behavior across thresholds when both classes and ranking tradeoffs are meaningful. ROC can look optimistic under severe imbalance. |
87
+ | `precision_recall_curve(y_true, y_scores, ...)` | Prefer for imbalanced positive-class evaluation or when positive predictions and recall drive the decision. State positive-class prevalence. |
88
+ | `learning_curve(train_sizes, train_scores, validation_scores, ...)` | Use for train and validation score arrays across declared sizes or steps. Preserve fold or repeat dimensions so spread is visible. |
89
+
90
+ ```python
91
+ import matplotlib.pyplot as plt
92
+ import braintools.visualize as btvis
93
+
94
+
95
+ fig, axes = plt.subplots(1, 3, figsize=(10, 3.2))
96
+ btvis.confusion_matrix(y_test, y_pred, normalize="true", ax=axes[0])
97
+ btvis.roc_curve(y_test, y_score, ax=axes[1])
98
+ btvis.precision_recall_curve(y_test, y_score, ax=axes[2])
99
+ fig.tight_layout()
100
+ ```
101
+
102
+ Fix the positive class, score direction, decision threshold, class order, and evaluation cohort before comparing models. Use cross-validation score distributions and paired comparisons rather than presenting one split or one scalar score as definitive.
103
+
104
+ A persistent train-validation gap suggests variance or leakage and requires protocol inspection. Low converged train and validation performance suggests bias, weak features, or an unsuitable metric. A learning curve diagnoses patterns; it does not identify the cause by itself.
105
+
106
+ ## Preserve statistical integrity
107
+
108
+ - Display raw observations when feasible and state `n` for every group or condition.
109
+ - Report effect sizes and confidence intervals with exact definitions. Distinguish practical from statistical significance.
110
+ - Correct multiple comparisons and state the correction family. Do not decorate uncorrected pairwise results as discoveries.
111
+ - Preserve paired, repeated-measures, nested, and cross-validation structure in both analysis and display.
112
+ - Keep axes honest. Use a truncated axis only when necessary, conspicuous, and unable to reverse the visual conclusion.
113
+ - Use the same scales, bins, ordering, metric definitions, and encodings across model or condition comparisons.
114
+ - Separate exploratory, training, validation, and held-out test evidence. Record preprocessing and threshold selection provenance.
115
+ - Treat correlation, feature importance, and fitted association as descriptive unless the design supports a causal claim.
116
+
117
+ ## Common failures
118
+
119
+ - A mean and error bar hide the raw distribution, group size, or failed runs.
120
+ - Density or violin shape is overinterpreted for a small sample.
121
+ - Paired or nested observations are plotted and tested as independent.
122
+ - Correlation variables or labels use the wrong axis, or correlation is called connectivity or causality.
123
+ - A nonlinear relationship is summarized with an unjustified linear fit.
124
+ - Residuals are inspected only in aggregate, hiding bias or heteroscedasticity.
125
+ - ROC is selected for a highly imbalanced task without a precision-recall view or prevalence context.
126
+ - Confusion matrices use inconsistent class order or undisclosed normalization.
127
+ - Model comparison uses one score, one split, or tuned test-set thresholds.
128
+ - Axis truncation, changing bins, or inconsistent scales exaggerate differences.
129
+
130
+ ## Tutorial sources
131
+
132
+ - [Statistical visualization](https://brainx.chaobrain.com/braintools/visualize/03_statistical_visualization.html)
133
+ - [Model evaluation plots](https://brainx.chaobrain.com/braintools/visualize/04_model_evaluation_plots.html)
@@ -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
- Keep network wiring, projections, and network training outside this skill. Open `skills/brainpy-state/SKILL.md` when multiple cells must communicate.
16
+ Keep network wiring, projections, and network training outside this skill. Open `skills/package-skills/brainpy-state/SKILL.md` when multiple cells must communicate.
17
17
 
18
18
  ## Underlying principle of BrainCell
19
19
 
@@ -52,11 +52,13 @@ A `SingleCompartment` cell stores one membrane voltage per independent neuron an
52
52
  | `braincell.channel.*` | Use for membrane-current and gating dynamics; inspect `root_type` before attachment, and attach root-cell channels such as `IL` directly to the cell. |
53
53
  | `cell.init_state()` / `cell.reset_state()` | Use before the first step or to reseed an existing cell; they initialize or reset voltage, spike, ion, and channel State without changing the model declaration. |
54
54
  | `cell.update(I_ext)` | Use for one integration step; pass a current-density or total-current `Quantity`, let the cell area normalize total current, update all cellular State, and receive the spike output. |
55
+ | `braintools.input.Constant(...)` | Use when a current-clamp protocol contains timed baseline and stimulation sections; generate one unit-aware time-major sample per step under the rollout `dt`. |
55
56
  | `brainstate.environ.context()` / `brainstate.transform.for_loop()` | Use to provide `dt` and `t` and to execute a transformed time loop that returns recorded State instead of mutating Python containers. |
56
57
 
57
58
  ```python
58
59
  import braincell
59
60
  import brainstate
61
+ import braintools
60
62
  import brainunit as u
61
63
 
62
64
 
@@ -79,22 +81,27 @@ class HH(braincell.SingleCompartment):
79
81
 
80
82
  cell = HH(1)
81
83
  cell.init_state()
82
- current = 5.0 * u.uA / u.cm**2
83
84
 
84
85
 
85
- def step(t):
86
+ def step(t, current):
86
87
  with brainstate.environ.context(t=t):
87
88
  spike = cell.update(current)
88
89
  return cell.V.value, spike
89
90
 
90
91
 
91
92
  with brainstate.environ.context(dt=0.01 * u.ms):
93
+ protocol = braintools.input.Constant([
94
+ (0.0 * u.uA / u.cm**2, 20.0 * u.ms),
95
+ (5.0 * u.uA / u.cm**2, 60.0 * u.ms),
96
+ (0.0 * u.uA / u.cm**2, 20.0 * u.ms),
97
+ ])
98
+ current = protocol()
92
99
  times = u.math.arange(
93
100
  0.0 * u.ms,
94
- 100.0 * u.ms,
101
+ protocol.duration,
95
102
  brainstate.environ.get_dt(),
96
103
  )
97
- voltages, spikes = brainstate.transform.for_loop(step, times)
104
+ voltages, spikes = brainstate.transform.for_loop(step, times, current)
98
105
 
99
106
  assert voltages.shape[:1] == times.shape
100
107
  assert spikes.shape[:1] == times.shape
@@ -102,7 +109,7 @@ assert spikes.shape[:1] == times.shape
102
109
 
103
110
  Treat `V_th` only as the spike-event threshold; it does not change the membrane equation. Keep membrane capacitance and channel conductance density-based in the canonical path. `update()` accepts current density or total current and uses `SingleCompartment.area` to normalize total input; do not manually area-scale only part of the model. Use `size=N` for `N` independent cells, never for `N` compartments. For a multidimensional condition sweep, use the condition-grid shape as `size` and pass shape-aligned channel parameters and inputs; do not wrap identity functions in `vmap` merely to construct that grid.
104
111
 
105
- Open `references/area-scaled-hh-pattern.md` when changing cell geometry or explicitly converting density parameters to total quantities. Open `references/ion-library.md`, `references/channel-library.md`, or `references/mixions-for-adaptation.md` only when the classical fixed-ion HH path is insufficient.
112
+ Open `references/braintools/input-current.md` when generating timed sections, pulses, waveforms, or stochastic injected current. Open `references/area-scaled-hh-pattern.md` when changing cell geometry or explicitly converting density parameters to total quantities. Open `references/ion-library.md`, `references/channel-library.md`, or `references/mixions-for-adaptation.md` only when the classical fixed-ion HH path is insufficient.
106
113
 
107
114
  ## Build and run a multicompartment cell
108
115
 
@@ -175,7 +182,11 @@ Open only the smallest reference that owns the non-canonical decision.
175
182
  |---|---|
176
183
  | `references/area-scaled-hh-pattern.md` | Changing single-compartment geometry or converting density parameters consistently to total capacitance and conductance. |
177
184
  | `references/braincell-custom-ion-channel-authoring.md` | Implementing a custom ion or channel after confirming that no built-in mechanism fits. |
185
+ | `references/braintools/input-current.md` | Generating or composing unit-aware current sections, pulses, waveforms, or stochastic stimulation for a cellular rollout. |
186
+ | `references/braintools/metric.md` | Selecting standard waveform losses or neuroscience metrics for cellular fitting or trace evaluation; keep custom observation features separate. |
187
+ | `references/braintools/optimizer.md` | Selecting a gradient optimizer or a standalone SciPy or Nevergrad fitting boundary after the objective and reset lifecycle are fixed. |
178
188
  | `references/channel-library.md` | Selecting a built-in sodium, potassium, calcium, leak, HCN, or mixed-ion channel. |
189
+ | `references/scripts/fitting_hh_neuron.py` | Studying the official complete HH fitting composition: custom sodium and potassium channels, trace loading, unit-bearing bounds, independent cell initialization, time-major rollout, voltage loss, candidate `vmap`, and Nevergrad. Also open the three local `references/braintools/` files before adapting it; supply the upstream trace CSVs and reconcile its source-version APIs with the current BrainCell and BrainState skills. |
179
190
  | `references/ion-library.md` | Choosing fixed, Nernst-initialized, or dynamic ions and their concentration behavior. |
180
191
  | `references/mixions-for-adaptation.md` | Adding calcium-dependent adaptation, AHP/KCa currents, rebound, dynamic calcium, or multi-ion channel dependencies. |
181
192
  | `references/multicompartment/multicompartment-cell-workflow.md` | Extending the canonical `Morphology -> Cell -> paint/place -> run` path and selecting the exclusive multicompartment references. |
@@ -0,0 +1,200 @@
1
+ # Braintools input currents
2
+
3
+ Use this reference to generate unit-aware stimulation currents, waveforms,
4
+ pulses, and stochastic processes. Prefer the composable class API when a
5
+ protocol combines, transforms, repeats, or sequences several signals; use the
6
+ functional API for one direct array.
7
+
8
+ ## Choose an interface
9
+
10
+ | Interface | Use when | Result |
11
+ |---|---|---|
12
+ | Composable classes | The protocol needs algebra, clipping, smoothing, time shifts, repetition, overlays, or concatenation | Returns an `Input` object; call it to generate the array. |
13
+ | Functional helpers | One signal can be generated in a single call | Returns the generated array immediately. |
14
+
15
+ Names ending in `Input` or `_input` are deprecated aliases. Use the class and
16
+ function names documented below.
17
+
18
+ ## Time-step and composition model
19
+
20
+ An `Input` stores a duration and reads its time step from
21
+ `brainstate.environ`. Calling it generates a cached array; pass
22
+ `recompute=True` when the stochastic or environmental inputs must be evaluated
23
+ again.
24
+
25
+ | API | Description |
26
+ |---|---|
27
+ | `Input(duration)` | Base class for composable currents. It exposes `duration`, `dt`, `n_steps`, and `shape`. |
28
+ | `input_obj(recompute=False)` | Generate and return the current array. |
29
+ | `input_obj.scale(factor)` | Multiply all values by a factor. |
30
+ | `input_obj.shift(time_shift)` | Delay or advance the signal in time. |
31
+ | `input_obj.clip(min_val, max_val)` | Bound the signal values. |
32
+ | `input_obj.smooth(tau)` | Apply exponential smoothing. |
33
+ | `input_obj.repeat(n_times)` | Repeat the pattern. |
34
+ | `input_obj.apply(func)` | Apply a custom transformation to the generated values. |
35
+ | `a + b`, `a - b`, `a * b`, `a / b`, `-a` | Combine compatible signals pointwise. |
36
+ | `a & b` | Concatenate signals sequentially in time. |
37
+ | `a \| b` | Overlay signals by taking their pointwise maximum. |
38
+
39
+ ```python
40
+ import brainstate
41
+ import brainunit as u
42
+ from braintools.input import Constant, Ramp, Sinusoidal
43
+
44
+ with brainstate.environ.context(dt=0.1 * u.ms):
45
+ baseline = Constant([(0.2 * u.nA, 500 * u.ms)])
46
+ ramp = Ramp(0 * u.nA, 1 * u.nA, 500 * u.ms)
47
+ oscillation = Sinusoidal(
48
+ amplitude=0.5 * u.nA,
49
+ frequency=10 * u.Hz,
50
+ duration=500 * u.ms,
51
+ )
52
+ protocol = (baseline + ramp + 0.5 * oscillation).clip(
53
+ 0 * u.nA,
54
+ 2 * u.nA,
55
+ )
56
+ current = protocol()
57
+ assert current.shape[0] == protocol.n_steps
58
+ ```
59
+
60
+ **Invariant:** set or scope `brainstate.environ.dt` before constructing and
61
+ generating the protocol. A different `dt` changes the number of samples.
62
+
63
+ ## Feed a protocol into a BrainCell rollout
64
+
65
+ A generated protocol is time-major data: construct it under the rollout `dt`,
66
+ then give it to `for_loop` so one current sample reaches each cell step.
67
+
68
+ | API | Description |
69
+ |---|---|
70
+ | `Constant([(value, duration), ...])` | Use for a baseline-pulse-baseline protocol; calling it under the active `dt` returns one unit-aware sample per step. |
71
+ | `brainstate.transform.for_loop(step, times, current)` | Slice `times` and `current` together along their leading axes and stack the step outputs. |
72
+
73
+ ```python
74
+ import braincell
75
+ import brainstate
76
+ import braintools
77
+ import brainunit as u
78
+
79
+
80
+ class PassiveCell(braincell.SingleCompartment):
81
+ def __init__(self, size):
82
+ super().__init__(size)
83
+ self.IL = braincell.channel.IL(
84
+ size,
85
+ E=-65.0 * u.mV,
86
+ g_max=0.03 * u.mS / u.cm**2,
87
+ )
88
+
89
+
90
+ with brainstate.environ.context(dt=0.1 * u.ms):
91
+ cell = PassiveCell(1)
92
+ cell.init_state()
93
+ protocol = braintools.input.Constant([
94
+ (0.0 * u.uA / u.cm**2, 20.0 * u.ms),
95
+ (5.0 * u.uA / u.cm**2, 60.0 * u.ms),
96
+ (0.0 * u.uA / u.cm**2, 20.0 * u.ms),
97
+ ])
98
+ current = protocol()
99
+ times = u.math.arange(
100
+ 0.0 * u.ms,
101
+ protocol.duration,
102
+ brainstate.environ.get_dt(),
103
+ )
104
+
105
+ def step(t, injected_current):
106
+ with brainstate.environ.context(t=t):
107
+ cell.update(injected_current)
108
+ return cell.V.value
109
+
110
+ voltages = brainstate.transform.for_loop(step, times, current)
111
+
112
+ assert voltages.shape == (1000, 1)
113
+ ```
114
+
115
+ Do not reconstruct the same sections with comparisons against `t` inside
116
+ `step`. For a mapped parameter sweep that shares this protocol, keep the
117
+ per-step current sample unmapped (`in_axes=None`) while mapping the independent
118
+ condition parameters and dynamical State. Open
119
+ `skills/package-skills/brainstate/references/brainstate/transformation-vmap-expansion.md` for
120
+ the mapped-State contract.
121
+
122
+ ## Basic currents
123
+
124
+ | Composable API | Functional API | Use |
125
+ |---|---|---|
126
+ | `Section(values, durations)` | `section(values, durations, return_length=False)` | Build consecutive constant sections from parallel value and duration sequences. |
127
+ | `Constant(I_and_duration)` | `constant(I_and_duration)` | Build piecewise-constant sections from `(value, duration)` pairs. |
128
+ | `Step(amplitudes, step_times, duration=None)` | `step(amplitudes, step_times, duration=None)` | Change among discrete levels at specified times. |
129
+ | `Ramp(c_start, c_end, duration, t_start=None, t_end=None)` | `ramp(c_start, c_end, duration, t_start=None, t_end=None)` | Interpolate linearly, optionally only within a subinterval. |
130
+
131
+ `Constant` takes a sequence of pairs:
132
+
133
+ ```python
134
+ from braintools.input import Constant
135
+
136
+ protocol = Constant([
137
+ (0.0 * u.nA, 100 * u.ms),
138
+ (1.0 * u.nA, 200 * u.ms),
139
+ (0.0 * u.nA, 100 * u.ms),
140
+ ])
141
+ ```
142
+
143
+ Use `Section(values=[...], durations=[...])` when separate arrays are more
144
+ convenient.
145
+
146
+ ## Pulse generators
147
+
148
+ | Composable API | Functional API | Use |
149
+ |---|---|---|
150
+ | `Spike(sp_times, duration, sp_lens=..., sp_sizes=...)` | `spike(sp_times, sp_lens, sp_sizes, duration)` | Place short current spikes at explicit times. |
151
+ | `GaussianPulse(amplitude, center, sigma, duration)` | `gaussian_pulse(amplitude, center, sigma, duration, ...)` | Generate a Gaussian-shaped pulse. |
152
+ | `ExponentialDecay(amplitude, tau, duration, ...)` | `exponential_decay(amplitude, tau, duration, ...)` | Generate a one-sided exponential decay. |
153
+ | `DoubleExponential(amplitude, tau_rise, tau_decay, ...)` | `double_exponential(amplitude, tau_rise, tau_decay, ...)` | Generate a rise-and-decay synaptic-current shape. |
154
+ | `Burst(...)` | `burst(...)` | Generate repeated pulses within one or more bursts. |
155
+
156
+ ## Waveforms
157
+
158
+ | Composable API | Functional API | Use |
159
+ |---|---|---|
160
+ | `Sinusoidal(amplitude, frequency, duration, ...)` | `sinusoidal(amplitude, frequency, duration, ...)` | Generate a fixed-frequency sine wave. |
161
+ | `Square(amplitude, frequency, duration, ...)` | `square(amplitude, frequency, duration, ...)` | Generate a square wave; configure its duty cycle deliberately. |
162
+ | `Triangular(amplitude, frequency, duration, ...)` | `triangular(amplitude, frequency, duration, ...)` | Generate a triangular periodic wave. |
163
+ | `Sawtooth(amplitude, frequency, duration, ...)` | `sawtooth(amplitude, frequency, duration, ...)` | Generate a sawtooth periodic wave. |
164
+ | `Chirp(amplitude, f_start, f_end, duration, ...)` | `chirp(amplitude, f_start, f_end, duration, ...)` | Sweep frequency over time. |
165
+ | `NoisySinusoidal(amplitude, frequency, ..., noise_amplitude=...)` | `noisy_sinusoidal(amplitude, frequency, ..., noise_amplitude=...)` | Add stochastic noise to a sinusoid. |
166
+
167
+ ## Stochastic processes
168
+
169
+ | Composable API | Functional API | Use |
170
+ |---|---|---|
171
+ | `WienerProcess(duration, n=1, t_start=None, t_end=None, sigma=1.0, seed=None)` | `wiener_process(duration, sigma=1.0, n=1, ...)` | Model Brownian fluctuations with independent Gaussian increments. |
172
+ | `OUProcess(mean, sigma, tau, duration, n=1, t_start=None, t_end=None, seed=None)` | `ou_process(mean, sigma, tau, duration, n=1, ...)` | Model mean-reverting fluctuations around `mean`. |
173
+ | `Poisson(rate, duration, n=1, t_start=None, t_end=None, amplitude=1.0, seed=None)` | `poisson(rate, duration, amplitude=1.0, n=1, ...)` | Generate independent Poisson spike-current trains. |
174
+
175
+ Use `seed=` for reproducibility and `n=` for multiple independent processes.
176
+ For Poisson input, ensure `rate * dt` is a valid per-bin spike probability.
177
+ Call with `recompute=True` only when a new stochastic realization is intended.
178
+
179
+ ## Composition wrappers
180
+
181
+ These classes are normally created through operators or methods rather than
182
+ instantiated directly.
183
+
184
+ | API | Description |
185
+ |---|---|
186
+ | `Composite(input1, input2, operator)` | Pointwise combination of two inputs. |
187
+ | `ConstantValue(value, duration)` | Promote a scalar to a duration-matched input. |
188
+ | `Sequential(*inputs)` | Time concatenation corresponding to `&`. |
189
+ | `TimeShifted(input_obj, time_shift)` | Result of `.shift()`. |
190
+ | `Clipped(input_obj, min_val=None, max_val=None)` | Result of `.clip()`. |
191
+ | `Smoothed(input_obj, tau)` | Result of `.smooth()`. |
192
+ | `Repeated(input_obj, n_times)` | Result of `.repeat()`. |
193
+ | `Transformed(input_obj, func)` | Result of `.apply()`. |
194
+
195
+ Pointwise operands must have compatible duration, shape, and units. Use `&`
196
+ when durations differ and should occur one after another.
197
+
198
+ ## Official source
199
+
200
+ - `https://brainx.chaobrain.com/braintools/apis/input.html`