Du, Lai, Hu & Ye (2026) on LINK: temporal offset and context capacity¶

Paper doi:10.64898/2026.08.04.742876; dataset DANDI:001201 version 0.251023.2336 (the cited version; see 02_link_development.ipynb for the header, the full claims table and the data check).

Claim Status
temporal-offset tested, readings (i) fully nested and (ii) evaluate_decoders_nested
context-capacity-contrast tested, readings (i) and (ii)

The release has no script for either analysis, and the paper does not name the estimator for Figure 7a or 7c; the claims file names both readings. Reading (ii) is du2026.decoders_nested, a port of evaluate_decoders_nested, whose residual-neural gain is used.

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)

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])
312 assets in DANDI:001201 0.251023.2336; 9 dates with two sessions, 18 development sessions
In [2]:
sessions = [d.load_link_session(a["asset_id"], a["path"], signals=("SpikingBandPower", "ThresholdCrossings")) for a in dev_assets]
check = pd.DataFrame([dict(session=s.identifier, trials=len(s.trials), bins=len(s.timestamps),
                           dt_ms=1000 * float(np.median(np.diff(s.timestamps))),
                           sbp_range=f"{s.signals['SpikingBandPower'].min():.3g}..{s.signals['SpikingBandPower'].max():.3g}",
                           tcr_range=f"{s.signals['ThresholdCrossings'].min():.3g}..{s.signals['ThresholdCrossings'].max():.3g}",
                           pos_range=f"{s.position.min():.3g}..{s.position.max():.3g}",
                           vel_range=f"{s.velocity.min():.3g}..{s.velocity.max():.3g}") for s in sessions])
print(check.to_string())
print("tasks:", collections.Counter(s.task for s in sessions), "; units:", sessions[0].units)
print("The full data check of these sessions (duplicates, clock, velocity) is in 02_link_development.ipynb.")
del sessions
print(f"peak memory {resource.getrusage(resource.RUSAGE_SELF).ru_maxrss / 1e6:.2f} GB")
              session  trials   bins  dt_ms    sbp_range tcr_range      pos_range       vel_range
0   2021-10-15_CO_nwb     375  21825   20.0  0.794..30.5      0..6       0.066..1  -0.0998..0.154
1   2021-10-15_RD_nwb     375  26836   20.0  0.725..25.7      0..7           0..1   -0.202..0.308
2   2022-02-25_RD_nwb     375  27135   20.0  0.719..16.6      0..6           0..1   -0.138..0.544
3   2022-02-25_CO_nwb     375  23816   20.0  0.719..15.8      0..6  0.0307..0.981    -0.12..0.153
4   2022-04-08_CO_nwb     375  22384   20.0  0.725..21.1      0..5      0.0529..1    -0.135..0.21
5   2022-04-08_RD_nwb     375  24997   20.0    0.7..21.3      0..5       0.028..1    -0.18..0.254
6   2022-04-15_CO_nwb     375  22568   20.0  0.725..23.5      0..7      0.0838..1   -0.113..0.215
7   2022-04-15_RD_nwb     375  24874   20.0  0.663..28.1      0..7     0.00575..1   -0.223..0.361
8   2022-04-29_RD_nwb     375  24682   20.0  0.731..21.1      0..7      0.0211..1   -0.245..0.228
9   2022-04-29_CO_nwb     375  22364   20.0  0.667..20.5      0..6      0.0789..1   -0.162..0.183
10  2022-05-13_RD_nwb     375  25290   20.0   0.75..19.4      0..6      0.0315..1   -0.219..0.219
11  2022-05-13_CO_nwb     375  23653   20.0  0.712..40.2      0..6  0.0785..0.952   -0.118..0.114
12  2022-08-10_CO_nwb     375  22292   20.0  0.769..24.9      0..7  0.0868..0.991   -0.123..0.153
13  2022-08-10_RD_nwb     375  23475   20.0    0.681..31     0..11           0..1   -0.182..0.261
14  2022-09-21_CO_nwb     375  22725   20.0  0.744..24.6      0..5      0.0383..1   -0.174..0.199
15  2022-09-21_RD_nwb     375  25015   20.0  0.706..25.1      0..5           0..1   -0.211..0.263
16  2022-11-02_RD_nwb     375  24786   20.0  0.706..21.6      0..8      0.0321..1   -0.272..0.236
17  2022-11-02_CO_nwb     375  22194   20.0  0.681..22.3      0..7      0.0615..1   -0.135..0.155
tasks: Counter({'CO': 9, 'RD': 9}) ; units: {'SpikingBandPower': 'volts', 'ThresholdCrossings': 'volts', 'index_position': 'flexion units', 'index_velocity': 'flexion units per time bin'}
The full data check of these sessions (duplicates, clock, velocity) is in 02_link_development.ipynb.
peak memory 0.62 GB
In [3]:
jobs = []
# temporal offset: both histories end `offset` before the behaviour bin; one window start for all
# offsets, 280 ms after the start bin (eight SBP bins plus six offset bins; claims file)
for offset in (0, 40, 80, 120):
    build_kw = dict(signal="SpikingBandPower", context_mode="causal_history", neural_lead_ms=offset,
                    output_lead_ms=offset, sample_offset_ms=280, seed=20260726)
    jobs.append((f"offset{offset}_nested", build_kw, "nested", {"seed": 20260726}, False))
    jobs.append((f"offset{offset}_decoders", build_kw, "decoders", {"seed": 20260726}, False))
