Neural Mass Models

Background reading: what neural mass models are and how the Jansen-Rit model works

The Problem: Simulating Brain Activity

A human brain has roughly 86 billion neurons. Each neuron connects to thousands of others through synapses, producing electrical signals that we can measure with electrodes. When we record SEEG (stereotactic EEG), we are measuring the combined electrical activity of millions of neurons near each electrode contact.

We would like to simulate this activity — to build a mathematical model that produces signals that look like real brain recordings. Why? Because if we can reproduce what we observe, we can understand the mechanisms behind it. For epilepsy, this means understanding what makes certain brain regions generate seizures.

But simulating 86 billion individual neurons is computationally impossible for most purposes. We need a shortcut.

The Shortcut: Populations Instead of Individual Neurons

A neural mass model takes a radical simplification: instead of modeling each neuron individually, it models the average behavior of a large population of similar neurons. Think of it like weather forecasting — you do not track every air molecule; you track temperature and pressure as average properties of large volumes of air.

In the brain, neurons of the same type that are physically close together tend to behave similarly. So we group them into populations and describe each population with just a few numbers:

This reduces millions of neurons to a handful of variables. A single brain region might be described by 3 populations and 6 variables — instead of millions of individual neuron states.

The key trade-off Neural mass models sacrifice individual neuron detail to gain the ability to simulate large-scale brain dynamics quickly. They are accurate enough to reproduce the rhythms and patterns we see in EEG/SEEG, while being fast enough to run on a laptop.

Two Key Ingredients

Every neural mass model is built from two fundamental operations:

1. The Post-Synaptic Potential (PSP) Operator

When a neuron fires, it sends a signal to connected neurons. The receiving neuron does not respond instantly — the incoming spike is transformed into a smooth, gradual voltage change called a post-synaptic potential. This is modeled as a simple second-order linear system (like a spring that gets pushed and then wobbles back to rest):

Second-order linear system (one per population):

  d²y/dt² = A · a · input - 2a · dy/dt - a² · y

  A = maximum amplitude of the response (how big the voltage bump is)
  a = time constant (how fast it rises and decays)
  y = the resulting post-synaptic potential

An incoming spike goes in; a smooth voltage curve comes out. Excitatory PSPs push the voltage up (making neurons more likely to fire), while inhibitory PSPs push it down (making them less likely to fire).

2. The Sigmoid Function

The other direction: given a population's average membrane potential, how fast does it fire? The relationship is not linear — at very low voltages, neurons barely fire at all. At very high voltages, they fire at their maximum rate. In between, there is a smooth S-shaped transition. This is the sigmoid function:

S(v) = 2 · e0 / (1 + exp(r · (v0 - v)))

  e0 = half the maximum firing rate
  v0 = voltage at which firing is half-maximal
  r  = steepness of the transition

Low voltage in → near-zero firing rate out. High voltage in → maximum firing rate out. The sigmoid converts between the two "languages" of the model: voltage and firing rate.

2.5
6.0
0.56
Drag the sliders to see how each parameter shapes the sigmoid. The dot marks the half-maximum point (v0, e0).
The feedback loop PSP operators convert firing rate → voltage. The sigmoid converts voltage → firing rate. Chain them together and you get a feedback loop: firing produces voltage changes, which change firing rates, which produce more voltage changes. This is what creates oscillations.

The Jansen-Rit Model

The Jansen-Rit model (1995) is the most widely used neural mass model. It describes a single cortical column — a small vertical cylinder of brain tissue about 2 mm wide — using three interconnected populations:

PopulationTypeRole
Pyramidal cellsExcitatoryThe main output neurons. Their activity is what we measure with electrodes.
Excitatory interneuronsExcitatoryReceive input from pyramidal cells and feed excitation back to them.
Inhibitory interneuronsInhibitoryReceive input from pyramidal cells and send inhibition back to them.

How They Connect

The three populations form a loop:

