Peyrache et al. (2015), Fig. 5d,e: optimal readout windows of the ADn to PoS GLM, from DANDI:000056¶

Paper. Peyrache A, Lacroix MM, Petersen PC, Buzsáki G (2015). Internally organized mechanisms of the head direction sense. Nature Neuroscience 18, 569-575. doi:10.1038/nn.3968.

Dataset. DANDI:000056, version 0.261106.1949, streamed from the archive (the version is discussed in reproduce_peyrache_2015.ipynb).

Claim. fig5e-readout-windows. It was recorded as blocked (too_large) and verified so in round 1; the round-2 verifier found that the printed timing did not support the block. It is run here, and the third verification round agreed with the outcome it gives.

Method. The GLM of glm_peyrache_2015.ipynb (hd.glm_session; Methods, Information measures), for PoS HD targets (hd-a or hd-b) of ADn HD cell assemblies only, the direction the claim is about, with the dense grid hd.GLM_WINDOWS_DENSE: Gaussian readout windows with s.d. from 20 to 251 ms at 20 per decade, the grid the criterion asks for near 50 to 200 ms, which covers both readings (a, the window is the s.d.; b, it is the full width at half maximum, 2.355 s.d.), and 10, 500 and 1000 ms outside it. As in that notebook, at most the first 20 minutes of each state are used. Targets are kept when positively predicted at one window or more (fig5d-adn-predicts-pos-reliably), and each kept target's best window is the one with the highest cross-validated information.

In [1]:
import os
os.environ["OMP_NUM_THREADS"] = "1"
os.environ["OPENBLAS_NUM_THREADS"] = "1"
import time, resource
import numpy as np
import pandas as pd
from scipy import stats
import hd
pd.set_option("display.width", 200)
print("dandiset", hd.DANDISET, "version", hd.VERSION, "| readout window s.d. (ms):", np.round(hd.GLM_WINDOWS_DENSE * 1000, 1).tolist(),
      "| at most", hd.GLM_MAX_S, "s of each state")
dandiset 000056 version 0.261106.1949 | readout window s.d. (ms): [10.0, 20.0, 22.4, 25.1, 28.2, 31.6, 35.5, 39.8, 44.7, 50.1, 56.2, 63.1, 70.8, 79.4, 89.1, 100.0, 112.2, 125.9, 141.3, 158.5, 177.8, 199.5, 223.9, 251.2, 500.0, 1000.0] | at most 1200.0 s of each state
In [2]:
# The dense-window GLM on every session of the mice whose files hold units
# labelled ADn and PoS, PoS targets only.
t0 = time.time()
G = hd.run_glm(["Mouse20", "Mouse24", "Mouse25", "Mouse28"], workers=4, dense=True)
print(f"analysed {len(G)} sessions in {(time.time() - t0) / 60:.1f} min; "
      f"peak memory of this process {resource.getrusage(resource.RUSAGE_SELF).ru_maxrss / 1e6:.2f} GB")
GLM = pd.DataFrame([g for o in G for g in o["glm"]])
analysed 26 sessions in 20.7 min; peak memory of this process 0.19 GB

Data check¶

In [3]:
print("seconds per session:", {o["meta"]["path"].split("_ses-")[1].split("_")[0]: round(o["meta"]["seconds"]) for o in G})
print("sessions with a GLM (HD cells in both structures):", GLM.session.nunique(), "by mouse:", GLM.groupby("subject").session.nunique().to_dict())
print("target regions:", GLM.target_region.unique().tolist(), "| windows per target:", GLM.groupby(["session", "state", "target"]).size().unique().tolist())
print("PoS targets per state:", GLM.groupby("state").target.size().div(len(hd.GLM_WINDOWS_DENSE)).astype(int).to_dict())
lw = np.log10(hd.GLM_WINDOWS_DENSE)
print("windows per decade between 50 and 200 ms (s.d.):", round(1 / np.median(np.diff(lw[(hd.GLM_WINDOWS_DENSE >= 0.05) & (hd.GLM_WINDOWS_DENSE <= 0.2)])), 1),
      "| as full width (x 2.355), windows inside 50 to 200 ms:", int(((hd.GLM_WINDOWS_DENSE * 2.3548 >= 0.05) & (hd.GLM_WINDOWS_DENSE * 2.3548 <= 0.2)).sum()))
