MINT

Every 20 ms, an electrode array reports how many spikes each motor neuron fired, and a decoder must say how the hand is moving. MINT asks which stored brain trajectory best explains the last spikes. It beat every Kalman and Wiener comparison, and 37 of 42 neural network comparisons.

Learn why motor cortex activity looks like a thin mesh of trajectories, and how a decoder built from counting, a lookup table and one Newton step uses that mesh.

Pick the linear filter, then Play a reach. Switch to MINT and play the same reach. Drag the direction to an angle between the eight trained ones. Then we build the decoder piece by piece: the spikes, the geometry, the library, the likelihood, the recursion and the interpolation.

You need a feel for averages and a little calculus (a slope tells you which way a curve rises). We teach the spikes, the Poisson count and the geometry from zero.

Based on Perkins SM, Amematsro EA, Cunningham JP, Wang Q and Churchland MM, “An emerging view of neural geometry in motor cortex supports high-performance decoding”, eLife 2025, doi 10.7554/eLife.89421. It is the paper behind the lecture Linear Decoders. The instrument above is our toy of the idea, not the authors’ data.

Decode a reach from spikes

135°

A toy, not the paper’s data: 60 made-up neurons, eight trained reach directions (every 45°), a 1 s reach in fifty 20 ms bins, Poisson spikes. R² is a score where 1 is a perfect decode and 0 is no better than guessing the average. It is computed live from the decoded and true velocity of this one reach. The linear filter is a ridge fit on 6 trials per trained direction, fed the spike counts of the last 5 bins. The paper’s own comparison is in Chapter 7.

Chapter 0

A Decoder Is a Bet About Geometry

See why every brain-computer interface decoder hides a guess about the shape of neural activity, and why MINT bets differently

Picture a person with paralysis who wants to move a cursor. A small array of electrodes sits in the motor cortex, the brain region that plans and drives movement. Every 20 milliseconds the array reports how many spikes each neuron fired. A spike is one brief electrical pulse from a neuron.

A decoder is the program that turns those counts into a cursor velocity. It must work on spike patterns it has never seen, because no two moments of brain activity repeat exactly. To do that, the decoder must assume something about how the activity is organised. That assumption is the bet.

The old bet: a flat sheet with a slope

Think of the activity of 100 neurons as one point in a space with 100 axes. This point is the neural state. As the hand moves, the point moves. The classic view says the point stays near a flat sheet, called a subspace, with only a few dimensions. On that sheet, some directions line up with hand velocity. Push the point along such a direction and the hand speeds up.

The Kalman filter and the Wiener filter both make this bet. Both read hand velocity off a weighted sum of the neurons. If the bet is right, a weighted sum is all you need. The paper calls this the view in its Figure 1a.

The new bet: a thin mesh with a current

The authors argue for a second view, their Figure 1b. The neural state does not wander over a sheet. It follows trajectories: paths that run in one direction, like boats on a river. Most of the space is empty, because the dynamics of the circuit rule out most states. The occupied part is thin and twisted, more like a net than a sheet.

In this view, a direction that always matches velocity need not exist. Much of the activity is "output-null". It changes a lot but does not change the muscles. So two very different neural states can mean the same hand velocity. The map from neural state to behaviour is many-to-one, and it is far from a straight line.

The claim, as a trade. MINT decodes motor cortex with simple counting where a linear decoder falls short, because it stores the real trajectories and asks which one the spikes came from. If the geometry bet is right, it should match flexible neural networks too.

This is a test of the new bet. If Figure 1b is true, a decoder built for it should beat the decoders built for Figure 1a. It should also keep up with deep networks, which can learn any geometry from data. The paper reports that it does both.

Predict, then reveal

The abstract compares MINT with expressive machine learning methods, such as feedforward networks and recurrent networks called GRUs. There were 42 comparisons in total. Before you read on, guess how many MINT won.

Guess the win count

Each square is one comparison against an expressive method. Drag the guess, then press Reveal to see the paper’s count.

21

From the paper’s abstract: MINT outperformed expressive machine learning methods in 37 of 42 comparisons, and outperformed other interpretable methods in every comparison. The grid layout is ours.

Notice what the number does not say. MINT won by small margins in many cases. In the paper’s own words, the best decoders were all very close. The case for MINT rests on more than the score: it is simple, fast to train, and every output comes with a likelihood you can inspect.

What we will build

MINT is short to state. Store a library of typical neural trajectories, each paired with the behaviour that went with it. At each 20 ms step, score every library state by how likely it makes the recent spikes. Pick the best state, interpolate with its neighbour, and read off the paired behaviour. We build each part from zero.

  1. Spikes, rates and states: what a Poisson count is, and why a rate is a hidden number behind it. This builds the raster in the instrument.
  2. Two pictures of neural geometry: low tangling and a many-to-one map. This is why the linear filter in the instrument struggles.
  3. The library: the purple spokes in the instrument. How trial averaging builds them.
  4. Scoring a state: the Poisson log-likelihood and its lookup table.
  5. The recursion: how MINT scores hundreds of states in under a millisecond.
  6. Interpolation: the Newton step that lets a 135° reach decode from eight trained directions.
  7. The results: Kalman, Wiener, GRU and feedforward, side by side.
  8. Where it breaks: new tasks, lost neurons, and the likelihood alarm.
  9. Field guide: numbers, checklist and the core in code.
What does the new view of neural geometry predict about the map from neural state to hand velocity?

Chapter 1

Spikes, Rates and the Neural State

Turn a noisy stream of spikes into counts, then see why a hidden firing rate sits behind every count

Imagine you hold a microphone next to one neuron. You hear clicks at uneven gaps: click, silence, click click, silence. Each click is a spike. Play the same reach ten times and the clicks fall in different places every time. The pattern is noisy, yet something steady hides underneath.

