Du, Lai, Hu & Ye (2026) on LINK: the 20 confirmation sessions¶
Paper doi:10.64898/2026.08.04.742876; dataset DANDI:001201 version 0.251023.2336 (the version the
paper cites; see 02_link_development.ipynb for the full header and claims table).
The confirmation sessions are re-selected here with the paper's rule (Methods 4.2; port of
build_link_confirmation_manifest.py) from the archive's asset metadata, and compared with the
paper's frozen manifest (outputs/primary_analysis/link_confirmation_manifest.json in the release at
commit b042fbe, read from GitHub; an input).
| Claim | Status |
|---|---|
| confirm-geometry-gain | tested |
| confirm-history-contraction | tested |
| confirm-replacement | tested |
| confirm-table1-values | tested |
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)
assets = d.list_assets(d.LINK_ID, d.LINK_VERSION)
by_date = collections.defaultdict(list)
for a in assets:
by_date[d.session_date(a["path"])].append(a)
paired_dates = sorted(k for k, v in by_date.items() if len(v) > 1)
dev_assets = [a for k in paired_dates for a in sorted(by_date[k], key=lambda a: a["path"])]
print(f"{len(assets)} assets in DANDI:{d.LINK_ID} {d.LINK_VERSION}; {len(paired_dates)} dates with two sessions, {len(dev_assets)} development sessions")
def table(results, name, field="gain"):
return pd.DataFrame([{"date": r["date"], "task": r["task"], field: r[name][field]} for r in results])
from concurrent.futures import ThreadPoolExecutor
import json, urllib.request
with ThreadPoolExecutor(12) as pool:
metadata = dict(zip([a["asset_id"] for a in assets],
pool.map(lambda a: d.asset_metadata(d.LINK_ID, d.LINK_VERSION, a["asset_id"]), assets)))
dev_ids = {a["asset_id"] for a in dev_assets}
records = [dict(asset_id=a["asset_id"], path=a["path"], date=d.session_date(a["path"]), task=d.link_task_from_metadata(metadata[a["asset_id"]]))
for a in assets]
print("tasks over all 312 assets:", collections.Counter(r["task"] for r in records))
selected = []
for task in ("CO", "RD"):
eligible = sorted((r for r in records if r["task"] == task and r["asset_id"] not in dev_ids), key=lambda r: (r["date"], r["asset_id"]))
ranks = d.interior_ranks(len(eligible))
print(f"{task}: {len(eligible)} eligible assets, ranks {ranks}")
selected += [eligible[k] for k in ranks]
url = f"https://raw.githubusercontent.com/gwkuqgfkqe/neural-decoder-context-audit/{d.PAPER_COMMIT}/outputs/primary_analysis/link_confirmation_manifest.json"
frozen = json.load(urllib.request.urlopen(url, timeout=60))
frozen_ids = [r["asset_id"] for r in frozen.get("selected", frozen.get("sessions", []))]
print(f"frozen manifest: {len(frozen_ids)} assets; re-selected here: {len(selected)}; identical sets: {set(frozen_ids) == {r['asset_id'] for r in selected}}")
print("in the frozen manifest only:", set(frozen_ids) - {r['asset_id'] for r in selected}, "; re-selected only:", {r['asset_id'] for r in selected} - set(frozen_ids))
print(pd.DataFrame(selected)[["date", "task", "path"]].to_string())
312 assets in DANDI:001201 0.251023.2336; 9 dates with two sessions, 18 development sessions
tasks over all 312 assets: Counter({'CO': 156, 'RD': 156})
CO: 147 eligible assets, ranks [13, 27, 40, 53, 66, 80, 93, 106, 119, 133]
RD: 147 eligible assets, ranks [13, 27, 40, 53, 66, 80, 93, 106, 119, 133]
frozen manifest: 20 assets; re-selected here: 20; identical sets: True
in the frozen manifest only: set() ; re-selected only: set()
date task path
0 2020-09-24 CO sub-Monkey-N/sub-Monkey-N_ses-20200924_ecephys.nwb
1 2020-12-11 CO sub-Monkey-N/sub-Monkey-N_ses-20201211_ecephys.nwb
2 2021-03-23 CO sub-Monkey-N/sub-Monkey-N_ses-20210323_ecephys.nwb
3 2021-06-01 CO sub-Monkey-N/sub-Monkey-N_ses-20210601_ecephys.nwb
4 2021-08-05 CO sub-Monkey-N/sub-Monkey-N_ses-20210805_ecephys.nwb
5 2021-09-15 CO sub-Monkey-N/sub-Monkey-N_ses-20210915_ecephys.nwb
6 2021-11-16 CO sub-Monkey-N/sub-Monkey-N_ses-20211116_ecephys.nwb
7 2022-02-28 CO sub-Monkey-N/sub-Monkey-N_ses-20220228_ecephys.nwb
8 2022-04-27 CO sub-Monkey-N/sub-Monkey-N_ses-20220427_ecephys.nwb
9 2022-09-02 CO sub-Monkey-N/sub-Monkey-N_ses-20220902_ecephys.nwb
10 2020-09-04 RD sub-Monkey-N/sub-Monkey-N_ses-20200904_ecephys.nwb
11 2021-04-28 RD sub-Monkey-N/sub-Monkey-N_ses-20210428_ecephys.nwb
12 2021-07-01 RD sub-Monkey-N/sub-Monkey-N_ses-20210701_ecephys.nwb
13 2021-08-04 RD sub-Monkey-N/sub-Monkey-N_ses-20210804_ecephys.nwb
14 2022-02-10 RD sub-Monkey-N/sub-Monkey-N_ses-20220210_ecephys.nwb
15 2022-05-11 RD sub-Monkey-N/sub-Monkey-N_ses-20220511_ecephys.nwb
16 2022-08-25 RD sub-Monkey-N/sub-Monkey-N_ses-20220825_ecephys.nwb
17 2023-01-24 RD sub-Monkey-N/sub-Monkey-N_ses-20230124_ecephys.nwb
18 2023-03-10 RD sub-Monkey-N/sub-Monkey-N_ses-20230310_ecephys.nwb
19 2023-04-26 RD sub-Monkey-N/sub-Monkey-N_ses-20230426_ecephys.nwb
conf_assets = [a for a in assets if a["asset_id"] in set(frozen_ids)]
sessions = [d.load_link_session(a["asset_id"], a["path"], signals=("SpikingBandPower",)) for a in conf_assets]
chk = []
for s in sessions:
start_idx = np.array([int(np.argmin(np.abs(s.timestamps - t))) for t in s.trials.start_time])
usable = int(np.sum(start_idx + 8 + 24 < np.minimum(start_idx + s.trials.trial_count.to_numpy(), len(s.timestamps))))
chk.append(dict(session=s.identifier, task=s.task, trials=len(s.trials), usable=usable, bins=len(s.timestamps),
dt_ms=1000 * float(np.median(np.diff(s.timestamps))),
sbp=f"{s.signals['SpikingBandPower'].min():.3g}..{s.signals['SpikingBandPower'].max():.3g}",
pos=f"{s.position.min():.3g}..{s.position.max():.3g}", vel=f"{s.velocity.min():.3g}..{s.velocity.max():.3g}"))
chk = pd.DataFrame(chk)
print(chk.to_string())
print("tasks:", collections.Counter(chk.task), "; usable trials", chk.usable.sum(), "(paper 7,500); sessions with 375 usable:", int((chk.usable == 375).sum()))
print("task in the NWB identifier agrees with the asset metadata:",
all(s.task == d.link_task_from_metadata(metadata[s.asset_id]) for s in sessions))
import hashlib
h = [hashlib.sha1(s.signals["SpikingBandPower"].tobytes()).hexdigest() for s in sessions]
print("distinct SBP arrays:", len(set(h)), "of", len(h))
del sessions
print(f"peak memory {resource.getrusage(resource.RUSAGE_SELF).ru_maxrss / 1e6:.2f} GB")
session task trials usable bins dt_ms sbp pos vel
0 2020-09-04_RD_nwb RD 375 375 28807 20.0 0.0562..341 0.0111..1 -0.195..0.295
1 2020-09-24_CO_nwb CO 375 375 22642 20.0 0.85..34.6 0.0381..1 -0.123..0.207
2 2020-12-11_CO_nwb CO 375 375 23285 20.0 0.0437..249 0..1 -0.109..0.237
3 2021-03-23_CO_nwb CO 375 375 24470 20.0 0.881..63.3 0.0221..1 -0.17..0.221
4 2021-04-28_RD_nwb RD 375 375 27046 20.0 0.798..21.4 0..1 -0.236..0.275
5 2021-06-01_CO_nwb CO 375 375 22790 20.0 0.556..25.2 0.104..0.961 -0.147..0.172
6 2021-07-01_RD_nwb RD 375 375 25545 20.0 0.69..20.1 0..1 -0.159..0.374
7 2021-08-05_CO_nwb CO 375 375 23348 20.0 0.681..37.3 0.0955..1 -0.154..0.124
8 2021-08-04_RD_nwb RD 375 375 26783 20.0 0.744..54.7 0.00821..1 -0.228..0.249
9 2021-09-15_CO_nwb CO 375 375 24679 20.0 0.7..24.3 0.0843..1 -0.13..0.209
10 2021-11-16_CO_nwb CO 375 375 24711 20.0 0.698..30.5 0.0587..1 -0.139..0.318
11 2022-02-10_RD_nwb RD 375 375 28074 20.0 0.606..23.2 0..1 -0.123..0.422
12 2022-02-28_CO_nwb CO 375 375 26111 20.0 0.662..22.3 0.0811..1 -0.0827..0.318
13 2022-04-27_CO_nwb CO 375 375 22286 20.0 0.701..31.2 0..1 -0.175..0.166
14 2022-05-11_RD_nwb RD 375 375 26616 20.0 0.681..27.4 0.00922..1 -0.183..0.182
15 2022-08-25_RD_nwb RD 375 375 25763 20.0 0.731..29.8 0..1 -0.243..0.34
16 2022-09-02_CO_nwb CO 375 375 21498 20.0 0.656..32 0.0782..1 -0.129..0.235
17 2023-01-24_RD_nwb RD 375 375 24647 20.0 0.55..14.8 0..1 -0.283..0.251
18 2023-03-10_RD_nwb RD 375 375 25916 20.0 0.525..37.5 0..1 -0.251..0.239
19 2023-04-26_RD_nwb RD 375 375 24437 20.0 0.569..22.4 0..1 -0.2..0.261
tasks: Counter({'RD': 10, 'CO': 10}) ; usable trials 7500 (paper 7,500); sessions with 375 usable: 20
task in the NWB identifier agrees with the asset metadata: True
distinct SBP arrays: 20 of 20
peak memory 0.47 GB
The fits¶
Fully nested estimator, SBP, geometry by phase and plus history, outer split seed 20260726
(run_link_confirmation.py), and the same under split and refit seeds plus 1000 to 4000 (protocol,
seed sensitivity).
SEED = 20260726
jobs = []
for k in (0,) + EXTRA:
for context in ("geometry_tensor", "causal_history"):
jobs.append((f"{context}_{SEED + k}", dict(signal="SpikingBandPower", context_mode=context, seed=SEED + k), "nested", {"seed": SEED + k}, False))
t = time.time()
results = d.run_parallel(d.link_session_jobs, [(a["asset_id"], a["path"], jobs, ("SpikingBandPower",)) for a in conf_assets])
print(f"{len(jobs)} fits per session on {len(results)} sessions in {(time.time() - t) / 60:.1f} min")
G, H = f"geometry_tensor_{SEED}", f"causal_history_{SEED}"
per = table(results, G).rename(columns={"gain": "geometry"})
per["history"] = table(results, H).gain
per["replacement_geometry"] = table(results, G, "replacement_gain").replacement_gain
per["replacement_history"] = table(results, H, "replacement_gain").replacement_gain
per["mse_red_geometry"] = table(results, G, "mse_reduction_percent").mse_reduction_percent
per["mse_red_history"] = table(results, H, "mse_reduction_percent").mse_reduction_percent
print(per.round(5).to_string())
def seed_line(field, ctx):
out = []
for k in (0,) + EXTRA:
t_ = table(results, f"{ctx}_{SEED + k}", field)
out.append(f"{t_[field].mean():.5f} ({int((t_[field] > 0).sum())} positive)")
return "; ".join(out)
10 fits per session on 20 sessions in 8.8 min
date task geometry history replacement_geometry replacement_history mse_red_geometry mse_red_history
0 2020-09-04 RD 0.04001 0.01130 -0.02781 -0.02008 7.36944 2.48794
1 2020-09-24 CO 0.02186 0.01058 -0.00018 -0.00036 5.07135 2.76950
2 2020-12-11 CO 0.02404 0.00774 0.00427 0.00466 4.70159 1.70127
3 2021-03-23 CO 0.01497 0.00436 -0.00692 -0.00745 3.44698 1.23822
4 2021-04-28 RD 0.02400 0.01291 -0.01016 -0.00793 6.11077 3.72098
5 2021-06-01 CO 0.01503 0.00396 -0.00905 -0.00422 3.38962 1.19533
6 2021-07-01 RD 0.02151 0.01045 -0.00856 -0.00569 4.94842 2.97995
7 2021-08-05 CO 0.01457 0.00290 -0.00385 0.00136 3.19766 0.76490
8 2021-08-04 RD 0.00809 0.00390 -0.00878 -0.00495 2.22265 1.27457
9 2021-09-15 CO 0.02289 0.01017 0.00166 0.00303 3.95831 2.20919
10 2021-11-16 CO 0.02879 0.01275 -0.00434 -0.00096 4.91536 2.54948
11 2022-02-10 RD 0.01349 0.00486 -0.01204 -0.00900 2.87810 1.26017
12 2022-02-28 CO 0.03433 0.00510 0.00517 -0.00007 6.73833 1.43224
13 2022-04-27 CO 0.01654 0.00530 -0.00424 -0.00081 4.46873 1.74894
14 2022-05-11 RD 0.02752 0.01206 -0.00494 -0.00701 7.37388 4.07656
15 2022-08-25 RD 0.03650 0.01271 -0.01573 -0.00993 7.36646 3.28931
16 2022-09-02 CO 0.01734 0.00410 -0.01169 -0.00706 4.40339 1.32451
17 2023-01-24 RD 0.02576 0.00935 -0.02042 -0.01040 6.29765 2.98382
18 2023-03-10 RD 0.00593 -0.00128 -0.00638 -0.00499 1.58563 -0.45000
19 2023-04-26 RD 0.01845 0.00770 -0.01022 -0.00781 4.76666 2.39143
confirm-geometry-gain¶
In the 20 untouched LINK confirmation sessions, SBP geometry-by-phase gain was positive in all 20 and averaged 0.02158 (CO 0.02104, RD 0.02213).
m = per.groupby("task").geometry.mean()
print(f"positive {int((per.geometry > 0).sum())}/20 (expected 20, tolerance 2); mean {per.geometry.mean():.5f} (0.02158 +- 0.002158); "
f"CO {m['CO']:.5f} (0.02104 +- 0.002104); RD {m['RD']:.5f} (0.02213 +- 0.002213); range {per.geometry.min():.5f} to {per.geometry.max():.5f}")
print("paper's gate (at least 16 of 20 positive, positive CO and RD means):", bool((per.geometry > 0).sum() >= 16 and m["CO"] > 0 and m["RD"] > 0))
print("combined mean under seeds 20260726 + 0/1000/2000/3000/4000:", seed_line("gain", "geometry_tensor"))
positive 20/20 (expected 20, tolerance 2); mean 0.02158 (0.02158 +- 0.002158); CO 0.02104 (0.02104 +- 0.002104); RD 0.02213 (0.02213 +- 0.002213); range 0.00593 to 0.04001 paper's gate (at least 16 of 20 positive, positive CO and RD means): True combined mean under seeds 20260726 + 0/1000/2000/3000/4000: 0.02158 (20 positive); 0.01478 (19 positive); 0.01699 (19 positive); 0.02070 (20 positive); 0.01843 (19 positive)
Result: reproduced. The paper's rule re-run on the archive's asset metadata selects the same 20 sessions as its frozen manifest. Under geometry by phase all 20 gains are positive and the mean is 0.02158 (CO 0.02104, RD 0.02213), the paper's values. The values depend on the split: under the four other split seeds the combined mean is 0.01478 to 0.02070, with 19 or 20 sessions positive, so three of those seeds put the mean outside its 10% tolerance.
confirm-history-contraction¶
In the confirmation sessions, adding measured-output history reduced the combined mean gain to 0.00755 (CO 0.00670, RD 0.00840), with 19 of 20 sessions positive.
m = per.groupby("task").history.mean()
print(f"mean {per.history.mean():.5f} (0.00755 +- 0.000755); CO {m['CO']:.5f} (0.0067 +- 0.00067); RD {m['RD']:.5f} (0.0084 +- 0.00084); "
f"positive {int((per.history > 0).sum())}/20 (19 +- 1.9); below the geometry mean {per.geometry.mean():.5f}: {per.history.mean() < per.geometry.mean()}")
print(f"range {per.history.min():.5f} to {per.history.max():.5f}")
print("combined mean under the five seeds:", seed_line("gain", "causal_history"))
mean 0.00755 (0.00755 +- 0.000755); CO 0.00670 (0.0067 +- 0.00067); RD 0.00840 (0.0084 +- 0.00084); positive 19/20 (19 +- 1.9); below the geometry mean 0.02158: True range -0.00128 to 0.01291 combined mean under the five seeds: 0.00755 (19 positive); 0.00335 (18 positive); 0.00475 (19 positive); 0.00818 (19 positive); 0.00600 (18 positive)
Result: reproduced. With measured-output history the combined mean is 0.00755 (CO 0.00670, RD 0.00840) with 19 of 20 sessions positive, below the geometry-by-phase mean of 0.02158. Under the four other split seeds the combined mean is 0.00335 to 0.00818, three of them outside the tolerance.
confirm-replacement¶
In the confirmation sessions, nearest-replacement gain averaged -0.00771 under geometry by phase, and correct-pair gain exceeded replacement gain in all 20 sessions and in both task means.
above = int((per.geometry > per.replacement_geometry).sum())
mt = per.groupby("task")[["geometry", "replacement_geometry"]].mean()
print(f"mean replacement gain {per.replacement_geometry.mean():.5f} (-0.00771 +- 0.000771); sessions with gain above replacement {above}/20 (20 +- 2)")
print(mt.round(5).to_string())
print("correct-pair mean above replacement in CO and RD:", bool((mt.geometry > mt.replacement_geometry).all()))
print("replacement mean under the five seeds:", seed_line("replacement_gain", "geometry_tensor"))
for k in (0,) + EXTRA:
g_, r_ = table(results, f"geometry_tensor_{SEED + k}"), table(results, f"geometry_tensor_{SEED + k}", "replacement_gain")
tm = pd.DataFrame({"task": g_.task, "g": g_.gain, "r": r_.replacement_gain}).groupby("task").mean()
print(f"seed {SEED + k}: sessions with gain above replacement {int((g_.gain > r_.replacement_gain).sum())}/20; "
f"task means above replacement in CO and RD: {bool((tm.g > tm.r).all())}")
mean replacement gain -0.00771 (-0.00771 +- 0.000771); sessions with gain above replacement 20/20 (20 +- 2)
geometry replacement_geometry
task
CO 0.02104 -0.00292
RD 0.02213 -0.01250
correct-pair mean above replacement in CO and RD: True
replacement mean under the five seeds: -0.00771 (3 positive); -0.01963 (2 positive); -0.00902 (2 positive); -0.00938 (0 positive); -0.01515 (0 positive)
seed 20260726: sessions with gain above replacement 20/20; task means above replacement in CO and RD: True
seed 20261726: sessions with gain above replacement 20/20; task means above replacement in CO and RD: True
seed 20262726: sessions with gain above replacement 19/20; task means above replacement in CO and RD: True
seed 20263726: sessions with gain above replacement 20/20; task means above replacement in CO and RD: True
seed 20264726: sessions with gain above replacement 20/20; task means above replacement in CO and RD: True
Result: reproduced. The mean nearest-replacement gain is -0.00771, and the correct-pair gain exceeds the replacement gain in 20 of 20 sessions and in both task means (CO 0.02104 against -0.00292, RD 0.02213 against -0.01250). Under the four other split seeds the replacement mean is -0.00902 to -0.01963, outside the 10% tolerance in each; the correct-pair gain exceeds the replacement gain in 20, 19, 20 and 20 of 20 sessions and in both task means under each.
confirm-table1-values¶
Table 1 gives, for the confirmation sessions, a replacement gain of -0.00498 with measured-output history and MSE reductions of 4.76% (geometry by phase) and 2.05% (plus history).
print(f"replacement gain, plus history: {per.replacement_history.mean():.5f} (-0.00498 +- 0.000498)")
print(f"MSE reduction, geometry: {per.mse_red_geometry.mean():.3f}% (4.76 +- 0.476); plus history: {per.mse_red_history.mean():.3f}% (2.05 +- 0.205)")
print("plus-history replacement under the five seeds:", seed_line("replacement_gain", "causal_history"))
print("geometry MSE reduction under the five seeds:", seed_line("mse_reduction_percent", "geometry_tensor"))
print("history MSE reduction under the five seeds:", seed_line("mse_reduction_percent", "causal_history"))
print(f"run time {(time.time() - T0) / 60:.1f} min; peak memory {resource.getrusage(resource.RUSAGE_SELF).ru_maxrss / 1e6:.2f} GB")
replacement gain, plus history: -0.00498 (-0.00498 +- 0.000498) MSE reduction, geometry: 4.761% (4.76 +- 0.476); plus history: 2.047% (2.05 +- 0.205) plus-history replacement under the five seeds: -0.00498 (3 positive); -0.01462 (3 positive); -0.00508 (3 positive); -0.00467 (2 positive); -0.00803 (1 positive) geometry MSE reduction under the five seeds: 4.76055 (20 positive); 3.42644 (19 positive); 3.86092 (19 positive); 4.58229 (20 positive); 4.10710 (19 positive) history MSE reduction under the five seeds: 2.04742 (19 positive); 1.14654 (18 positive); 1.49115 (19 positive); 2.20586 (19 positive); 1.73388 (18 positive) run time 9.6 min; peak memory 0.48 GB
Result: reproduced. With measured-output history the mean replacement gain is -0.00498, and the mean MSE reductions are 4.761% (geometry by phase) and 2.047% (plus history), the values of Table 1. Under the four other split seeds these become -0.00467 to -0.01462, 3.43 to 4.58% and 1.15 to 2.21%, mostly outside their tolerances.
Summary¶
| Claim | Outcome |
|---|---|
| confirm-geometry-gain | reproduced (seed sensitive) |
| confirm-history-contraction | reproduced (seed sensitive) |
| confirm-replacement | reproduced (seed sensitive) |
| confirm-table1-values | reproduced (seed sensitive) |
The confirmation sessions re-selected from the archive's metadata are those of the paper's frozen manifest; each has 375 usable trials (7,500 in all) and no SBP array repeats. Every value equals the paper's under its split seed 20260726. Under the four other split seeds most values fall outside their 10% tolerances (the combined geometry and history means are inside only under seed plus 3000, and the replacement mean under none), while the qualitative pattern holds in the printed seed runs: positive geometry gain, a smaller history gain, and replacement below correct pairing in both task means and in 19 or 20 of the 20 sessions.