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")
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.
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.
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.
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.
ω = √(1.57 × 1.73) ≈ 1.65 rad/s → period ≈ 3.8 s
| Equations | Terms | Match 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.
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.
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.
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")
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.
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")
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.
cebra.DYSCO: CEBRA pull request #317. We switched off its default density correction (potential=None): with it, the latent collapsed on these data.