# context capacity: linear and quadratic geometry, with and without history (Methods 4.4)
for signal, tag in (("SpikingBandPower", "SBP"), ("ThresholdCrossings", "TCR")):
    for context in ("geometry_tensor", "geometry_quadratic", "causal_history", "causal_history_quadratic"):
        build_kw = dict(signal=signal, context_mode=context, seed=20260726)
        jobs.append((f"{tag}_{context}_nested", build_kw, "nested", {"seed": 20260726}, False))
        jobs.append((f"{tag}_{context}_decoders", build_kw, "decoders", {"seed": 20260726}, False))
t = time.time()
results = d.run_parallel(d.link_session_jobs, [(a["asset_id"], a["path"], jobs) for a in dev_assets])
print(f"{len(jobs)} fits per session on {len(results)} sessions in {(time.time() - t) / 60:.1f} min")
print("context feature counts (Methods 4.4: 141, 351, 151, 361):",
      {ctx: sorted(set(r[f"SBP_{ctx}_nested"]["n_context"] for r in results))
       for ctx in ("geometry_tensor", "geometry_quadratic", "causal_history", "causal_history_quadratic")})
print("usable trials at the 280 ms window start:", sorted(set(r["offset0_nested"]["n_usable"] for r in results)))
24 fits per session on 18 sessions in 17.4 min
context feature counts (Methods 4.4: 141, 351, 151, 361): {'geometry_tensor': [141], 'geometry_quadratic': [351], 'causal_history': [151], 'causal_history_quadratic': [361]}
usable trials at the 280 ms window start: [367, 368, 369, 370, 371, 375]

temporal-offset¶

Shifting both the neural and the measured-output histories back by 40, 80 and 120 ms with the behavioral window fixed reduced the small output-history-conditional gain and changed the RD direction at intermediate offsets.

In [4]:
for reading, key, field in (("(i) fully nested", "nested", "gain"), ("(ii) evaluate_decoders_nested", "decoders", "innovation_gain")):
    rows = []
    for offset in (0, 40, 80, 120):
        t_ = table(results, f"offset{offset}_{key}", field)
        rows.append(dict(offset_ms=offset, CO=t_[t_.task == "CO"][field].mean(), RD=t_[t_.task == "RD"][field].mean(),
                         RD_minus_CO=t_[t_.task == "RD"][field].mean() - t_[t_.task == "CO"][field].mean(),
                         positive=int((t_[field] > 0).sum())))
    off = pd.DataFrame(rows).set_index("offset_ms")
    print(reading)
    print(off.to_string(float_format=lambda v: f"{v:.5f}"))
    reduced = bool(off.loc[120, "CO"] < off.loc[0, "CO"] and off.loc[120, "RD"] < off.loc[0, "RD"])
    a = bool(off.loc[40, "RD"] < 0 or off.loc[80, "RD"] < 0)
    b = bool(np.sign(off.loc[40, "RD_minus_CO"]) != np.sign(off.loc[0, "RD_minus_CO"]) or np.sign(off.loc[80, "RD_minus_CO"]) != np.sign(off.loc[0, "RD_minus_CO"]))
    print(f"   gain at 120 ms below 0 ms for both tasks: {reduced}; RD change reading (a) RD mean negative at 40 or 80 ms: {a}; "
          f"reading (b) RD minus CO changes sign at 40 or 80 ms: {b}\n")