print("information range (bits/spike):", round(GLM["info"].min(), 3), "to", round(GLM["info"].max(), 3), "| non-finite:", int((~np.isfinite(GLM["info"])).sum()))
seconds per session: {'Mouse20-130514': 3, 'Mouse20-130515': 3, 'Mouse20-130516': 3, 'Mouse20-130517': 4, 'Mouse20-130520': 4, 'Mouse24-131213': 44, 'Mouse24-131216': 73, 'Mouse24-131217': 106, 'Mouse24-131218': 86, 'Mouse25-140123': 238, 'Mouse25-140124': 159, 'Mouse25-140128': 90, 'Mouse25-140129': 158, 'Mouse25-140130': 281, 'Mouse25-140131': 129, 'Mouse25-140203': 229, 'Mouse25-140204': 151, 'Mouse25-140205': 172, 'Mouse25-140206': 40, 'Mouse28-140310': 302, 'Mouse28-140311': 320, 'Mouse28-140312': 669, 'Mouse28-140313': 1022, 'Mouse28-140314': 3, 'Mouse28-140317': 217, 'Mouse28-140318': 179}
sessions with a GLM (HD cells in both structures): 20 by mouse: {'Mouse24': 4, 'Mouse25': 10, 'Mouse28': 6}
target regions: ['PoS'] | windows per target: [26]
PoS targets per state: {'REM': 104, 'SWS': 102, 'wake': 124}
windows per decade between 50 and 200 ms (s.d.): 20.0 | as full width (x 2.355), windows inside 50 to 200 ms: 12
information range (bits/spike): -1.053 to 3.163 | non-finite: 0

fig5e-readout-windows¶

The optimal readout windows of the ADn to PoS prediction are similar in waking and REM, median 123 ms and 133 ms, and shorter in SWS, median 79 ms.

Readings (criterion): (a) the window is the Gaussian's s.d., (b) its full width at half maximum. Reproduced when all three medians are within tolerance under one reading (123 plus or minus 12.3, 133 plus or minus 13.3 and 79 plus or minus 7.9 ms); partially reproduced when the SWS median is below both others and some medians are outside. The kept-target selection and hd-a targets are shown as variants, with the medians by mouse and the count of best windows at the ends of the grid.

In [4]:
best = GLM.loc[GLM.groupby(["session", "state", "target"])["info"].idxmax()]
best = best.assign(kept=best["info"] > 0)
EXP = {"wake": (123, 12.3), "REM": (133, 13.3), "SWS": (79, 7.9)}
rows = []
for tg in ("hd-a or hd-b", "hd-a"):
    for sel in ("kept", "all targets"):
        b0 = best if tg == "hd-a or hd-b" else best[best.hd_a.astype(bool)]
        if sel == "kept":
            b0 = b0[b0.kept]
        for rd, f in (("a s.d.", 1.0), ("b FWHM", 2.3548)):
            m = {st: 1000 * f * b0[b0.state == st].window.median() for st in ("wake", "REM", "SWS")}
            rows.append(dict(targets=tg, selection=sel, reading=rd, n_wake=int((b0.state == "wake").sum()),
                             n_REM=int((b0.state == "REM").sum()), n_SWS=int((b0.state == "SWS").sum()),
                             wake_ms=m["wake"], REM_ms=m["REM"], SWS_ms=m["SWS"],
                             within=sum(abs(m[st] - EXP[st][0]) <= EXP[st][1] for st in EXP),
                             SWS_shortest=m["SWS"] < min(m["wake"], m["REM"])))
F5W = pd.DataFrame(rows)
print(F5W.to_string(index=False, float_format=lambda x: f"{x:.1f}"))
print("expected medians: wake 123 (+-12.3), REM 133 (+-13.3), SWS 79 (+-7.9) ms")
k = best[best.kept]
print("kept targets (hd-a or hd-b), median best window s.d. (ms) by mouse:")
print(k.groupby(["subject", "state"]).window.median().mul(1000).round(1).unstack().to_string())
print("best window s.d. (ms), quartiles per state:", {st: np.round(1000 * k[k.state == st].window.quantile([0.25, 0.5, 0.75]).values, 1).tolist() for st in ("wake", "REM", "SWS")})
print("best windows at an end of the grid (10 or 1000 ms):", k.groupby("state").window.apply(lambda w: int(((w <= 0.0101) | (w >= 0.999)).sum())).to_dict(),
      "| outside the dense part (10, 500 or 1000 ms):", k.groupby("state").window.apply(lambda w: int(((w < 0.019) | (w > 0.26)).sum())).to_dict())