That steady thing is the neuron’s firing rate: how many spikes per second it tends to fire at this moment of the movement. The rate is smooth and repeatable. The spikes are a noisy sample drawn from it. A decoder never sees the rate. It sees only the clicks, and must work backwards.

Bins and counts

The decoder cannot act on single clicks. So it chops time into short windows called bins and counts the spikes in each. MINT uses bins of 20 ms for all its main results. A neuron firing at 20 spikes per second fires 0.4 spikes on average in one bin. The actual count is 0, 1, 2 or more.

For 60 neurons and 50 bins you get a table of whole numbers with 60 rows and 50 columns. This table is the spike count matrix. The raster in the instrument at the top of the page is this table drawn as dots.

Where the Poisson count comes from

How likely is a count of 0, 1 or 2 when the average is 0.4? Think of the 20 ms bin as a thousand tiny slices. In each slice the neuron has a very small chance of firing, and slices do not affect each other. Add up the slices and you get the Poisson distribution: the standard law for counting rare, independent events.

h(s, λ)
The chance of seeing exactly s spikes in one bin when the expected count is λ. The paper uses the letter h for this.
λs
The expected count multiplied by itself s times. It rewards counts near what you expect.
e−λ
The chance of seeing no spike at all. It shrinks as the expected count grows.
s!
s factorial: s × (s − 1) × … × 1. It stops the chances from adding up to more than 1.

λ = 20 spikes/s × 0.02 s = 0.4:  P(0) = e−0.4 = 0.670,  P(1) = 0.4 × 0.670 = 0.268,  P(2) = 0.16/2 × 0.670 = 0.054,  P(3) = 0.064/6 × 0.670 = 0.007

Those four numbers add to 0.999. A bin with three spikes from a 20 Hz neuron is rare but not impossible. Play with the rate below and watch the bars move.

From a rate to a count

Bars: the chance of each count in one 20 ms bin. Teal ticks: how often each count came up in the bins you drew. Drag the rate, then press Draw 200 bins.

20 spikes/s

The Poisson formula is exact. The draws are a seeded random sample from it in your browser. The 20 ms bin width is the paper’s choice for all main analyses.

Two facts make Poisson counts easy to work with. First, once you know the rate, the count in one bin tells you nothing new about the next bin. Second, the same holds across neurons. The paper calls this conditional independence. It lets MINT score a whole window by adding up one small number per neuron and per bin.

Rate first, count second

The word conditional matters. Counts are not independent in general. A neuron that fires a lot in one bin will probably fire a lot in the next, because its rate is high. They become independent only after you fix the rates. So the model has two layers. A hidden rate vector comes first. Poisson noise on top of it gives the counts.

The hidden rate vector for all N neurons at one moment is the neural state. It is a point in N dimensions. One state per time bin traces a path through that space. That path is a neural trajectory, and the next two chapters are about its shape. For the link between spikes and rates in more depth, see Spikes to Rates; for how a Poisson count enters a regression, see Generalized Linear Models.

Why the sum of two neurons still works

Real systems often cannot tell two neurons apart. They record one threshold crossing: every time the voltage on a channel passes a line, count a spike. If two neurons feed one channel, the channel sees both. A fact about Poisson counts helps here. The sum of two Poisson counts is a Poisson count, with the two rates added.

So a merged unit behaves like one fast neuron. MINT’s statistics still hold. The paper tests this: moving from sorted spikes to good threshold crossings cost only a small R² change of −0.014 on the cycling data.

A neuron has a rate of 30 spikes per second. What is the expected count in one 20 ms bin, and why can a count of 0 still be likely?

Chapter 2

Two Pictures of Neural Geometry

Measure why distant neural states can mean the same movement, and why that breaks a weighted-sum decoder

A monkey sits holding a pedal in its hand. It turns the pedal in circles, forward to move through a virtual landscape, or backward when the landscape colour says so. The hand traces the same circle either way. The hand velocity at a 45° phase going forward equals the hand velocity at a 225° phase going backward. So the hand makes the same velocity twice, once in each direction.

You would guess the motor cortex also repeats itself. The paper shows it does not. This chapter explains what the cortex does instead, and why the answer matters for building a decoder. The data come from the paper’s MC_Cycle set: 112 sorted neurons, two cycling directions and four distances (1, 2, 4 or 7 cycles), so 8 conditions.

Low tangling: no two flows cross

Picture a river seen from above. Two boats can float close together if they drift the same way. They cannot sit at the same spot heading in opposite directions, because the current would not allow it. Neural trajectories follow the same rule. The paper calls it low trajectory tangling: states that are close together always move in similar directions.

Forward and backward cycling go in opposite directions. So their neural trajectories must stay apart, even where they seem to cross in a flat picture. In the paper’s Figure 2a, the forward and backward loops overlap in the two biggest dimensions. In the third dimension they are well apart, at every apparent crossing. The loops also have an empty centre that no cycling speed fills.

Try it. The two loops below are a toy, drawn so you can slide the gap in the third dimension.

Loops that look like they cross

Left: the top view, dimensions 1 and 2. Right: the side view, dimensions 1 and 3. Purple is forward cycling, pink is backward. Drag the gap, then drag the moment on the loop.

1.20
45°

Illustrative toy: both loops are the same ellipse in dimensions 1 and 2, and sit at heights +gap/2 and −gap/2 in dimension 3. Units are arbitrary. The paper’s real data show the same pattern at every apparent crossing (its Figure 2a).

With the gap at 0 the two loops share every point, and a decoder cannot tell them apart. Raise the gap and a third axis separates them. A flat top view hides the third axis. This is why the paper looks past the two biggest dimensions.

Non-isometry: far apart in the brain, equal in the hand

Take any two moments of the recording. Measure how far apart the hand is, using phase and speed. Measure how far apart the neural states are. If the brain simply copied the hand, big hand gaps would go with big neural gaps. A map that keeps distances is called an isometry. The paper tests this by plotting every pair of moments.

