Show a mouse a movie type it never trained on, and a model fitted to other mice can still guess each neuron. Wang et al. (2025): 0.65 accuracy in under 30 minutes of data, where a lone model needs over 60.
Learn how a digital twin of the mouse visual cortex is built: four modules, one shared core, and a barcode for every neuron.
Pick a stimulus, then drag the minutes of data from the new mouse. Watch the foundation model (purple) track the real neuron (orange) long before the lone model (grey) can. Then we build it piece by piece: the eye, the arousal, the core, the readout, the loss, and what the twin lets you do.
You need a feel for correlation (a number from −1 to 1 that says how closely two curves move together) and a little Python. We build the neuroscience and the network from zero.
Based on Wang, Fahey, Ding, Papadopoulos, Ponder, Weis, Chang, Muhammad, Patel and colleagues of the MICrONS Consortium, with Andreas Tolias (corresponding author) and Fabian Sinz, “Foundation model of neural activity predicts response to new stimulus types”, Nature 640, 470 to 477 (2025), open access (CC BY 4.0). Every idea is re-taught here in our own words and devices. It is a reading of the lecture Task-Trained Networks.
The paper's stops (Fig. 3b, 3d): natural videos, foundation under 30 min and individual over 60 min to pass a median CCnorm of 0.65; Gabor patches, foundation above 0.55 at 16 min, individual needs over an hour. The smooth curves between those stops are our illustrative guide lines, and the wiggly traces are a toy neuron, not recorded data.
Chapter 0
See why one hour of recordings from one mouse is too little, and why pooling many mice can fix it
Picture a lab at night. A mouse stands on a treadmill, head held still, facing a monitor. The monitor plays short movies: a bird in flight, a hand on a door, a tunnel in black and white. Under a small glass window in the mouse’s skull, a microscope watches thousands of nerve cells flash as they react.
Each flash is a neuron (a brain cell that sends signals) changing how active it is. The record of how active one neuron is, frame after frame, is its response. A neuron in visual cortex does not respond to everything. It prefers certain edges, motions and places in the picture, a bit like a person who only laughs at certain jokes.
The scientists want a program that does what the brain does: take the movie in, and give each neuron’s response out. Such a program is called a digital twin. If the twin is good, you can show it a thousand movies in seconds, find what a neuron likes, and only then test the best guesses on a real mouse.
The first problem is time. The microscope session lasts about an hour. After that the mouse tires, the tissue drifts, and the picture blurs. So each mouse gives a small pile of data. A network that must learn every wrinkle of the visual system from one hour starts from nothing, and it learns slowly.
The second problem is surprise. The earlier best models were trained on natural movies. They predicted new natural movies well. But vision scientists have studied neurons for decades with simple, artificial patterns: stripes, dots, noise. Models trained on natural movies struggled with those (the paper cites an earlier model by Sinz and colleagues). A twin that fails on the classic experiments is hard to trust.
Both problems have the same cure that language models found. Do not train one model per task. Train one big model on a lot of varied data, then adapt it. The paper calls the result a foundation model: a model trained on broad data so that it transfers to new subjects and new tasks with little extra training.
Mice brains are alike in the ways that matter for vision. So pool the movies and the responses from eight mice, train one shared core (the part of the network that turns video into rich features), and freeze it. For a ninth mouse, fit only the small parts that differ: where it looks, how awake it is, and which feature each of its neurons reads.
The word in vivo means in the living animal. The word in silico means in the computer. The whole paper is about making in silico answers match in vivo ones, on stimuli the model never saw.
Here is the arithmetic. The paper combined recordings from eight mice into one training set. In total it holds more than 900 minutes of natural-video responses, from about 66,000 neurons across six visual areas. One session gives about an hour. Slide the number of pooled mice and watch the pile grow.
Bars show minutes of video responses and thousands of neurons. The dashed line is one hour, a single session. Add mice one at a time.
The totals at 8 mice are the paper’s: more than 900 min and around 66,000 neurons (Extended Data Table 1). Smaller counts are the average per mouse times n, so they are illustrative: real mice differ.
Eight mice give about 15 hours, more than fifteen times one session. The model sees many more neurons, many more movies and many more moments of arousal. What it learns is the shared part. Only the quirks of a new mouse remain to be learned.
A twin is useful only if its answers can be trusted. The payoff has three parts. First, in silico experiments: show the twin ten thousand stimuli and find the ones that drive a neuron hardest, then test only those on a real mouse. The paper cites earlier work that did this in closed loop, which the authors call inception loops. Second, time. In vivo recording time is scarce, so any question the twin can answer for free leaves more of the session for the questions it cannot.
Third, longevity. In the MICrONS project, the same mouse was recorded and then its brain was cut thin for electron microscopy. After that, no more recordings are possible. A twin fitted before that step keeps answering questions about those same neurons forever. The authors name this as a main reason to build one.
Two schools build such models. A task-driven model is trained to do something useful, such as naming objects, and then compared with the brain. Its hidden layers often resemble cortex. A data-driven model is trained directly to predict recorded neurons. The paper notes that, with large datasets, data-driven models now beat task-driven ones at prediction. This paper belongs to the second school. Its lecture, Task-Trained Networks, covers the first school and shows the contrast.
The word “foundation” comes from language and image models, which learn from huge broad data and then serve many tasks. The authors borrow the recipe at a smaller scale and ask whether it transfers to a brain.
Chapter 1
Follow one second of an experiment from photons to the arrays the network reads
A mouse watches a movie for an hour. Four things are measured at once: the movie, the activity of thousands of neurons, the position and size of the pupil, and the speed of the treadmill under its feet. The network must learn the link between them. Before any network, we need to know what these numbers are and how noisy they are.
Neurons talk with brief electrical spikes. The authors do not measure spikes directly. They use two-photon calcium imaging. The mice are bred so that their excitatory neurons carry GCaMP6s, a protein that glows brighter when calcium floods into the cell, which happens when it fires. A laser at 920 nm scans the brain through a window in the skull. The brighter the cell, the more active it was.
Think of a stadium crowd holding glow sticks that brighten when people cheer. You do not hear the cheers. You film the glow and infer the cheers. A program called CaImAn turns the glow into an estimate of spiking activity for each neuron. That estimate is what the model must predict.
The scanner is a large-field microscope called a mesoscope. In most scans (11 of 15) it covers about 1,200 × 1,100 µm, at four depths spread over layers 2/3, 4 and 5 (cortex is a stack of layers numbered from the surface down), at 6.3 Hz. That is 6.3 full pictures of the tissue per second. The region spans the border of the primary visual area, V1, and three higher areas: LM, RL and AL. Four other scans use a single plane to cover six areas, including AM and PM, at 6.8 to 6.9 Hz.
An infrared camera films the eye at about 20 Hz. A network called DeepLabCut marks eight points on the pupil edge in each frame. The authors fit the smallest circle through the confident points. It gives the pupil’s centre (two numbers) and its radius. A rotary encoder on the treadmill gives running speed at about 100 Hz.
The monitor is 31.0 × 55.2 cm, 15 cm from the left eye. A small light sensor on its corner records exactly when each frame appeared, so the video can be lined up with the brain data to within a frame.
The signals arrive at different rates: 6.3 Hz for neurons, 20 Hz for the eye, 100 Hz for the treadmill, and 29.967 Hz for the video. The network needs one value of each per video frame. So the authors resample neurons and behaviour to 29.967 Hz by linear interpolation: draw a straight line between neighbouring samples and read it at the frame times.
Worked example. One training sample holds 70 frames. At 29.967 frames per second, that is 70 / 29.967 = 2.336 s, the paper’s “2.33 s”. In that window a 6.3 Hz scan gives 2.336 × 6.3 = 14.7 real samples, so about 15. The other 55 values per neuron are straight-line fill. Each real sample is spread over 29.967 / 6.3 = 4.76 frames.
Orange stems are real scan samples of a toy neuron. Blue ticks are video frames. The purple line is the linear fill the network sees. Switch the scan rate.
The rates (6.3 and 6.8 to 6.9 Hz scans, 29.967 Hz frames) and the 70-frame sample are the paper’s (Methods). The neuron is a toy.
The cost is a limit. The model cannot see anything faster than the scan allows. Spikes a few milliseconds apart are blurred into one sample. The model predicts a smooth rate, not single spikes.
| Signal | Per video frame | Source |
|---|---|---|
| Stimulus | one monitor image | Psychtoolbox, frame times from the light sensor |
| Pupil centre | (px, py) | eye camera, DeepLabCut, circle fit |
| Pupil size | p and p′ (size and its change) | same circle fit |
| Running speed | r | treadmill encoder, low-pass filtered |
| Neurons | yt in RN, N neurons | CaImAn on two-photon scans |
A training batch holds 5 such samples of 70 frames each. The network gets the stimulus, the pupil and the treadmill. It must output rt in RN for every frame. It never sees the neurons’ true activity as input.
Symptom: in some frames the eyelid covers the pupil or the reflection moves, and the tracker returns bad points. Measurement: the authors keep a pupil point only if its likelihood is above 0.9. A frame needs at least 3 good points. They also drop frames whose circle is more than 5.5 standard deviations from the mean. Together this removes under 1.2% of frames per scan. Fix: a gap of up to 10 dropped frames is filled by linear interpolation. Trials with longer gaps are discarded, fewer than 18 trials per scan.
The lesson for a data engineer: a perspective model that trusts a bad pupil would aim its virtual eye at the wrong part of the screen. Cleaning the behaviour signals is part of the model.
Predictions are scored on held-out stimuli: movies shown to the mouse but kept out of training. Chapter 5 shows exactly how.
Each scan mixes several stimulus kinds. Natural videos come from a library of ecological movies. They are rich: edges, textures and motion all at once, and no one property is isolated. Directional pink noise is texture that moves coherently in one chosen direction. Static natural images are photographs.
The artificial ones isolate one property. A drifting Gabor patch is a soft blob filled with moving stripes. A 10 s trial holds 10 patches of 1 s each, with random position, direction, phase and spatial and temporal frequency. A random dot kinematogram is a field of dots moving together. A 10 s trial holds 5 patterns of 2 s: translation (up, down, left, right), radial flow (in or out) or rotation (clockwise or anticlockwise), at 50% or 100% coherence, which is the share of dots that move together.
Only natural videos train the models. Everything else is a test. That split is the whole point of Chapter 6, so remember it.
A fair test needs the frames and the neurons to line up. A small photodiode on the corner of the monitor records the screen’s brightness at 10 kHz. During the stimulus, each displayed frame number is encoded as a binary pattern in a corner signal. The authors recover that binary code from the photodiode for more than 96% of the frame flips. They then fit a straight line between the stimulus clock and the behaviour clock to place every frame on the same timeline as the scan and the camera.
Why does this matter to a modeller? A one-frame error means a 33 ms shift between the picture and the response. For fast stimuli, that is enough to blur the match. So part of the accuracy in this paper comes from careful lab engineering, not from the network.
The excitatory neurons imaged sit in layers 2/3, 4 and 5 of visual cortex. In 11 of the 15 scans the imaged site was chosen to mimic the MICrONS volume: about half V1 and half higher visual areas. The mice themselves are 2.2 to 4 months old, six female and eight male, and all procedures were approved by the Baylor College of Medicine animal care committee. The foundation cohort therefore mixes areas and depths on purpose, so that the core learns what is shared across them.
Chapter 2
Build the two small modules that turn a monitor image and two behaviour signals into what the cortex actually receives
Two mice watch the same frame on the same monitor. One glances left. The other sits up straighter, with wide pupils, and starts to walk. The first sees a different patch of the screen. The second has neurons that fire harder to everything. A model that ignores both would blame the stimulus for differences that belong to the mouse.
The paper gives each problem its own module. The perspective module works out what part of the screen lands on the retina. The modulation module turns running and pupil size into a hidden description of the mouse’s state. Both feed the core in Chapter 3.
The retina is the sheet of light-sensing cells at the back of the eye. The authors model it as a regular grid of points on a sphere. Each point looks out along a straight ray. For a grid point at polar angle θ (angle from straight ahead) and azimuth φ (angle around the axis), the ray is a unit vector in 3D:
Now the eye turns. A small multilayer perceptron (MLP, a stack of simple learned layers) reads the pupil centre (px, py) and outputs three eye-rotation angles. The MLP has 3 layers with 8 hidden units in the Conv-LSTM model and 16 in the CvT-LSTM one. Each ray is then rotated by those angles: l̂ = Rz Ry Rx l, where each R is a rotation matrix (a grid of numbers that turns a vector about one axis).
The monitor is a flat plane with six numbers: three for its position m0 and three for its tilt. A ray meets the plane where a line meets a plane:
Project m onto the screen’s own horizontal and vertical axes and you get a position (mx, my) in centimetres from the monitor centre. The pixel value for that retina point comes from bilinear interpolation: a weighted mix of the four pixels around (mx, my).
Worked example. Put the eye at the origin and the monitor flat, 15 cm ahead. A ray at θ = 30°, φ = 0 is (0.5, 0, 0.866). Its ratio is 15 / 0.866 = 17.32, so it hits at (8.66, 0, 15): 8.66 cm to the right of centre. Now turn the eye 10° about the vertical axis. The ray becomes (0.643, 0, 0.766). The ratio is 15 / 0.766 = 19.58, so it hits at x = 12.59 cm. A 10° glance moves this retina point 3.93 cm across the screen. Try it below.
The rectangle is the monitor (55.2 by 31.0 cm, 15 cm away). Each dot is one retina point traced to the screen. Turn the eye with the two sliders.
The geometry is the paper’s (Methods, Perspective module, Extended Data Fig. 1) with the eye on-axis and the screen flat and centred. The real module fits the pupil to angle map and the monitor pose with the rest of the network. The 24 × 10 grid is ours.
Why do this at all? The authors removed the module in a lesion study. Predictive accuracy fell by 2.3%, a modest but significant loss. The mouse’s eye moves, and a neuron with a small receptive field really does see a different patch from frame to frame.
Visual neurons do not respond to pictures alone. When a mouse runs or its pupil widens, many neurons fire more strongly to the same picture. Think of a volume knob that the brain turns with its state. The modulation module learns that knob.
It is a small LSTM (long short-term memory network: a recurrent layer with a memory cell and gates that decide what to keep). Each frame it reads running speed r, pupil diameter p and the change in pupil diameter p′, plus its own previous state. It writes a new hidden state hm and cell state cm, each of size 6 in the Conv-LSTM model (16 in the CvT-LSTM one, which reads only r and p). The vector hm is then copied across every position of a height by width grid, giving feature maps of shape C × H × W that the core can add to its own features.
Memory matters. Pupil size drifts over seconds, and arousal does not switch off the instant you stop moving. A model with memory can carry the effect. The authors show the hidden state, squashed to a flat 2D picture with a method called UMAP, is organised by pupil size and treadmill speed (Extended Data Fig. 2).
Pink: running bursts. Purple: a slow hidden state that remembers them. Orange: a toy neuron whose gain follows arousal. Dashed: the model’s guess. Toggle the module.
Illustrative toy: the neuron is exp(0.9 × picture + gain × arousal), arousal is a leaky average of running. The real module is an LSTM with 6 hidden units (Conv-LSTM model). The 2.8% accuracy drop when the module is removed is the paper’s (Extended Data Fig. 3).
Without the module the paper’s accuracy fell by 2.8%. Small, but real. Notice what both modules share: they cost almost nothing next to the core. They exist so that the core can concentrate on what the picture means.
Follow one frame through the first half of the network. The monitor image and the pupil centre enter the perspective module. Out comes a retinal image, the picture as it lands on the retina, a grid with one value per retina point. In parallel, running speed and pupil size enter the modulation LSTM. Out comes a short vector. The retinal image goes to the feedforward part of the core. The vector is copied over space and joins at the recurrent part. Both modules are trained together with the rest of the network, through the same loss. Nothing in them is set by hand, except the retina grid.
The mice are head-fixed, but each session places the head a little differently relative to the monitor. The lab positions the monitor on a six-way arm so that the screen is centred on the recorded cortex. Even so, the pose differs from session to session. So the perspective module treats the monitor’s position and tilt as six parameters and trains them with the network (our reading of the Methods). Extended Data Fig. 1c shows nine sample views, from three horizontal and three vertical rotations of the eye. A reader who builds this should expect the six numbers to differ for each new mouse.
Failure mode. Symptom: the model fits well on one mouse and poorly on the next, although the cores are the same. Measurement: the lesion study shows the module is worth 2.3% of accuracy on average. Fix: keep the perspective module among the parts that are fitted to the new mouse, not frozen. That is exactly what the foundation paradigm does.
Both modules are tiny next to the core. The pupil-to-angle network is an MLP with 3 layers of 8 hidden units (Conv-LSTM model). The modulation LSTM has 6 hidden units. Our reading of why: a new mouse has only a few minutes of data to fit them, and a small module is easy to fit from little data. The paper does not state this motive. It does show the result: with little training data these small modules plus a readout beat a model trained from scratch (Fig. 3).
One more detail. The modulation vector is copied to every position, because arousal is global. It does not say where in the field to look. The core decides how to use the vector: it may add it to some features and not others.
Chapter 3
Build the part of the network that holds most of the capacity: 3D convolutions to see, a Conv-LSTM to remember
A neuron that likes rightward motion cannot decide from one frame. A single picture of a bird says nothing about which way it flies. The cortex needs the last few frames, and also a memory that fades slowly after a stimulus ends. The core gives the model both.
The core has two parts. A feedforward part (data flows one way, no loops) looks at short stretches of video. A recurrent part (it feeds its own output back in) carries a memory from frame to frame and mixes in the behaviour signals from Chapter 2.
A convolution slides a small set of weights across an image, like a stamp pressed at every position. Each stamp position computes one number: how well the patch matches the weights. A 3D convolution uses a stamp that also spans time, say the last few frames, so it can detect motion as well as shape.
The authors use a DenseNet with three blocks. Each block holds two layers of 3D convolutions with a nonlinearity (ELU in the Conv-LSTM model, GELU in the CvT-LSTM one) and dense connections, meaning each layer also sees the outputs of the earlier layers in its block. After every block, spatial pooling shrinks height and width. The result is a stack of feature maps for each frame, Hft.
One rule is critical. A neuron at time t cannot depend on frames after t. So the authors shift the convolutions along time so that no future frame reaches the output. The device below shows what happens without that shift.
An LSTM keeps a cell state C, a running memory. Three gates, numbers between 0 and 1 produced by a sigmoid, control it. The forget gate F says how much old memory to keep. The input gate I says how much new content G to write. The output gate O says how much to show. The update is:
Worked example. Let Ct−1 = 1.0, F = 0.9, I = 0.5, G = 0.4, O = 0.8. Then Ct = 0.9 × 1.0 + 0.5 × 0.4 = 1.10. The output is Ht = 0.8 × tanh(1.10) = 0.8 × 0.800 = 0.640. With no new input the memory would shrink by 10% per frame. After about 6.6 frames (0.22 s at 29.967 Hz) it halves.
In the paper the LSTM is convolutional: the gates are computed by 2D convolutions, so the memory is a feature map that keeps its place in the visual field. The input to each cell is Xt = W1*Hft + W1*Hmt + Σ W1*Ht−1c′: the video features, the tiled modulation maps, and the previous outputs of all cells. A group of cells is built, and their hidden maps are concatenated along channels into Ht, which has 512 channels. That is the core’s output.
A flash arrives at frame 20. The 5-frame filter either looks only back in time (causal) or also forward. The cell below it keeps a fading memory.
Toy signals with a 5-frame box filter and one memory slot, written as Ct = F Ct−1 + 0.4 × filter output. The causal shift, the gate equations and 29.967 Hz are the paper’s (Methods, Core module).
The paper does not list Cf and Cm in the text we read, so we leave them as symbols. T is 70 in training.
The authors also built the CvT-LSTM. It inserts attention into the same cell: queries, keys and values come from convolutions of the feature map, as in the convolutional vision transformer. The attention output joins the gates. (For attention basics, see the Transformer lesson.)
The result is a lesson in small data. With the full training set, the two cores performed alike. With only 4 minutes of natural video from a new mouse, the Conv-LSTM did better. The authors suggest a better inductive bias for the Conv-LSTM, or simply less hyperparameter tuning for the CvT-LSTM. They do not claim to know which.
One more result: replacing 3D convolutions with 2D ones in the feedforward part cost 0.88%. Small, but significant.
In a plain stack, layer 2 sees only the output of layer 1. In a dense block, layer 2 sees the block input and the output of layer 1 glued together along the channel axis. Imagine passing notes down a line of people. In a plain line, each person only reads the note from the person before. In a dense line, each person also keeps every earlier note. Early, simple features then stay available to later layers. The DenseNet idea is old; the paper uses three such blocks and pools after each one, so height and width shrink step by step. The text we read does not give the pooling factor.
The Conv-LSTM has four gate signals per cell: input I, output O, forget F and candidate G. Each is a 3 × 3 convolution of the cell’s input X and of its previous hidden map, plus a bias. The first three go through a sigmoid, which squeezes values into 0 to 1. The candidate G goes through tanh, which squeezes into −1 to 1. The ordinary LSTM does the same with matrix multiplies. Using convolutions means the memory is a map: the cell remembers what happened at each place.
The input X mixes three streams with 1 × 1 convolutions: the feedforward features, the modulation maps, and the previous hidden maps of all cells in the group. Because X includes the other cells’ previous outputs, the cells can talk to each other from frame to frame. The final output is the concatenation of every cell’s hidden map. With C channels in total the readout in Chapter 4 reads C = 512 numbers.
In the CvT-LSTM the cell first builds Z = W3*X + W3*Ht−1. Three 1 × 1 convolutions of Z give queries Q, keys K and values V, one token per map position. Attention then compares every position with every other, so a position at the top of the field can borrow from the bottom. The result A joins Z in the four gates. The change from the Conv-LSTM is only in how the gate inputs are formed. The paper reports that the extra reach did not help at full data and hurt with 4 minutes of data.
Failure mode. Symptom: with very little data from a new mouse, the more flexible core predicts worse. Measurement: Extended Data Fig. 5 shows the Conv-LSTM ahead at 4 minutes in all six stimulus domains. Fix, in the authors’ words: either a better inductive bias, meaning built-in assumptions that suit the data, or a wider hyperparameter search for the CvT-LSTM. They leave it open.
Chapter 4
Turn the core’s shared feature maps into the response of each individual neuron
The core produces one big set of feature maps. Thousands of neurons need an answer from it. A new mouse has around 9,000 neurons in the test sets of the paper. You cannot give each one its own network. So each neuron gets just two small things: a place to look and a recipe for mixing what it sees.
Think of the feature maps as a wall of 512 transparent sheets laid on a picture of the visual field. Every neuron puts a pin through the wall at its own spot. At that spot it reads 512 numbers, one per sheet. Then it takes a weighted sum of them. That is the whole readout.
For neuron n the readout holds a position pn = (x, y), the centre of the receptive field it learned, and a feature weight vector wn with C = 512 numbers (one per core channel), plus a single bias bn. The receptive field is the part of the visual field a neuron responds to.
At frame t, the core outputs Ht with shape (512, H, W). The position is rarely on a grid point, so we read a feature vector by bilinear interpolation: a weighted mix of the four nearest grid cells. This is why each neuron reads only from a 2 × 2 window.
Why exp? A firing rate cannot be negative, and the exponential keeps the output positive. It also matches the Poisson loss of Chapter 5. If you know generalized linear models, this is a log link: a linear score, then exp.
Worked example with 3 channels instead of 512. Let the position be (2.3, 4.6). The four neighbours are (2,4), (3,4), (2,5), (3,5). The weights are (1 − 0.3)(1 − 0.6) = 0.28, 0.3 × 0.4 = 0.12, 0.7 × 0.6 = 0.42, 0.3 × 0.6 = 0.18. They sum to 1. Say the mix gives h = (0.5, −1.0, 2.0) and the recipe is w = (1.2, 0.4, 0.3), b = −0.5. Then h · w = 0.6 − 0.4 + 0.6 = 0.8. Add b to get 0.3. The response is e0.3 = 1.35.
The grid is a toy feature map with two channels. Colour shows the rate this neuron would give at each spot. The ring marks its pin, the box its 2 by 2 window. Move the pin, then turn the recipe.
Toy: 7 × 7 cells, 2 channels instead of 512, bias −0.5, weights of length 2 set by the angle. The readout equations, C = 512 and the 2 × 2 window are the paper’s (Methods, Readout module).
There is a catch. Gradients only reach the 4 cells in the window. A pin that starts in a poor spot gets almost no signal about better spots. The symptom: positions stay near their start. The paper’s fix is to sample the position during training from a 2D Gaussian, pn ~ N(μn, Σn), and to learn μ and Σ with the reparameterization trick (write the sample as μ plus noise scaled by Σ, so the gradient flows to μ and Σ).
Measurement: the learned covariance Σ shrinks to small values by the end of training. The pin settles. At test time the authors use the mean μn as the one position.
Because the core is shared and frozen for new mice, wn is the only thing that says what a neuron does. The authors call it a functional barcode. Is it stable? In the MICrONS data some neurons were scanned twice, in overlapping planes. They compared readout weights by angular distance (the angle between two vectors, divided by π). For 919 of 1,013 neurons, fewer than 5% of nearby neurons (within 100 µm, other scans) were more similar than the neuron to itself. For same-scan neighbours the count was 840 of 1,013.
So a neuron’s barcode is mostly its own, across sessions. Chapter 8 uses barcodes to predict anatomy.
The final models use an ensemble of four heads. The modulation, core and readout modules are parameterized separately in each head. The perspective transform and the readout grid are shared. The prediction averages the standardized log-responses of the four heads. Ensembles reduce the noise of a single fit.
Real fitting handles thousands of neurons at once. Take one frame. The core output has shape (512, H, W). For N neurons, the readout gathers N feature vectors of length 512: a (N, 512) table. It multiplies that table by the weight table (N, 512) slot by slot, adds up each row, adds the bias, and applies exp. The output is N rates. For a clip it does this for all 70 frames. A batch of 5 clips gives (5, 70, N) rates.
Count the parameters for a mouse with 9,000 neurons (the test mice had 8,014 to 10,246). The readout holds 9,000 × 515 = 4,635,000 numbers. That is already millions, so fitting needs the minutes of data the new mouse gives. This arithmetic is ours, not the paper’s, and it shows why the position was kept to only 2 numbers.
The split into position and weights separates two questions: where in the visual field does this neuron look, and what does it compute from what it sees? A neuron in cortex has a small receptive field, so the answer to “where” is a point plus a small spread. The answer to “what” is a direction in a 512-dimensional feature space. This is why the weights can serve as a barcode: the core features are shared, so the same direction means the same thing for every neuron.
Failure mode. Symptom: two scans of one neuron give different weights. Measurement: Extended Data Fig. 6 compares the angle between weight vectors, and colours each neuron by CCmax, the noise ceiling from Chapter 5. The colouring lets a reader see how noise affects the match. Fix: for tasks that need one barcode per neuron, the authors keep the scan with the highest CCmax (Methods).
Chapter 5
Derive the loss that fits counts, then derive the score that does not punish a model for the neuron’s own noise
The four modules are wired. Now they must learn. The network guesses a rate for each neuron at each frame. The neuron’s true activity then arrives. How wrong was the guess? The answer is the loss: a single number the optimiser pushes down. The choice of loss turns out to matter more than any architecture detail in this paper.
Neural activity is like a count of events. A cell with an average rate r produces a count y that jumps around r. The Poisson distribution describes this: the chance of seeing y events when the average is r is ry e−r / y!. Take the negative log, drop the term log y! that does not depend on r, and you get the per-frame loss:
Take the slope with respect to r: 1 − y / r. It is zero exactly when r = y. If r is too small, the slope is negative and training pushes r up. The log term also means that predicting a rate near zero for a neuron that did fire is punished harshly.
Worked example. Observed y = 5. Guess r = 1: slope = 1 − 5/1 = −4, loss r − y log r = 1 − 5 × 0 = 1. Guess r = 5: slope 0, loss 5 − 5 × 1.609 = −3.05. The squared error (r − y)2 would give slopes of −8 and 0. Mean squared error treats a miss on a rare burst like a miss on a busy cell; the Poisson loss scales the push with r, which is how counts behave.
Both curves are shifted so their minimum is zero. Choose the true activity y and a guess r. The ring is your guess on each curve.
The formulas are the textbook Poisson negative log-likelihood and squared error; curves are plotted for guesses from 0.1 to 10 and scaled to share one axis. The paper reports the Poisson loss beating mean squared error by 9.6% accuracy (Extended Data Fig. 3).
All four modules train together, end to end, by stochastic gradient descent with Nesterov momentum. A batch is 5 clips of 70 frames (2.33 s each). An epoch is 512 steps. The run lasts 200 epochs, so 200 × 512 = 102,400 steps, or 512,000 clips. The learning rate rises linearly for 10 epochs, follows a cosine decay for 90, then restarts and decays again over the last 100.
One honesty detail matters for trust. The authors searched hyperparameters on a preliminary set of mice, then trained the final models on a separate set of mice with no overlap in animals or experiments. The reported numbers are not tuned to the mice they are reported on.
Now the harder question: how do you score the result? Correlation seems natural. Compute the Pearson correlation between the model’s trace and the neuron’s trace on held-out stimuli. But a real neuron is noisy. Even a perfect model cannot reach a correlation of 1 against one noisy run. A model that scores 0.6 on a noisy neuron may be nearly perfect, while 0.6 on a clean neuron is poor.
The fix repeats the stimulus. Play the same held-out clip N times and average the neuron’s responses to get ȳ. Then compute the best correlation any model could reach, given that noise (a formula from Schoppe and colleagues). The paper writes the score as:
Worked example. N = 10 repeats, Var(ȳ) = 0.5, mean trial variance 2.0. CCmax = √((10 × 0.5 − 2.0) / (9 × 0.5)) = √(3 / 4.5) = 0.816. If CCabs = 0.60, then CCnorm = 0.60 / 0.816 = 0.735.
A toy neuron has a true rate (orange line). Each trial adds noise. The average of N trials is the grey line. The model is exactly right, yet its raw score falls short of 1.
Toy data, seeded so it repeats. The CC formulas are the paper’s (Methods, Model testing). CCmax is an estimate from the trials, so CCnorm of a perfect model lands near 1, not exactly 1.
The lesion study removes one part at a time and re-scores the model on held-out natural videos.
| Removed or swapped | Accuracy loss | Where |
|---|---|---|
| Perspective module | 2.3% | Extended Data Fig. 3a to e |
| Modulation module | 2.8% | Extended Data Fig. 3f to j |
| 3D convolutions swapped for 2D | 0.88% | Extended Data Fig. 3k to o |
| Poisson loss swapped for squared error | 9.6% | Extended Data Fig. 3p to t |
The biggest single choice is the loss. The architecture ablations all sit under 3%. And the paper says the main driver of its gain is the much larger training set. That is Chapter 6.
The learning rate starts near zero and climbs for 10 epochs. This is a warm-up. Our reading of the reason: at the start, the weights are random and the gradients are large and noisy, so a small step is safer. The rate then falls along a cosine curve for 90 epochs, which means a smooth slope that is gentle at the ends. After that the rate jumps back up (a warm restart) and falls again for 100 epochs. The restart lets the model leave one valley and settle in a new one. Both are standard tools; the paper reports them without ablation.
For a Poisson count the variance equals the mean. A neuron whose rate is 10 wobbles more in absolute terms than one whose rate is 1. Squared error treats both wobbles the same, so busy neurons dominate the loss. The Poisson loss scales the error by the rate, so each neuron contributes roughly in proportion to how surprising its miss is. The recorded activity here is an estimate from calcium glow and not a true integer count, but the shape of the noise is close enough for the loss to work. The 9.6% gain is the paper’s evidence.
Predictions are scored on stimuli that were shown to the mouse but kept out of training. For each neuron, the score uses the response averaged over repeats of the same stimulus. Averaging reduces noise, so that the comparison asks whether the model predicts the neuron’s expected response. For models trained on single sessions of about an hour, the authors found accuracy rose with the amount of training data across seven training fractions from 4 to 76 minutes (Fig. 2b). They found no significant link between accuracy and visual area (P = 0.45): higher areas were predicted about as well as V1.
That last point is a result worth pausing on. Higher visual areas respond to more complex features, so one might expect them to be harder to predict. The authors note this and report no gap.
Chapter 6
Freeze a core trained on eight mice, fit the small parts to a new mouse, and test on stimuli the core never saw
You now own all four modules. The question is how to use them so that a ninth mouse is cheap. A new lab member who joins a team with a good shared toolbox learns only what is personal: where the desk is, who sits where. The toolbox stays. That is the plan here.
The authors pooled recordings from eight mice, called the foundation cohort: more than 900 minutes of natural-video responses, around 66,000 neurons, six visual areas (V1, LM, AL, RL, AM, PM). They trained one shared core on all of it, along with the modules the cohort mice need. The trained core is the foundation core. Models built from it are foundation models.
Why would one core serve many mice? The authors argue that visual neurons respond in similar ways across animals. What differs from mouse to mouse is small: head pose, eye position, how each neuron samples the features. The similarities are learned once, from lots of data. The idiosyncrasies are learned per mouse.
For each new mouse the core is frozen: its parameters are copied and never updated. The new mouse’s own natural-video data trains only the perspective, modulation and readout modules. The control, the individual model, has the same four modules but trains all of them, core included, on that one mouse’s session. The only difference between the two is whether the core is inherited or learned from scratch. That makes the comparison clean.
Choose a stage. Filled boxes are trained on that stage’s data. Boxes with a lock are copied and frozen. The lower bars show the MICrONS result.
The structure is the paper’s (Fig. 3a). The MICrONS ranges are the paper’s: median CCnorm 0.48 to 0.65 for individual models and 0.58 to 0.76 for foundation models, over 14 scans of 33 to 53 min (mean 42 min).
Four new mice (not in the cohort) saw natural videos in seven training amounts from 4 to 76 minutes. The models were then scored on six kinds of held-out stimuli. Neuron counts per mouse were 8,862, 8,014, 9,452 and 10,246.
| Test stimulus | In training? | What it is |
|---|---|---|
| Natural videos | same type, new clips | Ecological movies, held out |
| Natural images | never | Still photographs |
| Drifting Gabor patches | never | Moving striped blobs of random position, direction and frequency |
| Flashing Gaussian dots | never | Blobs flashed on a grid, 300 ms each |
| Directional pink noise | never | Textured noise that moves coherently in one direction |
| Random dot kinematograms | never | Dots in translation, radial or rotating flow at 50% or 100% coherence |
The last five are out-of-distribution (OOD): different from what the model trained on. The paper stresses that no OOD stimulus was used to train any component, including the foundation core.
Natural videos: individual models needed more than 60 min to pass a median CCnorm of 0.65 for all mice. Foundation models needed less than 30 min. That is at least a factor of 2 in data. Drifting Gabor patches: foundation models passed 0.55 with only 16 min of natural video. Individual models needed more than an hour. That is at least 3.75 times as much data (60 / 16). The same gain held for all five OOD domains (Fig. 3c to g).
For the MICrONS mouse the time budget was tight: 14 scans, mean 42 min each. Individual models reached 0.48 to 0.65. Transferring the core lifted them to 0.58 to 0.76.
The earlier single-session comparison is also in the paper. Trained on the same V1 data as an earlier state-of-the-art dynamic model (Sinz et al.), this architecture gained 25 to 46% in accuracy across three sessions (Fig. 2a). It did equally well on the higher areas LM, RL and AL as on V1 (Fig. 2c).
Symptom to watch for: a model that is good on in-distribution movies and weak on gratings. Measurement: score on both, as above. Fix: more varied data in the core. But note the limits. The test used four new mice. The stimuli were shown to head-fixed mice that were passively watching. The paper says plainly that its model covers only parts of mouse vision under passive viewing, and the authors expect that wider data (freely moving animals, more areas, more cell types) are needed. The main driver of gain, the authors write, is the larger training set, in line with scaling laws.
Each panel of Fig. 3 shows accuracy (median CCnorm over neurons) against minutes of training data. Each panel holds 56 diamonds: 4 mice × 7 amounts of data × 2 model types. Lines join diamonds of the same mouse and model type. Foundation models are drawn against grey individual models. If a purple line sits above the grey one at every point, the foundation model wins at every data size. Read how far left you can move along the foundation line before it drops under the bar. That distance is the saved data.
Worked example from the text. Natural videos, bar 0.65: foundation under 30 min, individual over 60 min, a saving of at least 30 minutes, and at least a factor 2. Gabor patches, bar 0.55: foundation 16 min, individual over 60 min, a saving of at least 44 minutes, a factor of at least 3.75. The hero at the top of this page draws smooth lines through those two stops.
The MICrONS mouse had 14 scans in as short a time as possible, so the tissue stayed good. That left each scan with a mean of 42 min of training data, range 33 to 53 min, less than the other sessions. So this is a small-data test by design. With a single scan, individual models got 0.48 to 0.65. Transferring the core lifted that to 0.58 to 0.76. Only natural movies were tested here, because the MICrONS sessions did not include the other stimuli.
A reader who wants to challenge the result should look where it could still be weak: four test mice, one species, passive viewing. The paper itself lists the last as a limit.
Chapter 7
Use the twin to measure what each neuron prefers, and check the answer against the real animal
For decades, vision scientists have asked a plain question of a neuron: what do you like? They show stripes at many angles and see which angle makes it fire. This is tuning: how a neuron’s response changes as one stimulus property changes. A twin that cannot reproduce tuning would not convince the field. A twin that can lets a lab run those experiments without the mouse.
The paper tests this on three new mice (not in the cohort), about 30,000 neurons in V1, LM, AL and RL. Each mouse sees natural videos to train its foundation model, and also parametric stimuli. The real responses give the in vivo tuning. The model, fed the same stimuli it never trained on, gives the in silico tuning. Then they compare neuron by neuron.
The stimulus is directional pink noise: texture that moves coherently in one direction. There are 16 directions spread over 0 to 360°. A neuron’s direction preference is the way of motion it likes best. Its orientation preference is the axis, with both ways of travel counted as the same (0 to 180°).
To measure how selective a neuron is, treat each response as a weight on an arrow pointing at its angle. Add the arrows. If one direction dominates, the sum is long. The ratio of the sum’s length to the total response is the selectivity index:
Worked example with four angles. A neuron gives responses (4, 0, 4, 0) at 0°, 90°, 180°, 270°. For DSI: 4 − 4 = 0, so DSI = 0. For OSI, the doubled angles are 0°, 180°, 360°, 540°, which point to +1, −1, +1, −1: the sum is 4 + 4 = 8, over a total of 8, so OSI = 1. This neuron likes an axis but not a direction. A second neuron gives (6, 2, 0, 2): DSI = 6 / 10 = 0.6, OSI = 2 / 10 = 0.2. It prefers rightward motion.
For the preferred angle, the authors fit a mixture of two von Mises curves (smooth bumps on a circle) with peaks at μ and μ + 180°, an amplitude for each, a width κ and a baseline, by least squares. The preferred orientation is (μ + 90°) mod 180°. They then compare in vivo with in silico.
The polygon is a tuning curve sampled at 16 directions. Purple: the twin. Orange: a noisy recording. Shape the neuron, then turn up the recording noise.
Toy neuron: a two-lobe von Mises bump with width 2 and a baseline, noise drawn from a fixed seed. Preferred orientation here comes from the second harmonic of the 16 samples, a quick stand-in for the paper’s least-squares fit. Selectivity formulas are the paper’s.
Result: in vivo and in silico OSI and DSI matched closely across neurons (Fig. 4d, f). For neurons with an in silico OSI above 0.5, which is 11% of neurons, the median gap in preferred orientation was 4°. With a looser threshold of 0.3 (43% of neurons) it was 7°. The device shows why the gap grows for weakly tuned cells: a flat curve has no clear peak, so noise moves it.
For spatial tuning, mice saw 300 ms Gaussian dots flashed at positions on a 17 × 29 grid. Dark dots drove neurons more than bright ones, so the authors used the dark dots. They computed a spike-triggered average (STA): the average stimulus, weighted by the response, which shows what the neuron liked to see. A tight blob means a sharp place preference. The spatial selectivity index (SSI) is the negative log of the determinant of the blob’s covariance, so a smaller blob scores higher. A 2D Gaussian fit gives its centre.
Most neurons were weakly tuned to dots. But for neurons with in silico SSI above 8, the in vivo and in silico preferred locations differed by a median of 0.02 monitor widths, about 2° of visual angle.
The point is not that the twin knows stripes. The point is that it never saw stripes, dots or noise in training, and still reproduced tuning. Then the authors argue that parametric tuning can be done in silico, freeing in vivo time for other experiments. The limit is that the match is best for strongly tuned neurons. Weak neurons, the majority for dots, give weak evidence either way. The paper reports the match for neurons selected by in silico selectivity, and a reader should keep that selection in mind.
The comparison is fair because the twin never trained on the noise or dot stimulus. Only the recorded responses give it the right answer to check against.
The spike-triggered average at screen location x is s̄x = ∑t |sxt − s0| rt / ∑t rt. Here sxt is the pixel at x and time t, s0 is the grey of a blank screen, and rt is the response. It asks: how far from grey was location x, on average, when the neuron was firing? Locations that are bright or dark only when the neuron fires get a big value.
Toy example with three locations and three time steps. Pixel differences from grey: location A is (1, 0, 0), B is (0, 1, 0), C is (0, 0, 1). Responses are (3, 1, 0). Then s̄A = 3/4, s̄B = 1/4, s̄C = 0. The neuron fired most when the dot was at A, so A is the preferred place. The paper then measures how spread out the map is: the covariance of s̄ over (x, y). SSI is minus the log determinant of that covariance, so a tighter map scores higher.
Symptom: for a neuron with flat tuning, in vivo and in silico preferred angles agree less well. Measurement: the two thresholds. At OSI above 0.5 the median gap is 4 degrees; at OSI above 0.3, with more neurons included, it is 7 degrees. Fix: report the gap for increasingly selective groups of neurons, as the paper does (Fig. 4e, g, i stack histograms by threshold). Honest reporting means saying which neurons the number covers.
Chapter 8
Use a neuron’s readout weights to predict its brain area and cell type, and test whether the result is real
Suppose you have two maps of the same city. One shows what every shop sells. The other shows each shop’s building: its size, its shape, its street. If shops that sell similar goods also have similar buildings, the first map tells you something about the second. The MICrONS project built both maps for a piece of mouse cortex, and this paper links them.
MICrONS recorded the responses of more than 70,000 excitatory neurons to natural videos, in 14 scans of a 1 mm3 volume that spans V1, LM, AL and RL. The same tissue was then cut thin and imaged by electron microscopy at nanometre scale. That gave detailed shapes of about 60,000 excitatory neurons and 500 million synapses. It is the largest joint study of structure and function in cortex so far, as the paper puts it.
The authors applied the same recipe: transfer the foundation core, fit the perspective, modulation and readout for each neuron of the MICrONS mouse. The model never saw any anatomy. It only saw video and neural responses. Yet each neuron ends up with two readout parameters that depend on its own behaviour.
The first is its position. Plot the learned (x, y) positions of all neurons on top of the physical window over the brain. The positions form a smooth map: neighbouring neurons look at neighbouring places in the visual field. This is retinotopy. In V1 the x position tracks the medial to lateral axis, and the y position the rostral to caudal axis. At the border of V1 with LM and RL, the x map flips direction, which marks the boundary between areas. This matches known mouse retinotopy. The model found it unaided.
The second is the 512-number weight vector, the barcode from Chapter 4. It records which core features the neuron reads. Neurons with similar jobs should have similar barcodes.
Logistic regression is a simple classifier. It computes a weighted sum of the inputs for each class, turns the sums into probabilities, and picks the largest. The authors fed it the 512 weights and asked for the neuron’s visual area (4 classes) and its morphological cell type (11 excitatory types of layers 2 to 5, defined from electron microscopy by a companion paper). They used 10-fold cross-validation, with a second 10-fold loop to pick the regularization strength, and tested every prediction on neurons the classifier had not seen.
The score is balanced accuracy: the average of each class’s recall, where recall is the fraction of that class’s neurons found. Plain accuracy rewards ignoring rare classes. Worked example. A set holds 100 neurons of type A, 10 of B and 10 of C. A lazy classifier always says A. Plain accuracy is 100 / 120 = 83%. Balanced accuracy is (1 + 0 + 0) / 3 = 33%, which is exactly chance for 3 classes. Try it below.
Three classes: a big one and two small ones of 10 each. Pick the classifier, then make the big class bigger. Lower bars: the paper’s results with chance.
The top bars are a toy with 10 neurons in each small class. The lower bars are the paper’s (Fig. 5d, e): visual area 68% against 25% chance, cell type 32% against 9% chance.
Results. Visual area: 68% balanced accuracy, against 25% chance for 4 areas. Cell type: 32%, against 9% chance for 11 types. Eleven fine-grained types is a hard task, and 32% is far from perfect. It is well above chance.
Symptom: cell types in layers 2 to 5 separate by depth. Two-photon imaging has a depth-dependent signal-to-noise ratio. A classifier might be reading noise level, a proxy for depth, and not function. A careless claim would be that the barcode encodes cell type when it only encodes depth.
Measurement: the authors trained a reduced classifier that sees only the two-photon depth, and a full classifier that sees depth plus the barcode. A likelihood ratio test asks whether the extra weights help. The answer: the full model was significantly better, with P below 10−9. Fix: that control. So the barcode adds information beyond depth.
The paper also notes that companion articles use the same barcodes. One predicts detailed dendrite shape of layer 4 pyramidal neurons. Another predicts which neurons are synaptically connected, beyond what the nearness of their axons and dendrites can explain. We take those as the authors’ report; this lesson does not re-derive them.
Because the core is frozen and shared, the barcodes of different neurons live in one common space. Because the model is a twin, it keeps working after the tissue has been destroyed for electron microscopy, as the authors point out: unlimited in silico experiments, long after the in vivo ones end. The cost is clear too. Balanced accuracy of 32% is a statistical tilt, not a label. You cannot name a single neuron’s type from its barcode with confidence.
This is nested cross-validation. The held-out fold never helps choose the penalty, so the score is not inflated by tuning. For areas, the authors used the neurons of 13 scans that had readout weights. A neuron scanned more than once could appear twice, so for cell types they kept, for each neuron, the scan with the highest CCmax. That left 16,561 unique neurons with a matched electron-microscopy cell type.
The companion article defines 20 cell classes from morphology. The authors used the excitatory classes of layers 2 to 5, except one class (L5NP) that had too few co-registered cells. That leaves 11: L2a, L2b, L2c, L3a, L3b, L4a, L4b, L4c, L5a, L5b and L5ET. Chance for 11 balanced classes is 1/11, about 9%. A score of 32% means roughly three and a half times chance.
Look at the confusion matrices in Fig. 5d and 5e to see what kind of mistakes remain. Each row is normalized to sum to 1, so the diagonal is recall. Types that sit close together in depth are likely to be confused with each other. This is a reading of how such matrices behave; check the figure for the actual pattern.
The structural data arrive years after the recordings. The functional data cannot be re-collected. A model of function that transfers across animals and tasks gives each neuron a compact, comparable description: one vector. Other teams in the MICrONS project used that description to ask questions about shape and wiring. The authors argue that a foundation model extends the usefulness of such a dataset to questions nobody had thought of when it was recorded.
Chapter 9
Keep the numbers, the terms, a checklist and the core code, and find where to go next
One mouse hour is too little data. So Wang and colleagues pooled eight mice, trained one core, froze it, and fitted only the eye, the arousal and the readout of each new mouse. That model predicted new mice with far less data. It predicted stimulus types it never saw. It reproduced classic tuning. And the weights of its readout formed a barcode that tilts toward a neuron’s area and cell type.
| Quantity | Value | Where |
|---|---|---|
| Mice and neurons recorded | 14 mice, about 135,000 neurons | Main text |
| Foundation cohort | 8 mice, over 900 min, around 66,000 neurons, 6 areas | Extended Data Table 1 |
| Single-session gain over the earlier model | 25 to 46% higher accuracy | Fig. 2a |
| Natural videos, to pass median CCnorm 0.65 | foundation under 30 min, individual over 60 min | Fig. 3b |
| Gabor patches, median CCnorm above 0.55 | foundation 16 min, individual over an hour | Fig. 3d |
| MICrONS, median CCnorm | individual 0.48 to 0.65, foundation 0.58 to 0.76 | Extended Data Fig. 4 |
| Lesions | perspective 2.3%, modulation 2.8%, 3D vs 2D 0.88%, Poisson vs MSE 9.6% | Extended Data Fig. 3 |
| Orientation tuning match | median gap 4 degrees (OSI above 0.5, 11% of neurons), 7 degrees (OSI above 0.3, 43%) | Fig. 4e |
| Place tuning match | 0.02 monitor widths, about 2 degrees (SSI above 8) | Fig. 4i |
| Barcode to visual area | 68% balanced accuracy, chance 25% | Fig. 5d |
| Barcode to cell type | 32% balanced accuracy, chance 9% (11 types) | Fig. 5e |
| Training | 200 epochs of 512 steps, batch of 5 clips of 70 frames, Nesterov SGD, Poisson loss | Methods |
| Term | Meaning |
|---|---|
| Digital twin | A program that maps stimulus and behaviour to each neuron’s response. |
| In vivo, in silico | In the living animal, in the computer. |
| Foundation core | The core trained on the 8-mouse cohort and then frozen. |
| Perspective | Ray tracing from the retina to the monitor, aimed by the pupil. |
| Modulation | An LSTM turning running and pupil into a state that scales the core. |
| Readout | Per neuron: a position, 512 weights and a bias, then exp. |
| CCnorm | Correlation divided by the noise ceiling CCmax. |
| OSI, DSI, SSI | Selectivity indices for orientation, direction and place. |
| Functional barcode | A neuron’s 512 readout weights. |
python# A sketch of the forward pass and the transfer step. Not the authors' code: # their code and weights are at github.com/cajal/fnn and github.com/cajal/foundation. import torch, torch.nn as nn, torch.nn.functional as F class Twin(nn.Module): def __init__(self, perspective, core, n_neurons, C=512): super().__init__() self.perspective = perspective # pupil MLP + ray tracing -> retinal frames self.modulation = nn.LSTM(3, 6, batch_first=True) # inputs: speed, pupil size, its change self.core = core # causal 3D convs + Conv-LSTM, 512 channels self.pos = nn.Parameter(torch.zeros(n_neurons, 2)) # mean readout position (x, y) in [-1, 1] self.log_std = nn.Parameter(torch.full((n_neurons, 2), -2.0)) self.w = nn.Parameter(torch.randn(n_neurons, C) * 0.01) # the barcode self.b = nn.Parameter(torch.zeros(n_neurons)) def forward(self, video, pupil_xy, behav): # video (B, T, Hs, Ws) pupil_xy (B, T, 2) behav (B, T, 3) retina = self.perspective(video, pupil_xy) # (B, T, h, w) hm, _ = self.modulation(behav) # (B, T, 6) H = self.core(retina, hm) # (B, T, 512, H, W) B, T = H.shape[:2] p = self.pos + (torch.randn_like(self.pos) * self.log_std.exp() if self.training else 0) grid = p.view(1, -1, 1, 2).expand(B * T, -1, 1, 2) h = F.grid_sample(H.flatten(0, 1), grid, align_corners=True) # bilinear: (B*T, 512, N, 1) z = (h.squeeze(-1).transpose(1, 2) * self.w).sum(-1) + self.b # (B*T, N) return z.view(B, T, -1) # log-rate; rate = z.exp() def loss_fn(log_rate, y): # sum of r - y log r, with r = exp(log_rate) return F.poisson_nll_loss(log_rate, y, log_input=True) def transfer(twin): # new mouse: freeze the foundation core for p in twin.core.parameters(): p.requires_grad = False return [p for p in twin.parameters() if p.requires_grad] def cc_norm(pred_mean, trials): # trials (N, T) of one neuron; pred_mean (T,) N = trials.shape[0]; ybar = trials.mean(0) cc_abs = torch.corrcoef(torch.stack([pred_mean, ybar]))[0, 1] cc_max = ((N * ybar.var(unbiased=False) - trials.var(1, unbiased=False).mean()) / ((N - 1) * ybar.var(unbiased=False))).sqrt() return cc_abs / cc_max
The sketch leaves out the real perspective ray tracer, the core and the four-head ensemble. The shapes and the loss are the parts to keep.
Our reading, not the paper’s claim: the pattern of one pooled core with small per-subject parts is the same pattern that brain-computer interface teams use when they pool sessions and fit a small adapter per person. The lecture Task-Trained Networks places this paper next to the task-driven models it contrasts with.
Credit: Eric Y. Wang, Paul G. Fahey, Zhuokun Ding, Stelios Papadopoulos and colleagues in the MICrONS Consortium, with Andreas S. Tolias and Fabian H. Sinz, Baylor College of Medicine and partners. The paper is open access under CC BY 4.0. Now press Present or Teach and explain, from memory, why freezing the core helps a new mouse. Then go back to the instrument at the top and find the minute count where the grey and purple curves cross the paper’s bar.