← Research

Brain-implant drift9 min read

The Fix Is Simpler Than You Think: Gold r_norm for Chronic SBP Drift

This post is part of an earlier series and is no longer updated. The current answer is on Can a brain implant work without daily re-tuning?.

Part 2 of 3. Part 1 established the drift problem. This part tests a fix. Part 3 introduces the nonlinear cross-session decoder.

Correction (2026-10-25): the shared decoder predicted finger velocity 60 ms ahead of the newest SBP bin. Checked against the LINK authors' own ridge baseline, that lead cost about 0.07 R² on raw SBP, and the 50 ms two-sided smoothing in Gold r_norm hid part of the cost because it reads future bins. The decoder now predicts velocity at the current bin; every number below is re-stated from that run, now with 95 % confidence intervals (session bootstrap). One conclusion reverses: the smoothing step no longer adds a little, it lowers cross-session transfer. The normalisation result itself holds.

Correction (2026-10-23): an earlier version of this post reported numbers from a different run, including a positive 1 month+ R² (0.118). All numbers below are now taken from the notebook's outputs; at month-scale gaps the fix does not hold. Updated again the same day: the series now uses one decoder everywhere (Ridge on 100 ms of SBP history, 60 ms lead, first 6 s of each session unscored); this part used to map SBP at each bin to velocity at the same bin. Under the shared decoder raw SBP transfers much worse (−0.636, was −0.151), the z-score accounts for nearly all of the gain (99 %, was 76 %), and the "1–7 days" horizon now means 1–7 days after Day 0 by date (it was the next 7 sessions, days 3–28).


Part 1 ended with a sharp claim: the decoder failure I showed isn't a neuroscience problem, it's an engineering one. If the representation going into the decoder keeps shifting underneath it, the decoder can't be expected to hold. Fix the representation, and the decoder should recover.

That's what this part tests.


The Fix

Gold r_norm is a two-step preprocessing operation applied within each session, independently:

  1. Per-channel z-score: For every channel i in session d, subtract the session mean and divide by the session standard deviation at every time bin t:
zi,d(t)=SBPi,d(t)−μi,dσi,d\begin{aligned} z_{i,d}(t) &= \frac{\mathrm{SBP}_{i,d}(t)-\mu_{i,d}}{\sigma_{i,d}} \end{aligned}

where μi,d\mu_{i,d} and σi,d\sigma_{i,d} are computed over all time bins tt in session dd.

  1. 50 ms Gaussian smoothing: Apply a Gaussian kernel (σ = 2.5 bins × 20 ms/bin = 50 ms) along the time axis:
ri,d(t)=(zi,d∗h)(t),h∼N(0,50 ms)\begin{aligned} r_{i,d}(t) &= (z_{i,d}\ast h)(t), \qquad h \sim \mathcal{N}(0, 50\,\text{ms}) \end{aligned}

Nothing crosses session boundaries. No alignment model. No labelled recalibration data. The entire operation uses only the statistics of the current session.

Implementation: drift.py:normalize_sessions_sbp_gold()


Why This Should Work

The drift fingerprint in Part 1 was specific: the columns of the channel × session heatmap shifted: whole-session amplitude went up and down over time. The rows were stable: relative channel ordering persisted across the 443 days analysed.

That asymmetry points directly at the fix. The problem is session-level amplitude and variance mismatch, not the loss of spatial structure. A per-session z-score removes exactly that: it recenters each session to zero mean and rescales to unit variance, per channel, before the decoder ever sees the data.

Gaussian smoothing was meant to add a second correction: suppress bin-to-bin noise in z-scored SBP without erasing the movement-relevant modulations. The ablation below tests that, and it does not hold up.

The pairwise matrices below make the effect concrete: session-level amplitude mismatch shows up as cold off-diagonal mass under raw SBP, and Gold r_norm removes much of it without any cross-day alignment.


The Direct Test

The clearest test mirrors the failure in Part 1: train a RidgeCV decoder on Day 0, freeze the weights, and test on every subsequent session. Both parts use the same decoder (SBP over the last 100 ms → velocity at the current bin). With raw SBP, 27 of the 29 later sessions score below zero; with Gold r_norm, 13 of 29. All 13 are sessions recorded five or more months after Day 0. The full (train, test) picture is in the pairwise heatmaps, not just Day 0 as trainer.


The Full Pairwise Picture

Day-0-fixed is one training scenario. The complete test is all (train, test) pairs. What happens when you train on any session and evaluate on any other?

Pairwise decoder R² matrix: raw SBP (left) versus Gold r_norm (right). Each cell is the R² for a decoder trained on session i and tested on session j; axes are labelled by days since Day 0, and the colour scale floors at −5.

Under raw SBP, many off-diagonal cells are far below zero, and decoders trained on the last sessions fail hardest on the early ones. Under Gold r_norm the whole matrix sits close to zero: the catastrophic failures are gone, and the warmest block is among the Jan–Mar 2020 sessions. Pairs separated by months stay near or below zero.

The summary:

Wide table: on a narrow screen, scroll sideways to see all columns.

ConditionMean off-diagonal R²
Raw SBP−0.907 (95 % CI −1.381 to −0.524)
Gold r_norm+0.030 (95 % CI −0.012 to +0.079)

The improvement is +0.937 (95 % CI +0.576 to +1.399), but read it carefully: most of it is the removal of raw SBP's large failures. A decoder fitted to one session's raw amplitudes extrapolates badly to another session's. Gold r_norm brings the average to a value indistinguishable from zero, not to a decoder that works everywhere. The negative-transfer regime that made the decoder actively harmful in Part 1 shrinks, but it does not disappear.