The cloud is not diagonal. Where the hand distance is small, below 0.1 in normalised units, the neural distance runs from 0.02 up to 1.46. The converse never happens. When the hand distance is about 2, the neural distance is always at least 0.53. So similar neural states always mean similar behaviour, but similar behaviour can come from far-apart neural states. The map is many-to-one.

A second test compares the order of distances. Pick two random pairs of neural states. Ask: does the bigger neural gap also give the bigger hand gap? For kinematics it did so 67.3% of the time, across 100,000 comparisons. For muscle activity it was 79.2%. A true copy would score near 100%: the control data scored 99.7%. Chance is 50%.

Why this hurts a weighted sum

A linear decoder can ignore the dimensions that do not carry movement. That works, but only if those dimensions are small. In the cortex, the dimensions that drive muscles often hold a small share of the activity. The paper’s artificial network is a clear case: the output dimension holds about 2% of the total variance. Variance is the spread of a quantity. The rest is large, structured and ignored by the muscles.

The linear readout then discards most of the signal. When many neurons are missing, what remains may carry little of that 2%. So the paper argues for decoding that is quite nonlinear: it should use all the dimensions, not just the ones that line up with velocity.

The wrong-parameter objection. Maybe the hand was the wrong thing to compare. Perhaps the brain copies joint angles or muscles instead. The authors test muscles (7 recorded EMG channels) and the effect holds. They also note the pedal task leaves the shoulder and elbow almost fixed by phase. So few other variables could differ.

The two views, side by side

Now you can state both pictures plainly. Figure 1a: a low-dimensional sheet, with directions that correlate with velocity. Figure 1b: many factors, a sparse set of occupied states, flow in one direction, and much of the activity invisible to the muscles. Principal component analysis, the tool that finds the biggest dimensions, builds Figure 1a by design. See PCA and Neural Manifolds for that tool.

In the paper’s pairwise-distance plots, which statement is true?

Chapter 3

The Library: Idealized Trajectories by Averaging

Build MINT’s only parameters, a neural library and a behaviour library, with nothing but filtering and averaging

A person reaches to the same target fifteen times. On each reach, one neuron fires a slightly different set of spikes. No single trial shows the neuron’s true rate curve. But lay the fifteen trials on top of each other and average them. The noise shrinks, and the smooth shape of the rate appears.

MINT does exactly this, for every neuron and every condition. A condition is one kind of movement, such as “reach to target 3” or “cycle forward seven times”. The result is an idealized trajectory: the typical path of the neural state during that movement, with the noise averaged out.

Step by step, with shapes

  1. Filter. Smooth each neuron’s spikes on each trial with a Gaussian bump (a soft bell) to get a single-trial rate. The bump width is a standard deviation σ in milliseconds. The paper says 20 to 30 ms is typical.
  2. Align. Cut each trial to the same window around a key event, such as movement onset. In the maze data the window runs from 500 ms before onset to 700 ms after.
  3. Stack. For condition c you now hold a tensor Xc ∈ RN × Kc × R: N neurons, Kc time points, R trials. The behaviour has the matching shape Zc ∈ RM × Kc × R, with M behaviour variables such as x and y velocity.
  4. Average over R. Take the mean over the trial axis. You get X̄c ∈ RN × Kc and Z̄c ∈ RM × Kc.

Stack the averages for all C conditions. The neural library is Ω: C trajectories, each N × K. The behaviour library is Φ: C trajectories, each M × K. These two stacks are MINT’s whole set of parameters. In our toy, N = 60, K = 50, C = 8 and M = 2. So Ω holds 24,000 numbers and Φ holds 800.

See why averaging works. Pick the number of trials and the smoothing, and compare the result with the true rate.

Average trials into a rate

One toy neuron during one reach. Dashed: the true rate. Blue: one noisy trial. Warm: your average. Raise the trial count, then add smoothing. Press Resample for new spikes.

5
20 ms

Toy neuron and toy rates, Poisson spikes in 20 ms bins, Gaussian smoothing in your browser. The error is the root mean square gap between the estimate and the true rate, in spikes per second. The 1/√R fall is a statistical fact, not a number from the paper.

With one trial the estimate is mostly noise. With sixty trials it hugs the true rate. The error falls roughly as one over the square root of the trial count. Smoothing helps a little more, but too much blurs real peaks. This is why the width σ is a hyperparameter that the paper tunes for each dataset.

The two rules that tie the libraries together

Each library state carries two indices: the condition c and the position k along it. The paper defines two lookups with them.

g
The step back in time. The state before x̄kc is the one at index k − 1 on the same trajectory. So each state has exactly one past.
f
The link to behaviour. A neural state maps to the behaviour state with the same c and k. It is a lookup, not a fitted weight matrix.

This is where the many-to-one map of Chapter 2 pays off. The map f can be as nonlinear as you like, because it is just a table. Two neural states far apart can point to the same velocity without any trouble. And you can add any behaviour variable later, such as muscle activity, by averaging it into Φ. No retraining is needed. The paper notes MINT decodes a different variable with no new training once the neural state is estimated.

What “training” costs

Nothing here minimises a loss. Filtering and averaging take seconds on a laptop CPU. In the Neural Latents Benchmark run the paper cites, MINT trained in 28 seconds. The Gaussian process baseline took 30 minutes, the transformer baseline 3.5 hours and the switching nonlinear model 4.5 hours. The authors stress that MINT uses a library; it does not say how to build one. When trials do not repeat, as in the random-target task, they used AutoLFADS to infer the library, and training then took hours.

Four practical fixes the paper uses

Time warping. In cycling, trials of the same condition last different lengths. A 5% change in speed shifts the end of a seven-cycle trial by about 180 ms. The authors stretch trials to match, after filtering. Warping raw spikes would change the rates.