(i) fully nested
               CO      RD  RD_minus_CO  positive
offset_ms                                       
0         0.00382 0.00623      0.00241        18
40        0.00134 0.00110     -0.00024        15
80        0.00104 0.00043     -0.00061        17
120       0.00055 0.00038     -0.00017        17
   gain at 120 ms below 0 ms for both tasks: True; RD change reading (a) RD mean negative at 40 or 80 ms: False; reading (b) RD minus CO changes sign at 40 or 80 ms: True

(ii) evaluate_decoders_nested
                CO       RD  RD_minus_CO  positive
offset_ms                                         
0          0.00400  0.00678      0.00277        18
40         0.00076  0.00080      0.00004        12
80        -0.00022 -0.00032     -0.00010        12
120        0.00058  0.00000     -0.00058        15
   gain at 120 ms below 0 ms for both tasks: True; RD change reading (a) RD mean negative at 40 or 80 ms: True; reading (b) RD minus CO changes sign at 40 or 80 ms: True

Result: reproduced. Under the fully nested estimator (reading i), shifting both histories from 0 to 120 ms lowers the CO mean from 0.00382 to 0.00055 and the RD mean from 0.00623 to 0.00038, and the RD-minus-CO difference turns from 0.00241 at 0 ms to -0.00024 at 40 ms and -0.00061 at 80 ms (reading b of the RD change); the RD mean stays positive (reading a fails). Under evaluate_decoders_nested (reading ii) the reduction holds (0.00400 to 0.00058, 0.00678 to 0.00000) and both readings of the RD change hold (RD -0.00032 at 80 ms). The outcome holds under both estimators.

context-capacity-contrast¶

Adding quadratic geometry to the context changed the descriptive RD-minus-CO gain contrast, and the richest quadratic-history context gave a small positive contrast for both SBP and TCR.

