Du, Lai, Hu & Ye (2026) on MC_RTT (DANDI:000129)¶

Paper doi:10.64898/2026.08.04.742876 (claims file written from the bioRxiv full text, without the supplement). Dataset: DANDI:000129 (MC_RTT, Neural Latents Benchmark), pinned at version 0.241017.1444, the version the paper cites (Methods 4.2, Data availability) and the only published version; file sub-Indy/sub-Indy_desc-train_behavior+ecephys.nwb, streamed. See 02_link_development.ipynb for the full claims table.

Claim Status
rtt-data tested
rtt-gain tested
rff-rtt tested
estimator-family-nlb tested on MC_RTT (reading (a) of the nonlinear context); the MC_Maze part is reported in 07_mc_maze.ipynb
maze-gain, rff-maze tested in 07_mc_maze.ipynb (DANDI:000139, data elsewhere)
In [1]:
import collections, resource, time, zlib
import numpy as np
import pandas as pd
import du2026 as d

PAPER = "du-2026"
def claim_seed(claim_id):
    return zlib.crc32(f"{PAPER}/{claim_id}".encode())
T0 = time.time()
EXTRA = (1000, 2000, 3000, 4000)

rtt_assets = d.list_assets(d.RTT_ID, d.RTT_VERSION)
print([(a["path"], a["size"]) for a in rtt_assets])
train_asset = next(a for a in rtt_assets if a["path"] == d.RTT_TRAIN_PATH)
raw = d.load_rtt_raw(train_asset["asset_id"])
ds = d.build_rtt_dataset(raw)
[('sub-Indy/sub-Indy_desc-test_ecephys.nwb', 1201344), ('sub-Indy/sub-Indy_desc-train_behavior+ecephys.nwb', 49764168)]
In [2]:
print("behaviour series:", raw.descriptions)
print(f"behaviour sampling: starting time {raw.behavior_timestamps_head}, rate {raw.behavior_rate} Hz; 20 ms bins: {raw.n_bins}")
print(f"units: {raw.n_units}; spike counts per 20 ms bin range {raw.spike_counts.min():.0f} to {raw.spike_counts.max():.0f}, mean rate {raw.spike_counts.mean() / 0.02:.1f} Hz")
print("trials table:", raw.trials.shape, "split counts", raw.trials.split.value_counts().to_dict())
dur = (raw.trials.stop_time - raw.trials.start_time)
print(f"block durations {dur.min():.3f} to {dur.max():.3f} s; first start {raw.trials.start_time.min()}, last stop {raw.trials.stop_time.max()} s; record {raw.n_bins * 0.02:.2f} s")
print(f"finger velocity range {np.nanmin(raw.finger_vel):.1f} to {np.nanmax(raw.finger_vel):.1f}; cursor {np.nanmin(raw.cursor_pos):.1f} to {np.nanmax(raw.cursor_pos):.1f}; target {np.nanmin(raw.target_pos):.1f} to {np.nanmax(raw.target_pos):.1f}")
bad = ~np.isfinite(raw.finger_vel).all(axis=1) | ~np.isfinite(raw.cursor_pos).all(axis=1) | ~np.isfinite(raw.target_pos).all(axis=1)
print(f"20 ms bins with a missing (NaN) behaviour value: {int(bad.sum())} of {raw.n_bins}; NaN in the analysis arrays: "
      f"behaviour {int(np.isnan(ds.behavior).sum())}, context {int(np.isnan(ds.context).sum())}")
print("analysis arrays: neural", ds.neural.shape, "context", ds.context.shape, "behaviour", ds.behavior.shape, "train/val", len(ds.train_indices), len(ds.test_indices))
# velocity against the derivative of cursor position, as a check of units and alignment (mm/s against mm per 20 ms bin)
dcur = np.gradient(raw.cursor_pos, axis=0) / 0.02
for lag in (-5, -2, 0, 2, 5):
    a, b = (raw.finger_vel[max(0, lag):len(dcur) + min(0, lag)], dcur[max(0, -lag):len(dcur) - max(0, lag)])
    ok = np.isfinite(a).all(axis=1) & np.isfinite(b).all(axis=1)
    print(f"corr(finger velocity, cursor velocity shifted {lag} bins): x {np.corrcoef(a[ok, 0], b[ok, 0])[0, 1]:.3f}, y {np.corrcoef(a[ok, 1], b[ok, 1])[0, 1]:.3f}")