Circular behaviour. Pedal phase wraps at 360°. It cannot be averaged directly. They unwrap it, average, then wrap again.

Outlier-proof averaging. The paper’s Type II average keeps only the first principal component across trials before averaging. A single neuron with one wild trial then counts for less.

Condition smoothing. You may prefer 5 trials for each of 24 conditions over 15 trials for each of 8. Smoothing across conditions with PCA makes up for the fewer trials. The paper makes it optional.

What are MINT’s learned parameters?

Chapter 4

Scoring a State with the Poisson Likelihood

Ask each library state how well it explains the spikes, and replace every logarithm with a table lookup

A detective has eight suspects. Each suspect has a known habit. A witness describes what happened last night. The detective does not guess. She asks of each suspect: how likely is it that this person would produce this exact description? The suspect with the highest score is the lead.

MINT does the same with library states. A library state is a suspect, and its recent history of firing rates is its habit. The witness is the window of spike counts. The question is: how likely are these counts, if the brain were really at this state?

The likelihood of one window

Take a state x̄kc, meaning condition c, position k. Chapter 3 gave it a single past: the states at k − 1, k − 2 and so on along the same trajectory. So it predicts a rate for every neuron in every recent bin. Compare those predicted rates to the counts you actually saw.

Chapter 1 gave the chance of a count under a rate. Because bins and neurons are independent once the rates are fixed, the chance of the whole window is a product of many small chances. Products of many small numbers get tiny and unwieldy, so we take logarithms. A logarithm turns a product into a sum. The paper’s Equation 10 is this sum.

x̂t
The decoded neural state: the library state that explains the spikes best.
argmax
“The choice that gives the largest value.” Here the choice is one of the library states.
∑∑
Add over the τ′ + 1 recent bins and over all N neurons. One small term per neuron per bin.
log h(·)
The log of the Poisson chance of the observed count s̄ under the rate λn that this library state predicts for that neuron and bin.

This is a maximum a posteriori choice with a flat prior. The prior says every library state is equally likely before you see any spikes. With a flat prior, the most probable state is just the one with the highest likelihood. Because the library is finite, the paper adds, you can also turn the scores into exact probabilities by dividing by their sum.

A worked example, every step

Two neurons, one bin. State A predicts expected counts (0.4, 1.0). State B predicts (1.0, 0.4). You observe counts (2, 0).

  1. State A, neuron 1. log h(2, 0.4) = 2 ln 0.4 − 0.4 − ln 2 = −1.833 − 0.4 − 0.693 = −2.926.
  2. State A, neuron 2. log h(0, 1.0) = −1.0.
  3. State A total. −2.926 + (−1.0) = −3.926.
  4. State B, neuron 1. log h(2, 1.0) = 0 − 1.0 − 0.693 = −1.693.
  5. State B, neuron 2. log h(0, 0.4) = −0.4. Total: −2.093.
  6. Compare. B beats A by 1.833 in log terms. That means B makes the counts e1.833 ≈ 6.2 times more likely.

The lookup table

Look at the terms again. Each one depends on only two numbers: the observed count s and the predicted rate. Both have limited ranges. Counts in a 20 ms bin rarely exceed 20. Rates can be rounded to steps of 0.1 spikes per second. So you can compute every possible answer once, before decoding, and store it.

The paper’s example is a table of 2001 × 21 entries. It covers rates from 0 to 200 spikes per second in steps of 0.1 and counts from 0 to 20. During training, each library rate is rounded to its nearest table row. During decoding, a term costs one memory read and no logarithm. With 200 neurons and a 200 ms history of ten 20 ms bins, scoring one library state needs 200 × 10 = 2000 reads and 2000 additions.

Now view the whole score map. Each cell below is one library state. Brightness is its log-likelihood given the spikes in the window ending now.

Score every library state

Rows: the 8 trained conditions. Columns: position k along each trajectory. Bright cells explain the spikes well. The teal ring is the true state, the white dot is the best one. Change the window length, then press New spikes.

5 bins
bin 26

Toy library (60 neurons, 8 conditions, 50 bins), true state is condition 4 (135°). The log-likelihood is the real Poisson sum (constants that do not depend on the state dropped). The paper uses windows of a few hundred ms; for MC_Maze it was 300 ms.

With a one-bin window the map is a mess of bright patches. Several states fit one noisy bin. As the window grows, the bright patch shrinks onto the true cell. A longer window also reacts more slowly to change, so the paper tunes window length for each dataset. Shortening the window cost position R² just 0.011 on MC_Maze in its robustness test.

Why this suits Poisson, and why the Kalman filter cannot

A Kalman filter tracks a continuous state and wants Gaussian noise so the maths stays closed. Spike counts are small whole numbers, so the Gaussian fits poorly at low rates. See Kalman Filter for the usual setting. MINT avoids the problem. Its states form a finite list, so the likelihood of each is computed directly. There is no integral to solve.

Why can MINT replace the logarithms in its score with a table lookup?

Chapter 5

The Recursion That Makes It Fast

Slide the window by adding the newest bin and removing the oldest, so each step costs the same however long the window is

A shop keeps a running total of the last seven days of sales. On Monday morning the manager does not re-add seven numbers. She adds Monday and subtracts last Monday. The total updates in two steps, and a longer week costs nothing extra.

MINT uses the same trick. Chapter 4 scored each state from scratch, adding up one term per neuron per bin in the window. That is wasteful. When the window slides by one bin, all but two of the bins are the same ones as before, shifted by one position along each trajectory.

Why the old terms can be reused

Suppose at the last bin you scored state (c, k). Now the window has moved one bin forward in time. If the brain is at (c, k) now, one bin ago it was at (c, k − 1). So the state you scored last bin, (c, k − 1), has almost the same window as the one you want now. The two windows differ only at the ends. The strong flow along trajectories gives every state exactly one past, so the match is clean.

