Determine which layer of a pretrained CNN best predicts single-neuron responses in mouse V1 to natural images, using the Allen Institute Visual Coding – Neuropixels dataset.
Across the 110 VISp units of session 732592105, ridge-regressing per-image mean spike counts onto AlexNet features is best predicted by an early-to-mid convolutional stage — conv2 or conv3, which cannot be resolved between them. Median cross-validated r over 118 natural scenes is 0.284 (conv2) and 0.266 (conv3); the paired difference is Δz = +0.0113, SE 0.0082, t = 1.37, p = 0.17, so the ordering within that pair is not established.
That stage does beat its neighbours by clear margins: over conv1 (Δz = +0.0445, t = 4.92, p < 0.0001) and over every layer from conv4 onward (worst case Δz = +0.0559, t = 4.04, p = 0.0002). The profile rises conv1 → conv2/conv3, then falls monotonically through the fully-connected layers. The best stage reaches ~30% of the achievable ceiling — the 50-trial mean has split-half reliability 0.917, so the maximum r a noiseless predictor could reach is √0.917 = 0.957.
Both response windows agree ([0,250) ms and [50,300) ms; layer-profile Spearman ρ = +0.963).
Every layer is far above a shuffled-image null (z = 6.2–10.9), and 9 of 10 layers beat a
raw-pixel baseline (median r = 0.147) — the exception being the 1000-way logit layer.
No single winning layer. conv2 and conv3 are statistically tied (above), and all p-values here treat units as independent when they are not — see the next point — so even those are optimistic. Any claim naming one layer would be unsupported. See D-011.
The depth profile as a whole is not interpretable as a claim about representations. Median r and effective degrees of freedom df(α) are rank-correlated across layers at ρ = +0.90 (p = 0.0004). df saturates at its ceiling for 7 of the 10 layers, so it cannot order those — which is why the conv2/conv3 region survives — but the decline into the fully-connected layers is confounded with regularisation and this design cannot separate the two. In AlexNet, depth, feature count and df are collinear by construction. See D-009.
One session, one probe. All 110 units come from session 732592105 and sit on a single probe (probeC), so they share noise correlations and are not independent replicates. The effective n is below 110 and every interval quoted anywhere in this repository is correspondingly optimistic. See D-007.
The pixel-baseline comparison is at unmatched capacity. The pixel baseline is regularised harder than the CNN layers it loses to (median df 65.6 vs 105), which is the same confound flagged above for layers. It was checked for the random-weights control and not for pixels. See D-013.
One CV fold partition, one random-weights seed. Nothing here has been repeated across seeds, so no figure in this repository carries a variance estimate over that source. See D-013.
A recommended robustness check was not run. FEAT-01 §3.1 specified an aspect-preserving resize variant (option 3.1-B) as a check on whether the layer profile survives a defensible change of preprocessing. It was never run, and FEAT-01 argued such a change could shift the apparent best layer earlier or later — the same magnitude as the conv2/conv3 margin.
The stimulus index mapping is bounded, not proven. That natural_scene_N.tiff is the image
shown when frame == N could not be verified from this dataset: the ecephys NWB carries no
templates and the warehouse paths carry no provenance. What was verified is that the response
matrix's frame axis matches Allen's own published analysis (108/110 on preferred image, the two
exceptions being ties; r = 0.999999 on lifetime sparseness). A wrong template mapping would
collapse every layer to the null rather than shift the ordering, and that did not happen — but
this is a bound, not a proof. See FEAT-02 §1.
Nothing here is a claim about mouse V1 in general, or about CNNs in general — one architecture was fitted. No absolute effect size should be read as "variance explained", and no layer's receptive-field size in degrees should be compared to V1's without carrying the −13%/+30% geometry exposure documented in FEAT-02 §2.
The same architecture with untrained weights outperformed the pretrained network at 9 of 10
layers (best untrained 0.390 vs best trained 0.284). It is not a null artifact (z = 14.6) and
not a regularisation artifact (in the six layers where both networks sit at df = 105: 0.199
trained vs 0.350 untrained). conv1 is the only layer training helps.
This rests on a single random initialisation, so 0.390 and the "9 of 10" count are point estimates with unknown variance. It is recorded, not investigated. Following it up — multiple seeds, other architectures, whether ImageNet training discards the low-level structure V1 responds to — falls outside the scope set in D-001 and would be a separate project. See D-010 and D-013.
This does not run from a clean checkout, and not on this machine alone. Nine tracked files
hardcode absolute paths (C:\dev\allen-v1-encoding\... on sys.path, D:\allen-data\... for
every input and output): pilot/_common.py, feat/01, feat/02, feat/05, fit/01–fit/04,
doc/plot_layer_profile.py. There is no config file, environment variable, or relative-path
resolution. Separately, pilot/_common.py resolves ctypes.windll at import time, which
exists only on Windows, so every script under feat/ and fit/ fails on import on Linux or
macOS before any path is consulted. The scripts are Windows-only and machine-specific. This
is stated as a limitation, not scheduled for a fix.
Environment. Python 3.11 with the pinned set in requirements.txt (88 packages). hdmf must
stay at 3.14.6 — a clean resolve picks 6.1.0, which imports fine and then cannot open an NWB
(D-004). torch==2.13.0 is pinned without a platform marker, so a CUDA machine may resolve a
different build than the CPU one D-003 validated.
uv venv --python 3.11 .venv
uv pip install --python .venv\Scripts\python.exe -r requirements.txtData. Nothing lives in this repository. The SDK cache and all derived outputs are on D:,
outside the working tree, so correctness does not depend on .gitignore (D-006):
D:\allen-data\ecephys_cache\manifest.json SDK cache (2.77 GiB, one session)
D:\allen-data\derived\session_732592105\ response matrix, fit outputs
D:\allen-data\derived\stimulus_templates\ 118 natural-scene templates
D:\allen-data\derived\features\session_732592105\ extracted CNN features
Script order. Each directory is one stage; run in this order with the venv's interpreter.
| stage | scripts | what it does |
|---|---|---|
pilot/ |
01a, 01, 02, 03, 04, 05 |
download session 732592105, verify the stimulus table, build the (110, 118, 50) response matrix, measure split-half reliability |
feat/ |
01–06 |
fetch the 118 templates, establish the presentation geometry, verify the index link and warp provenance |
fit/ |
01–04 |
extract AlexNet features, run the nested-CV ridge protocol, controls, diagnostics |
audit/ |
verify_headline, checks, check_random_seed |
independent re-derivation of the headline and the correctness checks behind AUDIT-01 |
doc/ |
plot_layer_profile.py |
the figure |
Per-stage logs are in each directory's logs/.
DECISIONS.md is the append-only record of every decision, its rationale, and the evidence
behind it — including the four that turned out to be wrong or overstated (D-008, D-002-A1,
D-011, D-012). The reports it refers to are, in order: recon/RECON-01..03.md, PILOT-01.md,
FEAT-01.md, FEAT-02.md, FIT-01.md, AUDIT-01.md. Those documents are records of what was
concluded at the time and are not retrofitted when a later stage corrects them — where they
disagree with DECISIONS.md, DECISIONS.md is current. Read it first; it indexes the rest.