# clock check: decode finger velocity from 100 ms of spikes ending `lag` bins before the behaviour bin
from sklearn.linear_model import Ridge
from sklearn.pipeline import make_pipeline
from sklearn.preprocessing import StandardScaler
from sklearn.metrics import r2_score
bins_ = np.arange(50, raw.n_bins - 50)
bins_ = bins_[~bad[bins_]]
row = {}
for lag in (-25, -10, -4, 0, 2, 4, 6, 10, 25):
    X = np.stack([raw.spike_counts[b - lag - 5:b - lag].reshape(-1) for b in bins_])
    half = len(bins_) * 3 // 4
    m = make_pipeline(StandardScaler(), Ridge(alpha=1000.0)).fit(X[:half], raw.finger_vel[bins_[:half]])
    row[lag] = round(r2_score(raw.finger_vel[bins_[half:]], m.predict(X[half:]), multioutput="variance_weighted"), 3)
print("held-out R2 (last quarter of the record) by lag in bins:", row)
print(f"peak memory {resource.getrusage(resource.RUSAGE_SELF).ru_maxrss / 1e6:.2f} GB")
behaviour series: {'finger_vel': {'unit': 'm/s', 'conversion': np.float64(0.001), 'description': 'The x and y velocity of the finger in mm/s. Calculated offline from upsampled finger position'}, 'cursor_pos': {'unit': 'meters', 'conversion': np.float64(0.001), 'description': 'The position of the cursor in Cartesian coordinates (x, y) in mm. Recorded at 250 Hz and upsampled to 1 kHz'}, 'target_pos': {'unit': 'meters', 'conversion': np.float64(0.001), 'description': 'The position of the target in Cartesian coordinates (x, y) in mm. Recorded at 250 Hz and upsampled to 1 kHz'}}
behaviour sampling: starting time [0.], rate 1000.0 Hz; 20 ms bins: 32455
units: 130; spike counts per 20 ms bin range 0 to 3, mean rate 4.0 Hz
trials table: (1080, 3) split counts {'train': 810, 'val': 270}
block durations 0.600 to 0.600 s; first start 0.0, last stop 648.9 s; record 649.10 s
finger velocity range -490.2 to 467.2; cursor -65.1 to 117.9; target -52.5 to 112.5
20 ms bins with a missing (NaN) behaviour value: 15 of 32455; NaN in the analysis arrays: behaviour 0, context 0
analysis arrays: neural (1080, 21, 650) context (1080, 21, 14) behaviour (1080, 21, 2) train/val 810 270
corr(finger velocity, cursor velocity shifted -5 bins): x 0.701, y 0.770
corr(finger velocity, cursor velocity shifted -2 bins): x 0.959, y 0.969
corr(finger velocity, cursor velocity shifted 0 bins): x 0.993, y 0.996
corr(finger velocity, cursor velocity shifted 2 bins): x 0.890, y 0.921
corr(finger velocity, cursor velocity shifted 5 bins): x 0.609, y 0.695
held-out R2 (last quarter of the record) by lag in bins: {-25: 0.059, -10: 0.151, -4: 0.287, 0: 0.405, 2: 0.431, 4: 0.425, 6: 0.389, 10: 0.254, 25: 0.034}
peak memory 0.59 GB

rtt-data¶

The MC_RTT training file holds 1,080 fixed analysis blocks, 130 units, finger velocity, cursor position and target position, with a release split of 810 train and 270 validation blocks.

In [3]:
print(f"blocks kept by the mc_rtt.py rule: {len(ds.neural)} of {len(raw.trials)} (expected 1080); units {raw.n_units} (expected 130); "
      f"train {len(ds.train_indices)} (810), validation {len(ds.test_indices)} (270); bins per block {ds.neural.shape[1]}")
print("series present: finger_vel, cursor_pos, target_pos:", sorted(raw.descriptions))
blocks kept by the mc_rtt.py rule: 1080 of 1080 (expected 1080); units 130 (expected 130); train 810 (810), validation 270 (270); bins per block 21
series present: finger_vel, cursor_pos, target_pos: ['cursor_pos', 'finger_vel', 'target_pos']