Per date RD minus CO, mean over nine dates, 95% paired date-bootstrap interval (10,000 resamples, generator from the claim's seed; the seed plus 1000 to 4000 give the range of the interval bounds).

In [5]:
for reading, key, field in (("(i) fully nested", "nested", "gain"), ("(ii) evaluate_decoders_nested", "decoders", "innovation_gain")):
    rows = []
    for tag in ("SBP", "TCR"):
        for context in ("geometry_tensor", "geometry_quadratic", "causal_history", "causal_history_quadratic"):
            p = table(results, f"{tag}_{context}_{key}", field).pivot(index="date", columns="task", values=field)
            diff = (p["RD"] - p["CO"]).to_numpy()
            bounds = []
            for k in (0,) + EXTRA:
                rng = np.random.default_rng(claim_seed("context-capacity-contrast") + k)
                boots = np.array([rng.choice(diff, len(diff), replace=True).mean() for _ in range(10000)])
                bounds.append(np.quantile(boots, [0.025, 0.975]))
            rows.append(dict(signal=tag, context=d.LADDER_NAMES[context], CO=p["CO"].mean(), RD=p["RD"].mean(), RD_minus_CO=diff.mean(),
                             ci_low=bounds[0][0], ci_high=bounds[0][1], excludes_zero=bool(bounds[0][0] > 0 or bounds[0][1] < 0),
                             excludes_zero_all_seeds=all(b[0] > 0 or b[1] < 0 for b in bounds) if (bounds[0][0] > 0 or bounds[0][1] < 0) else not any(b[0] > 0 or b[1] < 0 for b in bounds)))
    cap = pd.DataFrame(rows)
    print(reading)
    print(cap.to_string(float_format=lambda v: f"{v:.5f}"))
    qh = cap[cap.context == "quadratic plus history"].set_index("signal").RD_minus_CO
    changed = []
    for tag in ("SBP", "TCR"):
        lin = cap[(cap.signal == tag) & (cap.context == "geometry by phase")].iloc[0]
        quad = cap[(cap.signal == tag) & (cap.context == "quadratic geometry")].iloc[0]
        changed.append(bool(np.sign(lin.RD_minus_CO) != np.sign(quad.RD_minus_CO) or lin.excludes_zero != quad.excludes_zero))
    print(f"   quadratic-plus-history contrast positive: SBP {qh['SBP'] > 0}, TCR {qh['TCR'] > 0}; "
          f"quadratic contrast differs from linear (sign or interval excluding zero): SBP {changed[0]}, TCR {changed[1]}\n")
print(f"run time {(time.time() - T0) / 60:.1f} min; peak memory {resource.getrusage(resource.RUSAGE_SELF).ru_maxrss / 1e6:.2f} GB")
(i) fully nested
  signal                       context      CO      RD  RD_minus_CO   ci_low  ci_high  excludes_zero  excludes_zero_all_seeds
0    SBP             geometry by phase 0.01933 0.02085      0.00152 -0.00351  0.00764          False                     True
1    SBP            quadratic geometry 0.01571 0.01971      0.00400 -0.00059  0.00980          False                     True
2    SBP  plus measured-output history 0.00766 0.00980      0.00214 -0.00144  0.00670          False                     True
3    SBP        quadratic plus history 0.00532 0.00906      0.00374  0.00070  0.00793           True                     True
4    TCR             geometry by phase 0.01042 0.01269      0.00227 -0.00246  0.00686          False                     True
5    TCR            quadratic geometry 0.00703 0.01198      0.00495  0.00079  0.00915           True                     True
6    TCR  plus measured-output history 0.00329 0.00510      0.00181 -0.00057  0.00434          False                     True
7    TCR        quadratic plus history 0.00193 0.00468      0.00275  0.00039  0.00509           True                     True
   quadratic-plus-history contrast positive: SBP True, TCR True; quadratic contrast differs from linear (sign or interval excluding zero): SBP False, TCR True

(ii) evaluate_decoders_nested
  signal                       context      CO      RD  RD_minus_CO   ci_low  ci_high  excludes_zero  excludes_zero_all_seeds
0    SBP             geometry by phase 0.01974 0.02045      0.00071 -0.00405  0.00691          False                     True
1    SBP            quadratic geometry 0.01599 0.01958      0.00358 -0.00100  0.00903          False                     True
2    SBP  plus measured-output history 0.00779 0.01004      0.00226 -0.00117  0.00657          False                     True
3    SBP        quadratic plus history 0.00540 0.00950      0.00410  0.00116  0.00816           True                     True
4    TCR             geometry by phase 0.01073 0.01243      0.00171 -0.00358  0.00636          False                     True
5    TCR            quadratic geometry 0.00717 0.01235      0.00519  0.00115  0.00927           True                     True
6    TCR  plus measured-output history 0.00307 0.00542      0.00235  0.00003  0.00493           True                     True
7    TCR        quadratic plus history 0.00164 0.00538      0.00374  0.00140  0.00654           True                     True
   quadratic-plus-history contrast positive: SBP True, TCR True; quadratic contrast differs from linear (sign or interval excluding zero): SBP False, TCR True

run time 17.9 min; peak memory 0.62 GB

Result: reproduced. Under the fully nested estimator the quadratic-plus-history RD-minus-CO contrast is positive for SBP (0.00374) and TCR (0.00275), and for TCR the quadratic-geometry contrast (0.00495, interval 0.00079 to 0.00915) excludes zero where the linear one (0.00227, -0.00246 to 0.00686) does not. For SBP the contrast keeps its sign and its interval contains zero in both. The release's other estimator gives the same pattern (0.00410 and 0.00374; TCR quadratic interval 0.00115 to 0.00927).

Summary¶

Claim Outcome
temporal-offset reproduced (under both estimators)
context-capacity-contrast reproduced (under both estimators)

The paper's figure for these analyses plots a frozen table whose script is not in the release; both estimators the claims file names were run, and they give the same outcomes. Holding the behavioural window fixed was read as one window start, 280 ms after the start bin, for every offset; at that start 367 to 375 trials per session are usable, against 375 in the other analyses.