Write r for the score of a single bin: the sum over neurons of the lookup values for that bin. Write q for the score of the whole window. The paper’s recursion is:

qt,k
The window score of library state k, now at time bin t. The condition index c is the same on both sides.
qt−1,k−1
The score you already computed one bin ago for the state one step earlier on the same trajectory.
rnew
The score of the newest spike-count bin against this state: N lookups, one per neuron.
rold
The score of the bin that just left the window against the state it matched: N more lookups, which you subtract.

A tiny example makes it concrete. Take a window of 3 bins and a state whose per-bin scores are −4, −5 and −3, oldest first. Its window score is −12. Now a new bin arrives and scores −6 against the same state moved one step on. The old bin, worth −4, leaves. The new window score is −12 + (−6) − (−4) = −14. You did two sums of lookups, not three, and you did not touch the middle bin again.

So the cost per state is 2N lookups. It does not depend on window length. With 60 neurons that is 120 lookups per state. Compare that with the full recomputation, which needs 60 × (window bins). Step through the recursion below. It checks itself against the direct sum on every step.

Add one bin, drop one bin

Top: 50 time bins with the window shaded. Bottom: lookups per state for the direct sum and the recursion. Press Step to slide the window one bin. Change the window length to see the gap grow.

5 bins

The scores are real: the recursion and the direct sum are both computed for all 400 toy library states (8 conditions × 50 bins), and the largest difference is shown. Lookup counts are N = 60 neurons times the bins touched, per state, for this toy.

The difference between the two methods is only rounding error, far below 10−9. They are the same number reached by different routes. The recursion simply refuses to repeat work.

Fewer states, and updates between bins

Two more savings stack on top. First, the library does not need every millisecond. MINT keeps only states spaced one bin apart, 20 ms in the paper. Take the paper’s own example: four conditions with 1,000 samples each give 4,000 states. Spacing them at 20 ms leaves 200. Interpolation in Chapter 6 restores the lost precision.

Second, spike counts arrive once per bin, but a behaviour estimate can be updated every millisecond. Between bins, MINT assumes the state keeps flowing along its trajectory. The estimate at 5 ms after a bin is simply the library state five samples further along. When a new bin arrives, it picks the best state again.

What it costs overall

The paper states the cost for state estimation is O(N × Ttotal), where Ttotal is the total number of library time points across conditions. If all conditions have equal length, that is O(N × C). Memory is O((N + M) × C), where M is the number of behaviour variables. Both grow in a straight line with neurons or conditions. Much of the work is condition by condition, so it can run in parallel.

The authors timed the code on a MacBook Pro CPU in MATLAB with the core recursion as a compiled MEX file. They report execution well below the real-time limit, and in many cases estimates in under a millisecond. When a millisecond is too tight, they suggest a small decoding lag of about 5 ms so computing can start early.

The window grows from 5 bins to 20 bins. How does the recursive cost per library state change?

Chapter 6

Interpolation: Decoding Between the Trajectories

Mix two library states with one number, and find the best mix with a few Newton steps

A painter owns tins of two blues, one pale and one deep. A customer wants a shade between them. She does not need a new tin for every shade. She mixes a share of each. One number, the share, fixes the colour.

The library holds eight reach directions, but a person may reach at 160°. No stored trajectory matches. MINT mixes two stored states and chooses the share that best explains the spikes. The behaviour is mixed with the same share.

The mixing model

First find two candidate states. The first is the best state from Chapter 4. The second is the best state on a different trajectory, a different condition. Call them x̄1 and x̄2, with behaviour z̄1 and z̄2. Then the paper’s model (Equations 20 to 23) says:

x
The mixed neural state. At α = 0 it is the first candidate. At α = 1 it is the second. In between it is a straight line of states.
z
The mixed behaviour, using the same α. The model assumes that as the neural state slides smoothly, the behaviour slides smoothly too.

The window of history gets mixed in the same way: every recent bin of candidate 1 is blended with the matching bin of candidate 2. The prior on α is flat between 0 and 1. So, as before, the best α is the one that maximises the log-likelihood of the spikes.

One hill, no false peaks

Write the log-likelihood as a function of α. The paper shows its second derivative is never positive:

d2q/dα2
How fast the slope of the log-likelihood changes. Negative everywhere means the curve bends downward like the top of a hill.
∑ s
Sum over every neuron and bin of the observed count s. Counts are never negative.
(Δλ / λmix)2
A squared ratio, so never negative. Δλ is the rate gap between the two candidates, λmix the mixed rate.

A concave function has one peak and no false ones. That makes the search easy. No clever starting point is needed.

Newton’s method in plain words

Newton’s method finds the top of a hill by jumping. Stand at your current α. Look at the slope and at how sharply the hill bends. Pretend the hill is a perfect bowl with that bend. Jump to the top of that bowl. Repeat. For a gently curved hill, a few jumps land very close to the peak.

The update is α ← α − q′ / q′′, with q′ the slope and q′′ the bend (negative here). Worked example, one neuron and one bin. Candidate rates are 0.4 and 1.2 expected spikes, and you saw 1 spike. Start at α = 0.5.

  1. Mixed rate. m = 0.4 + 0.8α = 0.8. Slope q′ = s × 0.8/m − 0.8 = 1 − 0.8 = 0.2. Bend q′′ = −s × (0.8/m)2 = −1.
  2. Jump. α = 0.5 − 0.2/(−1) = 0.700.
  3. Again. m = 0.96, q′ = 0.0333, q′′ = −0.694. α = 0.700 + 0.048 = 0.748.
  4. Again. m = 0.9984, q′ = 0.0013. The change is 0.002, below 0.01, so stop. The exact answer is 0.75, where m equals the count.

The paper stops when α moves less than 0.01, when it hits 0 or 1, or after 10 steps. Try it on the toy library below. Pick a direction between two trained ones.

Climb the hill with Newton

