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,270 @@
1
+ # BrainX task-training workflow
2
+
3
+ Use this reference when `NeuroSpecification.md` selects `task-training` or the
4
+ training phase of `hybrid`. It owns the experimental contract around task data,
5
+ BrainX State, optimization, monitoring, tuning, checkpoint selection, and
6
+ held-out evaluation. The routed package skills still own model equations,
7
+ construction, simulation, and package-specific APIs.
8
+
9
+ Use task training to optimize model or readout weights over many input-target
10
+ examples. Use `parameter-fitting-workflow.md` instead to estimate
11
+ scientific model parameters against observations. In `hybrid`, keep the two
12
+ objectives, trainable State collections, data partitions, checkpoints, and
13
+ reported evidence distinct.
14
+
15
+ ## Underlying training principle
16
+
17
+ Training reuses the scientific forward model: reset runtime State at the
18
+ declared independence boundary, execute the same BrainX rollout used for
19
+ evaluation, reduce aligned outputs and targets to one scalar loss,
20
+ differentiate only the declared parameter State, and apply one optimizer update
21
+ at the declared cadence.
22
+
23
+ `ParamState` represents learned values that persist across batches. Hidden,
24
+ short-term, random, delay, eligibility, monitor, membrane, conductance, and
25
+ other runtime State represent the condition of one rollout; reset or preserve
26
+ each role according to the scientific protocol, never because an optimizer or
27
+ batch loop makes reset convenient.
28
+
29
+ Do not put a framework-neutral learner around a BrainX simulator callback. Keep
30
+ the forward model, trainable State, runtime State, reset lifecycle, temporal
31
+ execution, physical units, and represented biological scale BrainX-native.
32
+
33
+ ## Lock the training contract
34
+
35
+ Declare the experiment before writing the train step. A later change to the
36
+ task, target, independence unit, data inclusion, primary metric, or accepted
37
+ claim changes the locked specification; do not treat it as hyperparameter
38
+ tuning.
39
+
40
+ | Contract field | Required decision |
41
+ |---|---|
42
+ | Samples | Identify the independence unit: trial, sequence, subject, animal, session, recording, or another declared unit. |
43
+ | Axes and units | Name batch, time, feature, neuron, region, and target axes; record every transpose, temporal alignment, reduction, and unit boundary. |
44
+ | Partitions | Split immutable sample IDs by the independence unit before fitting preprocessing; prevent subject, session, temporal-neighbor, augmentation, and preprocessing leakage. |
45
+ | State lifecycle | Declare which State resets at sample, batch, sequence, phase, training/evaluation, and seed boundaries and which learned State persists. |
46
+ | Trainables | Select only intended parameter State; enumerate every excluded runtime State and any frozen parameter State. |
47
+ | Objective | Lock loss inputs, target alignment, reduction axes, units, regularization, primary metric, metric direction, and chance or null baseline. |
48
+ | Update cadence | Declare whether one optimizer update follows a timestep, window, complete sequence, batch, or accumulated set of batches. |
49
+ | Selection | Lock validation metric, checkpoint rule, seed aggregation, search space, budget, minimum evidence, patience, and stop rule before tuning. |
50
+ | Held-out use | Reserve held-out data until configuration and checkpoint selection are complete; never use it to continue, stop, tune, or choose a seed. |
51
+
52
+ Record the contract as an iteration artifact:
53
+
54
+ ```yaml
55
+ training_contract:
56
+ independence_unit: subject
57
+ axes:
58
+ input: [batch, time, feature]
59
+ target: [batch, class]
60
+ rollout_input: [time, batch, feature]
61
+ reset_boundary: independent_sequence
62
+ trainable_state: declared ParamState collection only
63
+ split_fit_scope: training subjects
64
+ update_cadence: one update per minibatch of complete sequences
65
+ primary_metric: validation loss
66
+ metric_direction: minimize
67
+ checkpoint_rule: minimum validation loss within each run
68
+ config_selection_rule: minimum mean validation loss across declared seeds
69
+ seed_aggregation: mean and declared uncertainty interval
70
+ tuning_budget: 12 completed or invalidated configurations
71
+ held_out_access: after all model and checkpoint selection
72
+ ```
73
+
74
+ Replace the example values with the locked scientific design. Store exact
75
+ sample IDs, preprocessing state, seeds, code/data/environment identity, and
76
+ configuration outside this compact contract and point to those artifacts.
77
+
78
+ ## Pass the mechanical gates
79
+
80
+ Do not start a production baseline until every gate passes on a small case.
81
+
82
+ | Gate | Required evidence |
83
+ |---|---|
84
+ | Data and leakage | Disjoint split IDs, training-only preprocessing fit, expected shapes/units, target range, class or target distribution, and explicit time alignment. |
85
+ | Forward parity | Training and evaluation call the same scientific rollout and observation path; only declared fit/evaluation behavior differs. |
86
+ | State reset | Replaying one sample from the same declared initial State reproduces its output; reordering independent samples does not change their predictions. |
87
+ | Gradient reach | Loss and every intended gradient are finite; expected trainables receive nonzero signal; excluded State is absent from the gradient and optimizer trees. |
88
+ | Update isolation | One update changes intended trainables and optimizer State only; it does not silently change frozen parameters, data transforms, or persistent scientific configuration. |
89
+ | Temporal reduction | A synthetic target at a known timestep changes only the intended scored output or window; masks exclude padding and ignored phases. |
90
+ | Tiny-case overfit | The unchanged pipeline can overfit a tiny batch or short sequence and move the declared metric in the expected direction. |
91
+ | Replay and compilation | Declared seeds replay exactly where promised, and repeated shape-compatible calls reuse the model graph without State-shape drift. |
92
+
93
+ Treat failure as diagnostic evidence. Fix data, State, alignment, gradient, or
94
+ objective mechanics before changing learning rate, optimizer, surrogate,
95
+ architecture, or model dynamics.
96
+
97
+ ## Establish the baseline and run ledger
98
+
99
+ Run 0 is the unchanged declared baseline. Give every run an immutable identity
100
+ and append it to one ledger before interpreting results.
101
+
102
+ | Run field | Record |
103
+ |---|---|
104
+ | Identity | Run ID, parent or warm-start ancestor, status, start/end time, and artifact paths. |
105
+ | Provenance | Exact code revision, data/split manifest, preprocessing state, package/environment identity, device, seed, and command or entry point. |
106
+ | Configuration | Complete resolved model, training, optimizer, schedule, reset, batching, and stopping configuration; do not store only overrides. |
107
+ | Outcomes | Raw training/validation curves, gradient and State diagnostics, checkpoints, runtime/resource data, and the primary plus guardrail metrics. |
108
+ | Decision | `CONTINUE`, `WAIT`, `STOP_INVALID`, `STOP_RULE`, `STOP_BUDGET`, or `COMPLETE`, with the evidence and locked rule that justified it. |
109
+
110
+ Do not compare a tuned run only with another tuned run. Preserve run 0 even
111
+ when it fails, because its failure constrains the next hypothesis.
112
+
113
+ ## Monitor process health and training quality
114
+
115
+ Check process liveness, device activity, checkpoint/log freshness, loss,
116
+ validation metric, learning rate, and gradient norm at the declared cadence. A
117
+ live process can train invalidly; unavailable metrics mean unknown, not failed.
118
+
119
+ | Evidence over the declared window | Decision | Action |
120
+ |---|---|---|
121
+ | Metrics are temporarily unreachable but the process is observable | `WAIT` | Retry observation; preserve the last evidence and make no quality claim. |
122
+ | Process exit, unexpected idle device, stale outputs, storage failure, or no checkpoint progress is confirmed | `STOP_INVALID` | Preserve logs and the last valid checkpoint; retry only the identical compatible run. |
123
+ | NaN/Inf, invalid gradients, State leakage, or target/reset misalignment appears | `STOP_INVALID` | Preserve the first failing step and diagnostics; return to implementation. |
124
+ | Training loss and the locked validation metric improve | `CONTINUE` | Continue; widen the check interval only after repeated healthy checks. |
125
+ | Metrics are flat, noisy, or slightly worse before minimum evidence or patience | `WAIT` | Keep or shorten the interval and gather the next planned checkpoint. |
126
+ | Loss diverges across the window, validation degradation exceeds patience, or gradients repeatedly explode or vanish | `STOP_RULE` | Stop under the locked rule and preserve the metric window and reason. |
127
+ | Maximum epochs or target criterion is reached with valid artifacts | `COMPLETE` | Close the run and compare it through the locked selection rule. |
128
+ | The tuning budget is exhausted | `STOP_BUDGET` | Launch no new configuration; compare every completed or invalidated run. |
129
+
130
+ Do not stop on one noisy point. For every stop, record the run ID, metric window,
131
+ checkpoint and log paths, exact rule, and reason. Monitoring ends or invalidates
132
+ a run; it never validates a scientific claim.
133
+
134
+ ## Tune hyperparameters with bounded evidence
135
+
136
+ Use this bounded hyperparameter-tuning loop: `run -> analyze -> record ->
137
+ choose`. Do not launch tuning until run 0 and the mechanical gates establish
138
+ what needs improvement.
139
+
140
+ 1. Diagnose the limiting signal from the complete run history: optimization,
141
+ generalization, temporal credit assignment, gradient scale, State leakage,
142
+ capacity, or compute/memory.
143
+ 2. State one falsifiable tuning hypothesis and the validation result that would
144
+ support or reject it.
145
+ 3. Choose the smallest coherent parameter set that tests that hypothesis. Give
146
+ each value a type, range, scale, default, and scientific or optimization
147
+ rationale.
148
+ 4. Create a complete new run record before execution. Change no unrecorded
149
+ model, split, preprocessing, reset, metric, seed aggregation, or stop rule.
150
+ 5. Analyze the primary validation metric with its guardrails, gradient/State
151
+ diagnostics, resource cost, and variability. Append failed, stopped, and
152
+ pruned runs to the same ledger.
153
+ 6. Stop when the locked budget or patience is exhausted, the hypothesis is
154
+ rejected, gradients or data become invalid, or no remaining candidate can
155
+ answer the declared question.
156
+
157
+ Establish `Adam` or another routed canonical baseline before a specialized
158
+ optimizer. Do not change optimizer, scheduler, surrogate, temporal reduction,
159
+ reset policy, and architecture together. When parallel resources are available,
160
+ run independent configurations concurrently only if each has an allocated
161
+ budget entry, isolated BrainState/RNG/checkpoint artifacts, and the same locked
162
+ comparison contract.
163
+
164
+ ## Resume and reuse checkpoints safely
165
+
166
+ Checkpoint compatibility is a State-graph and experiment-contract decision,
167
+ not a matching filename.
168
+
169
+ | Case | Rule |
170
+ |---|---|
171
+ | Resume an interrupted run | Restore model parameters, optimizer and scheduler State, RNG State, counters, preprocessing identity, and runtime configuration only when the complete configuration and State tree are identical. |
172
+ | Compare independent hyperparameter candidates | Start every candidate from the same declared initialization or base checkpoint. Do not give one candidate inherited training progress and compare it as an independent run. |
173
+ | Warm-start a later phase | Permit only when the plan declares a dependent phase and parameter structure, shapes, dtypes, units, task, targets, preprocessing, partitions, model dynamics, and runtime-State contract remain compatible. Record the ancestor checkpoint. |
174
+ | Change optimizer or schedule | Parameter-only restore may be valid, but do not restore incompatible optimizer or scheduler State; treat the run as a warm start, not an identical resume. |
175
+ | Change architecture, parameter shapes, solver, `dt`, surrogate, target semantics, preprocessing, data partitions, or State/reset meaning | Restart from the declared initialization. Do not coerce or partially load State to preserve progress. |
176
+
177
+ Save checkpoint metadata with the full State-tree signature and resolved
178
+ configuration. Validate a restored checkpoint with one deterministic evaluation
179
+ before training continues.
180
+
181
+ ## Select without touching held-out data
182
+
183
+ Apply the locked checkpoint rule to validation evidence only. Confirm the
184
+ selected configuration across every declared seed or replication and report
185
+ seed-wise results plus the locked aggregate; never select or present the best
186
+ seed alone.
187
+
188
+ After every modeling, preprocessing, tuning, checkpoint, seed, and stop decision
189
+ is frozen, restore the selected checkpoint for each declared replica, reset
190
+ evaluation State, and evaluate the untouched held-out partition. Preserve raw
191
+ predictions, sample IDs, per-sample or per-group metrics, aggregation, and
192
+ uncertainty. Do not tune, choose another checkpoint, or suppress a seed after
193
+ seeing held-out results.
194
+
195
+ Successful optimization proves that the declared training pipeline can learn
196
+ the task under its tested conditions. It does not by itself establish
197
+ biological validity, mechanism recovery, identifiability, or generalization
198
+ beyond the locked held-out population.
199
+
200
+ ## Return training evidence to the modeling loop
201
+
202
+ Return these artifacts through steps 2-5 of `brainx-modeling-loop`:
203
+
204
+ - the locked training contract, split IDs, and fitted preprocessing state;
205
+ - axis, unit, target-alignment, State-selection, reset, gradient, and tiny-case
206
+ tests;
207
+ - run 0 and the immutable ledger for every completed, stopped, failed, or pruned
208
+ run;
209
+ - raw training and validation curves plus process, gradient, State, runtime, and
210
+ resource diagnostics;
211
+ - every checkpoint, its selection trace, State-tree signature, and compatibility
212
+ decision;
213
+ - seed-wise and aggregate validation results;
214
+ - the untouched held-out predictions, metrics, aggregation, and uncertainty;
215
+ - unresolved training limitations and every claim this evidence does not
216
+ support.
217
+
218
+ Report an out-of-contract request to change the task, target, independence unit,
219
+ data inclusion, primary metric, or accepted claim. Do not edit the locked
220
+ specification inside this coverage. Report implementation, optimizer, schedule,
221
+ reset, checkpoint, or bounded-tuning defects as exact in-contract corrections.
222
+ Step 5 still emits only `REFUSE` or `PASS` and owns the loop transition.
223
+
224
+ ## Common failures
225
+
226
+ - Random row splitting when subjects, sessions, sequences, or neighboring time
227
+ windows are the independence unit.
228
+ - Learned preprocessing fitted outside the training partition.
229
+ - BrainCell scientific-parameter estimation mislabeled as task training.
230
+ - Hidden or runtime State included in the optimizer collection.
231
+ - Dynamical State carried across independent samples or reset across a boundary
232
+ that should preserve it.
233
+ - Raw `jax.grad`, `jax.jit`, or a non-BrainX trainer wrapped around
234
+ State-mutating BrainX code.
235
+ - Target indices shifted relative to the temporal output being scored, or padded
236
+ timesteps included in the loss.
237
+ - Optimizer updates placed inside a temporal loop when the contract specifies
238
+ one update per complete sequence or minibatch.
239
+ - Tuning started before finite gradients and tiny-case overfitting pass.
240
+ - Multiple optimizer, surrogate, architecture, reset, and reduction decisions
241
+ changed in one run without a testable hypothesis.
242
+ - Checkpoint selection, early stopping, seed choice, or tuning influenced by
243
+ held-out metrics.
244
+ - A warm-started run compared as if it were an independent candidate.
245
+ - Best-seed reporting, silent failed-run exclusion, or aggregation changed after
246
+ results.
247
+ - BrainTrace activated for generic speed rather than a demonstrated temporal
248
+ memory bottleneck and an accepted estimator boundary.
249
+
250
+ ## Package and reference routing
251
+
252
+ Read every active modeling skill before implementing training, then open only
253
+ the smallest routed reference that owns the next decision. The package skills
254
+ own model construction and train-step mechanics; this reference owns the
255
+ training contract, gates, experiment discipline, and evidence.
256
+
257
+ | Need | Required route |
258
+ |---|---|
259
+ | Large temporal workloads limited by sequence-length-dependent BPTT activation memory | First open the active package's checkpointed-control-flow reference. When ordinary BPTT remains memory-limited and an online eligibility-trace estimator is scientifically acceptable, open `skills/package-skills/braintrace/SKILL.md` and use BrainTrace as the memory-efficient alternative. Its memory is constant only in sequence length and still scales with batch size, participating parameters, hidden dimensions, and estimator choice. |
260
+
261
+ ### Choose Braintools training components
262
+
263
+ | Decision | BrainPy-State route | BrainMass route |
264
+ |---|---|---|
265
+ | Loss or neuroscience metric | `skills/package-skills/brainpy-state/references/braintools/metric.md` | `skills/package-skills/brainmass/references/braintools/metric.md` |
266
+ | Optimizer, scheduler, clipping, or update lifecycle | `skills/package-skills/brainpy-state/references/braintools/optimizer.md` | `skills/package-skills/brainmass/references/braintools/optimizer.md` |
267
+ | Parameter initialization | `skills/package-skills/brainpy-state/references/braintools/parameter-initializer.md` | `skills/package-skills/brainmass/references/braintools/parameter-initializer.md` |
268
+ | Input encoding | `skills/package-skills/brainpy-state/references/braintools/data-preprocessing.md` | `skills/package-skills/brainmass/references/braintools/data-preprocessing.md` |
269
+ | Hard-spike backward derivative | `skills/package-skills/brainpy-state/references/braintools/surrogate.md` | `skills/package-skills/brainmass/references/braintools/surrogate.md` |
270
+ | Phase-structured cognitive trials | Open the shared `skills/package-skills/brainmass/references/braintools/cogtask.md`, then preserve the BrainPy-State model's time-major input contract. | `skills/package-skills/brainmass/references/braintools/cogtask.md` |
@@ -0,0 +1,157 @@
1
+ ---
2
+ name: brainx-visualization
3
+ description: Visualize BrainX simulations, training, fitting, and analysis results as diagnostic or publication-ready scientific figures. Use for neural traces, spikes, activity, connectivity, trajectories, distributions, interactive exploration, animations, cellular topology, BrainMass summaries, or figure-integrity review after a BrainX route is selected.
4
+ ---
5
+
6
+ # BrainX visualization
7
+
8
+ ## Purpose and boundary
9
+
10
+ Use this skill after selecting the active BrainX modeling route and obtaining the data or run artifacts to visualize. Preserve the biological meaning, axes, units, conditions, observation mapping, and provenance established by that route.
11
+
12
+ Follow this path:
13
+
14
+ `state the figure question -> bind source evidence -> validate the data contract -> choose the highest-level visualization API -> render -> compare with raw values -> export and record provenance`
15
+
16
+ Choose the evidence mode independently from the work type:
17
+
18
+ | Decision | Choices | Rule |
19
+ |---|---|---|
20
+ | Evidence mode | `diagnostic`, `final` | Allow unaccepted runs only in diagnostic figures. Use accepted run IDs for final figures unless failed or null evidence is intentionally shown and labeled. |
21
+ | Work type | `audit`, `adapt`, `create` | Preserve originals during audits, preserve scientific meaning during adaptations, and write new plotting code and outputs in the research project rather than the installed skill. |
22
+
23
+ Visualization communicates evidence. It does not decide scientific acceptance or repair an invalid simulation, observation mapping, or statistical comparison.
24
+
25
+ ## Underlying mental model
26
+
27
+ A figure maps selected BrainX evidence through declared transformations to visual encodings that answer one scientific question.
28
+
29
+ The active BrainX route defines what every State, event, region, compartment, quantity, and observation means. Never infer that meaning from array shape alone.
30
+
31
+ Define a figure contract before choosing the representation:
32
+
33
+ | Contract field | Required decision |
34
+ |---|---|
35
+ | Question and mode | State one claim, diagnostic question, or comparison and choose `diagnostic` or `final`. |
36
+ | Sources | Record run IDs, artifact paths, hashes, conditions, seeds, checkpoints, and acceptance status. |
37
+ | Data | Record each variable's meaning, shape, axis order, sampling interval, ordering, and physical unit. |
38
+ | Transformations | Declare slicing, alignment, baseline correction, normalization, smoothing, aggregation, exclusions, and observation mapping. |
39
+ | Comparisons | Name controls, interventions, aligned landmarks, and fixed display limits. |
40
+ | Statistics | State the sampling unit, sample size, center, spread, uncertainty definition, and every reduction shown. |
41
+ | Destination | Set diagnostic, report, presentation, single-column paper, or double-column paper output before size and format. |
42
+
43
+ Freeze displayed cases, thresholds, smoothing, aggregation, exclusions, normalization, and axis or color limits before inspecting intervention outcomes. Keep raw per-condition evidence available beside aggregates.
44
+
45
+ ## Choose the visualization layer
46
+
47
+ Use the highest-level API that owns the scientific view; package ownership preserves domain semantics that generic plotting cannot recover.
48
+
49
+ | Layer | Use |
50
+ |---|---|
51
+ | Selected package visualization | Use first when BrainCell or BrainMass owns the represented structure, quantity, or analysis result. |
52
+ | `braintools.visualize` | Use for general neural, statistical, model-evaluation, interactive, 3D, styling, and animation workflows. |
53
+ | `matplotlib.pyplot` | Use for simple composition, labels, annotations, and export after the owning helper. Add custom artists only for a verified gap. |
54
+
55
+ Choose a general figure family by question:
56
+
57
+ | Question | Figure family | Required evidence |
58
+ |---|---|---|
59
+ | When and where do events or activity occur? | Raster, trace, population activity, histogram, rate map, or activity dashboard | Preserve event representation, time-major axes, recorded interval, units, and neuron or spatial ordering. |
60
+ | What dynamical regime or network structure appears? | Trajectory, phase portrait, tuning curve, ordered matrix, topology, or 3D view | Declare transient removal, coordinate meaning, ordering, layout semantics, and any threshold. |
61
+ | How variable is a result or does an assumption hold? | Distribution, Q-Q, raw samples with interval, box/violin, correlation, or scatter matrix | State sampling unit, `n`, uncertainty, comparison correction, and the exact statistic. |
62
+ | Does a model predict or generalize correctly? | Prediction comparison, residuals, confusion matrix, ROC or precision-recall curve, or learning curve | Separate train and held-out evidence; preserve labels, score meaning, prevalence, folds, and residual units. |
63
+ | Does hover, zoom, depth, or time evolution answer the question? | Plotly interaction, 3D view, or animation | Keep a stable final figure for archival evidence and fix encodings, camera, thresholds, and frame timing across comparisons. |
64
+
65
+ Open the matching general reference before choosing concrete functions:
66
+
67
+ - Open `references/neural-data-visualization.md` for neural events, activity, connectivity, trajectories, tuning, topology, or general 3D data.
68
+ - Open `references/statistical-and-model-visualization.md` for distributions, assumptions, grouped comparisons, regression, residuals, classification evaluation, or learning curves.
69
+ - Open `references/interactive-and-visualization-styling.md` for Plotly exploration, dashboards, themes, palettes, colormaps, export, or animation.
70
+
71
+ ## Compose a static neural figure
72
+
73
+ Static helpers render into supplied axes; compose the figure once, pass `ax=` to every helper, export once, and close it after non-interactive output.
74
+
75
+ | API | Description |
76
+ |---|---|
77
+ | `braintools.visualize.spike_raster(...)` | Use for flat spike-time events with matching neuron IDs, or per-neuron spike-train sequences. It returns the Matplotlib axes. |
78
+ | `braintools.visualize.population_activity(...)` | Use for time-major `(time, neurons)` activity or an already aggregated one-dimensional rate. It returns the axes. |
79
+
80
+ ```python
81
+ import matplotlib.pyplot as plt
82
+ import braintools.visualize as btvis
83
+
84
+
85
+ assert spike_times.ndim == neuron_ids.ndim == 1
86
+ assert spike_times.shape == neuron_ids.shape
87
+ assert activity.ndim == 2
88
+ assert time.shape == (activity.shape[0],)
89
+
90
+ fig, axes = plt.subplots(2, 1, figsize=(7.0, 5.0), sharex=True)
91
+ btvis.spike_raster(spike_times, neuron_ids, ax=axes[0])
92
+ btvis.population_activity(activity, time=time, ax=axes[1])
93
+ axes[0].set_ylabel("neuron index")
94
+ axes[1].set(xlabel="time (ms)", ylabel="population activity")
95
+ fig.tight_layout()
96
+ fig.savefig("neural-activity.png", dpi=600, bbox_inches="tight")
97
+ plt.close(fig)
98
+ ```
99
+
100
+ Open `references/neural-data-visualization.md` when the event representation differs, the figure requires another neural family, or a 3D view is scientifically necessary.
101
+
102
+ ## Prepare final figures
103
+
104
+ Make the evidence readable at its destination size without changing the encoded comparison.
105
+
106
+ - Follow the venue specification first. Otherwise use intentional physical dimensions, prefer PDF or SVG for vector line art, and use sufficient raster resolution.
107
+ - Label axes with units, omit placeholder units for dimensionless values, and use one name for the same quantity throughout a report.
108
+ - Use consistent panel labels, axes, normalization, line and marker hierarchies, and accessible colors. Do not encode a comparison only by hue.
109
+ - Use sequential colormaps for ordered magnitude, diverging colormaps only around a meaningful center, and categorical palettes for unordered conditions.
110
+ - Add labels, legends, colorbars, and panel marks before the final layout pass. Keep legends and grids secondary to the evidence.
111
+ - Reduce overplotting before increasing figure size. Use an inset only when a local difference is scientifically important and unused space is available.
112
+
113
+ Open `references/interactive-and-visualization-styling.md` for scoped styles, palette and colormap selection, interactive export, animation export, and comparison-stable visual settings.
114
+
115
+ ## Verify and record the figure
116
+
117
+ Render every export and inspect it against source values before delivery.
118
+
119
+ Verify that the output is nonblank, unclipped, legible at destination size, and free of overlaps. Check axis values, units, event timing, ordering, sample count, summaries, and fixed scales against source arrays. Confirm that smoothing, aggregation, uncertainty, exclusions, interpolation, and overplotting do not hide failures or differences.
120
+
121
+ Create or update `FIGURE_MANIFEST.md` with one entry per figure:
122
+
123
+ ```markdown
124
+ ## <figure path>
125
+ - Work type, evidence mode, scientific role, and question:
126
+ - Source run IDs, artifacts, hashes, and acceptance status:
127
+ - Variables, axes, ordering, and units:
128
+ - Transformations, smoothing, aggregation, and exclusions:
129
+ - Sample size and uncertainty:
130
+ - Controls and fixed comparison settings:
131
+ - Plotting source, output path, size, format, and resolution:
132
+ - Render and source-value checks:
133
+ ```
134
+
135
+ ## Reference routing
136
+
137
+ | Route | Open when | Contains |
138
+ |---|---|---|
139
+ | `references/neural-data-visualization.md` | Selecting neural event, activity, connectivity, dynamical, topology, tuning, spatial, or general 3D figures. | Data contracts, family selection, concrete BrainTools helpers, 3D boundaries, workflows, and comparison rules. |
140
+ | `references/statistical-and-model-visualization.md` | Inspecting distributions or assumptions, comparing groups, diagnosing regression, or evaluating classification and learning behavior. | Statistical helper selection, raw-data and uncertainty rules, residual diagnostics, ROC-versus-precision-recall decisions, and learning-curve interpretation. |
141
+ | `references/interactive-and-visualization-styling.md` | Adding interactive exploration, dashboards, styles, palettes, colormaps, export, or animation. | Plotly return behavior, stable encodings, scoped Matplotlib styles, output decisions, animation data contracts, and performance boundaries. |
142
+ | `skills/package-skills/braincell/references/multicompartment/topology-building-and-visualization.md` | Visualizing BrainCell morphology branches, CVs, runtime nodes, selector placement, topology layouts, or node and mechanism values. | Branch/CV/node decisions, initialization, physical-versus-topological views, selector coverage, value coloring, and canonical compositions. |
143
+ | `skills/package-skills/brainmass/references/visualization-analysis-api.md` | Computing or plotting BrainMass trajectories, phase portraits, connectivity, FC/FCD, or spectra. | `brainmass.viz`, BrainTools metric selection, time-major and sampling rules, unit boundaries, canonical analysis, and failures. |
144
+
145
+ ## Boundaries and common failures
146
+
147
+ - The figure is designed before its question, mode, evidence, and destination are fixed.
148
+ - Biological meaning, time axis, region order, or units are guessed from shape.
149
+ - Dense spike matrices and flat event arrays are sent to the wrong raster representation.
150
+ - Integration `dt` is used after recording subsampling changed the plotted interval.
151
+ - Package-owned morphology, topology, BrainMass analysis, or visualization is rebuilt with generic plotting code.
152
+ - Comparison scales, smoothing, normalization, thresholds, or exclusions vary without disclosure.
153
+ - Aggregate curves hide raw outcomes, sample size, uncertainty, failed runs, or null evidence.
154
+ - A reference figure is cloned without adapting its layout to the scientific role and real data geometry.
155
+ - Existing figures are overwritten, or plotting scripts and outputs are written into the installed skill directory.
156
+ - Diagnostic output is presented as final evidence, or a visual pattern is treated as scientific acceptance.
157
+ - Final artifacts are delivered without source provenance and render inspection.
@@ -0,0 +1,4 @@
1
+ interface:
2
+ display_name: "BrainX Visualization"
3
+ short_description: "Create rigorous figures from BrainX results"
4
+ default_prompt: "Use $brainx-visualization to create or review diagnostic or final scientific figures from my BrainX results."
@@ -0,0 +1,155 @@
1
+ # Interactive and visualization styling
2
+
3
+ ## Purpose and boundary
4
+
5
+ Use this reference for Plotly exploration, neural dashboards, Matplotlib styles, palettes, colormaps, export, and animation. Interaction and motion must expose evidence that is difficult to inspect statically; keep a stable static figure when the destination is a paper or archival report.
6
+
7
+ ## Choose interaction, styling, or animation
8
+
9
+ | Need | Use | Preserve |
10
+ |---|---|---|
11
+ | Hover, zoom, filtering, or trace toggling | Matching `interactive_*` helper | Data meaning, axis units, ordering, fixed comparison ranges, and a static evidence view. |
12
+ | A combined event-level overview | `dashboard_neural_activity(...)` | Per-neuron spike representation, population time alignment, and dashboard source data. |
13
+ | Consistent Matplotlib appearance | `apply_style(...)` or a named style helper | Destination size, readability, scientific encodings, and process-local scope. |
14
+ | Reusable categorical colors | `get_color_palette(...)` | Stable condition-to-color mapping and redundant line or marker encodings. |
15
+ | Scalar, diverging, or cyclic color encoding | Existing or custom colormap | Quantity meaning, neutral point, cyclicity, and fixed limits. |
16
+ | Evolution of a 1D profile or 2D field | `animate_1D(...)`, `animate_2D(...)`, or `animator(...)` | Time-first frames, physical `dt`, fixed axes and color limits, and retained output object. |
17
+ | Custom multi-artist temporal story | Matplotlib `FuncAnimation` | Frame update contract, stable layout, export writer, and numerical source data. |
18
+
19
+ Do not add interaction, 3D rotation, dark styling, or animation as decoration. A view that requires manual interaction to reveal the claimed result is insufficient as the only final evidence.
20
+
21
+ ## Explore with interactive figures
22
+
23
+ Interactive BrainTools helpers require Plotly and return Plotly figures. Confirm that Plotly is available before selecting this route; then inspect figures with `.show()`, refine them with Plotly figure methods, and export only after fixing comparison settings.
24
+
25
+ | API | Description |
26
+ |---|---|
27
+ | `interactive_spike_raster(spike_times, neuron_ids=None, ...)` | Use for event-level hover, zoom, time or neuron filtering, and optional coloring by neuron or time. |
28
+ | `interactive_line_plot(x, y, labels=None, ...)` | Use for one or more aligned traces. Legend toggling supports exploration but must not silently redefine the final comparison. |
29
+ | `interactive_heatmap(data, x_labels=None, y_labels=None, ...)` | Use for matrix inspection. Fix `zmin`, `zmax`, label order, and colorscale across comparable matrices. |
30
+ | `interactive_3d_scatter(x, y, z, color=None, size=None, labels=None, ...)` | Use when three coordinates and hover metadata are part of the question. Declare color and size meanings. |
31
+ | `interactive_network(adjacency, positions=None, ...)` | Use for topology exploration. Preserve adjacency direction, positions, threshold, and node or edge encodings. |
32
+ | `interactive_histogram(data, labels=None, bins=30, ...)` | Use to inspect one or more distributions and bin sensitivity. Do not compare quantities with incompatible units on one axis. |
33
+ | `interactive_surface(z, x=None, y=None, ...)` | Use for a scalar surface over declared coordinates. Preserve grid orientation and fixed height/color ranges. |
34
+ | `interactive_correlation_matrix(data, labels=None, method='pearson', ...)` | Use for exact-value hover over correlation structure. Preserve variable orientation and do not infer causality. |
35
+ | `dashboard_neural_activity(spike_times, neuron_ids=None, population_activity=None, time=None, ...)` | Use for a linked overview of spikes and population summaries. Supply either matching flat events or per-neuron sequences and align population activity to `time`. |
36
+
37
+ ```python
38
+ import braintools.visualize as btvis
39
+
40
+
41
+ fig = btvis.interactive_heatmap(
42
+ connectivity,
43
+ x_labels=target_labels,
44
+ y_labels=source_labels,
45
+ colorscale="RdBu_r",
46
+ title="source-to-target connectivity",
47
+ )
48
+ fig.update_traces(zmin=-weight_limit, zmax=weight_limit)
49
+ fig.show()
50
+ fig.write_html("connectivity-explorer.html")
51
+ ```
52
+
53
+ For Plotly static export, use `fig.write_image(...)` with an available image engine. Use `fig.write_html(...)` for a self-contained interactive artifact. Record the visible defaults, filtering state, camera, axis ranges, and color limits in the figure manifest.
54
+
55
+ Subsample dense interactive data only by a declared rule. Validate extrema, labels, and representative points before and after subsampling.
56
+
57
+ ## Apply styles without leaking state
58
+
59
+ Matplotlib style helpers modify process-wide defaults; scope them when plotting code shares a process with unrelated figures.
60
+
61
+ | API | Description |
62
+ |---|---|
63
+ | `apply_style(style_name, **kwargs)` | Use as a context manager for `neural`, `publication`, `dark`, or `colorblind`; it restores prior `rcParams` on exit. |
64
+ | `neural_style(...)` | Use for process-wide neural-data defaults only when all subsequent figures should share them. |
65
+ | `publication_style(fontsize=10, figsize=(6, 4), dpi=300, usetex=False)` | Use for process-wide print defaults after the destination size and font constraints are known. Do not enable TeX unless the environment and glyph set are verified. |
66
+ | `dark_style(...)` | Use for screen or projection output with a dark background. Export with matching face colors and do not reuse it blindly for print. |
67
+ | `colorblind_friendly_style()` | Use for the accessible process-wide preset. Preserve redundant line, marker, or direct-label encodings. |
68
+ | `get_color_palette(palette_name, n_colors=None)` | Use for a fixed categorical palette. Save the condition-to-color mapping rather than requesting colors independently per panel. |
69
+ | `create_neural_colormap(name, colors, n_bins=256)` | Use to create a named continuous colormap only when existing maps cannot express the quantity correctly. |
70
+ | `brain_colormaps()` | Use to register the supplied neural colormap set before referring to those names in Matplotlib. |
71
+
72
+ ```python
73
+ import matplotlib.pyplot as plt
74
+ import braintools.visualize as btvis
75
+
76
+
77
+ with btvis.apply_style("publication", fontsize=9, dpi=300):
78
+ fig, ax = plt.subplots(figsize=(3.35, 2.4))
79
+ btvis.population_activity(activity, time=time, ax=ax)
80
+ ax.set(xlabel="time (ms)", ylabel="population activity")
81
+ fig.savefig("population-activity.pdf", bbox_inches="tight")
82
+ plt.close(fig)
83
+ ```
84
+
85
+ Follow the destination specification before any preset. Verify the rendered output at final physical size; preset names do not guarantee readable labels, correct fonts, or valid dimensions.
86
+
87
+ ## Select colors by data meaning
88
+
89
+ - Use sequential colormaps for ordered magnitude, diverging maps around a meaningful center, and cyclic maps for phase or direction.
90
+ - Use categorical palettes for unordered conditions. Keep each condition's color fixed across all panels and figures.
91
+ - Add a line style, marker, pattern, or direct label when color carries group identity. Check grayscale and color-vision-deficiency legibility.
92
+ - Fix color limits before comparing matrices, surfaces, volumes, or animation frames. Autoscaling each panel or frame destroys magnitude comparison.
93
+ - Label colorbars with quantity and unit. Do not use decorative color variation without a declared encoding.
94
+ - Avoid rainbow maps for ordered scientific values when they introduce false boundaries or nonuniform perceptual changes.
95
+
96
+ ## Animate declared temporal data
97
+
98
+ Animation maps the first array dimension to frames; physical frame time and display delay are separate quantities.
99
+
100
+ | API | Description |
101
+ |---|---|
102
+ | `animate_1D(dynamical_vars, static_vars=(), dt=None, frame_delay=50, frame_step=1, save_path=None, show=True, ...)` | Use for one or more `(frames, x)` profiles and optional static one-dimensional references. Supply physical `dt`; the function returns the created figure. |
103
+ | `animate_2D(values, net_size, dt=None, val_min=None, val_max=None, frame_step=1, save_path=None, show=True, ...)` | Use for `(frames, neurons)` values reshapeable to `net_size` or `(frames, height, width)` fields. It returns a `FuncAnimation`; retain it through display or export. |
104
+ | `animator(data, fig, ax, num_steps=False, interval=40, cmap='plasma')` | Use for time-first `(frames, height, width)` image data with existing figure and axes. It returns an `ArtistAnimation`; retain it through display or export. |
105
+ | `matplotlib.animation.FuncAnimation(...)` | Use for coordinated custom artists, sliding windows, dynamic networks, or learning diagnostics that the high-level helpers cannot express. Return every changed artist when using blitting. |
106
+
107
+ ```python
108
+ import matplotlib.pyplot as plt
109
+ import braintools.visualize as btvis
110
+
111
+
112
+ assert field.ndim == 3 # (frames, height, width)
113
+ animation = btvis.animate_2D(
114
+ field,
115
+ net_size=field.shape[1:],
116
+ dt=recorded_dt,
117
+ val_min=fixed_min,
118
+ val_max=fixed_max,
119
+ show=False,
120
+ )
121
+ animation.save("activity.mp4", writer="ffmpeg", fps=20)
122
+ plt.close(animation._fig)
123
+ ```
124
+
125
+ Set `dt` from the recorded interval, not the integration step when monitoring was subsampled. Set `frame_step` as a declared temporal decimation. Keep axis limits, camera, colormap, and value limits constant across frames and comparable animations.
126
+
127
+ Use GIF for short, simple, widely embedded motion; use MP4 for compact presentation video; use HTML for notebook or browser controls. Verify writer availability before a long render. For large animations, update existing artists, enable blitting when compatible, decimate by a declared rule, precompute expensive frame quantities when memory permits, and disable or limit frame caching for streaming data.
128
+
129
+ ## Export and verify
130
+
131
+ - Export static line art as PDF or SVG when supported; use intentional pixel dimensions and raster resolution for PNG.
132
+ - Export Plotly HTML when interaction is the deliverable and a static companion when the scientific claim must be visible without interaction.
133
+ - Inspect text, math glyphs, background, transparency, colorbars, hover labels, default camera, and initial animation frame.
134
+ - Check that interaction or animation does not reveal values outside the declared source range or hide condition failures behind filters.
135
+ - Compare representative frames and hover values against source arrays. Check first, middle, and last frames plus extrema.
136
+ - Close Matplotlib figures after non-interactive export and retain animation objects until saving or display completes.
137
+
138
+ ## Common failures
139
+
140
+ - Interactive controls define the result, but the saved artifact does not record their state.
141
+ - Plotly figures use different axis or color ranges across conditions.
142
+ - A process-wide style leaks into unrelated figures or overwrites venue settings.
143
+ - Color is the only condition encoding, or a colormap has no relation to the data semantics.
144
+ - Each animation frame autoscales, creating false changes in magnitude.
145
+ - Display `interval` is confused with physical `dt`, or integration `dt` is used after monitor subsampling.
146
+ - An animation object is garbage-collected before display or export completes.
147
+ - Dense data are subsampled without recording the rule or checking retained extrema.
148
+ - Dark output is exported with the wrong face color, or TeX/font settings fail only in the final render.
149
+ - Animation or interaction is used where a static comparison would be clearer and more inspectable.
150
+
151
+ ## Tutorial sources
152
+
153
+ - [Interactive visualization](https://brainx.chaobrain.com/braintools/visualize/05_interactive_visualization.html)
154
+ - [Styling and themes](https://brainx.chaobrain.com/braintools/visualize/07_styling_and_themes.html)
155
+ - [Animation and dynamics](https://brainx.chaobrain.com/braintools/visualize/08_animation_and_dynamics.html)