graph TD
  INPUT(["External input p(t)"])
  EXC["Excitatory Interneurons\n(amplify signal)"]
  PYR["**Pyramidal Cells**\n(main output: y1 − y2)"]
  INH["Inhibitory Interneurons\n(dampen signal)"]

  INPUT -->|"p(t)"| EXC
  PYR -->|"C1"| EXC
  EXC -->|"C2 · excitatory"| PYR
  PYR -->|"C3"| INH
  INH -->|"C4 · inhibitory"| PYR

  style EXC fill:#0a3d1a,stroke:#4ade80,color:#4ade80
  style PYR fill:#162450,stroke:#5b8dee,color:#5b8dee
  style INH fill:#3d0a0a,stroke:#f87171,color:#f87171
  style INPUT fill:#2a1850,stroke:#a78bfa,color:#a78bfa

The C values (C1, C2, C3, C4) control how strongly the populations talk to each other. They are all derived from a single connectivity constant C:

C1 = C          # pyramidal → excitatory interneurons
C2 = 0.8 · C    # excitatory interneurons → pyramidal
C3 = 0.25 · C   # pyramidal → inhibitory interneurons
C4 = 0.25 · C   # inhibitory interneurons → pyramidal

The External Input

The excitatory interneurons receive an external input p(t) representing activity arriving from other brain regions and sensory pathways. This input is modeled as random noise with a mean value and some variability:

p(t) = mean_input + noise

# Typically: mean = 220 Hz, noise std = 22 Hz
# This represents the average background bombardment
# from the rest of the brain.

The noise is what keeps the model "alive" — without it, the system would settle to a fixed point and stop oscillating.

The Output

What we measure with an electrode is the difference between excitatory and inhibitory post-synaptic potentials arriving at the pyramidal cells:

output(t) = y1(t) - y2(t)

# y1 = excitatory PSP on pyramidal cells
# y2 = inhibitory PSP on pyramidal cells
# The difference is what the electrode picks up

This is a direct analog of real EEG/SEEG: the signal we record at electrodes is generated primarily by the summed post-synaptic potentials of pyramidal cells.

The Full Equations

Each population has a PSP operator (second-order ODE), which we split into two first-order ODEs. Three populations × 2 variables each = 6 state variables:

# State vector: [y0, y1, y2, y3, y4, y5]
# y0..y2 are PSP outputs, y3..y5 are their derivatives

# Position derivatives (just linking to velocities)
dy0/dt = y3
dy1/dt = y4
dy2/dt = y5

# Velocity derivatives (the actual dynamics)
dy3/dt = A·a·S(y1 - y2) - 2a·y3 - a²·y0
dy4/dt = A·a·(p(t) + C2·S(C1·y0)) - 2a·y4 - a²·y1
dy5/dt = B·b·C4·S(C3·y0) - 2b·y5 - b²·y2

# Output (simulated SEEG signal)
output = y1 - y2

The Parameters

ParameterDefaultUnitsWhat it controls
A3.25mVMaximum excitatory PSP amplitude
B22.0mVMaximum inhibitory PSP amplitude
a1001/sExcitatory time constant (faster rise and decay)
b501/sInhibitory time constant (slower rise and decay)
C135Global connectivity strength
e02.51/sHalf of the maximum firing rate
v06.0mVPSP at half-maximal firing rate
r0.561/mVSigmoid steepness
p220HzMean external input (from other brain regions)
sigma22HzNoise standard deviation on external input

What It Produces

At the default parameter values, the Jansen-Rit model produces a signal with a dominant frequency around 10 Hz — the alpha rhythm, the most prominent rhythm in human EEG. This matches what we observe when a person is relaxed with eyes closed.

By changing the mean input p, the model transitions through different regimes:

Input range (p)BehaviorAnalog
0 – 100 HzLow-amplitude noiseLow background activity
120 – 320 HzAlpha oscillation (~10 Hz)Normal resting-state EEG
Above 320 HzLarge-amplitude spikesEpileptiform activity
220 Hz alpha
22 Hz
135
Live Jansen-Rit simulation running in your browser. Drag p to move between noise, alpha rhythm, and epileptiform spiking regimes.
Why this matters for epilepsy The Jansen-Rit model shows that a small change in a single parameter (the input drive) can push a brain region from normal activity into epileptiform spiking. More complex models like Wendling (which extends Jansen-Rit with a fourth population) can reproduce a full range of seizure dynamics. The goal of model fitting is to find which parameter values best explain a patient's recorded brain activity.