The curve is the log-likelihood of the spikes as the mix slides from candidate 1 to candidate 2. Dots are Newton iterates. Press Newton step to jump, or Run all.

160°

Toy library, a window of 5 bins at bin 26 of the reach, real Poisson log-likelihood and the paper’s stopping rules. The two candidates are the best state and the best state on a different condition. Decoded direction is the angle of the mixed velocity.

Slide the true direction from 135° towards 180°. The two candidates are usually the two nearest trained directions. The best share α moves smoothly from one to the other, and the decoded angle follows the truth.

Two kinds of interpolation, and a few variants

Across indices. Because MINT keeps only every 20 ms state, it mixes a state with its neighbour on the same trajectory. This restores timing precision. It is a cost saver, not a way to generalise.

Across conditions. This is the interpolation of this chapter: two different trajectories. The paper’s ablation says it helps. Turning it off cost 0.018 in R² (paired t-test, p < 0.001, over 964 R² values).

For the random-target task MC_RTT, there is no condition structure. The second candidate could lie on the same trajectory if it was at least 1,000 ms away. They also used 6 candidate states and took the best pairwise mix. For circular phase, mixing runs along the shorter arc: 10° and 350° are 20° apart, not 340°.

Not a fill-in. Mixing could fill in the empty centre of a tube-shaped manifold. It does so only if the spikes demand it. The paper reports that in practice essentially all interpolation is local, between nearby trajectories. The mesh stays a mesh.
Why can Newton’s method find the best mixing share α reliably?

Chapter 7

The Results: Four Decoders on Four Datasets

Read the paper’s main tables and figures, and see what each comparison does and does not show

A coach wants to know which of five runners is fastest. A fair race needs the same track, the same distance, and the same start. The paper builds such a race for decoders. All decoders get the same spikes, binned at 20 ms. All are scored on held-out trials they never trained on. All decode causally, using only spikes from before the moment being decoded. All comparisons are offline.

The competitors and the tracks

MINT faces four rivals. The Kalman filter and the Wiener filter are interpretable: they make explicit linear assumptions. A feedforward network and a GRU (a recurrent network with gates) are expressive: they learn assumptions from data. The tracks are four datasets: MC_Cycle (pedalling), MC_Maze (straight and curved reaches, 108 conditions), Area2_Bump (somatosensory cortex) and MC_RTT (random point-to-point reaches with no repeated conditions).

The score is R², the share of the variation in the true behaviour that the decode captures. 1 is perfect. 0 is no better than guessing the average. It can go negative. The paper’s Figure 5 shows one marker per decoder, for each behaviour group in each dataset. There were 15 behaviour groups in all, such as position, velocity, muscle activity and phase.

What the headline says

MINT beat the Kalman and Wiener filters on every one of the 15 groups. Against the expressive networks it was the best decoder on 11 of 15 groups. On 3 of the 4 others, the gap to the best was tiny: under 0.004 in R². So in only 1 of 15 groups was MINT clearly behind. MC_RTT was the one dataset where MINT did noticeably worse than the feedforward network and the GRU.

For velocity, averaged over the four datasets, the paper reports R² of 0.841 for MINT, 0.837 for the feedforward network, 0.830 for the GRU, 0.719 for the Wiener filter and 0.630 for the Kalman filter. MINT and the two networks are close. The linear methods trail by a wide margin.

The paper’s numbers

Choose a panel. Each bar is a number printed in the paper. Warm is MINT; pink is a linear baseline; blue-purple are the neural networks.

All values are printed in the paper: velocity averages in its Discussion, the MC_Maze pair in its Interpretability section, the changes in R² in Figure 5 supplement 2 (964 values over 4 datasets), the training times in its reply to a reviewer (MC_Scaling 5 ms Phase benchmark task).

Look at the third panel. The direct lookup from neural state to behaviour beat a linear readout of the same estimated neural state by 0.061 in R². That one choice is worth more than interpolation (0.018). Acausal decoding, which also uses future spikes, gained 0.051. Sorted spikes versus good threshold crossings cost only 0.014.

The details that make the claim honest

  1. Fair tuning? Rival decoders were tuned by Bayesian optimisation, and each got its own window length per behaviour. MINT was tuned lightly, with one window length per dataset. Moving each hyperparameter to half and to one and a half times its value changed MINT very little. Shortening the window cost 0.011 in position R².
  2. Did the averaging give MINT an edge? MINT trains on trial averages; rivals on single trials. The authors tried adding averages to the rivals. That hurt them, so they kept single-trial training for rivals.
  3. Is any Bayesian decoder enough? A naive Bayes decoder on MC_Maze scored R² 0.688 for position and 0.093 for velocity. So MINT’s structure matters, not just the use of Poisson counts.
  4. Is the Kalman filter just weak? On MC_Maze it scored 0.609 for velocity against MINT’s 0.914. On simulated data built to match the Kalman assumptions, it did much better. The point: a decoder is only as good as its assumptions match the data.

Where MINT is weak: MC_RTT

MC_RTT has slow, varied reaches. The median speed during movement was just 5.9 cm/s, against 38.1 cm/s for MC_Maze. Correlations were Rx = 0.785 and Ry = 0.843. Every decoder did worst here. MINT had no repeated trials to average, so the library came from AutoLFADS with only about 10 minutes of training data. The authors say this may explain part of the gap, and that the data may strain every method’s generalisation.

Seen from the other side: neural state estimation

The paper also submitted MINT to the Neural Latents Benchmark, which tests how well a method predicts held-out neurons. On the bits per spike score, MINT matched AutoLFADS and beat the neural data transformer slightly. An ensemble of transformers scored higher: 0.386 against MINT’s 0.330 on MC_Maze. MINT had the best PSTH R² on every dataset, a measure of how well average firing-rate curves are recovered. For velocity decoded linearly from the estimated state, MINT beat every baseline method on every dataset.