Result: reproduced. The training file's trials table has 1,080 blocks of 600 ms, all kept by the loader's rule (21 bins each after the warm-up), with 130 units and the finger velocity, cursor position and target position series; the split labels give 810 train and 270 validation blocks.

rtt-gain¶

In MC_RTT, target plus lag-matched cursor-position history gave context-only R2 of 0.6031, and fully nested neural gain beyond it was 0.06846 (conditional interval 0.05371 to 0.08478), context RMSE falling from 39.78 to 36.19 (a 17.25% MSE reduction), with component gains 0.0836 and 0.0513 and replacement gain -0.02297.

Estimator seed 20260726 (run_primary_analyses.py); the release split is fixed, and the estimator's folds and inner splits are also run under seeds plus 1000 to 4000. The same fits give the three nonlinear-neural maps (rff-rtt).

In [4]:
SEED = 20260726
jobs = [(f"nested_{SEED + k}", {}, "nested", dict(seed=SEED + k, rff_seeds=d.RFF_SEEDS if k == 0 else (), n_bootstrap=500 if k == 0 else 0), False) for k in (0,) + EXTRA]
jobs_family = [("block", {}, "block", {"seed": SEED}, False), ("rffctx", {}, "rff_context", {"seed": SEED}, False)]
t = time.time()
out = d.run_parallel(d.rtt_jobs, [(train_asset["asset_id"], [j]) for j in jobs + jobs_family])
res = {k: v for o in out for k, v in o.items()}
print(f"fits in {(time.time() - t) / 60:.1f} min")
r = res[f"nested_{SEED}"]
exp = [("context-only R2", r["context_r2"], 0.6031, 0.06031), ("fully nested gain", r["gain"], 0.06846, 0.01632),
       ("context RMSE", r["context_rmse"], 39.78, 3.978), ("context-plus-neural RMSE", r["exact_rmse"], 36.19, 3.619),
       ("% MSE reduction", r["mse_reduction_percent"], 17.25, 1.725), ("gain, component 1", r["component_gain"][0], 0.0836, 0.00836),
       ("gain, component 2", r["component_gain"][1], 0.0513, 0.00513), ("replacement gain", r["replacement_gain"], -0.02297, 0.002297)]
for label, v, e, tol in exp:
    print(f"{label}: {v:.5f} (expected {e} +- {tol}; within: {abs(v - e) <= tol})")
print(f"conditional interval {r['conditional_ci'][0]:.5f} to {r['conditional_ci'][1]:.5f} (paper 0.05371 to 0.08478; "
      "estimators.py _cluster_bootstrap_delta_r2, 500 resamples, the run_primary_analyses.py default)")
for k in (0,) + EXTRA:
    rr = res[f"nested_{SEED + k}"]
    print(f"seed {SEED + k}: gain {rr['gain']:.5f}, replacement {rr['replacement_gain']:.5f}, context R2 {rr['context_r2']:.4f}")
print("penalties (context, residualizer, residual learner):", r["context_alpha"], r["residualizer_alpha"], r["innovation_alpha"])
fits in 1.3 min
context-only R2: 0.60308 (expected 0.6031 +- 0.06031; within: True)
fully nested gain: 0.06846 (expected 0.06846 +- 0.01632; within: True)
context RMSE: 39.78138 (expected 39.78 +- 3.978; within: True)
context-plus-neural RMSE: 36.18841 (expected 36.19 +- 3.619; within: True)
% MSE reduction: 17.24786 (expected 17.25 +- 1.725; within: True)
gain, component 1: 0.08359 (expected 0.0836 +- 0.00836; within: True)
gain, component 2: 0.05125 (expected 0.0513 +- 0.00513; within: True)
replacement gain: -0.02297 (expected -0.02297 +- 0.002297; within: True)
conditional interval 0.05371 to 0.08478 (paper 0.05371 to 0.08478; estimators.py _cluster_bootstrap_delta_r2, 500 resamples, the run_primary_analyses.py default)
seed 20260726: gain 0.06846, replacement -0.02297, context R2 0.6031
seed 20261726: gain 0.06855, replacement -0.02300, context R2 0.6031
seed 20262726: gain 0.06846, replacement -0.02326, context R2 0.6031
seed 20263726: gain 0.06822, replacement -0.02305, context R2 0.6031
seed 20264726: gain 0.06821, replacement -0.02332, context R2 0.6031
penalties (context, residualizer, residual learner): 0.1 0.1 10000.0

