Ghaderi, Crochet & Petersen (2026) from dandiset 001530: population decoding and clustering¶
Paper. Ghaderi P, Crochet S, Petersen CCH (2026), Nature Communications 17, 5982, doi:10.1038/s41467-026-73622-y; claims written from the version of record (PMC13346651), main text, legends and Methods.
Dandiset. DANDI:001530, version
0.260605.0601, the only published version (the draft has the same assets and was last modified
with the publication); the paper cites no version. The data check, the trial and unit selection
and the claims on behaviour, optogenetics and single neurons are in reproduce_ghaderi_2026.ipynb;
this notebook loads the same sessions through the same helper.
Outside inputs. data_helpers/Area_list.mat (CCF labels of each area) and
processed_data/Data_Clustering.mat (the paper's cluster labels, linked by claim
cluster-label-link in the first notebook), from Zenodo doi:10.5281/zenodo.17973874.
Run size. The paper's decoding repeats each fit over 100 neuron subsets (Fig. 5b) or 5 runs (Fig. 7d), and its GMM uses 1,000 initialisations per k. The Methods' grid search fits 36 SVMs for every one of the code's decoder (7 values of C in an inner 5-fold search, then the refit), and the run times printed below put a full run of either reading beyond what fits here, so both are run with fewer repetitions (constants in the next cell); each section prints what was run, its run time and the estimate for the full run.
| Claim | Here |
|---|---|
| fig5b-context-decoding-delay | tested, fewer repetitions |
| fig5b-decoding-time-course | tested, fewer repetitions |
| fig5c-cluster-removal, fig7d-context-decoding-after-whisker, fig4-29-clusters | decoding_clusters_whisker.ipynb |
| fig5d-null-space-decoding | blocked (see the record) |
import time
import warnings
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from joblib import Parallel, delayed
from scipy import stats
import ghaderi as g
warnings.filterwarnings("ignore")
pd.set_option("display.width", 220)
pd.set_option("display.max_columns", 40)
pd.set_option("display.max_rows", 400)
N_JOBS = 4
REPS_CODE = 5 # neuron subsets per session, code's decoder (paper: 100)
REPS_TC = 3 # the same for 5 to 45 neurons (time course)
REPS_METHODS = 1 # neuron subsets per session, Methods' grid search (paper: 100)
BASE_STEP_METHODS = 5 # Methods' reading: every 5th baseline bin of -1 to 0 s
RUNS_7D = 1 # Fig. 7d runs (paper: 5)
GMM_INITS = 5 # GMM initialisations per k (paper: 1,000)
started = time.time()
S = g.load_sessions(workers=4)
print(f"dandiset {g.DANDISET_ID} version {g.DANDISET_VERSION}: loaded {len(S)} sessions in {time.time() - started:.0f} s")
dandiset 001530 version 0.260605.0601: loaded 35 sessions in 185 s
rows = []
for a in g.AREAS:
for s, cols in g.area_sessions(S, a, 5):
q = g.quiet_mask(s)
rows.append({"area": a, "session": s["session"], "subject": s["subject"], "neurons": len(cols),
"quiet Hit": int((g.trial_mask(s, 1, True) & q).sum()),
"quiet Nogo CR": int((g.trial_mask(s, 3, False) & q).sum())})
dsess = pd.DataFrame(rows)
print(dsess.to_string(index=False))
print("\nArea-sessions with at least 5 neurons:", dsess.groupby("area").size().loc[g.AREAS].to_dict())
print("with at least 50 neurons:", dsess[dsess.neurons >= 50].groupby("area").size().loc[g.AREAS].to_dict(),
"(paper, Fig. 5b: A1 8, wS1 17, wS2 19, wM2 18, ALM 16)")
print("mice with at least 50 neurons:", dsess[dsess.neurons >= 50].groupby("area").subject.nunique().loc[g.AREAS].to_dict(),
"(paper: 6, 9, 9, 8, 6)")
print("Spike counts per 10 ms bin, range:", min(int(s["c10"].min()) for s in S if s["c10"].size), "to", max(int(s["c10"].max()) for s in S if s["c10"].size))
area session subject neurons quiet Hit quiet Nogo CR
A1 sub-PG061_ses-20220212T233813 PG061 75 14 45
A1 sub-PG062_ses-20220207T213136 PG062 74 13 34
A1 sub-PG082_ses-20221113T145317 PG082 86 43 58
A1 sub-PG082_ses-20221114T163239 PG082 33 20 24
A1 sub-PG082_ses-20221120T182616 PG082 16 42 59
A1 sub-PG083_ses-20221125T180851 PG083 8 44 32
A1 sub-PG083_ses-20221129T153120 PG083 59 26 26
A1 sub-PG083_ses-20221130T230127 PG083 40 42 61
A1 sub-PG084_ses-20221206T162236 PG084 32 26 47
A1 sub-PG084_ses-20221207T192711 PG084 34 49 83
A1 sub-PG084_ses-20221208T224009 PG084 99 44 65
A1 sub-PG085_ses-20221213T195032 PG085 65 41 58
A1 sub-PG085_ses-20221214T211712 PG085 50 55 53
A1 sub-PG085_ses-20221215T222439 PG085 109 30 36
wS1 sub-PG019_ses-20200906T175456 PG019 154 22 39
wS1 sub-PG027_ses-20210403T115220 PG027 42 11 26
wS1 sub-PG027_ses-20210404T111739 PG027 79 19 48
wS1 sub-PG028_ses-20210318T163504 PG028 37 34 59
wS1 sub-PG028_ses-20210319T135422 PG028 45 48 78
wS1 sub-PG030_ses-20210405T163808 PG030 88 33 64
wS1 sub-PG030_ses-20210406T164509 PG030 68 9 44
wS1 sub-PG032_ses-20210711T175822 PG032 124 31 55
wS1 sub-PG032_ses-20210712T185829 PG032 128 32 46
wS1 sub-PG038_ses-20210316T152753 PG038 119 15 48
wS1 sub-PG061_ses-20220211T222307 PG061 30 40 61
wS1 sub-PG062_ses-20220207T213136 PG062 48 13 34
wS1 sub-PG082_ses-20221113T145317 PG082 170 43 58
wS1 sub-PG082_ses-20221114T163239 PG082 88 20 24
wS1 sub-PG082_ses-20221120T182616 PG082 165 42 59
wS1 sub-PG083_ses-20221125T180851 PG083 55 44 32
wS1 sub-PG083_ses-20221129T153120 PG083 63 26 26
wS1 sub-PG083_ses-20221130T230127 PG083 48 42 61
wS1 sub-PG084_ses-20221206T162236 PG084 17 26 47
wS1 sub-PG084_ses-20221207T192711 PG084 54 49 83
wS1 sub-PG084_ses-20221208T224009 PG084 71 44 65
wS1 sub-PG085_ses-20221213T195032 PG085 55 41 58
wS1 sub-PG085_ses-20221214T211712 PG085 126 55 53
wS1 sub-PG085_ses-20221215T222439 PG085 64 30 36
wS2 sub-PG019_ses-20200904T224847 PG019 73 32 60
wS2 sub-PG028_ses-20210318T163504 PG028 89 34 59
wS2 sub-PG028_ses-20210319T135422 PG028 102 48 78
wS2 sub-PG030_ses-20210405T163808 PG030 138 33 64
wS2 sub-PG030_ses-20210406T164509 PG030 140 9 44
wS2 sub-PG032_ses-20210711T175822 PG032 108 31 55
wS2 sub-PG032_ses-20210712T185829 PG032 52 32 46
wS2 sub-PG061_ses-20220211T222307 PG061 128 40 61
wS2 sub-PG061_ses-20220212T233813 PG061 131 14 45
wS2 sub-PG062_ses-20220206T200225 PG062 61 34 37
wS2 sub-PG083_ses-20221125T180851 PG083 99 44 32
wS2 sub-PG083_ses-20221129T153120 PG083 131 26 26
wS2 sub-PG083_ses-20221130T230127 PG083 85 42 61
wS2 sub-PG084_ses-20221206T162236 PG084 120 26 47
wS2 sub-PG084_ses-20221207T192711 PG084 74 49 83
wS2 sub-PG084_ses-20221208T224009 PG084 87 44 65
wS2 sub-PG085_ses-20221213T195032 PG085 211 41 58
wS2 sub-PG085_ses-20221214T211712 PG085 55 55 53
wS2 sub-PG085_ses-20221215T222439 PG085 180 30 36
wM2 sub-PG030_ses-20210408T223046 PG030 133 7 21
wM2 sub-PG032_ses-20210715T223447 PG032 152 30 87
wM2 sub-PG061_ses-20220211T222307 PG061 164 40 61
wM2 sub-PG061_ses-20220212T233813 PG061 125 14 45
wM2 sub-PG062_ses-20220206T200225 PG062 211 34 37
wM2 sub-PG062_ses-20220207T213136 PG062 89 13 34
wM2 sub-PG082_ses-20221113T145317 PG082 216 43 58
wM2 sub-PG082_ses-20221114T163239 PG082 141 20 24
wM2 sub-PG082_ses-20221120T182616 PG082 167 42 59
wM2 sub-PG083_ses-20221125T180851 PG083 139 44 32
wM2 sub-PG083_ses-20221129T153120 PG083 270 26 26
wM2 sub-PG083_ses-20221130T230127 PG083 199 42 61
wM2 sub-PG084_ses-20221206T162236 PG084 91 26 47
wM2 sub-PG084_ses-20221207T192711 PG084 83 49 83
wM2 sub-PG084_ses-20221208T224009 PG084 119 44 65
wM2 sub-PG085_ses-20221213T195032 PG085 194 41 58
wM2 sub-PG085_ses-20221214T211712 PG085 115 55 53
wM2 sub-PG085_ses-20221215T222439 PG085 141 30 36
ALM sub-PG030_ses-20210407T211250 PG030 117 11 33
ALM sub-PG030_ses-20210408T223046 PG030 101 7 21
ALM sub-PG030_ses-20210410T012800 PG030 104 15 23
ALM sub-PG032_ses-20210715T223447 PG032 183 30 87
ALM sub-PG082_ses-20221113T145317 PG082 116 43 58
ALM sub-PG082_ses-20221114T163239 PG082 168 20 24
ALM sub-PG082_ses-20221120T182616 PG082 248 42 59
ALM sub-PG083_ses-20221125T180851 PG083 119 44 32
ALM sub-PG083_ses-20221129T153120 PG083 138 26 26
ALM sub-PG083_ses-20221130T230127 PG083 135 42 61
ALM sub-PG084_ses-20221206T162236 PG084 210 26 47
ALM sub-PG084_ses-20221207T192711 PG084 162 49 83
ALM sub-PG084_ses-20221208T224009 PG084 245 44 65
ALM sub-PG085_ses-20221213T195032 PG085 262 41 58
ALM sub-PG085_ses-20221214T211712 PG085 231 55 53
ALM sub-PG085_ses-20221215T222439 PG085 224 30 36
Area-sessions with at least 5 neurons: {'A1': 14, 'wS1': 24, 'wS2': 19, 'wM2': 18, 'ALM': 16}
with at least 50 neurons: {'A1': 8, 'wS1': 17, 'wS2': 19, 'wM2': 18, 'ALM': 16} (paper, Fig. 5b: A1 8, wS1 17, wS2 19, wM2 18, ALM 16)
mice with at least 50 neurons: {'A1': 6, 'wS1': 9, 'wS2': 9, 'wM2': 8, 'ALM': 6} (paper: 6, 9, 9, 8, 6)
Spike counts per 10 ms bin, range: 0 to 8
The sessions with at least 50 neurons per area match the paper's n for Fig. 5b (8, 17, 19, 18, 16 sessions); quiet Hit and Nogo CR trials per session are listed above, some as few as 7.
fig5b-context-decoding-delay¶
With 50 neurons per area, context (Hit against Nogo-tone Whisker CR) is decoded in the last 200 ms of the delay above baseline in every area, but far better in wM2 (64 +/- 1%) and ALM (61 +/- 1%) than in A1 (52 +/- 1%), wS1 (52 +/- 1%) and wS2 (52 +/- 0.4%).
As the criterion: per 10 ms bin, a linear SVM on the counts of 50 random neurons, majority class undersampled, z-scored, stratified 5-fold, mean over subsets. Delay = bins labelled 0.8 to 1.0 s, baseline -1 to 0 s (Methods) and -0.8 to 0 s (code). Reading (b) is the code's nu-SVC, reading (a) the Methods' C-SVM with nested grid search; (a) is run on one subset per session and on every 5th baseline bin.
DELAY = g.bin_index(0.8, 1.0)
BASE = g.bin_index(-1.0, 0.0)
BASE_CODE = g.bin_index(-0.8, 0.0)
CUE_A, CUE_B = g.bin_index(0.01, 0.03), g.bin_index(0.01, 0.2)
def session_classes(s, cols, rule="median", counts="c10"):
q = g.quiet_mask(s, rule)
X = s[counts][:, :, cols]
return X[g.trial_mask(s, 1, True) & q], X[g.trial_mask(s, 3, False) & q]
tasks = []
for a in g.AREAS:
for k, (s, cols) in enumerate(g.area_sessions(S, a, 50)):
X1, X2 = session_classes(s, cols)
tasks.append((a, s["session"], X1, X2, k))
t0 = time.time()
X1, X2 = tasks[0][2], tasks[0][3]
g.decode_session(X1, X2, DELAY[:4], 50, 1, "code", 0)
per_bin_code = (time.time() - t0) / 4
t0 = time.time()
g.decode_session(X1, X2, DELAY[:2], 50, 1, "methods", 0)
per_bin_methods = (time.time() - t0) / 2
bins_main = np.concatenate([BASE, CUE_B, DELAY])
print(f"Warm-up timing on one session (includes start-up): code {per_bin_code * 1000:.0f} ms, Methods {per_bin_methods * 1000:.0f} ms per bin and subset.")
t0 = time.time()
acc_code = Parallel(n_jobs=N_JOBS)(delayed(g.decode_session)(t[2], t[3], bins_main, 50, REPS_CODE, "code", 1000 + i)
for i, t in enumerate(tasks))
t_code = time.time() - t0
print(f"code's decoder, {REPS_CODE} subsets: {t_code:.0f} s; 100 subsets would take about {t_code * 100 / REPS_CODE / 60:.0f} min")
# The cue bins come last, so the baseline and delay bins draw the same random numbers as without them.
bins_methods = np.concatenate([BASE[::BASE_STEP_METHODS], DELAY, CUE_B])
t0 = time.time()
acc_meth = Parallel(n_jobs=N_JOBS)(delayed(g.decode_session)(t[2], t[3], bins_methods, 50, REPS_METHODS, "methods", 2000 + i)
for i, t in enumerate(tasks))
t_meth = time.time() - t0
print(f"Methods' grid search, {REPS_METHODS} subset(s) and {len(bins_methods)} bins: {t_meth:.0f} s; 100 subsets on all "
f"{len(bins_main)} bins would take about {t_meth * 100 / REPS_METHODS * len(bins_main) / len(bins_methods) / 3600:.1f} h")
ix = {b: i for i, b in enumerate(bins_main)}
ixm = {b: i for i, b in enumerate(bins_methods)}
dec = pd.DataFrame([{"area": t[0], "session": t[1],
"delay_b": acc[[ix[b] for b in DELAY]].mean(), "base_b": acc[[ix[b] for b in BASE]].mean(),
"base_code_b": acc[[ix[b] for b in BASE_CODE]].mean(),
"cue_a_b": acc[[ix[b] for b in CUE_A]].mean(), "cue_b_b": acc[[ix[b] for b in CUE_B]].mean(),
"delay_a": am[[ixm[b] for b in DELAY]].mean(), "base_a": am[[ixm[b] for b in BASE[::BASE_STEP_METHODS]]].mean(),
"cue_a_a": am[[ixm[b] for b in CUE_A]].mean(), "cue_b_a": am[[ixm[b] for b in CUE_B]].mean()}
for t, acc, am in zip(tasks, acc_code, acc_meth)])
Warm-up timing on one session (includes start-up): code 123 ms, Methods 139 ms per bin and subset.
code's decoder, 5 subsets: 111 s; 100 subsets would take about 37 min
Methods' grid search, 1 subset(s) and 61 bins: 496 s; 100 subsets on all 141 bins would take about 31.9 h
exp5b = {"A1": (52, 1), "wS1": (52, 1), "wS2": (52, 0.4), "wM2": (64, 1), "ALM": (61, 1)}
rows = []
for reading, dcol, bcols in (("b, code", "delay_b", ("base_b", "base_code_b")), ("a, Methods", "delay_a", ("base_a",))):
for a in g.AREAS:
sub = dec[dec.area == a]
row = {"reading": reading, "area": a, "sessions": len(sub), "delay %": sub[dcol].mean(),
"SEM": sub[dcol].std(ddof=1) / np.sqrt(len(sub)), "paper": f"{exp5b[a][0]} +/- {exp5b[a][1]}",
"within": abs(sub[dcol].mean() - exp5b[a][0]) <= exp5b[a][1]}
for bc in bcols:
row[f"{bc} %"] = sub[bc].mean()
row[f"p vs {bc}"] = stats.wilcoxon(sub[dcol], sub[bc]).pvalue
rows.append(row)
res5b = pd.DataFrame(rows)
print(res5b.round(4).to_string(index=False))
for reading in ("b, code", "a, Methods"):
sub = res5b[res5b.reading == reading].set_index("area")
pcol = "p vs base_b" if reading.startswith("b") else "p vs base_a"
order = min(sub.loc[["wM2", "ALM"], "delay %"]) > max(sub.loc[["A1", "wS1", "wS2"], "delay %"])
print(f"{reading}: within tolerance {int(sub.within.sum())} of 5; all five tests p < 0.05: {bool((sub[pcol] < 0.05).all())}; "
f"wM2 and ALM above A1, wS1, wS2: {order}")
print("\nPer mouse (reading b, delay accuracy):")
dec["subject"] = dec.session.str[4:9]
print(dec.pivot_table(index="subject", columns="area", values="delay_b").round(1).to_string())
reading area sessions delay % SEM paper within base_b % p vs base_b base_code_b % p vs base_code_b base_a % p vs base_a b, code A1 8 52.6447 0.8079 52 +/- 1 True 50.0031 0.0078 49.9746 0.0078 NaN NaN b, code wS1 17 51.8577 0.6658 52 +/- 1 True 50.0911 0.0017 50.0434 0.0008 NaN NaN b, code wS2 19 51.4358 0.3906 52 +/- 0.4 False 49.9949 0.0006 49.9721 0.0005 NaN NaN b, code wM2 18 61.9575 1.2424 64 +/- 1 False 49.9834 0.0000 49.9644 0.0000 NaN NaN b, code ALM 16 58.9148 1.2204 61 +/- 1 False 50.0094 0.0000 49.9807 0.0000 NaN NaN a, Methods A1 8 53.0530 0.5031 52 +/- 1 False NaN NaN NaN NaN 48.5368 0.0078 a, Methods wS1 17 52.2810 0.8552 52 +/- 1 True NaN NaN NaN NaN 50.3136 0.0267 a, Methods wS2 19 51.9606 0.5187 52 +/- 0.4 True NaN NaN NaN NaN 49.8881 0.0014 a, Methods wM2 18 63.1385 1.4754 64 +/- 1 True NaN NaN NaN NaN 50.3542 0.0000 a, Methods ALM 16 58.4552 1.2313 61 +/- 1 False NaN NaN NaN NaN 50.1425 0.0001 b, code: within tolerance 2 of 5; all five tests p < 0.05: True; wM2 and ALM above A1, wS1, wS2: True a, Methods: within tolerance 3 of 5; all five tests p < 0.05: True; wM2 and ALM above A1, wS1, wS2: True Per mouse (reading b, delay accuracy): area A1 ALM wM2 wS1 wS2 subject PG019 NaN NaN NaN 52.8 49.8 PG027 NaN NaN NaN 51.1 NaN PG028 NaN NaN NaN NaN 50.2 PG030 NaN 56.8 60.6 52.1 53.8 PG032 NaN 59.9 59.8 52.0 52.3 PG038 NaN NaN NaN 51.0 NaN PG061 55.2 NaN 55.7 NaN 52.9 PG062 49.7 NaN 58.2 NaN 50.2 PG082 52.2 58.7 64.0 50.7 NaN PG083 50.6 55.6 64.9 50.4 50.3 PG084 51.4 62.1 66.2 51.3 51.3 PG085 54.0 61.1 60.5 54.3 51.4
# Variants the claims file asks for: the code's quiet rule (mean absolute deviation), and the
# spread over random subsets (seed sets) of the code's decoder on the delay bins.
tasks_mean = []
for a in g.AREAS:
for k, (s, cols) in enumerate(g.area_sessions(S, a, 50)):
X1, X2 = session_classes(s, cols, rule="mean")
tasks_mean.append((a, s["session"], X1, X2, k))
bins_mad = np.concatenate([BASE, DELAY])
t0 = time.time()
acc_mean_b = Parallel(n_jobs=N_JOBS)(delayed(g.decode_session)(t[2], t[3], bins_mad, 50, REPS_CODE, "code", 1000 + i)
for i, t in enumerate(tasks_mean))
print(f"code's quiet rule, code's decoder: {time.time() - t0:.0f} s (the grid search is not run with this rule, for time)")
ixb = {b: i for i, b in enumerate(bins_mad)}
dec_mean = pd.DataFrame([{"area": t[0], "session": t[1], "quiet trials (Hit, Nogo CR)": f"{len(t[2])}, {len(t[3])}",
"delay_b": ab[[ixb[b] for b in DELAY]].mean(), "base_b": ab[[ixb[b] for b in BASE]].mean()}
for t, ab in zip(tasks_mean, acc_mean_b)])
rows = []
for reading, dcol, bcol in (("b, code", "delay_b", "base_b"),):
for a in g.AREAS:
sub = dec_mean[dec_mean.area == a]
rows.append({"reading": reading, "area": a, "sessions": len(sub), "delay %": sub[dcol].mean(),
"SEM": sub[dcol].std(ddof=1) / np.sqrt(len(sub)), "baseline %": sub[bcol].mean(),
"p vs baseline": stats.wilcoxon(sub[dcol], sub[bcol]).pvalue,
"within": abs(sub[dcol].mean() - exp5b[a][0]) <= exp5b[a][1]})
res5b_mean = pd.DataFrame(rows)
print("\nQuiet trials by the code's mean absolute deviation:")
print(res5b_mean.round(4).to_string(index=False))
for reading in ("b, code",):
sub = res5b_mean[res5b_mean.reading == reading].set_index("area")
order = min(sub.loc[["wM2", "ALM"], "delay %"]) > max(sub.loc[["A1", "wS1", "wS2"], "delay %"])
print(f"{reading}: within tolerance {int(sub.within.sum())} of 5; all five tests p < 0.05: "
f"{bool((sub['p vs baseline'] < 0.05).all())}; wM2 and ALM above A1, wS1, wS2: {order}")
# Spread over subsets: 4 more seed sets of REPS_CODE subsets each, delay bins only, Methods' quiet rule.
t0 = time.time()
seed_sets = {0: [acc[[ix[b] for b in DELAY]].mean() for acc in acc_code]}
for r in range(1, 5):
out = Parallel(n_jobs=N_JOBS)(delayed(g.decode_session)(t[2], t[3], DELAY, 50, REPS_CODE, "code", 10000 * r + 1000 + i)
for i, t in enumerate(tasks))
seed_sets[r] = [acc.mean() for acc in out]
print(f"\nseed sets: {time.time() - t0:.0f} s")
spread = pd.DataFrame({f"set {r}": pd.Series(v).groupby([t[0] for t in tasks]).mean() for r, v in seed_sets.items()}).loc[g.AREAS]
spread["all 25 subsets"] = spread.mean(axis=1)
spread["range over sets"] = spread.iloc[:, :5].max(axis=1) - spread.iloc[:, :5].min(axis=1)
spread["paper"] = [f"{exp5b[a][0]} +/- {exp5b[a][1]}" for a in g.AREAS]
print("Delay accuracy (%) of the code's decoder by seed set of 5 subsets per session:")
print(spread.round(2).to_string())
print("within tolerance per set:", {c: int(sum(abs(spread.loc[a, c] - exp5b[a][0]) <= exp5b[a][1] for a in g.AREAS))
for c in list(spread.columns[:6])})
code's quiet rule, code's decoder: 108 s (the grid search is not run with this rule, for time) Quiet trials by the code's mean absolute deviation: reading area sessions delay % SEM baseline % p vs baseline within b, code A1 8 52.5204 0.8516 49.8926 0.0078 True b, code wS1 17 52.2231 0.6588 50.1364 0.0011 True b, code wS2 19 51.4777 0.3762 49.9656 0.0002 False b, code wM2 18 62.8663 1.3819 50.1085 0.0000 False b, code ALM 16 61.5506 1.3043 50.0571 0.0000 True b, code: within tolerance 3 of 5; all five tests p < 0.05: True; wM2 and ALM above A1, wS1, wS2: True
seed sets: 65 s
Delay accuracy (%) of the code's decoder by seed set of 5 subsets per session:
set 0 set 1 set 2 set 3 set 4 all 25 subsets range over sets paper
A1 52.64 52.72 52.14 52.64 52.24 52.48 0.58 52 +/- 1
wS1 51.86 52.35 51.96 52.03 51.73 51.99 0.62 52 +/- 1
wS2 51.44 51.48 51.53 51.56 51.31 51.46 0.25 52 +/- 0.4
wM2 61.96 62.39 62.45 62.74 61.72 62.25 1.02 64 +/- 1
ALM 58.91 59.47 59.42 58.76 58.95 59.10 0.72 61 +/- 1
within tolerance per set: {'set 0': 2, 'set 1': 2, 'set 2': 2, 'set 3': 2, 'set 4': 2, 'all 25 subsets': 2}
Result: partially reproduced. Under both readings of the SVM the delay accuracy is above baseline in all five areas (Wilcoxon p 0.0078 or less with the code's decoder, 0.027 or less with the grid search) and wM2 and ALM exceed A1, wS1 and wS2, but the values are partly out of tolerance. With the code's nu-SVC (5 subsets per session): A1 52.6, wS1 51.9, wS2 51.4, wM2 62.0 and ALM 58.9% (2 of 5 within; the paper 52, 52, 52, 64 and 61). With the Methods' grid search (one subset): 53.1, 52.3, 52.0, 63.1 and 58.5% (3 of 5 within). Five seed sets of 5 subsets each move the area means of the code's decoder by at most 1.02 points (wM2 61.7 to 62.7%, ALM 58.8 to 59.5%) and every set has 2 of 5 within tolerance, so the shortfall in wM2 and ALM is not Monte-Carlo noise. With the code's quiet rule (mean absolute deviation) the code's decoder gives 52.5, 52.2, 51.5, 62.9 and 61.6% (3 of 5 within, ALM now within, wM2 still 1.1 points low), all tests p < 0.05 and the ordering holds, so that variant is also partial. Fewer subsets than the paper's 100 were run (run times above).
fig5b-decoding-time-course¶
Context decoding is at chance in the baseline, highest in A1 right after the cue, and during the delay falls in A1, wS1 and wS2 but rises in wM2 and ALM; with fewer neurons accuracy drops but wM2 and ALM stay above A1, wS1 and wS2.
Baseline, cue and delay accuracies for 50 neurons come from the run above; for 5 to 45 neurons the delay bins are decoded with the code's decoder (REPS_TC subsets, set above) and, for 5 and 25 neurons, the Methods' grid search (one subset).
counts_n = list(range(5, 50, 5))
t0 = time.time()
jobs = [(n, i, t) for n in counts_n for i, t in enumerate(tasks)]
out = Parallel(n_jobs=N_JOBS)(delayed(g.decode_session)(t[2], t[3], DELAY, n, REPS_TC, "code", 3000 + 100 * n + i)
for n, i, t in jobs)
tc_rows = [{"n": n, "area": t[0], "session": t[1], "reading": "b", "delay": acc.mean()} for (n, i, t), acc in zip(jobs, out)]
jobs_m = [(n, i, t) for n in (5, 25) for i, t in enumerate(tasks)]
out_m = Parallel(n_jobs=N_JOBS)(delayed(g.decode_session)(t[2], t[3], DELAY, n, REPS_METHODS, "methods", 4000 + 100 * n + i)
for n, i, t in jobs_m)
tc_rows += [{"n": n, "area": t[0], "session": t[1], "reading": "a", "delay": acc.mean()} for (n, i, t), acc in zip(jobs_m, out_m)]
tc_rows += [{"n": 50, "area": r.area, "session": r.session, "reading": "b", "delay": r.delay_b} for r in dec.itertuples()]
tc_rows += [{"n": 50, "area": r.area, "session": r.session, "reading": "a", "delay": r.delay_a} for r in dec.itertuples()]
tcd = pd.DataFrame(tc_rows)
print(f"time-course runs: {time.time() - t0:.0f} s")
tab = tcd.pivot_table(index=["reading", "n"], columns="area", values="delay")[g.AREAS]
print(tab.round(2).to_string())
ok4 = {(r, n): bool(min(row["wM2"], row["ALM"]) > max(row["A1"], row["wS1"], row["wS2"])) for (r, n), row in tab.iterrows()}
print("\n(4) wM2 and ALM above A1, wS1 and wS2 at each count:", ok4)
m50 = dec.groupby("area")[["base_b", "cue_a_b", "cue_b_b", "delay_b"]].mean().loc[g.AREAS]
print("\n50 neurons, code's decoder, mean over sessions (%):")
print(m50.round(2).to_string())
print("(1) baseline within 45-55 in every area:", bool(((m50.base_b - 50).abs() <= 5).all()))
for cue in ("cue_a_b", "cue_b_b"):
print(f"(2) {cue}: highest in A1: {m50[cue].idxmax() == 'A1'}; "
f"(3) delay below cue in A1, wS1, wS2: {[bool(m50.loc[a, 'delay_b'] < m50.loc[a, cue]) for a in ('A1', 'wS1', 'wS2')]}, "
f"above in wM2, ALM: {[bool(m50.loc[a, 'delay_b'] > m50.loc[a, cue]) for a in ('wM2', 'ALM')]}")
m50a = dec.groupby("area")[["base_a", "cue_a_a", "cue_b_a", "delay_a"]].mean().loc[g.AREAS]
print("\n50 neurons, Methods' grid search (one subset, every 5th baseline bin), mean over sessions (%):")
print(m50a.round(2).to_string())
print("(1) baseline within 45-55 in every area:", bool(((m50a.base_a - 50).abs() <= 5).all()))
for cue in ("cue_a_a", "cue_b_a"):
print(f"(2) {cue}: highest in A1: {m50a[cue].idxmax() == 'A1'}; "
f"(3) delay below cue in A1, wS1, wS2: {[bool(m50a.loc[a, 'delay_a'] < m50a.loc[a, cue]) for a in ('A1', 'wS1', 'wS2')]}, "
f"above in wM2, ALM: {[bool(m50a.loc[a, 'delay_a'] > m50a.loc[a, cue]) for a in ('wM2', 'ALM')]}")
time-course runs: 318 s
area A1 wS1 wS2 wM2 ALM
reading n
a 5 50.66 50.52 50.53 52.07 51.37
25 51.95 50.63 51.35 58.10 56.67
50 53.05 52.28 51.96 63.14 58.46
b 5 49.97 50.12 50.04 50.63 50.59
10 50.34 49.90 50.16 51.37 51.61
15 50.28 50.43 50.23 52.96 51.71
20 50.43 50.48 50.19 54.28 53.30
25 50.73 50.95 50.29 55.69 54.26
30 51.23 51.39 50.32 56.76 55.90
35 51.48 51.31 50.68 58.29 56.96
40 51.81 51.78 50.91 61.40 57.95
45 51.77 52.37 51.21 60.07 58.12
50 52.64 51.86 51.44 61.96 58.91
(4) wM2 and ALM above A1, wS1 and wS2 at each count: {('a', 5): True, ('a', 25): True, ('a', 50): True, ('b', 5): True, ('b', 10): True, ('b', 15): True, ('b', 20): True, ('b', 25): True, ('b', 30): True, ('b', 35): True, ('b', 40): True, ('b', 45): True, ('b', 50): True}
50 neurons, code's decoder, mean over sessions (%):
base_b cue_a_b cue_b_b delay_b
area
A1 50.00 70.32 65.55 52.64
wS1 50.09 56.17 55.68 51.86
wS2 49.99 57.35 56.54 51.44
wM2 49.98 56.57 57.94 61.96
ALM 50.01 52.34 54.76 58.91
(1) baseline within 45-55 in every area: True
(2) cue_a_b: highest in A1: True; (3) delay below cue in A1, wS1, wS2: [True, True, True], above in wM2, ALM: [True, True]
(2) cue_b_b: highest in A1: True; (3) delay below cue in A1, wS1, wS2: [True, True, True], above in wM2, ALM: [True, True]
50 neurons, Methods' grid search (one subset, every 5th baseline bin), mean over sessions (%):
base_a cue_a_a cue_b_a delay_a
area
A1 48.54 68.35 65.01 53.05
wS1 50.31 55.98 55.11 52.28
wS2 49.89 57.36 57.18 51.96
wM2 50.35 55.58 57.36 63.14
ALM 50.14 53.01 54.67 58.46
(1) baseline within 45-55 in every area: True
(2) cue_a_a: highest in A1: True; (3) delay below cue in A1, wS1, wS2: [True, True, True], above in wM2, ALM: [True, True]
(2) cue_b_a: highest in A1: True; (3) delay below cue in A1, wS1, wS2: [True, True, True], above in wM2, ALM: [True, True]
fig, ax = plt.subplots(figsize=(5, 3))
for a in g.AREAS:
v = tab.loc["b"][a]
ax.plot(v.index, v.values, "-o", ms=3, label=a)
ax.axhline(50, color="k", lw=0.5)
ax.set_xlabel("neurons")
ax.set_ylabel("delay accuracy (%)")
ax.legend(fontsize=7)
plt.show()
print(f"Plotted delay accuracies span {tab.loc['b'].values.min():.1f} to {tab.loc['b'].values.max():.1f}%.")
Plotted delay accuracies span 49.9 to 62.0%.
Result: reproduced. With the code's decoder and 50 neurons, (1) baseline accuracy is 49.98 to 50.09% in every area; (2) the early cue accuracy is highest in A1 under both cue windows (70.3% over 0 to 30 ms, 65.6% over 0 to 200 ms; at most 57.4% and 57.9% elsewhere); (3) the delay accuracy is below the cue accuracy in A1, wS1 and wS2 and above it in wM2 and ALM, under both windows; (4) wM2 and ALM exceed A1, wS1 and wS2 at every neuron count from 5 to 50 (at 5 neurons by 0.47 to 0.51 points). The Methods' grid search (one subset) gives the same: (1) baseline 48.5 to 50.3%; (2) A1 highest in both cue windows (68.4% and 65.0%; at most 57.4% elsewhere); (3) holds in all five areas under both windows; (4) holds at 5, 25 and 50 neurons.
print(f"notebook ran in {(time.time() - started) / 60:.1f} min")
notebook ran in 21.5 min
Summary¶
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.
| Claim | Outcome |
|---|---|
| fig5b-context-decoding-delay | partially reproduced |
| fig5b-decoding-time-course | reproduced |
How the analysis differs from the paper's. 5 random subsets of 50 neurons per session (3 for 5 to 45 neurons) in place of 100 with the code's decoder, with four more seed sets on the delay bins to show the spread, and one subset on every 5th baseline bin (and the cue and delay bins) with the Methods' grid search, whose grid (C from 10^-3 to 10^3) is the claims file's. Quiet trials by the Methods' median absolute deviation; the code's mean absolute deviation is run with the code's decoder only. sklearn's NuSVC and SVC (both libsvm) stand in for the MATLAB libsvm interface; folds and undersampling use their own random draws.
What was found about the dataset. The area-sessions with at least 50 neurons are exactly the paper's (8, 17, 19, 18 and 16 sessions in 6, 9, 9, 8 and 6 mice).