It also held up with little data. With about five times fewer training trials, R² fell by only 0.037 for position and 0.050 for velocity. In the artificial network, MINT scored R² 0.968 using about 4.4 min of training.

Which statement best matches the paper’s results?

Chapter 8

Where It Breaks, and How MINT Tells You

Test new tasks, lost neurons and the likelihood alarm, and learn what the paper does and does not claim

Imagine a ship’s pilot with a chart of one bay. Inside the chart, her navigation is superb. Outside it, no instrument can help, because nobody has surveyed those waters. A good pilot also knows when she has left the chart. She notices that the depth readings no longer match anything she expected.

MINT is that pilot. Its library is the chart. This chapter shows where the chart ends, what happens when instruments fail, and how the likelihood tells MINT it is off the map.

Generalisation is limited for every decoder

Generalisation means decoding a movement not seen in training. Under the old view (Figure 1a), it should be easy for a linear decoder. If training covers the full range of velocities, any new path through those velocities is just a new route through known territory. MINT, which relies on stored trajectories, would then be at a disadvantage.

The paper tests this twice. First, in MC_Cycle, the hand covers the same velocities in forward and backward cycling. All tested methods, trained on one direction and tested on the other, failed. Most R² values were near zero or negative. The two directions use nearly orthogonal neural subspaces, which are directions at right angles to each other.

Second, the MC_PacMan task: monkeys pushed on an immovable handle to match a force target, recorded with Neuropixels probes. Force is the one central behaviour. Training used four ramp conditions that spanned the full range of forces. Testing used sinusoids and a chirp. Both MINT and the Wiener filter did well on the slow 0.25 Hz sine, almost as well as when trained on everything. Both did badly at the fastest frequencies, especially 3 Hz, even though training contained fast ramps.

So success depended on the test condition and hardly on the decoder. The authors read this as support for Figure 1b: different conditions can use different flow fields, even when the output range is the same. Where MINT beat the Wiener filter in one case, the Wiener filter beat it in another. Overall performance was so low that either would need retraining.

The likelihood as an alarm

Here is a useful by-product. MINT already computes how likely the spikes are under its best state. If the true neural state lies far from every library state, even the best state fits the spikes badly. The likelihood drops. No one has to ask the participant whether decoding feels wrong.

The paper shows this in its Figure 6e. For the 0.25 Hz sine, the distribution of negative log-likelihoods looked like the one for ramps. For the 3 Hz sine, a second mode of very unlikely observations appeared. The toy below mimics the idea. We measure the Poisson deviance, a standard misfit score. A perfect model gives about 1 per neuron per bin.

Raise the likelihood alarm

Slide the novelty up to push the test spikes away from anything in the library. Bars: the misfit of MINT’s best state at each time bin. The dashed line is a toy alarm level.

0%

Toy: a 100° reach whose neurons are blended with a scrambled copy of themselves, so the activity leaves the library’s mesh while the behaviour does not change. Misfit is the Poisson deviance of the best library state per neuron per bin. The alarm level 1.25 is our choice for illustration; the paper compares whole likelihood distributions instead.

Losing neurons

Electrodes die and channels drift. A decoder should survive that. The paper tests MINT on MC_Maze-L, with 162 neurons. Two cases matter. In an undetected loss, a neuron falls silent and nobody tells the decoder. In a known loss, the system knows the neuron is gone.

For known loss, MINT needs no retraining. It just leaves the lost neurons out of the sum in Equation 10. Other methods change every parameter when one input vanishes. With MINT, the average position R² stayed above 95% of its peak until fewer than 58 neurons (36%) remained. For velocity the limit was 62 (38%). A retrained Wiener filter needed about twice as many, 118 for position and 126 for velocity. For undetected loss, MINT showed essentially no deficit for fewer than 20 of the 162 neurons lost. It stayed above 95% until fewer than 113 (position) or 109 (velocity) remained. Losing half the neurons without telling it was a major loss.

Lose neurons, with or without telling MINT

Drag the number of lost neurons. Choose whether MINT knows. Press Trace both curves to see the whole picture.

20 of 60

Toy library of 60 neurons, R² averaged over three test reaches (30°, 100°, 250°) with fixed random spikes. The shape matches the paper’s finding, not its numbers: those come from 162 real neurons (MC_Maze-L) and are quoted above.

What the paper does not claim

  1. Other brain areas. MINT worked in S1 (Area2_Bump) and dorsomedial frontal cortex (DMFC_RSG). But the authors warn that other areas, such as hippocampus, may need different assumptions.
  2. Online use. All comparisons are offline. Some decoders lose accuracy online because the user changes strategy. The authors suggest retraining on online data, and time-stretched libraries.
  3. Labels from people who cannot move. A participant who cannot move can only attempt a movement. The behaviour label for each moment is then uncertain. MINT needs good estimates of both libraries, and falls if they are misaligned.
  4. Drift. The library assumes stable recordings. The paper sketches drift correction and rebuilding libraries as extensions, not results.
  5. Task switching is a strength. If all tasks appear in the library, MINT switches tasks with no extra logic. It decoded both tasks in the artificial network, and all conditions in MC_PacMan.
What does a sudden drop in MINT’s data likelihood most likely signal?

Chapter 9

Field Guide: MINT on One Page

Review the numbers, the checklist and the core code, then go back to the reach and explain it from memory

You can now rebuild the paper’s method from memory. MINT stores trial-averaged neural trajectories paired with behaviour (Chapter 3). At each 20 ms bin it scores every library state with a Poisson log-likelihood read from a lookup table (Chapter 4), kept cheap by a sliding-window recursion (Chapter 5). It mixes the two best states from different conditions, with a share found by Newton’s method (Chapter 6), and reads off the mixed behaviour. It rests on a view of motor cortex as a sparse mesh of low-tangled trajectories (Chapter 2).