Result: reproduced. Context-only R2 is 0.60308, the fully nested gain 0.06846, the context RMSE 39.781 and the context-plus-neural RMSE 36.188 (a 17.248% MSE reduction), the component gains 0.08359 and 0.05125, and the replacement gain -0.02297; all eight equal the paper's values at its precision. The conditional whole-trial interval, 0.05371 to 0.08478, also equals the paper's. Under four other estimator seeds the gain is 0.06821 to 0.06855 and the replacement gain -0.02300 to -0.02332.

rff-rtt¶

Under three prespecified nonlinear-neural random-feature maps, MC_RTT gain stayed positive (0.01491 to 0.01685).

In [5]:
g = {s: res[f"nested_{SEED}"]["rff"][s]["gain"] for s in d.RFF_SEEDS}
print({s: round(v, 5) for s, v in g.items()}, "penalties", {s: res[f"nested_{SEED}"]["rff"][s]["alpha"] for s in d.RFF_SEEDS})
lo, hi = 0.01491 - 0.001491, 0.01685 + 0.001685
print(f"all positive: {all(v > 0 for v in g.values())}; all inside {lo:.5f}..{hi:.5f}: {all(lo <= v <= hi for v in g.values())}")
print("replacement gains under the maps:", {s: round(res[f"nested_{SEED}"]["rff"][s]["replacement_gain"], 5) for s in d.RFF_SEEDS})
{20260802: 0.01685, 20260803: 0.01501, 20260804: 0.01491} penalties {20260802: 10000.0, 20260803: 10000.0, 20260804: 10000.0}
all positive: True; all inside 0.01342..0.01853: True
replacement gains under the maps: {20260802: -0.00553, 20260803: -0.00931, 20260804: -0.00547}

Result: reproduced. The three nonlinear-neural maps give MC_RTT gains of 0.01685, 0.01501 and 0.01491, all positive and spanning the paper's range of 0.01491 to 0.01685.

estimator-family-nlb¶

Under the separate-block and nonlinear-context estimators, MC_RTT gain remained positive while MC_Maze remained near zero.

In [6]:
print(f"block penalties: gain {res['block']['gain']:.5f} (penalties {res['block']['penalties']}); "
      f"nonlinear context (D 256, g chosen {res['rffctx']['gamma']}): gain {res['rffctx']['gain']:.5f}; fully nested linear {res[f'nested_{SEED}']['gain']:.5f}")
print("MC_RTT positive under both families:", res["block"]["gain"] > 0 and res["rffctx"]["gain"] > 0)
print(f"run time {(time.time() - T0) / 60:.1f} min; peak memory {resource.getrusage(resource.RUSAGE_SELF).ru_maxrss / 1e6:.2f} GB")
block penalties: gain 0.06901 (penalties (0.1, 10000.0)); nonlinear context (D 256, g chosen 0.25): gain 0.04619; fully nested linear 0.06846
MC_RTT positive under both families: True
run time 1.4 min; peak memory 0.59 GB

Result: reproduced. The block-penalty estimator gives an MC_RTT gain of 0.0690 and the nonlinear-context estimator 0.04619, both positive, as the criterion requires. The MC_Maze part, which the criterion reports without making the outcome depend on it, holds in 07_mc_maze.ipynb: block-penalty gain 0.000455 and nonlinear-context gain -0.000243, both of absolute size below 0.01.

Summary¶

Claim Outcome
rtt-data reproduced
rtt-gain reproduced
rff-rtt reproduced
estimator-family-nlb reproduced (MC_Maze part in 07_mc_maze.ipynb)
maze-gain, rff-maze see 07_mc_maze.ipynb

What was found about the dataset: the counts are as the paper states. The behaviour series hold 15 missing (NaN) 20 ms bins, none inside the analysis blocks. The units of the behaviour series are consistent once the conversion attribute is read: unit m/s or meters with conversion 0.001, so the stored values are mm/s and mm, as the descriptions say; the paper's statement that the NLB unit fields and descriptions disagree reads the unit without the conversion. Finger velocity follows the derivative of cursor position at lag 0 (correlation 0.993 and 0.996), and velocity decoding from spikes peaks 2 bins (40 ms) after the spikes, so the spikes and behaviour share a clock.