Parameter Regime Map

This plot sweeps the mean input p from 0 to 500 Hz and shows the RMS amplitude of the model output at each value. The three behavioral regimes are visible as distinct regions of the curve:

Each point is a 2-second simulation. The sharp transitions mark bifurcation boundaries where the model's behavior changes qualitatively.

How It Is Solved Numerically

The 6 ODEs cannot be solved with a closed-form formula — they must be integrated numerically. Starting from an initial state (all zeros), the solver takes tiny time steps (typically 0.1 ms) and computes the state at each step using the derivatives.

Montage Concord uses Runge-Kutta 4 (RK4) for this. RK4 evaluates the derivatives at four points within each time step and takes a weighted average, giving much better accuracy than simply stepping forward by the derivative (Euler's method). The noise enters through the external input p(t), which is pre-generated as a random time series and passed to the derivative function at each step.

After integration at the fine time step (0.1 ms = 10,000 Hz), the output is downsampled to the requested sampling rate (e.g. 256 Hz or 1024 Hz) to match typical EEG recording rates.

Where It Fits in the Concord Pipeline

In Montage Concord, the Jansen-Rit model implements the Model ABC defined in concord-core. The simulation pipeline is:

1
ParameterVector
Named values + bounds
2
Model.simulate()
RK4 integration
3
ModelOutput
Simulated signal + state
4
Metrics / Viz
Analyze like real data

The ModelOutput contains a simulated signal in the same format as a real Recording, so the same metrics and visualization tools work on both. This is how model fitting will work: simulate, compute metrics on the simulation, compare to metrics on real data, adjust parameters, repeat.

Beyond Jansen-Rit

Jansen-Rit is the foundation. The planned model packages extend it in different directions:

ModelExtensionWhat it adds
Wendling+1 population (fast inhibitory)Full seizure dynamics — can reproduce background through ictal activity
EpileptorDifferent math (bifurcation model)Automatic seizure onset and termination via slow variable
RobinsonThalamocortical loopSleep dynamics — spindles, K-complexes, arousal states

All share the same infrastructure: the Model ABC, models-utils (integrators, sigmoids), and the ParameterVectorModelOutput data flow.

The Gap Between Model and Reality

The Jansen-Rit model is a powerful explanatory tool, but it is not a literal replica of real EEG. Understanding where the model diverges from measured data is essential — both for interpreting model output honestly and for designing fitting procedures that know what they can and cannot recover.

1/f Noise: The Missing Background

Real EEG power spectra follow a characteristic 1/f shape: power decreases roughly as the inverse of frequency, forming a straight line on a log-log plot. This "pink noise" floor underlies all oscillatory peaks. It is thought to arise from the superposition of many independent processes at different timescales — synaptic noise, dendritic filtering, volume conduction through tissue.

The Jansen-Rit model does not produce 1/f noise. Its output has oscillatory peaks (driven by the excitatory-inhibitory loop) sitting on top of the white noise injected via p(t). White noise has flat power across all frequencies — the opposite of the 1/f slope seen in real data.

1.5
0.50
Left: pure JR output (white noise floor). Right: JR mixed with synthetic 1/f noise. The mix ratio blends JR (0.0) with 1/f (1.0). Real EEG falls somewhere in between. Drag the slope to see how steeper 1/f backgrounds change the spectral shape.

This matters in practice because many EEG metrics — band power, spectral edge frequency, 1/f exponent itself — are shaped as much by the aperiodic background as by the oscillatory peaks. A model that matches the alpha peak but ignores the 1/f floor will produce misleading metric values. Common strategies for dealing with this include:

Non-Identifiability: Multiple Solutions to the Same Data

The Jansen-Rit model has 10 free parameters. The measured data it must match is typically summarized by a handful of features: dominant frequency, relative band powers, waveform statistics. There are far more degrees of freedom in the model than constraints in the data. This means the problem is non-identifiable — multiple different parameter combinations can produce nearly identical output features.

Practical example of non-identifiability An alpha rhythm at 10 Hz with a certain amplitude can be produced by (A=3.25, C=135, p=220) or by (A=2.8, C=155, p=195) — the effects of higher connectivity and lower input can compensate for lower excitatory gain. The model output looks the same; the underlying "explanation" is completely different. Any fitting procedure that returns a single "best" parameter set without acknowledging this ambiguity is overstating its certainty.

Non-identifiability is not a bug — it is an inherent property of fitting a complex model to summary statistics. Strategies for dealing with it include:

StrategyApproachTrade-off
Fix known parameters Set physiological constants (e0, v0, r, a, b) to literature values and fit only the remaining parameters (A, B, C, p, sigma). Reduces the solution space but assumes the fixed values are correct for this patient and brain region.
Regularization Add a penalty term that favors parameter values close to physiological defaults. The optimizer can deviate, but only if the data strongly demands it. Biases toward "normal" values — which is usually desirable for clinical interpretation but may miss genuinely abnormal physiology.
Posterior sampling Instead of finding one "best" point, sample the full distribution of parameter values that explain the data (Bayesian inference, MCMC, or ensemble methods). Computationally expensive. Returns a distribution, not a single answer — harder to interpret but more honest.
Use more features Match not just the PSD but also time-domain statistics (Hjorth parameters, line length), cross-frequency coupling, or temporal dynamics — adding constraints narrows the space of viable solutions. Requires the model to be accurate across all those dimensions — which it may not be, introducing new mismatches.

A well-designed fitting engine should account for this reality. Rather than returning a single "answer," it is valuable to expose the loss landscape and use multi-start optimization to map out the space of viable solutions.

What the Model Cannot Represent

Some aspects of real SEEG data are structurally absent from the Jansen-Rit model. These are not parameter-tuning problems — they are limitations of the model's mathematical structure:

PhenomenonIn real dataIn Jansen-Rit
Volume conduction Each electrode picks up a weighted mix of activity from many nearby sources. Signal is spatially blurred. Each model instance represents one isolated column. No spatial mixing between sources unless explicitly added as a forward model.
Non-stationarity EEG changes character constantly — arousal state shifts, transient events, slow drifts in excitability over minutes. Parameters are fixed for the entire simulation. The model produces stationary output by design. Slow parameter modulation must be added externally.
High-frequency oscillations Ripples (80–250 Hz) and fast ripples (250–500 Hz) are clinically important biomarkers in epilepsy. The PSP time constants (a=100, b=50 Hz) act as low-pass filters. The model cannot generate oscillations much above 30–40 Hz.
Multiple rhythms Real EEG contains simultaneous alpha, beta, gamma, theta activity. A single JR column produces one dominant frequency. Multiple rhythms require coupling multiple model instances or using extended models (Wendling).
Measurement noise Amplifier noise, line noise (50/60 Hz), movement artifacts. Model output is clean. Measurement artifacts must be modeled separately or removed from the real data before comparison.
Models are tools, not truth A neural mass model is useful when it captures the features you care about, not when it reproduces every aspect of the signal. The Jansen-Rit model is good at explaining dominant oscillatory rhythms and transitions between activity regimes. It is not trying to be a full simulation of everything an electrode records. The art of model-based EEG analysis is choosing which features to match and which to acknowledge as outside the model's scope.

Implications for Model Fitting

These gaps have practical implications for any fitting procedure built on top of the Jansen-Rit model:

  1. Metric selection matters more than optimizer choice. Choosing which features to match (PSD peaks vs. broadband power vs. time-domain statistics) implicitly decides which aspects of the data the model is asked to explain — and which are ignored.
  2. Residual structure is informative. When the best-fit model still does not match certain features, that mismatch tells you something — the signal contains components (1/f noise, HFOs, artifacts) outside the model's scope.
  3. Confidence requires exploration. A single optimized parameter set is a point estimate. To know how much to trust it, you need to explore the neighborhood — are there other parameter sets that fit nearly as well? How sensitive is the fit to small perturbations?
  4. Pre-processing is part of the model. Re-referencing scheme, filtering, artifact rejection, and epoch selection all shape the data the model sees. Two different pre-processing pipelines applied to the same recording can yield different "best-fit" parameters.

Further Reading