The numbers that matter

WhatNumberWhy it matters
Bin and window20 ms bins; 300 ms window on MC_Maze (14 previous bins)The only two decoding settings; robust to changes
Lookup table2001 × 21 (0 to 200 spikes/s by 0.1; counts 0 to 20)No logarithm at run time
One state, 200 neurons, 10 bins2000 lookups directly; 2N = 400 by recursionCost no longer grows with the window
Newton stopping rulestep under 0.01, or α at 0 or 1, or 10 iterationsA few steps on a concave curve
Velocity R², 4 datasetsMINT 0.841; feedforward 0.837; GRU 0.830; Wiener 0.719; Kalman 0.630Simple counting matches deep networks
Win counts37 of 42 against expressive methods; best on 11 of 15 behaviour groupsClose, not overwhelming
MC_Maze velocity R²Kalman 0.609; MINT 0.914Assumptions must fit the data
Design choices (change in R²)direct vs linear +0.061; acausal +0.051; interpolation +0.018; threshold crossings −0.014The nonlinear lookup earns the most
Geometry testssign agreement 67.3% (kinematics), 79.2% (muscles), 99.7% (isometric control)Neural and behaviour geometry differ
Training time (one benchmark task)MINT 28 s; GPFA 30 min; NDT 3.5 h; switching nonlinear 4.5 hTraining is averaging
Known neuron loss (of 162)MINT above 95% of peak until under 58 (position) or 62 (velocity) remain; retrained Wiener needs 118 or 126Ignore, do not retrain
Less dataabout 5 times fewer trials: R² down 0.037 (position), 0.050 (velocity)Small training sets are enough
Neural state estimation, MC_Maze0.330 bits per spike for MINT; 0.386 for the best transformer ensembleNot the top on every score

The core, in code

This sketch is ours, written from the paper’s equations. It keeps the logic and drops the speed tricks. It uses spike counts for the last W bins, oldest first.

pythonimport numpy as np

def train(rates, beh):
    # rates[c]: (N, K, R) filtered single-trial rates, spikes per bin
    # beh[c]:   (M, K, R) matching behaviour
    omega = np.stack([x.mean(axis=2) for x in rates])      # (C, N, K)
    phi   = np.stack([z.mean(axis=2) for z in beh])        # (C, M, K)
    return omega, np.log(np.maximum(omega, 1e-3)), phi

def score(counts, omega, logom, W, keep=None):
    # counts: (N, W). Returns q[c, k]: log-likelihood of the window ending at library bin k
    C, N, K = omega.shape;  L = K - W + 1
    keep = np.ones(N, bool) if keep is None else keep   # known lost neurons: False
    q = np.zeros((C, K))
    for j in range(W):
        s = counts[keep, j]
        q[:, W-1:] += np.einsum('n,cnk->ck', s, logom[:, keep, j:j+L]) - omega[:, keep, j:j+L].sum(1)
    q[:, :W-1] = -np.inf
    return q

def decode(counts, omega, logom, phi, W, keep=None):
    q = score(counts, omega, logom, W, keep)
    c1, k1 = np.unravel_index(q.argmax(), q.shape)        # best state
    q2 = q.copy(); q2[c1] = -np.inf
    c2, k2 = np.unravel_index(q2.argmax(), q.shape)       # best state, other condition
    L1 = omega[c1, :, k1-W+1:k1+1];  L2 = omega[c2, :, k2-W+1:k2+1];  d = L2 - L1
    a = 0.5
    for _ in range(10):                                    # Newton on the concave q(alpha)
        m = (1-a)*L1 + a*L2
        g = (counts*d/m - d).sum();  h = -(counts*d*d/(m*m)).sum()
        if h > -1e-9: break
        new = np.clip(a - g/h, 0, 1);  done = abs(new-a) < 0.01;  a = new
        if done or a in (0, 1): break
    return (1-a)*phi[c1, :, k1] + a*phi[c2, :, k2]       # (M,) behaviour estimate

A checklist before you reach for MINT

  1. Do you have repeated trials per condition? If not, you need another way to build the library, such as AutoLFADS, which took hours in the paper.
  2. Is the brain area motor-like? The paper tested M1, PMd, area 2 and dorsomedial frontal cortex, not hippocampus.
  3. Will test movements resemble the library? Watch the likelihood. A rising misfit means you left the chart.
  4. Are the behaviour labels aligned? A shifted label shifts every output.
  5. Will neurons come and go? If you know which, drop them from the sum. No retraining.
  6. Is it offline only so far? The paper reports offline results. Plan for an online test.

Where it sits, and where to go next

MINT sits between the interpretable linear filters and the learned networks. It is as simple as the first and, on these datasets, close to the second. It belongs to the lecture Linear Decoders, which sets up the Wiener and Kalman filters that MINT is compared with.

The takeaway. A decoder is a bet about geometry. If motor cortex is a sparse mesh of one-way trajectories, then storing the trajectories and scoring them with a Poisson likelihood is a better bet than a weighted sum. It is simple, quick to train, and it tells you when the spikes stop fitting.

Credit

The method and every number on this page are from Perkins SM, Amematsro EA, Cunningham JP, Wang Q and Churchland MM, “An emerging view of neural geometry in motor cortex supports high-performance decoding”, eLife 2025 (doi 10.7554/eLife.89421), published under a Creative Commons Attribution license. The toy neurons, the instrument and the code sketch are ours, not the authors’ data or code. The authors link their MATLAB code in the paper’s Data availability section.

Now press Present or Teach and explain MINT out loud: why a weighted sum fails, what the library holds, how a state is scored, why the recursion is cheap and what Newton does. Then go back to the reach at the top, set the direction to 160°, and watch the linear filter and MINT decode the same spikes.

MINT: A Mesh of Idealized Neural Trajectories
Read the paper · The lecture: Linear Decoders · Back to Gleams