Demo · DYSCO × CEBRA

The equations of a place-cell population.

A rat runs back and forth on a 1.6 m track while we record 120 neurons in its hippocampus. DYSCO learns a low-dimensional state from the spikes, and a differential equation for how that state moves. Distilled to its two largest terms, the equation is a harmonic oscillator: each lap is one turn of a loop in neural state space.

Watch the equations run ahead of the rat

Eight laps the model never saw. Press play, or drag the time bar. At every moment, the learned equations predict where the neural state, and so the rat, is about to go. Click anywhere in the state space to let the equations run on their own.

Linear track, 1.6 m0.0 s
  • Rat
  • Read from neurons
  • Forecast by the equations
106 neurons, sorted by place field8 s window
  • Fires most running right
  • Fires most running left
Neural state spaceClick to let the equations run
Forecast
Equations

About this demo

Data: rat "Achilles" from Grosmark & Buzsáki (2016), as packaged in CEBRA: 120 CA1 neurons, spike counts in 25 ms bins, 42 laps. The last 8 laps are held out: they were not used for training, for matching views or for distilling the equations. The raster shows the 106 neurons whose firing peaks above 1 spike/s, sorted by where on the track they fire most in the training laps.

The neural state is a 3D latent learned by cebra.DYSCO. For display it is centred, rotated to its principal axes and scaled to unit variance (y₀, y₁, y₂); the panel shows y₁ and y₀, and the flow is drawn at the current value of y₂. "Read from neurons" is the position decoded from the state (k-nearest neighbours, k = 25, fitted on training laps; median error 8.9 cm on held-out laps). The forecast integrates the selected equations from the current state with fourth-order Runge–Kutta in your browser, and decodes the end point the same way.

In 100 ms the rat moves only 3.4 cm (median), less than the error of reading position from neurons at all, so a 100 ms forecast is about as close in position as assuming the rat stands still (8.6–8.7 cm vs 8.8 cm). What the equations add is the movement: their predicted displacement correlates with the actual one at r ≈ 0.5, against r = 0.18 for decoding the true future state. Longer horizons show where the oscillator heads, but the errors grow.

The equations

Running back and forth is a rotation.

DYSCO learns a cubic polynomial with 60 terms. Pruned to its two largest, it becomes the equation of a harmonic oscillator, with one turn every 3.8 s. For comparison, a lap (right run, turn, left run, turn) takes the rat 4.8 s at the median.

  • y₁ mostly tracks position along the track, y₀ mostly running velocity, with direction. A linear fit to position, direction and velocity explains 85% of the variance of each on the training laps.
  • Read as physics: position changes with velocity (dy₁/dt ∝ y₀), and velocity is pulled back towards the middle of the track (dy₀/dt ∝ −y₁), like a pendulum. Rightward runs sit on one side of the loop, leftward runs on the other, and the turns at the ends close it.
  • Pruning costs little: the 2-term field still matches the full field on held-out states with R² 0.76, and forecasts the rat's next 100 ms of movement as well as the full one.
dy₁/dt = +1.73 y₀
dy₀/dt = −1.57 y₁

ω = √(1.57 × 1.73) ≈ 1.65 rad/s → period ≈ 3.8 s

EquationsTermsMatch to full field (R², held-out states)Predicted vs actual 100 ms movement (r)

Sparse equations were found by sequential thresholded least squares on the learned field's values at the training states, in the canonical frame above. DYSCO's latent is only defined up to an affine change of coordinates, so "two terms" refers to this frame.

Play with the equations

What is a harmonic oscillator?

A mass on a spring. The spring pulls the mass back towards the middle, the mass overshoots, and it swings back and forth for ever. Its equations have exactly the form DYSCO found: position changes with momentum, and momentum is pulled back by position. Below, the same equations move a mass, a point in state space, and a virtual rat, all in step.

A mass on a spring—
The same motion in state space: one turn per swingClick to start elsewhere

The rat, driven by the same equations—

The virtual rat's position is read from the state with a straight-line map, position ≈ 0.43·y₁ + 0.69 m (R² 0.74 on training laps), held to the track's 0–1.6 m; its direction is the sign of y₀ (right on 83% of training samples). Spikes are drawn at random (Poisson) from each neuron's average rate at that position and direction in the training laps.

How it works

Four steps.

1

Spikes

Spike counts of 120 hippocampal neurons in 25 ms bins, with the rat's position and running direction, from the CEBRA datasets.

import cebra.datasets
ds = cebra.datasets.init(
    "rat-hippocampus-single-achilles")
2

Views from nearby positions

DYSCO needs several noisy recordings of the same latent trajectory. Here, a stretch of 0.45 s is matched with stretches from three other laps where the rat ran the same way, at nearly the same place and speed: within 3 cm and 0.15 m/s, and still within 5 cm at the end. That gives 5,996 groups of four views.

3

Fit encoder and equations

CEBRA's convolutional encoder (10 bins, 250 ms) and a cubic vector field are trained together, in real time units.

model = cebra.DYSCO(
    model_architecture="offset10-model-mse",
    output_dimension=3, polynomial_degree=3,
    sample_interval=0.025, rollout_steps=8,
    num_views=4, temperature=0.1, potential=None,
    batch_size=128, max_iterations=3000)
model.fit(views, alignment_ids=groups)
print(*model.equations(), sep="\n")
4

Distill

Rotate the latent to its principal axes, then drop small terms and refit the rest, again and again, on the learned field's values. The two largest terms that remain are an oscillator.

Data & credits

  • Recordings: Grosmark & Buzsáki (2016), Diversity in neural firing dynamics supports both rigid and learned hippocampal sequences, Science. Rat "Achilles", as packaged in CEBRA's hippocampus demos.
  • DYSCO: Muratore & Mathis, Extracting Governing Equations from Latent Dynamics via Multi-View Contrastive Learning, NeurIPS 2026. arXiv · code
  • cebra.DYSCO: CEBRA pull request #317. We switched off its default density correction (potential=None): with it, the latent collapsed on these data.
  • CEBRA: Schneider, Lee & Mathis (2023), Nature · cebra.ai