Sennesh et al. (2025) on dandiset 000253: claims across the six areas¶

Paper. Sennesh E, Westerberg JA, Spencer-Smith J, Bastos AM (2025). Ubiquitous predictive processing in the spectral domain of sensory cortex. bioRxiv, doi:10.1101/2025.07.31.667946. Claims file claims/sennesh-2025.yaml, written from the preprint's full text and the code at github.com/BastosLab/epych commit cee2e6f.

Dandiset. DANDI:000253, version 0.240923.1441. The paper cites 0.240503.0152, whose LFP cannot be put on the stimulus clock in 7 of the 14 mice; v1_laminar.ipynb shows the differences and gives the reasons for the choice.

What this notebook tests. The claims that compare the six areas (V1, LM, RL, AL, PM, AM): the aperiodic components (Supplementary Figures 1 and 3), the per-mouse gamma and alpha/beta peaks (Supplementary Figure 2) and the L2/3 gamma power of Figure 5. To fit the time limit, each area is read only at its kept rows (every fourth aligned channel, counted from the deepest as in the paper's code, S1), without the median filter over neighbouring channels, and the per-mouse spectra average over those rows. The V1 claims that need every channel are in v1_laminar.ipynb.

Claim Tested here
dd-aperiodic-no-difference, suppfig1-aperiodic-no-difference-all yes
dd-gamma-peak-frequency-lm, dd-gamma-power-and-peak-only-v1-lm, ssa-gamma-peak-frequency-lower yes
suppfig2-alphabeta-peaks, suppfig2-gamma-height-differences yes
fig5-l23-gamma-by-area, fig5-hierarchy-restriction yes
suppfig3-fastsweep-aperiodic yes
In [1]:
import time
import resource
import zlib
import warnings

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from scipy import stats

import glo

warnings.filterwarnings("ignore")
pd.set_option("display.width", 220)
pd.set_option("display.max_columns", 40)
pd.set_option("display.max_rows", 300)
PAPER = "sennesh-2025"
OFFS = [0, 1000, 2000, 3000, 4000]     # seed offsets (protocol: the claim's seed and four more)
started = time.time()


def seed(claim):
    return zlib.crc32(f"{PAPER}/{claim}".encode())


sess, smeta, pmeta = glo.survey()
mice = sorted(smeta)
conds = {m: glo.conditions(smeta[m][1]) for m in mice}
print(f"dandiset {glo.DANDISET_ID} version {glo.DANDISET_VERSION}: {len(mice)} subjects; survey {time.time() - started:.0f} s")
dandiset 000253 version 0.240923.1441: 14 subjects; survey 12 s

Data check¶

One probe per mouse and area: where a mouse has two probes labelled with one area, the probe with more channels of that area is used and the other is not used. Areas are aligned across mice as in S1.

In [2]:
probe = {}
for x in pmeta:
    if x[5] is None:
        continue
    n = int((x[4].location.map(glo.area_of) == x[5]).sum())
    if (x[0], x[5]) not in probe or n > probe[(x[0], x[5])][1]:
        probe[(x[0], x[5])] = (x, n)
rows = []
align = {}
for area in glo.AREAS:
    ms = [m for m in mice if (m, area) in probe]
    ch = {m: glo.cortical_channels(probe[(m, area)][0][4], area) for m in ms}
    spans, labels, kept, raw = glo.alignment(ch)
    align[area] = (ms, ch, spans, labels, kept)
    kl = [labels[k] for k in kept]
    rows.append({"area": area, "mice": len(ms), "aligned_rows": len(labels), "kept_rows": len(kept),
                 "kept_L2/3": kl.count("L2/3"), "kept_layers": "".join({"L1": "1", "L2/3": "2", "L4": "4", "L5/6": "5"}[k] for k in kl),
                 "missing": [m for m in mice if m not in ms]})
print(pd.DataFrame(rows).to_string(index=False))
print("\ntrials per condition, summed over mice:", {c: sum(len(conds[m][c]) for m in mice) for c in glo.CONDITIONS})
area  mice  aligned_rows  kept_rows  kept_L2/3          kept_layers                              missing
  V1    14            73         19          6  1222222444555555555                                   []
  LM    13            79         20          5 12222244455555555555                         [sub-632487]
  RL    14            66         17          5    12222244445555555                                   []
  AL    11            57         15          5      222224455555555 [sub-621890, sub-632485, sub-637908]
  PM    14            70         18          5   122222445555555555                                   []
  AM    14            62         16          5     1222224455555555                                   []

trials per condition, summed over mice: {'lonaive': 700, 'lo_gloexp': 8465, 'go_gloexp': 2046, 'lo_rndctl': 538, 'go_seqctl': 1351, 'igo_seqctl': 1351}

Three mice have no probe labelled AL, so AL has 11 mice; the other areas have 14. In the kept_layers string, 1, 2, 4 and 5 stand for L1, L2/3, L4 and L5/6, from the surface down.

In [3]:
jobs = [(a, m) for a in glo.AREAS for m in align[a][0]]
t = time.time()
metas = glo.chunk_indexes([(probe[(m, a)][0][2], probe[(m, a)][0][3]) for a, m in jobs], workers=24)
metas = dict(zip(jobs, metas))
print(f"chunk indexes of {len(jobs)} files in {time.time() - t:.0f} s")
clock = pd.DataFrame([{"area": a, "mouse": m, "max_resid_ms": 1000 * glo.lfp_clock(metas[(a, m)])[2],
                       "fs": glo.lfp_clock(metas[(a, m)])[1]} for a, m in jobs])
print("largest clock residual (ms):", clock.max_resid_ms.max(), "; sampling rates", clock.fs.min().round(4), "to", clock.fs.max().round(4))
chunk indexes of 80 files in 310 s
largest clock residual (ms): 5.4569682106375694e-09 ; sampling rates 1249.9976 to 1250.0066

Per area: spectrograms, cluster tests and per-mouse spectra¶

For each area, all mice are read, the S2 spectrograms and S3 aperiodic removal are computed as in v1_laminar.ipynb, the three contrasts are cluster-tested (S4) under both S3 readings, and the masked L2/3 gamma values of Figure 5 are kept; the per-mouse spectra are kept for the claims on Supplementary Figures 1 to 3. The four extra seeds are run for S3 reading (a) only, to fit the time limit.

In [4]:
freqs, times = glo.FOI, glo.TOI
FIT = {"a": [5, 150], "b": [5, 90]}
psd, n_trials, fig5, fast = {}, {}, {}, {}
for area in glo.AREAS:
    ms, ch, spans, labels, kept = align[area]
    kl = np.array([labels[k] for k in kept])
    t = time.time()
    spec = {c: [] for c in glo.CONDITIONS}
    for m in ms:
        o = glo.light_pass(probe[(m, area)][0][2], metas[(area, m)], ch[m], spans[m], kept, conds[m])
        for c in glo.CONDITIONS:
            spec[c].append(o["spec"][c])
            psd[(area, m, "a", c)] = o["psd"][("a", c)]
            psd[(area, m, "b", c)] = o["psd"][("b", c)]
            n_trials[(area, m, c)] = o["n"][c]
            # Supplementary Figure 3, reading a: per-mouse spectrogram 0-150 ms, mean over time, trials, rows
            fast[(area, m, c)] = o["spec"][c][:, (times >= 0) & (times <= 0.15)].mean((0, 1))   # freq, row
    pf = o["psd_freqs"]
    power = {c: np.concatenate(spec[c]) for c in glo.CONDITIONS}
    del spec
    read_min = (time.time() - t) / 60
    for c in glo.CONDITIONS:                     # reading b of Supplementary Figure 3: pooled, per row
        fast[(area, "pooled", c)] = power[c][:, (times >= 0) & (times <= 0.15)].mean((0, 1))
    for r, rng_ in FIT.items():
        dbs = {}
        for c in glo.CONDITIONS:
            mean = power[c].mean((0, 1))
            ap = np.stack([glo.fooof_aperiodic(freqs, mean[:, k], rng_)[0] for k in range(mean.shape[1])], -1)
            dbs[c] = (10 * (np.log10(power[c]) - ap[None, None])).astype(np.float32)
        for name, (ca, cb) in glo.CONTRASTS.items():
            for off in (OFFS if r == "a" else [0]):
                f_obs, lab, pv = glo.cluster_test(dbs[ca], dbs[cb], np.random.default_rng(seed("fig5-l23-gamma-by-area") + off))
                sig = np.isin(lab, 1 + np.flatnonzero(pv < 0.01))
                diff = dbs[ca].mean(0) - dbs[cb].mean(0)
                masked = np.where(sig, diff, 0.0)
                fig5[(area, name, r, off)] = {"masked_l23": masked[:, :, kl == "L2/3"], "mask_l23": sig[:, :, kl == "L2/3"],
                                              "n_sig_clusters": int((pv < 0.01).sum())}
        del dbs
    del power
    print(f"{area}: {len(ms)} mice read in {read_min:.1f} min; tests done; {(time.time() - started) / 60:.1f} min since start; "
          f"peak memory {resource.getrusage(resource.RUSAGE_SELF).ru_maxrss / 1e6:.1f} GB")
V1: 14 mice read in 3.8 min; tests done; 10.5 min since start; peak memory 7.1 GB
LM: 13 mice read in 3.7 min; tests done; 15.4 min since start; peak memory 7.3 GB
RL: 14 mice read in 3.4 min; tests done; 19.9 min since start; peak memory 7.3 GB
AL: 11 mice read in 2.3 min; tests done; 23.1 min since start; peak memory 7.3 GB
PM: 14 mice read in 3.5 min; tests done; 27.8 min since start; peak memory 7.3 GB
AM: 14 mice read in 3.2 min; tests done; 32.2 min since start; peak memory 7.3 GB

Per-mouse spectra and FOOOF fits¶

Per mouse, area and condition: the trial-mean power spectrum of each kept row. The aperiodic claims fit one FOOOF model to the spectrum averaged over rows; the peak claims fit FOOOF per row and average the oscillatory spectra (dB over the aperiodic fit) over rows (claims file, dd-gamma-peak-frequency-v1). Readings: (a) 50 ms margins, FOOOF 2 to 90 Hz; (b) 20 ms margins, FOOOF 2 to 150 Hz.

In [5]:
SPEC_FIT = {"a": [2, 90], "b": [2, 150]}
ok = pf > 0
fo = pf[ok]
ap_par, osc = {}, {}
for (area, m, r, c), P in psd.items():
    ap_par[(area, m, r, c)] = glo.fooof_aperiodic(fo, P[:, ok].mean(0), SPEC_FIT[r])[1]
    osc[(area, m, r, c)] = np.mean([10 * (np.log10(P[k, ok]) - glo.fooof_aperiodic(fo, P[k, ok], SPEC_FIT[r])[0])
                                    for k in range(P.shape[0])], 0)
print("fits:", len(ap_par), "spectra;", f"{(time.time() - started) / 60:.1f} min since start")


def per_mouse(area, r, c, fn):
    return np.array([fn(osc[(area, m, r, c)]) for m in align[area][0]])


g = (fo >= 30) & (fo <= 90)
peak_hz = lambda y: fo[g][y[g].argmax()]
fits: 960 spectra; 33.7 min since start

dd-aperiodic-no-difference¶

Over the whole stimulus, deviance detection gives no significant difference in the aperiodic component of the spectrum between oddball and control in any of the six areas.

In [6]:
CONTR = glo.CONTRASTS


def aperiodic_tests(name, claim, offs=OFFS):
    rows = []
    ca, cb = CONTR[name]
    for area in glo.AREAS:
        ms = align[area][0]
        for r in ["a", "b"]:
            for j, par in enumerate(["offset", "exponent"]):
                x = np.array([ap_par[(area, m, r, ca)][j] for m in ms])
                y = np.array([ap_par[(area, m, r, cb)][j] for m in ms])
                ps = [glo.welch_perm_test(x, y, np.random.default_rng(seed(claim) + off))[1] for off in offs]
                rows.append({"contrast": name, "area": area, "reading": r, "parameter": par, "n": len(ms),
                             "oddball_mean": x.mean(), "control_mean": y.mean(), "diff": x.mean() - y.mean(),
                             "t": stats.ttest_ind(x, y, equal_var=False).statistic, "p": ps[0], "p_min_5seeds": min(ps), "p_max_5seeds": max(ps)})
    return pd.DataFrame(rows)
In [7]:
apd = aperiodic_tests("DD", "dd-aperiodic-no-difference")
print(apd.round(4).to_string(index=False))
for r in ["a", "b"]:
    d = apd[apd.reading == r]
    print(f"reading {r}: tests with p < 0.05: {int((d.p < 0.05).sum())} of {len(d)}; areas:", sorted(set(d[d.p < 0.05].area)))
contrast area reading parameter  n  oddball_mean  control_mean    diff       t      p  p_min_5seeds  p_max_5seeds
      DD   V1       a    offset 14       -2.8245       -2.7577 -0.0667 -0.5164 0.6573        0.5594        0.6573
      DD   V1       a  exponent 14        1.5204        1.5779 -0.0575 -0.5920 0.5814        0.5275        0.6194
      DD   V1       b    offset 14       -2.6957       -2.6998  0.0041  0.0344 0.9650        0.9091        0.9710
      DD   V1       b  exponent 14        1.6944        1.6962 -0.0018 -0.0220 0.9950        0.9491        0.9950
      DD   LM       a    offset 13       -2.9502       -2.9685  0.0183  0.1228 0.9550        0.8971        0.9570
      DD   LM       a  exponent 13        1.4826        1.5010 -0.0183 -0.1804 0.8172        0.8172        0.8651
      DD   LM       b    offset 13       -2.8565       -2.8633  0.0068  0.0482 0.9710        0.9471        0.9970
      DD   LM       b  exponent 13        1.6309        1.6519 -0.0211 -0.2541 0.7812        0.7812        0.8372
      DD   RL       a    offset 14       -3.0499       -3.0419 -0.0080 -0.0549 0.9391        0.9131        0.9770
      DD   RL       a  exponent 14        1.4660        1.5077 -0.0417 -0.4565 0.6733        0.6334        0.7033
      DD   RL       b    offset 14       -2.9785       -3.0259  0.0474  0.3387 0.7293        0.7173        0.8052
      DD   RL       b  exponent 14        1.5817        1.5904 -0.0087 -0.1206 0.9411        0.8791        0.9650
      DD   AL       a    offset 11       -2.9897       -2.9929  0.0031  0.0159 0.9291        0.9291        0.9950
      DD   AL       a  exponent 11        1.5414        1.5542 -0.0128 -0.1004 0.9151        0.8791        0.9231
      DD   AL       b    offset 11       -2.8937       -2.9423  0.0486  0.2685 0.7173        0.7173        0.8212
      DD   AL       b  exponent 11        1.6647        1.6607  0.0039  0.0372 0.9570        0.9570        0.9890
      DD   PM       a    offset 14       -3.1405       -3.1943  0.0538  0.3288 0.7512        0.7193        0.8212
      DD   PM       a  exponent 14        1.5053        1.4838  0.0214  0.2166 0.8412        0.8312        0.8611
      DD   PM       b    offset 14       -3.1354       -3.1818  0.0464  0.3160 0.7493        0.7353        0.7992
      DD   PM       b  exponent 14        1.5819        1.5738  0.0080  0.0963 0.9351        0.9051        0.9391
      DD   AM       a    offset 14       -3.0455       -3.1199  0.0744  0.4123 0.6593        0.6573        0.7233
      DD   AM       a  exponent 14        1.5017        1.4536  0.0481  0.4484 0.6713        0.6513        0.7233
      DD   AM       b    offset 14       -3.0095       -3.0380  0.0285  0.1720 0.8352        0.8352        0.9191
      DD   AM       b  exponent 14        1.6058        1.5957  0.0102  0.1098 0.9151        0.9151        0.9351
reading a: tests with p < 0.05: 0 of 12; areas: []
reading b: tests with p < 0.05: 0 of 12; areas: []

Result: reproduced. None of the 24 tests (6 areas, offset and exponent, two readings) has p < 0.05; the smallest p is 0.53 over all seeds. Areas have 11 (AL) to 14 mice.

suppfig1-aperiodic-no-difference-all¶

Over the whole stimulus, the aperiodic component shows no significant difference between oddball and control for any of the three contrasts in any of the six areas.

In [8]:
ap_all = pd.concat([apd] + [aperiodic_tests(n, "suppfig1-aperiodic-no-difference-all") for n in ["GO", "SSA"]])
print(ap_all[ap_all.p < 0.05].round(4).to_string(index=False))
for r in ["a", "b"]:
    d = ap_all[ap_all.reading == r]
    print(f"reading {r}: {int((d.p < 0.05).sum())} of {len(d)} tests with p < 0.05;",
          "contrast-area pairs:", sorted(set(map(tuple, d[d.p < 0.05][["contrast", "area"]].values))))
# Variant: the legend's 2-SEM bands of the aperiodic curve (offset - log10(f^exponent)) across mice.
rows = []
for name, (ca, cb) in CONTR.items():
    for area in glo.AREAS:
        ms = align[area][0]
        cur = {c: np.array([ap_par[(area, m, "a", c)][0] - np.log10(fo ** ap_par[(area, m, "a", c)][1]) for m in ms]) for c in (ca, cb)}
        mu = {c: v.mean(0) for c, v in cur.items()}
        se = {c: v.std(0, ddof=1) / np.sqrt(len(ms)) for c, v in cur.items()}
        sep = np.abs(mu[ca] - mu[cb]) > 2 * (se[ca] + se[cb])
        rows.append({"contrast": name, "area": area, "freqs_bands_apart_2_90Hz": int(sep[(fo >= 2) & (fo <= 90)].sum())})
print(pd.DataFrame(rows).pivot(index="area", columns="contrast", values="freqs_bands_apart_2_90Hz").to_string())
Empty DataFrame
Columns: [contrast, area, reading, parameter, n, oddball_mean, control_mean, diff, t, p, p_min_5seeds, p_max_5seeds]
Index: []
reading a: 0 of 36 tests with p < 0.05; contrast-area pairs: []
reading b: 0 of 36 tests with p < 0.05; contrast-area pairs: []
contrast  DD  GO  SSA
area                 
AL         0   0    0
AM         0   0    0
LM         0   0    0
PM         0   0    0
RL         0   0    0
V1         0   0    0

Result: reproduced. None of the 72 tests (three contrasts, six areas, two parameters, two readings) has p < 0.05, and the 2-SEM bands of the aperiodic curves overlap at every frequency from 2 to 90 Hz in all 18 comparisons.

dd-gamma-peak-frequency-lm¶

In LM the deviance-detection oddball's gamma peak frequency is significantly higher than the control's (control 35 Hz, oddball 41 Hz, p < 0.01).

In [9]:
def peak_table(name, areas, claim, fn=peak_hz):
    ca, cb = CONTR[name]
    rows = []
    for area in areas:
        for r in ["a", "b"]:
            x, y = per_mouse(area, r, ca, fn), per_mouse(area, r, cb, fn)
            ps = [glo.welch_perm_test(x, y, np.random.default_rng(seed(claim) + off))[1] for off in OFFS]
            rows.append({"area": area, "reading": r, "n": len(x), "oddball_mean": x.mean(), "control_mean": y.mean(),
                         "t": stats.ttest_ind(x, y, equal_var=False).statistic, "p": ps[0], "p_min": min(ps), "p_max": max(ps)})
    return pd.DataFrame(rows)
In [10]:
pl = peak_table("DD", ["LM", "V1"], "dd-gamma-peak-frequency-lm")
pl["control_in_31.5_38.5"] = pl.control_mean.between(31.5, 38.5)
pl["oddball_in_36.9_45.1"] = pl.oddball_mean.between(36.9, 45.1)
print(pl.round(4).to_string(index=False))
area reading  n  oddball_mean  control_mean      t     p  p_min  p_max  control_in_31.5_38.5  oddball_in_36.9_45.1
  LM       a 13       40.4615       34.0000 2.9251 0.004  0.002  0.006                  True                  True
  LM       b 13       40.6154       34.1538 2.8994 0.004  0.002  0.006                  True                  True
  V1       a 14       37.5714       33.5714 2.8646 0.012  0.008  0.016                  True                  True
  V1       b 14       37.5714       33.7143 2.8044 0.012  0.008  0.016                  True                  True

Result: reproduced. In LM (13 mice) the gamma peak is 40.46 Hz for "XXXY" and 34.00 Hz for "xxxy" (reading a), both within tolerance, with p = 0.004 (0.002 to 0.006 over five seeds); reading (b) gives 40.62 and 34.15 Hz, p = 0.004.

dd-gamma-power-and-peak-only-v1-lm¶

After removing the aperiodic component, only V1 (p < 0.05) and LM (p < 0.01) show significant increases in both the power and the peak frequency of gamma oscillations for deviance detection.

In [11]:
ca, cb = CONTR["DD"]
claim = "dd-gamma-power-and-peak-only-v1-lm"
rows = []
for area in glo.AREAS:
    ms = align[area][0]
    for r in ["a", "b"]:
        X = np.array([osc[(area, m, r, ca)] for m in ms])
        Y = np.array([osc[(area, m, r, cb)] for m in ms])
        xm, ym = X[:, g].max(1), Y[:, g].max(1)
        xp, yp = per_mouse(area, r, ca, peak_hz), per_mouse(area, r, cb, peak_hz)
        for off in OFFS:
            rng = np.random.default_rng(seed(claim) + off)
            pb = np.array([glo.welch_perm_test(X[:, i], Y[:, i], rng)[1] if X[:, i].mean() > Y[:, i].mean() else 1.0
                           for i in np.flatnonzero(g)])
            pmax = glo.welch_perm_test(xm, ym, np.random.default_rng(seed(claim) + off + 1))[1] if xm.mean() > ym.mean() else 1.0
            ppk = glo.welch_perm_test(xp, yp, np.random.default_rng(seed(claim) + off + 2))[1] if xp.mean() > yp.mean() else 1.0
            rows.append({"area": area, "reading": r, "seed_offset": off, "power_any_bin_min_p": pb.min(), "power_bins_p<0.05": int((pb < 0.05).sum()),
                         "power_max_p": pmax, "peak_p": ppk, "peak_diff_hz": xp.mean() - yp.mean()})
pw = pd.DataFrame(rows)
for lvl in [0.05, 0.01]:
    pw[f"both_any_bin_{lvl}"] = (pw.power_any_bin_min_p < lvl) & (pw.peak_p < lvl)
    pw[f"both_max_{lvl}"] = (pw.power_max_p < lvl) & (pw.peak_p < lvl)
print(pw[pw.seed_offset == 0].round(4).to_string(index=False))
print("\nRange over the five seeds:")
print(pw.groupby(["area", "reading"])[["power_any_bin_min_p", "power_max_p", "peak_p", "both_any_bin_0.05", "both_any_bin_0.01"]].agg(["min", "max"]).round(4).to_string())
print("The p-values for 'oddball higher' are 1 where the oddball mean is not higher. Seeds: the claim's seed plus the offset, and +1 and +2 for the second and third tests.")
area reading  seed_offset  power_any_bin_min_p  power_bins_p<0.05  power_max_p  peak_p  peak_diff_hz  both_any_bin_0.05  both_max_0.05  both_any_bin_0.01  both_max_0.01
  V1       a            0               0.0020                  8       0.0180  0.0100        4.0000               True           True               True          False
  V1       b            0               0.0020                  8       0.0140  0.0140        3.8571               True           True              False          False
  LM       a            0               0.0080                  4       0.1479  0.0020        6.4615               True          False               True          False
  LM       b            0               0.0320                  1       0.1658  0.0040        6.4615               True          False              False          False
  RL       a            0               0.0140                  2       0.0799  0.6194        1.0000              False          False              False          False
  RL       b            0               0.0320                  2       0.1019  1.0000       -0.7143              False          False              False          False
  AL       a            0               0.0020                  4       0.4955  0.1239        2.0000              False          False              False          False
  AL       b            0               0.0659                  0       0.5854  0.3796        1.6364              False          False              False          False
  PM       a            0               0.0080                  2       0.2278  1.0000       -0.1429              False          False              False          False
  PM       b            0               0.0140                  2       0.3057  1.0000       -0.1429              False          False              False          False
  AM       a            0               0.0080                  2       0.2577  1.0000       -0.7143              False          False              False          False
  AM       b            0               0.0340                  1       0.4436  1.0000       -0.2857              False          False              False          False

Range over the five seeds:
             power_any_bin_min_p         power_max_p          peak_p         both_any_bin_0.05        both_any_bin_0.01       
                             min     max         min     max     min     max               min    max               min    max
area reading                                                                                                                  
AL   a                    0.0020  0.0020      0.4735  0.5095  0.1239  0.1738             False  False             False  False
     b                    0.0619  0.0839      0.5495  0.6014  0.3796  0.4555             False  False             False  False
AM   a                    0.0080  0.0140      0.2577  0.2897  1.0000  1.0000             False  False             False  False
     b                    0.0240  0.0500      0.4436  0.5035  1.0000  1.0000             False  False             False  False
LM   a                    0.0060  0.0120      0.1139  0.1499  0.0020  0.0040              True   True             False   True
     b                    0.0220  0.0320      0.1459  0.1758  0.0020  0.0040              True   True             False  False
PM   a                    0.0020  0.0080      0.2278  0.2837  1.0000  1.0000             False  False             False  False
     b                    0.0040  0.0220      0.3057  0.3596  1.0000  1.0000             False  False             False  False
RL   a                    0.0080  0.0160      0.0799  0.0939  0.5774  0.6573             False  False             False  False
     b                    0.0180  0.0320      0.1019  0.1319  1.0000  1.0000             False  False             False  False
V1   a                    0.0020  0.0020      0.0140  0.0320  0.0100  0.0240              True   True             False   True
     b                    0.0020  0.0020      0.0100  0.0160  0.0140  0.0260              True   True             False  False
The p-values for 'oddball higher' are 1 where the oddball mean is not higher. Seeds: the claim's seed plus the offset, and +1 and +2 for the second and third tests.

Result: reproduced, sensitive to the seed. Under power reading (a) (any gamma bin) with window (a), V1 passes both tests at 0.05 (power p = 0.002, peak p = 0.010) and LM both at 0.01 (power p = 0.008, peak p = 0.002); no other area passes both at 0.05 (peak p 0.12 or more, or the oddball peak not higher). Over the five seeds the LM power p runs from 0.006 to 0.012, so under some seeds LM fails at 0.01; under window (b) or power reading (b) LM does not pass at 0.01. The any-bin power test is uncorrected and passes at 0.05 in all six areas under window (a) (0.002 to 0.014), so the area specificity rests on the peak-frequency test.

ssa-gamma-peak-frequency-lower¶

For stimulus-specific adaptation, the "xxxY" oddball (P = 80%) has a significantly lower gamma peak frequency than the "yyyy" control in LM (37 against 43 Hz), RL (37 against 45 Hz), AL (36 against 44 Hz) and AM (38 against 47 Hz).

In [12]:
ps_ = peak_table("SSA", list(glo.AREAS), "ssa-gamma-peak-frequency-lower")
expect = {"LM": (37, 43, 0.05), "RL": (37, 45, 0.01), "AL": (36, 44, 0.05), "AM": (38, 47, 0.05)}
ps_["named"] = ps_.area.isin(list(expect))
ps_["lower_at_level"] = [(row.oddball_mean < row.control_mean) and row.p < expect.get(row.area, (0, 0, 0.05))[2] for row in ps_.itertuples()]
ps_["means_in_tol"] = [row.area in expect and abs(row.oddball_mean - expect[row.area][0]) <= 0.1 * expect[row.area][0]
                       and abs(row.control_mean - expect[row.area][1]) <= 0.1 * expect[row.area][1] for row in ps_.itertuples()]
print(ps_.round(4).to_string(index=False))
for r in ["a", "b"]:
    d = ps_[(ps_.reading == r) & ps_.named]
    print(f"reading {r}: named areas lower at their level with means in tolerance: {int((d.lower_at_level & d.means_in_tol).sum())} of 4;"
          f" lower at level: {int(d.lower_at_level.sum())} of 4")
area reading  n  oddball_mean  control_mean       t      p  p_min  p_max  named  lower_at_level  means_in_tol
  V1       a 14       36.1429       39.4286 -1.7872 0.1419 0.0979 0.1419  False           False         False
  V1       b 14       36.1429       40.7143 -1.9045 0.1039 0.0699 0.1039  False           False         False
  LM       a 13       36.7692       42.1538 -2.6100 0.0180 0.0120 0.0180   True            True          True
  LM       b 13       36.9231       46.0000 -3.3802 0.0060 0.0020 0.0060   True            True          True
  RL       a 14       37.1429       42.4286 -2.2381 0.0440 0.0260 0.0480   True           False          True
  RL       b 14       39.4286       44.2857 -1.7112 0.1079 0.0859 0.1499   True           False          True
  AL       a 11       36.1818       43.2727 -1.4547 0.0739 0.0559 0.0739   True           False          True
  AL       b 11       36.3636       44.7273 -1.6389 0.0799 0.0539 0.0819   True           False          True
  PM       a 14       38.8571       40.5714 -0.7398 0.4995 0.4715 0.5594  False           False         False
  PM       b 14       39.0000       41.1429 -0.8019 0.4535 0.4136 0.5235  False           False         False
  AM       a 14       38.1429       44.7143 -1.9362 0.0779 0.0739 0.0959   True           False          True
  AM       b 14       38.1429       45.8571 -2.2272 0.0420 0.0420 0.0559   True            True          True
reading a: named areas lower at their level with means in tolerance: 1 of 4; lower at level: 1 of 4
reading b: named areas lower at their level with means in tolerance: 2 of 4; lower at level: 2 of 4

Result: partially reproduced. The "xxxY" peak is lower than the "yyyy" peak in all four named areas, with the means within tolerance, but the test passes at the stated level in LM only under reading (a) (p = 0.018) and in LM and AM under reading (b) (p = 0.006 and 0.042); RL (p = 0.044 and 0.108, against 0.01) and AL (p = 0.074 and 0.080) do not.

suppfig2-alphabeta-peaks¶

In the oscillatory spectra the deviance-detection control has greater alpha/beta power than the oddball in all six areas; the global-oddball control has greater alpha/beta power in V1, LM, RL, AL and PM; for stimulus-specific adaptation the oddball has greater alpha/beta power in LM and AL.

In [13]:
def height_cases(cases, lo, hi):
    """cases: (contrast, area, direction) with direction +1 oddball > control, -1 control > oddball, 0 either."""
    sel = (fo >= lo) & (fo <= hi)
    rows = []
    for name, area, d in cases:
        ca, cb = CONTR[name]
        for r in ["a", "b"]:
            X = np.array([osc[(area, m, r, ca)] for m in align[area][0]])
            Y = np.array([osc[(area, m, r, cb)] for m in align[area][0]])
            mx, my = X.mean(0), Y.mean(0)
            # reading (a): at the frequency of the larger condition's mean maximum in the band
            big = mx if mx[sel].max() >= my[sel].max() else my
            i = np.flatnonzero(sel)[big[sel].argmax()]
            va, vb = X[:, i], Y[:, i]
            # reading (b): per-mouse maximum in the band
            wa, wb = X[:, sel].max(1), Y[:, sel].max(1)
            for rd, (a, b) in {"at_peak": (va, vb), "per_mouse_max": (wa, wb)}.items():
                se_a, se_b = a.std(ddof=1) / np.sqrt(len(a)), b.std(ddof=1) / np.sqrt(len(b))
                diff = a.mean() - b.mean()
                sig_max = abs(diff) > 2 * max(se_a, se_b)
                sig_pool = abs(diff) > 2 * np.sqrt(se_a ** 2 + se_b ** 2)
                right = (d == 0) or (np.sign(diff) == d)
                rows.append({"contrast": name, "area": area, "window": r, "reading": rd, "diff_dB": diff,
                             "2xlarger_SEM": 2 * max(se_a, se_b), "holds": bool(sig_max and right),
                             "holds_pooled_SEM": bool(sig_pool and right)})
    return pd.DataFrame(rows)
In [14]:
cases_ab = [("DD", a, -1) for a in glo.AREAS] + [("GO", a, -1) for a in ["V1", "LM", "RL", "AL", "PM"]] + [("SSA", a, +1) for a in ["LM", "AL"]]
hab = height_cases(cases_ab, 10, 30)
print(hab.round(3).to_string(index=False))
print(hab.groupby(["window", "reading"])[["holds", "holds_pooled_SEM"]].sum().to_string())
contrast area window       reading  diff_dB  2xlarger_SEM  holds  holds_pooled_SEM
      DD   V1      a       at_peak   -1.042         0.621   True              True
      DD   V1      a per_mouse_max   -0.863         0.980  False             False
      DD   V1      b       at_peak   -0.933         0.655   True              True
      DD   V1      b per_mouse_max   -0.878         1.031  False             False
      DD   LM      a       at_peak   -1.661         0.417   True              True
      DD   LM      a per_mouse_max   -0.900         0.631   True              True
      DD   LM      b       at_peak   -1.630         0.522   True              True
      DD   LM      b per_mouse_max   -1.112         0.598   True              True
      DD   RL      a       at_peak    0.693         0.576  False             False
      DD   RL      a per_mouse_max    0.171         0.882  False             False
      DD   RL      b       at_peak    0.694         0.588  False             False
      DD   RL      b per_mouse_max   -0.008         0.855  False             False
      DD   AL      a       at_peak   -1.395         0.439   True              True
      DD   AL      a per_mouse_max   -0.682         0.981  False             False
      DD   AL      b       at_peak   -1.439         0.484   True              True
      DD   AL      b per_mouse_max   -0.886         0.915  False             False
      DD   PM      a       at_peak   -0.462         0.405   True             False
      DD   PM      a per_mouse_max   -0.163         0.718  False             False
      DD   PM      b       at_peak   -0.468         0.556  False             False
      DD   PM      b per_mouse_max   -0.291         0.735  False             False
      DD   AM      a       at_peak    0.662         0.821  False             False
      DD   AM      a per_mouse_max   -0.039         0.863  False             False
      DD   AM      b       at_peak    0.680         0.844  False             False
      DD   AM      b per_mouse_max   -0.176         0.833  False             False
      GO   V1      a       at_peak   -0.094         0.464  False             False
      GO   V1      a per_mouse_max   -0.364         0.481  False             False
      GO   V1      b       at_peak    0.024         0.441  False             False
      GO   V1      b per_mouse_max   -0.155         0.432  False             False
      GO   LM      a       at_peak   -0.089         0.500  False             False
      GO   LM      a per_mouse_max   -0.323         0.353  False             False
      GO   LM      b       at_peak   -0.135         0.523  False             False
      GO   LM      b per_mouse_max   -0.274         0.392  False             False
      GO   RL      a       at_peak   -0.082         0.459  False             False
      GO   RL      a per_mouse_max   -0.166         0.457  False             False
      GO   RL      b       at_peak   -0.212         0.479  False             False
      GO   RL      b per_mouse_max   -0.339         0.457  False             False
      GO   AL      a       at_peak   -0.149         0.547  False             False
      GO   AL      a per_mouse_max   -0.334         0.481  False             False
      GO   AL      b       at_peak   -0.097         0.550  False             False
      GO   AL      b per_mouse_max   -0.338         0.467  False             False
      GO   PM      a       at_peak   -0.084         0.784  False             False
      GO   PM      a per_mouse_max   -0.340         0.670  False             False
      GO   PM      b       at_peak    0.013         0.743  False             False
      GO   PM      b per_mouse_max   -0.117         0.675  False             False
     SSA   LM      a       at_peak   -0.421         0.564  False             False
     SSA   LM      a per_mouse_max    0.266         0.503  False             False
     SSA   LM      b       at_peak    0.788         0.547   True              True
     SSA   LM      b per_mouse_max    0.408         0.471  False             False
     SSA   AL      a       at_peak    1.031         0.521   True              True
     SSA   AL      a per_mouse_max    0.880         0.895  False             False
     SSA   AL      b       at_peak    1.062         0.669   True              True
     SSA   AL      b per_mouse_max    0.926         0.780   True              True
                      holds  holds_pooled_SEM
window reading                               
a      at_peak            5                 4
       per_mouse_max      1                 1
b      at_peak            5                 5
       per_mouse_max      2                 2

Result: not reproduced. At most 5 of the 13 named cases differ by more than 2 SEM in the stated direction (at the peak frequency, either window): the DD control is higher in V1, LM and AL (and PM under window a), not in RL or AM; no GO case passes; SSA passes in AL and, under window (b), LM.

suppfig2-gamma-height-differences¶

DD and SSA show significant differences in the height of the gamma oscillatory peak in V1, LM, RL, AL and AM, and DD in PM as well.

In [15]:
cases_g = [("DD", a, 0) for a in glo.AREAS] + [("SSA", a, 0) for a in ["V1", "LM", "RL", "AL", "AM"]]
hg = height_cases(cases_g, 30, 90)
print(hg.round(3).to_string(index=False))
print(hg.groupby(["window", "reading"])[["holds", "holds_pooled_SEM"]].sum().to_string())
contrast area window       reading  diff_dB  2xlarger_SEM  holds  holds_pooled_SEM
      DD   V1      a       at_peak    2.861         1.220   True              True
      DD   V1      a per_mouse_max    1.601         0.990   True              True
      DD   V1      b       at_peak    3.032         1.280   True              True
      DD   V1      b per_mouse_max    1.870         1.111   True              True
      DD   LM      a       at_peak    2.104         1.377   True              True
      DD   LM      a per_mouse_max    1.181         1.206  False             False
      DD   LM      b       at_peak    2.151         1.615   True              True
      DD   LM      b per_mouse_max    1.360         1.443  False             False
      DD   RL      a       at_peak    1.970         1.295   True              True
      DD   RL      a per_mouse_max    1.335         1.290   True             False
      DD   RL      b       at_peak    2.044         1.507   True              True
      DD   RL      b per_mouse_max    1.421         1.503  False             False
      DD   AL      a       at_peak    2.152         1.707   True              True
      DD   AL      a per_mouse_max    0.571         1.367  False             False
      DD   AL      b       at_peak    2.060         1.933   True             False
      DD   AL      b per_mouse_max    0.563         1.591  False             False
      DD   PM      a       at_peak    1.552         0.921   True              True
      DD   PM      a per_mouse_max    0.536         0.781  False             False
      DD   PM      b       at_peak    1.548         0.915   True              True
      DD   PM      b per_mouse_max    0.529         0.840  False             False
      DD   AM      a       at_peak    1.303         0.849   True              True
      DD   AM      a per_mouse_max    0.467         0.602  False             False
      DD   AM      b       at_peak    1.196         0.853   True              True
      DD   AM      b per_mouse_max    0.367         0.792  False             False
     SSA   V1      a       at_peak    1.188         0.872   True              True
     SSA   V1      a per_mouse_max    1.501         0.840   True              True
     SSA   V1      b       at_peak    1.202         0.868   True             False
     SSA   V1      b per_mouse_max    1.473         0.909   True              True
     SSA   LM      a       at_peak    1.565         1.188   True              True
     SSA   LM      a per_mouse_max    1.548         1.175   True              True
     SSA   LM      b       at_peak    1.683         1.391   True              True
     SSA   LM      b per_mouse_max    1.591         1.408   True             False
     SSA   RL      a       at_peak    0.869         0.884  False             False
     SSA   RL      a per_mouse_max    0.684         1.092  False             False
     SSA   RL      b       at_peak    0.796         1.221  False             False
     SSA   RL      b per_mouse_max    0.782         1.262  False             False
     SSA   AL      a       at_peak    1.973         1.233   True              True
     SSA   AL      a per_mouse_max    1.889         1.131   True              True
     SSA   AL      b       at_peak    2.039         1.461   True              True
     SSA   AL      b per_mouse_max    1.933         1.353   True              True
     SSA   AM      a       at_peak    1.010         0.611   True              True
     SSA   AM      a per_mouse_max    0.740         0.620   True             False
     SSA   AM      b       at_peak    1.024         0.691   True              True
     SSA   AM      b per_mouse_max    0.650         0.748  False             False
                      holds  holds_pooled_SEM
window reading                               
a      at_peak           10                10
       per_mouse_max      6                 4
b      at_peak           10                 8
       per_mouse_max      4                 3

Result: reproduced. Under either window at the peak frequency 10 of the 11 named cases differ by more than 2 SEM (SSA in RL does not: 0.87 dB against 0.88); with the pooled SEM 10 and 8; the per-mouse maximum reading gives 6 (window a) and 4 (window b).

fig5-l23-gamma-by-area¶

In L2/3, the time-averaged gamma power difference in the significant clusters is, for deviance detection, about 1.5 dB in V1, 1.1 in LM, 1.3 in RL and 0.3 in AL (not significant in PM and AM); for the global oddball 0.2 dB in V1, 0.1 in LM and -0.5 in RL (none in AL, PM, AM); for stimulus-specific adaptation 0.4 dB in V1, 1.2 in LM, 0.3 in RL, 1.2 in AL, 0.4 in PM and 0.9 in AM.

In [16]:
EXP5 = {("DD", "V1"): 1.5, ("DD", "LM"): 1.1, ("DD", "RL"): 1.3, ("DD", "AL"): 0.3, ("GO", "V1"): 0.2, ("GO", "LM"): 0.1,
        ("GO", "RL"): -0.5, ("SSA", "V1"): 0.4, ("SSA", "LM"): 1.2, ("SSA", "RL"): 0.3, ("SSA", "AL"): 1.2, ("SSA", "PM"): 0.4,
        ("SSA", "AM"): 0.9}
NONE5 = [("DD", "PM"), ("DD", "AM"), ("GO", "AL"), ("GO", "PM"), ("GO", "AM")]


def l23_value(area, name, r, off, bname, tavg):
    d = fig5[(area, name, r, off)]
    bb = glo.band_bins(freqs, glo.BANDS[bname])
    mk, ms_ = d["masked_l23"][:, bb, :], d["mask_l23"][:, bb, :]
    if tavg == "whole":          # (a) band mean per time and row, then mean over time, then rows
        return float(mk.mean(1).mean(0).mean()), int(ms_.sum())
    return (float(mk[ms_].mean()) if ms_.any() else 0.0), int(ms_.sum())   # (b) significant points only


rows = []
for r in ["a", "b"]:
    for bname in ["gamma", "gamma_code"]:
        for tavg in ["whole", "significant"]:
            for area in glo.AREAS:
                for name in CONTR:
                    v, npts = l23_value(area, name, r, 0, bname, tavg)
                    rows.append({"S3": r, "band": bname, "time_avg": tavg, "contrast": name, "area": area, "value": v, "sig_points": npts})
f5 = pd.DataFrame(rows)
In [17]:
summ = []
for (r, bname, tavg), d in f5.groupby(["S3", "band", "time_avg"]):
    hit = 0
    for (name, area), e in EXP5.items():
        v = d[(d.contrast == name) & (d.area == area)].value.iloc[0]
        hit += abs(v - e) <= max(0.1 * abs(e), 0.05)
    none_ok = sum(d[(d.contrast == n) & (d.area == a)].sig_points.iloc[0] == 0 for n, a in NONE5)
    signs = sum(np.sign(d[(d.contrast == n) & (d.area == a)].value.iloc[0]) == np.sign(e) for (n, a), e in EXP5.items())
    summ.append({"S3": r, "band": bname, "time_avg": tavg, "in_tolerance_of_13": hit, "signs_match_of_13": signs,
                 "not_significant_cases_empty_of_5": none_ok})
print(pd.DataFrame(summ).to_string(index=False))
print(f5[(f5.S3 == "a") & (f5.band == "gamma")].pivot_table(index=["time_avg", "area"], columns="contrast", values="value").round(3).to_string())
print(f5[(f5.S3 == "a") & (f5.band == "gamma")].pivot_table(index=["area"], columns="contrast", values="sig_points").to_string())
seedrows = []
for off in OFFS:
    for (name, area) in list(EXP5) + NONE5:
        v, npts = l23_value(area, name, "a", off, "gamma", "whole")
        seedrows.append({"seed_offset": off, "case": f"{name}-{area}", "value": round(v, 3), "sig_points": npts})
print(pd.DataFrame(seedrows).pivot(index="case", columns="seed_offset", values="sig_points").to_string())
S3       band    time_avg  in_tolerance_of_13  signs_match_of_13  not_significant_cases_empty_of_5
 a      gamma significant                   0                 10                                 2
 a      gamma       whole                   0                 10                                 2
 a gamma_code significant                   0                 12                                 2
 a gamma_code       whole                   3                 12                                 2
 b      gamma significant                   2                 10                                 0
 b      gamma       whole                   0                 10                                 0
 b gamma_code significant                   2                 13                                 1
 b gamma_code       whole                   2                 13                                 1
contrast             DD     GO    SSA
time_avg    area                     
significant AL    1.250  0.668  0.612
            AM   -1.497  0.872  1.359
            LM    1.498  0.000  0.673
            PM    0.000  0.000  0.765
            RL    1.905 -0.925 -0.620
            V1    2.081  0.391 -0.070
whole       AL    0.433  0.001  0.198
            AM   -0.073  0.001  0.330
            LM    0.299  0.000  0.239
            PM    0.000  0.000  0.138
            RL    0.464 -0.167 -0.314
            V1    0.745  0.134 -0.041
contrast      DD      GO     SSA
area                            
AL        1100.0     4.0  1026.0
AM         156.0     2.0   773.0
LM         635.0     0.0  1129.0
PM           0.0     0.0   573.0
RL         775.0   574.0  1612.0
V1        1366.0  1308.0  2265.0
seed_offset  0     1000  2000  3000  4000
case                                     
DD-AL        1100  1100  1100  1100  1100
DD-AM         156   156   156   156   156
DD-LM         635   635   664   635   635
DD-PM           0     0   143     0     0
DD-RL         775   775   775   775   775
DD-V1        1366  1366  1366  1366  1366
GO-AL           4     4     4     4     4
GO-AM           2     2     2     2     2
GO-LM           0     0     0     0     0
GO-PM           0     0     0     0     0
GO-RL         574   574   574   574   574
GO-V1        1308  1308  1308  1308  1308
SSA-AL       1026  1026  1026  1026  1026
SSA-AM        773   773   773   773   773
SSA-LM       1129  1129  1129  1129  1129
SSA-PM        573   573   573   573   573
SSA-RL       1612  1612  1612  1612  1612
SSA-V1       2265  2265  2265  2265  2265

Result: not reproduced. At best 3 of the 13 values are within tolerance (S3 reading a, 30-50 Hz, whole-window average) and at best 13 of 13 signs match (S3 reading b, 30-50 Hz, with 2 in tolerance); under 30-90 Hz the whole-window values are 0 of 13 within tolerance. Of the five cases the paper calls not significant, at most 2 have no masked L2/3 gamma point: DD-AM (156 points), GO-AL (4) and GO-AM (2) have some, and DD-PM has 143 under one of the five seeds. v1_laminar.ipynb repeats the V1 tests with and without the median filter: the V1 values move by at most 0.09 dB, and its unfiltered variant gives this notebook's V1 values, with one significant GO point fewer (1307 against 1308).

fig5-hierarchy-restriction¶

Deviance-detection and global-oddball gamma modulations in L2/3 are restricted to early areas (V1, LM, RL and AL for deviance detection; V1, LM and RL for the global oddball), while stimulus-specific adaptation effects appear in all six areas; RL is the one area with a gamma decrease for global oddballs.

In [18]:
want = {"DD": {"V1", "LM", "RL", "AL"}, "GO": {"V1", "LM", "RL"}, "SSA": set(glo.AREAS)}
rows = []
for (r, bname, tavg), d in f5[f5.time_avg == "whole"].groupby(["S3", "band", "time_avg"]):
    got = {n: set(d[(d.contrast == n) & (d.sig_points > 0)].area) for n in CONTR}
    miss = sum(len(want[n] ^ got[n]) for n in CONTR)
    go_rl = d[(d.contrast == "GO") & (d.area == "RL")].value.iloc[0]
    rows.append({"S3": r, "band": bname, **{f"{n}_areas": sorted(got[n]) for n in CONTR}, "set_differences": miss, "GO_RL_value": round(go_rl, 3)})
print(pd.DataFrame(rows).to_string(index=False))
S3       band                 DD_areas                 GO_areas                SSA_areas  set_differences  GO_RL_value
 a      gamma     [AL, AM, LM, RL, V1]         [AL, AM, RL, V1] [AL, AM, LM, PM, RL, V1]                4       -0.167
 a gamma_code     [AL, AM, LM, RL, V1]         [AL, AM, RL, V1] [AL, AM, LM, PM, RL, V1]                4       -0.309
 b      gamma [AL, AM, LM, PM, RL, V1] [AL, AM, LM, PM, RL, V1] [AL, AM, LM, PM, RL, V1]                5       -0.096
 b gamma_code [AL, AM, LM, PM, RL, V1]     [AL, AM, LM, RL, V1] [AL, AM, LM, PM, RL, V1]                4       -0.288

Result: not reproduced. Under reading (a) the areas with masked L2/3 gamma are V1, LM, RL, AL and AM for DD (AM extra), V1, RL, AL and AM for GO (LM missing, AL and AM extra) and all six for SSA: four set differences, more than the one allowed. The GO value in RL is negative (-0.167 dB).

suppfig3-fastsweep-aperiodic¶

In the first 150 ms after onset the aperiodic component differs between oddball and control at p < 0.05 in DD-LM, GO-AL, GO-PM and SSA-AM, and at p < 0.01 in GO-V1, SSA-V1 and SSA-PM.

In [19]:
STAR = {("DD", "LM"): 0.05, ("GO", "AL"): 0.05, ("GO", "PM"): 0.05, ("SSA", "AM"): 0.05, ("GO", "V1"): 0.01, ("SSA", "V1"): 0.01, ("SSA", "PM"): 0.01}
claim = "suppfig3-fastsweep-aperiodic"
rows = []
for fitname, rng_ in FIT.items():
    for name, (ca, cb) in CONTR.items():
        for area in glo.AREAS:
            ms = align[area][0]
            # reading (a): per mouse, mean over rows
            pa = {c: np.array([glo.fooof_aperiodic(freqs, fast[(area, m, c)].mean(1), rng_)[1] for m in ms]) for c in (ca, cb)}
            # reading (b): pooled spectrogram, one fit per row, rows as samples
            pb = {c: np.array([glo.fooof_aperiodic(freqs, fast[(area, "pooled", c)][:, k], rng_)[1] for k in range(fast[(area, "pooled", c)].shape[1])]) for c in (ca, cb)}
            for rd, pp in {"a_per_mouse": pa, "b_rows": pb}.items():
                p_par = [[glo.welch_perm_test(pp[ca][:, j], pp[cb][:, j], np.random.default_rng(seed(claim) + off))[1] for j in range(2)] for off in OFFS]
                pmin = [min(x) for x in p_par]
                rows.append({"fit": fitname, "reading": rd, "contrast": name, "area": area, "p_offset": p_par[0][0], "p_exponent": p_par[0][1],
                             "p_min": pmin[0], "p_min_range_5seeds": f"{min(pmin):.3f}-{max(pmin):.3f}", "starred_level": STAR.get((name, area))})
s3 = pd.DataFrame(rows)
s3["starred_pass"] = [(row.contrast, row.area) in STAR and row.p_min < STAR[(row.contrast, row.area)] for row in s3.itertuples()]
s3["unstarred_pass_0.05"] = [(row.contrast, row.area) not in STAR and row.p_min < 0.05 for row in s3.itertuples()]
print(s3.round(4).to_string(index=False))
print(s3.groupby(["fit", "reading"])[["starred_pass", "unstarred_pass_0.05"]].sum().to_string())
print("(7 starred cases, 11 unstarred)")
fit     reading contrast area  p_offset  p_exponent  p_min p_min_range_5seeds  starred_level  starred_pass  unstarred_pass_0.05
  a a_per_mouse       DD   V1    0.6733      0.4695 0.4695        0.420-0.517            NaN         False                False
  a      b_rows       DD   V1    0.9011      0.2058 0.2058        0.200-0.246            NaN         False                False
  a a_per_mouse       DD   LM    0.6214      0.3936 0.3936        0.330-0.400           0.05         False                False
  a      b_rows       DD   LM    0.0300      0.0020 0.0020        0.002-0.002           0.05          True                False
  a a_per_mouse       DD   RL    0.7053      0.3856 0.3856        0.386-0.472            NaN         False                False
  a      b_rows       DD   RL    0.5075      0.0220 0.0220        0.022-0.044            NaN         False                 True
  a a_per_mouse       DD   AL    0.8511      0.7512 0.7512        0.673-0.751            NaN         False                False
  a      b_rows       DD   AL    0.9690      0.7053 0.7053        0.703-0.773            NaN         False                False
  a a_per_mouse       DD   PM    0.7752      0.5714 0.5714        0.565-0.691            NaN         False                False
  a      b_rows       DD   PM    0.5295      0.1239 0.1239        0.110-0.138            NaN         False                False
  a a_per_mouse       DD   AM    0.8831      0.8871 0.8831        0.859-0.937            NaN         False                False
  a      b_rows       DD   AM    0.0060      0.0180 0.0060        0.006-0.014            NaN         False                 True
  a a_per_mouse       GO   V1    0.7632      0.9850 0.7632        0.751-0.783           0.01         False                False
  a      b_rows       GO   V1    0.2418      0.0500 0.0500        0.046-0.062           0.01         False                False
  a a_per_mouse       GO   LM    0.9351      0.9431 0.9351        0.875-0.935            NaN         False                False
  a      b_rows       GO   LM    0.7652      0.8851 0.7652        0.727-0.819            NaN         False                False
  a a_per_mouse       GO   RL    0.7952      0.9471 0.7952        0.779-0.835            NaN         False                False
  a      b_rows       GO   RL    0.9850      0.8232 0.8232        0.811-0.875            NaN         False                False
  a a_per_mouse       GO   AL    0.7133      0.8192 0.7133        0.681-0.713           0.05         False                False
  a      b_rows       GO   AL    0.0500      0.0999 0.0500        0.038-0.062           0.05          True                False
  a a_per_mouse       GO   PM    0.9570      0.9790 0.9570        0.901-0.957           0.05         False                False
  a      b_rows       GO   PM    0.0220      0.0100 0.0100        0.008-0.014           0.05          True                False
  a a_per_mouse       GO   AM    0.7253      0.8132 0.7253        0.725-0.815            NaN         False                False
  a      b_rows       GO   AM    0.0220      0.0040 0.0040        0.004-0.008            NaN         False                 True
  a a_per_mouse      SSA   V1    0.8771      0.9211 0.8771        0.827-0.877           0.01         False                False
  a      b_rows      SSA   V1    0.2957      0.0060 0.0060        0.004-0.010           0.01          True                False
  a a_per_mouse      SSA   LM    0.5854      0.5435 0.5435        0.543-0.617            NaN         False                False
  a      b_rows      SSA   LM    0.1678      0.2817 0.1678        0.148-0.174            NaN         False                False
  a a_per_mouse      SSA   RL    0.6853      0.6394 0.6394        0.579-0.639            NaN         False                False
  a      b_rows      SSA   RL    0.3616      0.2418 0.2418        0.224-0.298            NaN         False                False
  a a_per_mouse      SSA   AL    0.5634      0.6114 0.5634        0.539-0.563            NaN         False                False
  a      b_rows      SSA   AL    0.9750      0.9231 0.9231        0.903-0.971            NaN         False                False
  a a_per_mouse      SSA   PM    0.9870      0.9690 0.9690        0.939-0.985           0.01         False                False
  a      b_rows      SSA   PM    0.0480      0.0080 0.0080        0.004-0.010           0.01          True                False
  a a_per_mouse      SSA   AM    0.7652      0.7572 0.7572        0.739-0.801           0.05         False                False
  a      b_rows      SSA   AM    0.0280      0.0040 0.0040        0.002-0.006           0.05          True                False
  b a_per_mouse       DD   V1    0.4775      0.3836 0.3836        0.352-0.416            NaN         False                False
  b      b_rows       DD   V1    0.6394      0.0539 0.0539        0.038-0.064            NaN         False                False
  b a_per_mouse       DD   LM    0.2657      0.2677 0.2657        0.184-0.266           0.05         False                False
  b      b_rows       DD   LM    0.0060      0.0020 0.0020        0.002-0.002           0.05          True                False
  b a_per_mouse       DD   RL    0.5954      0.3596 0.3596        0.360-0.458            NaN         False                False
  b      b_rows       DD   RL    0.2358      0.0020 0.0020        0.002-0.004            NaN         False                 True
  b a_per_mouse       DD   AL    0.6034      0.5375 0.5375        0.468-0.577            NaN         False                False
  b      b_rows       DD   AL    0.5015      0.0819 0.0819        0.078-0.104            NaN         False                False
  b a_per_mouse       DD   PM    0.6953      0.6134 0.6134        0.595-0.709            NaN         False                False
  b      b_rows       DD   PM    0.9131      0.9830 0.9131        0.871-0.931            NaN         False                False
  b a_per_mouse       DD   AM    0.7113      0.7193 0.7113        0.711-0.839            NaN         False                False
  b      b_rows       DD   AM    0.0020      0.0020 0.0020        0.002-0.004            NaN         False                 True
  b a_per_mouse       GO   V1    0.6294      0.7732 0.6294        0.607-0.647           0.01         False                False
  b      b_rows       GO   V1    0.1259      0.0240 0.0240        0.016-0.032           0.01         False                False
  b a_per_mouse       GO   LM    0.5974      0.6394 0.5974        0.535-0.597            NaN         False                False
  b      b_rows       GO   LM    0.3197      0.1039 0.1039        0.072-0.104            NaN         False                False
  b a_per_mouse       GO   RL    0.9830      0.8731 0.8731        0.823-0.889            NaN         False                False
  b      b_rows       GO   RL    0.9790      0.8492 0.8492        0.819-0.887            NaN         False                False
  b a_per_mouse       GO   AL    0.6693      0.7972 0.6693        0.669-0.695           0.05         False                False
  b      b_rows       GO   AL    0.0180      0.0020 0.0020        0.002-0.004           0.05          True                False
  b a_per_mouse       GO   PM    0.9331      0.9930 0.9331        0.919-0.979           0.05         False                False
  b      b_rows       GO   PM    0.0320      0.0060 0.0060        0.002-0.006           0.05          True                False
  b a_per_mouse       GO   AM    0.7053      0.7033 0.7033        0.695-0.775            NaN         False                False
  b      b_rows       GO   AM    0.0220      0.0020 0.0020        0.002-0.002            NaN         False                 True
  b a_per_mouse      SSA   V1    0.8472      0.8871 0.8472        0.797-0.847           0.01         False                False
  b      b_rows      SSA   V1    0.2677      0.0400 0.0400        0.032-0.060           0.01         False                False
  b a_per_mouse      SSA   LM    0.4236      0.4496 0.4236        0.424-0.498            NaN         False                False
  b      b_rows      SSA   LM    0.0320      0.0020 0.0020        0.002-0.004            NaN         False                 True
  b a_per_mouse      SSA   RL    0.8132      0.8012 0.8012        0.731-0.801            NaN         False                False
  b      b_rows      SSA   RL    0.2398      0.0300 0.0300        0.026-0.058            NaN         False                 True
  b a_per_mouse      SSA   AL    0.6873      0.7153 0.6873        0.653-0.695            NaN         False                False
  b      b_rows      SSA   AL    0.9770      0.9431 0.9431        0.825-0.943            NaN         False                False
  b a_per_mouse      SSA   PM    0.9730      0.9311 0.9311        0.857-0.931           0.01         False                False
  b      b_rows      SSA   PM    0.1998      0.0320 0.0320        0.026-0.036           0.01         False                False
  b a_per_mouse      SSA   AM    0.8551      0.9351 0.8551        0.855-0.931           0.05         False                False
  b      b_rows      SSA   AM    0.1698      0.0060 0.0060        0.006-0.014           0.05          True                False
                 starred_pass  unstarred_pass_0.05
fit reading                                       
a   a_per_mouse             0                    0
    b_rows                  6                    3
b   a_per_mouse             0                    0
    b_rows                  4                    5
(7 starred cases, 11 unstarred)

Result: not reproduced. With rows as samples (reading b), 6 of the 7 starred cases pass at their level under fit (a) (5 to 150 Hz) and 4 under fit (b), but 3 and 5 of the 11 unstarred cases also pass at 0.05, more than the 2 allowed; with per-mouse spectra (reading a), none of the 7 passes. The partial clause (3 or 4 starred cases) is read with the same bound on unstarred cases, so fit (b) is not counted as partial.

Summary¶

Claim Outcome
dd-aperiodic-no-difference reproduced
suppfig1-aperiodic-no-difference-all reproduced
dd-gamma-peak-frequency-lm reproduced
dd-gamma-power-and-peak-only-v1-lm reproduced (sensitive to the seed)
ssa-gamma-peak-frequency-lower partially reproduced
suppfig2-alphabeta-peaks not reproduced
suppfig2-gamma-height-differences reproduced
fig5-l23-gamma-by-area not reproduced
fig5-hierarchy-restriction not reproduced
suppfig3-fastsweep-aperiodic not 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. Each area is read at its kept rows only (every fourth aligned channel, from the deepest row as in the paper's code), without the median filter, to fit the time limit; the per-mouse spectra average over those rows. v1_laminar.ipynb repeats the V1 tests with and without the filter; the V1 Figure 5 values move by at most 0.09 dB. LM has 13 mice and AL 11, as the probe labels allow. For Figure 5 the four extra seeds were run for S3 reading (a) only.

What was found about the dataset. See v1_laminar.ipynb: the probe area labels leave three mice without an AL probe and one without an LM probe.

In [20]:
print(f"notebook ran in {(time.time() - started) / 60:.1f} min; peak memory {resource.getrusage(resource.RUSAGE_SELF).ru_maxrss / 1e6:.1f} GB")
notebook ran in 34.1 min; peak memory 7.3 GB