Ablation: What's Doing the Work?

Two-step methods invite the obvious question: which step matters?

Wide table: on a narrow screen, scroll sideways to see all columns.

FeatureMean off-diagonal Δ R² vs raw SBP
Z-score only+0.958
Gold r_norm (z-score + smoothing)+0.937

The z-score alone does better than the full pipeline. Its mean cross-session R² is +0.051 (95 % CI +0.014 to +0.095) against Gold r_norm's +0.030, and the smoothing lowers transfer by 0.021 (95 % CI 0.014 to 0.028). Standardisation does all the work; the two-sided smoothing costs a little, and it cannot run on a device anyway. The streaming post replaces it with a light causal smoother.

Pairwise R² matrix: raw SBP (left) versus z-score-only normalization (right). Z-score alone removes nearly all of raw SBP's failures.

Z-score only looks almost the same as the full Gold r_norm pipeline, slightly warmer off the diagonal: removing the per-session amplitude mismatch is what matters.


Does the Gain Hold Across Time?

A correction that only helps on short train-test gaps isn't solving the chronic problem. Part 1 showed raw SBP median transfer sliding negative as the train–test gap widens. The horizon table tests whether Gold r_norm holds as the gap grows, with a decoder trained on Day 0. Intra-day is scored on held-out blocks of Day 0; 1–7 days is one session (day 3); 1 month+ averages every session 30 or more days after Day 0:

Wide table: on a narrow screen, scroll sideways to see all columns.

Feature setIntra-day R²1–7 days1 month+
Gold r_norm (96-ch)0.3410.166−0.041 (95 % CI −0.122 to +0.037)
Raw mean (1-ch population)0.001−0.001−0.005

It does not. Gold r_norm keeps about half of its intra-day R² three days later (0.166 of 0.341, one session), then beyond a month averages −0.041, with a 95 % CI from −0.122 to +0.037: indistinguishable from zero, so no useful transfer. The short-gap drift is mostly gain and offset, which a per-session z-score corrects; month-scale drift has a residual that normalisation cannot remove.

Collapsing to a one-dimensional population mean throws away the spatial structure and yields nothing useful at any horizon, so the per-channel spatial pattern is what carries the decoding signal.


Qualitative Check: Do the Traces Still Make Sense?

Better R² is necessary but not sufficient. If the improved decoder is predicting noise that happens to correlate with velocity by accident, it won't look right. The decoded traces provide the intuition check.

Decoded finger velocity under raw SBP, decoder trained on Day 0: Day 0 (top) and day 443 (bottom), predictions versus true velocity.

Under raw SBP, the Day-0 decoder tracks Day 0's movements, but on day 443 its prediction is nearly flat. It has lost the movement structure once the feature distribution shifted.

Decoded finger velocity with Gold r_norm features, decoder trained on Day 0: Day 0 (top) and day 15 (bottom), predictions versus true velocity.

Under Gold r_norm, the day-15 prediction tracks true velocity with visible sign and timing agreement. This is a short-gap example, not the same late session as the raw-SBP figure: at a month and beyond, r_norm fails too (horizon table above).


Limits

Gold r_norm is a preprocessing step, not a general solution. The scope of what it solves is specific:

  • SBP only. TCR (threshold-crossing rates) drift over the same 443-day span and wasn't tested here. The same z-score logic may apply, but that's a separate analysis.
  • Session-internal statistics only. The z-score uses the mean and std of the current session. This assumes the session's internal statistics are informative, which is true for recordings with sufficient task-modulated activity. Quiet or severely degraded sessions may have uninformative baselines.
  • Linear decoder, full session. R² was computed with Ridge on the last 100 ms of SBP predicting velocity at the current bin, trained on one full session and tested on the full session of another day, with the first 6 s of each session unscored. Real-time use requires a calibration window and would see different numbers. The CIs resample sessions (2,000 draws), so they cover which sessions were recorded, not a different animal.
  • Fixed session set. The same 30 sessions as Part 1; how Gold r_norm behaves on held-out or lower-quality days is not characterized here.
  • NHP data. The LINK dataset is non-human primate motor cortex with a Utah array. Human implants may have different drift profiles, different electrode geometries, and different task structure.

What's Next

The fix confirmed here is a per-session operation on SBP. The next question is whether a nonlinear decoder trained once across all sessions, using both SBP r_norm and TCR z_norm, can push cross-session performance further, including at gaps beyond a month where the Ridge baseline fails.

Part 3 takes up that question with a single MLP trained jointly across sessions.

Read Part 3 →


References

  • Magland, J. F., Ly, R., Rübel, O., & Dichter, B. K. (2025). Facilitating analysis of open neurophysiology data on the DANDI Archive using large language model tools. Scientific Data, 12, 285. https://doi.org/10.1038/s41597-025-06285-x
  • Rübel, O., Tritt, A., Ly, R., Dichter, B. K., Ghosh, S., Niu, L., Baker, P., Soltesz, I., Ng, L., Svoboda, K., Frank, L., & Bouchard, K. E. (2022). The Neurodata Without Borders ecosystem for neurophysiological data science. eLife, 11, e78362. https://doi.org/10.7554/eLife.78362

The repository includes the analysis notebooks, the neurosignal package and related code, and HTML exports of those notebooks.

Code: github.com/radhakrishnanrishaban/ephys-signal-atlas · neurosignal v0.2.0