brainmass

Simulate, couple, and fit neural-mass models of regional and whole-brain population dynamics.

1|Updated Jul 23, 2026
One-click install
npx skills add https://github.com/chaobrain/BrainX-skill --skill brainmass-chaobrain
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: brainmass
Source: https://github.com/chaobrain/BrainX-skill/tree/main/brainx-display-cases/creative-experiment-verification/06-seizure-recruitment/run2/.agents/skills/brainmass
Command: npx skills add https://github.com/chaobrain/BrainX-skill --skill brainmass-chaobrain

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires brainmass, brainstate, brainunit, braintools, jax, numpy, and includes references (resource) and scripts (resource) components.

What problem does it solve? Building neural-mass models of brain activity requires choosing the right dynamical model, wiring structural connectivity with delays, adding stochastic drive, mapping latent activity to BOLD/EEG/MEG observables, and fitting parameters—each step with its own API pitfalls. This Skill guides an agent through the complete BrainMass workflow so simulations, network coupling, and parameter fitting follow the correct contracts. ## Core Features & Use Cases - Model discovery and simulation: Use brainmass.list_models() to select from phenomenological, physiological, seizure, decision, and oscillator models, then run them through the uniform Simulator with monitors, transients, and batched stochastic trials. - Delay-coupled whole-brain networks: Wrap an N-region model in brainmass.Network with structural connectivity, conduction delays, and diffusive, additive, sigmoidal, or Jansen-Rit coupling. - Observation models and fitting: Map neural activity to BOLD (HRF convolution or Balloon-Windkessel), EEG/MEG lead fields, then fit trainable Param values with gradient, Nevergrad, or SciPy backends via Fitter and reusable objectives (FC, FCD, RMSE). - Use Case: Fit a Hopf oscillator's bifurcation parameter to match the amplitude of an empirical signal, or build a connectome-based whole-brain network and compare simulated functional connectivity against measured data. ## Quick Start Ask the agent to simulate a Hopf neural-mass model with BrainMass, add Ornstein-Uhlenbeck noise, and run eight batched trials while monitoring the x state variable.

Frequently Asked Questions about brainmass

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I simulate a neural-mass model with BrainMass?

Create a model such as brainmass.HopfStep with an in_size, then pass it to brainmass.Simulator with a unit-aware dt and call run() with a duration, monitors, and optional transient. The result is a dict of time-major trajectories plus unit-aware timestamps.

How do I build a delay-coupled whole-brain network in BrainMass?

Set the global dt with brainstate.environ.set, load a connectome, then wrap an N-region model in brainmass.Network with conn, distance, speed, a coupling type, and coupled_var. Run it through Simulator and monitor wrapped state via model.node.

Which BrainMass model should I use for EEG or seizure dynamics?

Use JansenRitStep for EEG and alpha-rhythm cortical columns, reading its eeg() observable, and EpileptorStep for seizure onset and offset where x0 controls epileptogenicity. Call brainmass.list_models() to compare categories and state-variable counts.

Can BrainMass fit model parameters without gradients?

Yes. Fitter supports backend="nevergrad" and backend="scipy" for black-box or non-differentiable objectives, but every fitted parameter needs finite bounds from a transform or an explicit search_space. Use the default grad backend whenever the workflow is differentiable.

Why does my BrainMass stochastic run give different results each time?

Noise processes draw from the BrainState random stream, so you must call brainstate.random.seed() before each run that must be reproducible. Seeding once does not make later runs reuse the same draws.

When should I not use Fitter for HORN task training?

Fitter targets one fixed prediction-target pair, so minibatched sequence-task training with epochs, hidden-state resets, and held-out evaluation needs a custom training loop instead. Use HORNSeqNetwork with a compiled train step and explicit hidden-state reset per batch.