for a_, b_ in (("SWS", "wake"), ("SWS", "REM"), ("wake", "REM")):
    u = stats.mannwhitneyu(k[k.state == a_].window, k[k.state == b_].window, alternative="two-sided")
    print(f"Mann-Whitney best window {a_} against {b_}: p {u.pvalue:.3g}")
     targets   selection reading  n_wake  n_REM  n_SWS  wake_ms  REM_ms  SWS_ms  within  SWS_shortest
hd-a or hd-b        kept  a s.d.     122    101     99    168.2   177.8    63.1       0          True
hd-a or hd-b        kept  b FWHM     122    101     99    396.0   418.7   148.6       0          True
hd-a or hd-b all targets  a s.d.     124    104    102    158.5   177.8    63.1       0          True
hd-a or hd-b all targets  b FWHM     124    104    102    373.2   418.7   148.6       0          True
        hd-a        kept  a s.d.      81     69     66    199.5   223.9    66.9       0          True
        hd-a        kept  b FWHM      81     69     66    469.8   527.2   157.6       0          True
        hd-a all targets  a s.d.      82     69     67    199.5   223.9    70.8       0          True
        hd-a all targets  b FWHM      82     69     67    469.8   527.2   166.7       0          True
expected medians: wake 123 (+-12.3), REM 133 (+-13.3), SWS 79 (+-7.9) ms
kept targets (hd-a or hd-b), median best window s.d. (ms) by mouse:
state      REM   SWS   wake
subject                    
Mouse24  251.2  79.4  251.2
Mouse25  199.5  70.8  158.5
Mouse28  141.3  63.1  158.5
best window s.d. (ms), quartiles per state: {'wake': [125.9, 168.2, 251.2], 'REM': [89.1, 177.8, 500.0], 'SWS': [50.1, 63.1, 89.1]}
best windows at an end of the grid (10 or 1000 ms): {'REM': 22, 'SWS': 6, 'wake': 10} | outside the dense part (10, 500 or 1000 ms): {'REM': 31, 'SWS': 11, 'wake': 23}
Mann-Whitney best window SWS against wake: p 1.57e-18
Mann-Whitney best window SWS against REM: p 6.9e-12
Mann-Whitney best window wake against REM: p 0.959

Result: partially reproduced. With the windows read as the Gaussian's s.d. (a) and the kept PoS targets (HD cells under either reading), the median best window is 168 ms in waking, 178 ms in REM and 63 ms in SWS, against 123, 133 and 79 ms: none is within tolerance, and the SWS median is below both others. Read as the full width (b), the medians are 396, 419 and 149 ms, further off. With hd-a targets (a), they are 200, 224 and 67 ms. Every variant has the SWS median the shortest, and the SWS windows are shorter than the waking and REM ones (Mann-Whitney p = 1.6e-18 and 6.9e-12). Waking and REM are similar, as the claim says (Mann-Whitney p = 0.96), but both are longer than the paper's. The best window lies at an end of the grid (10 or 1000 ms) for 10 waking, 22 REM and 6 SWS targets, so the REM median in particular is loose; its interquartile range is 89 to 500 ms. So the claim is partially reproduced under the criterion. The third verification round agreed with this outcome.

Summary¶

claim outcome
fig5e-readout-windows partially reproduced

A failure to reproduce here may be a failure of this attempt, not of the paper: see the reasoning and the differences from the paper's method.

How the analysis differs from the paper's. HD cells as assembly and targets (readings g-b, g-c); PoS targets of ADn assemblies only; 26 readout windows, 23 of them at 20 per decade from 20 to 251 ms s.d.; at most the first 20 minutes of each state; Newton's method in place of a derivative-free search.