Daste, Pierré et al. (2025), Go/NoGo experiment, from dandiset 000785¶
Paper: Daste, Pierré et al., "Projection-specific Routing of Odor Information in the Olfactory
Cortex", bioRxiv preprint doi:10.64898/2025.12.12.694045 (version 1). The claims file
(claims/000785/10.64898-2025.12.12.694045.yaml) was written from the preprint's full text
flattened from its JATS XML: main text, Methods and supplementary legends, without the contents
of Tables 2 to 8.
Dataset: DANDI:000785, version 0.260520.1603 (doi:10.48324/dandi.000785/0.260520.1603). The paper cites no version. The two published versions, 0.260519.1753 and 0.260520.1603, hold the same 61 files with the same blobs (checked through the DANDI API before the analysis), so the most recent is pinned. Files are streamed, never downloaded.
This notebook covers the Go/NoGo sessions (experiments GNG_2021_dataset and GNG_2023b_dataset):
behavior, pseudo-population decoding and the tracked neurons. The counts and passive experiments
are in reproduce_daste_2025_passive.ipynb.
| Claim | Tested here |
|---|---|
| fig4c-behavior-learning, fig4c-anticipatory-licking | tested |
| fig4def-identity-decoding-gng, fig4g-valence-any, fig4h-valence-timing, fig4ij-valence-correct-trials, figs8-generalized-valence-correct | tested (day 3) |
| discussion-differences-grow | tested (days 1 to 3) |
| tracked-neuron-counts | tested |
| figs10d-slope-no-difference, figs10e-sparseness-slope-no-difference, fig5c-cv-higher-obp | tested (tracked neurons) |
| fig5e-transferability, fig5f-stability | tested (tracked neurons, per mouse) |
Mice. The paper's Go/NoGo experiment has 7 mice (4 OB-p, 3 mPFC-p); the dandiset has 8, with a fourth mPFC mouse, sub-668. The main analyses use the 7 mice without sub-668, an assumption: it is the only Go/NoGo mouse without tracking identifiers, and it has 24 to 58 cells per session against 98 to 361 for the others. Its performance does not explain its absence (the Methods exclude "Mice that failed to reach >= 60% correct after 3 days"; its day 3 performance is printed below). The behavior, licking and day 3 decoding claims are also shown with all 8 mice.
import os
os.environ.setdefault("OMP_NUM_THREADS", "1")
os.environ.setdefault("OPENBLAS_NUM_THREADS", "1")
import numpy as np
import pandas as pd
from scipy import stats
import matplotlib.pyplot as plt
import pingouin as pg
import warnings
import pcx
warnings.filterwarnings("ignore", message="The least populated class")
pd.set_option("display.width", 200)
pd.set_option("display.max_columns", 40)
S = pcx.survey_all()
S["subject"] = S.subject.astype(str)
SES = []
for exp in ["GNG_2021_dataset", "GNG_2023b_dataset"]:
ses = pcx.load_experiment(S, exp)
dates = sorted({s["meta"]["start"][:10] for s in ses})
for s in ses:
s["day"] = dates.index(s["meta"]["start"][:10]) # the code's day_num: rank of the date - 1
s["subject"] = s["meta"]["subject"]
s["proj"] = s["meta"]["projection_area"]
SES.append(s)
SES = [s for s in SES if s["day"] <= 3] # the code ignores day 4 of GNG_2023b
for s in SES:
tr = s["trials"]
s["good"] = (~tr.is_bad_trial.astype(bool)).to_numpy()
if s["day"] > 0:
tr["outcome_relabel"] = pcx.hit_relabel(tr)
tr["valence"] = np.where(tr.stim_annotation.str.startswith("go"), "reward", "none")
s["keep"] = s["good"] & tr.stim_annotation.notna().to_numpy()
print("sessions:", len(SES))
sessions: 32
Data check¶
rows = []
for s in SES:
tr = s["trials"]
r = dict(subject=s["subject"], proj=s["proj"], day=s["day"], task=s["meta"]["task"], cells=len(s["cells"]),
red=int(s["cells"].red.sum()), with_muse=int((s["cells"].muse >= 0).sum()), trials=len(tr),
bad=int(tr.is_bad_trial.sum()), fs=round(s["fs"], 3), X_min=round(float(s["X"].min()), 1),
X_max=round(float(s["X"].max()), 1))
if s["day"] > 0:
oc = tr.outcome.value_counts()
r.update(hit=oc.get("hit", 0), miss=oc.get("miss", 0), CR=oc.get("correct_rejection", 0), FA=oc.get("false_alarm", 0),
relabeled=int((tr.outcome != tr.outcome_relabel).sum()),
reward_after_onset=f"{(tr.reward_onset - tr.stim_onset).min():.2f}-{(tr.reward_onset - tr.stim_onset).max():.2f}",
per_CS=tr.stim_annotation.value_counts().min())
rows.append(r)
SAN = pd.DataFrame(rows).sort_values(["proj", "subject", "day"])
print(SAN.to_string(index=False))
tr = [s for s in SES if s["day"] == 1][0]["trials"]
print("onset within trial (s):", sorted({round(float(v), 2) for s in SES for v in (s["trials"].stim_onset_timestamp - s["trials"].start_time)}))
print("odor duration (s):", sorted({round(float(v), 2) for s in SES for v in (s["trials"].stim_offset_timestamp - s["trials"].stim_onset_timestamp)}))
L = np.concatenate([np.concatenate(s["trials"].lick_onset.to_list()) for s in SES if s["day"] > 0])
print(f"lick onsets (s from trial start): {L.min():.2f} to {L.max():.2f}, n = {len(L)}")
print("hit trials without reward:", sum(int(((s['trials'].outcome == 'hit') & s['trials'].reward_onset.isna()).sum()) for s in SES if s['day'] > 0),
"| rewarded trials not hits:", sum(int(((s['trials'].outcome != 'hit') & s['trials'].reward_onset.notna()).sum()) for s in SES if s['day'] > 0))
print("trial type matches CS annotation:", all(((s["trials"].trial_type == "GO") == s["trials"].stim_annotation.str.startswith("go")).all() for s in SES if s["day"] > 0))
n_clip = {f"sub-{s['subject']} day {s['day']}": s["n_clipped"] for s in SES if s["n_clipped"]}
print("trials whose -5 to 15 s window runs past the recording's ends (edge frames repeated):", n_clip if n_clip else 0,
"of", sum(len(s["trials"]) for s in SES))
print("largest distance between an onset and the plane-0 frame taken for it (s):", round(max(s["onset_error_s"] for s in SES), 3))
fpt = {s["n_frames_session"] // len(s["trials"]) for s in SES}
ok_frame = all(((s["on_idx"] - s["trials"].stim_onset_frame.to_numpy().astype(int))
== np.arange(len(s["trials"])) * (s["n_frames_session"] // len(s["trials"]))).all() for s in SES)
print(f"frames per trial: {fpt}; the onset frame taken from the timestamps equals the file's stim_onset_frame "
f"(frame within the trial) in every trial of every session: {ok_frame}")
ex = [s for s in SES if s["subject"] == "2456" and s["day"] == 3][0]["trials"]
cols_t = ["start_time", "stim_onset", "stim_onset_timestamp", "stim_onset_frame", "reward_onset", "reward_onset_timestamp", "outcome"]
print("one trial (sub-2456, day 3, trial 1):"); print(ex.loc[[1], cols_t].to_string())
print(" its first licks, lick_onset:", np.round(ex.lick_onset.iloc[1][:3], 3), "| lick_onset_timestamp:", np.round(ex.lick_onset_timestamp.iloc[1][:3], 3))
d_lick = max(float(np.max(np.abs(np.asarray(lt) - st - np.asarray(lo)))) for s in SES if s["day"] > 0
for lo, lt, st in zip(s["trials"].lick_onset, s["trials"].lick_onset_timestamp, s["trials"].start_time) if len(lo))
d_on = max(float((s["trials"].stim_onset_timestamp - s["trials"].start_time - s["trials"].stim_onset).abs().max()) for s in SES if s["day"] > 0)
print(f"lick_onset and stim_onset are times from the trial start: largest |lick_onset_timestamp - start_time - lick_onset| = {d_lick:.4f} s, "
f"|stim_onset_timestamp - start_time - stim_onset| = {d_on:.4f} s")
subject proj day task cells red with_muse trials bad fs X_min X_max hit miss CR FA relabeled reward_after_onset per_CS
2400 OB 0 passive 235 37 235 105 0 4.521 -2.5 17.0 NaN NaN NaN NaN NaN NaN NaN
2400 OB 1 go_nogo 236 36 236 100 0 4.521 -4.7 40.4 43.0 9.0 24.0 24.0 3.0 5.01-16.27 20.0
2400 OB 2 go_nogo 222 30 222 100 1 4.521 -3.5 17.2 44.0 0.0 6.0 50.0 0.0 5.00-11.98 19.0
2400 OB 3 go_nogo 222 31 222 100 1 4.521 -2.4 20.6 49.0 0.0 10.0 41.0 1.0 5.00-15.85 22.0
2401 OB 0 passive 247 36 247 105 0 4.521 -3.2 18.5 NaN NaN NaN NaN NaN NaN NaN
2401 OB 1 go_nogo 190 26 190 100 1 4.521 -18.4 20.9 16.0 32.0 46.0 6.0 1.0 6.14-15.69 21.0
2401 OB 2 go_nogo 227 28 227 100 2 4.521 -13.4 21.0 31.0 18.0 40.0 11.0 3.0 5.20-16.76 21.0
2401 OB 3 go_nogo 275 34 275 100 0 4.521 -3.4 17.4 49.0 6.0 28.0 17.0 1.0 5.00-16.45 22.0
513 OB 0 passive 131 17 131 100 0 4.521 -2.7 22.7 NaN NaN NaN NaN NaN NaN NaN
513 OB 1 go_nogo 98 20 98 100 0 4.521 -1.8 22.0 47.0 4.0 40.0 9.0 0.0 5.00-11.51 18.0
513 OB 2 go_nogo 126 19 126 100 2 4.521 -14.9 19.7 53.0 1.0 40.0 6.0 1.0 5.00-15.20 20.0
513 OB 3 go_nogo 138 20 138 100 0 4.521 -1.7 20.3 41.0 1.0 49.0 9.0 0.0 5.00-9.35 21.0
664 OB 0 passive 352 30 352 100 1 4.521 -2.7 12.8 NaN NaN NaN NaN NaN NaN NaN
664 OB 1 go_nogo 361 25 361 100 0 4.521 -3.5 17.2 46.0 6.0 36.0 12.0 2.0 5.01-16.50 22.0
664 OB 2 go_nogo 306 20 306 100 0 4.521 -2.6 19.0 36.0 15.0 39.0 10.0 2.0 5.00-15.83 21.0
664 OB 3 go_nogo 349 21 349 100 0 4.521 -2.6 18.4 45.0 3.0 37.0 15.0 0.0 5.00-14.05 21.0
2456 mPFC 0 passive 315 26 315 105 1 4.513 -25.7 17.6 NaN NaN NaN NaN NaN NaN NaN
2456 mPFC 1 go_nogo 304 28 304 100 0 4.513 -2.7 15.6 44.0 1.0 25.0 30.0 3.0 5.00-16.57 18.0
2456 mPFC 2 go_nogo 315 23 315 100 1 4.513 -2.6 17.2 41.0 2.0 26.0 31.0 1.0 5.00-15.24 16.0
2456 mPFC 3 go_nogo 288 30 288 100 0 4.513 -2.6 16.3 53.0 4.0 29.0 14.0 1.0 5.00-16.81 18.0
2457 mPFC 0 passive 268 29 268 105 0 4.513 -3.6 16.5 NaN NaN NaN NaN NaN NaN NaN
2457 mPFC 1 go_nogo 255 32 255 100 1 4.513 -22.7 15.8 42.0 13.0 20.0 25.0 2.0 5.06-16.32 18.0
2457 mPFC 2 go_nogo 312 39 312 100 0 4.513 -5.1 16.4 50.0 4.0 13.0 33.0 1.0 5.00-16.37 18.0
2457 mPFC 3 go_nogo 277 31 277 100 0 4.513 -2.7 16.0 56.0 1.0 10.0 33.0 0.0 5.00-12.56 20.0
644 mPFC 0 passive 430 48 430 100 0 4.521 -1.6 18.7 NaN NaN NaN NaN NaN NaN NaN
644 mPFC 1 go_nogo 342 32 342 100 1 4.521 -17.2 17.2 1.0 41.0 56.0 2.0 0.0 7.28-7.28 20.0
644 mPFC 2 go_nogo 352 28 352 100 0 4.521 -1.6 17.2 65.0 0.0 22.0 13.0 2.0 5.00-15.42 17.0
644 mPFC 3 go_nogo 260 32 260 100 0 4.521 -1.6 16.1 36.0 5.0 46.0 13.0 1.0 5.00-15.65 9.0
668 mPFC 0 passive 43 3 0 100 0 4.521 -2.8 34.0 NaN NaN NaN NaN NaN NaN NaN
668 mPFC 1 go_nogo 58 5 0 100 0 4.521 -2.5 23.4 4.0 50.0 43.0 3.0 2.0 5.52-16.27 17.0
668 mPFC 2 go_nogo 24 3 0 100 1 4.521 -1.7 18.0 47.0 7.0 29.0 17.0 0.0 5.00-13.31 18.0
668 mPFC 3 go_nogo 25 4 0 100 0 4.521 -6.2 24.0 48.0 2.0 42.0 8.0 1.0 5.00-15.58 23.0
onset within trial (s): [5.0, 5.09, 5.1]
odor duration (s): [1.99, 2.0]
lick onsets (s from trial start): 0.00 to 33.32, n = 47423
hit trials without reward: 0 | rewarded trials not hits: 0
trial type matches CS annotation: True
trials whose -5 to 15 s window runs past the recording's ends (edge frames repeated): 0 of 3220
largest distance between an onset and the plane-0 frame taken for it (s): 0.097
frames per trial: {100}; the onset frame taken from the timestamps equals the file's stim_onset_frame (frame within the trial) in every trial of every session: True
one trial (sub-2456, day 3, trial 1):
start_time stim_onset stim_onset_timestamp stim_onset_frame reward_onset reward_onset_timestamp outcome
1 32.278 5.0 37.278 23 10.026 42.304 hit
its first licks, lick_onset: [0.17 3.192 3.465] | lick_onset_timestamp: [32.448 35.47 35.743]
lick_onset and stim_onset are times from the trial start: largest |lick_onset_timestamp - start_time - lick_onset| = 0.0000 s, |stim_onset_timestamp - start_time - stim_onset| = 0.0000 s
Recordings deposited more than once¶
Every file of the dandiset is compared with every other, plane by plane: the correlation of the mean images, and whether the first 300 frames of summed raw fluorescence are identical. Planes within a file are compared too (the paper's code skips planes without red cells because they "tend to have issues, such as duplicated planes"). Sessions with identical trial stimulus sequences are listed.
from concurrent.futures import ThreadPoolExecutor
with ThreadPoolExecutor(12) as ex:
FP = dict(zip(S.path, ex.map(pcx.fingerprint, S.asset_id)))
keys = [(path, i) for path in FP for i in FP[path]["planes"]]
imgs = np.stack([FP[k[0]]["planes"][k[1]]["img"] for k in keys])
imgs = (imgs - imgs.mean(1, keepdims=True)) / imgs.std(1, keepdims=True)
Cimg = imgs @ imgs.T / imgs.shape[1]
same_trace = []
for a in range(len(keys)):
for b in range(a + 1, len(keys)):
ta, tb = FP[keys[a][0]]["planes"][keys[a][1]]["trace"], FP[keys[b][0]]["planes"][keys[b][1]]["trace"]
if len(ta) == len(tb) and np.array_equal(ta, tb):
same_trace.append((keys[a], keys[b]))
iu = np.triu_indices(len(keys), 1)
pairs = pd.DataFrame(dict(a=[keys[i] for i in iu[0]], b=[keys[j] for j in iu[1]], r=Cimg[iu]))
pairs["same_file"] = [x[0] == y[0] for x, y in zip(pairs.a, pairs.b)]
print("planes compared:", len(keys))
print("plane pairs with identical summed raw traces (first 300 frames):", same_trace)
print("plane pairs within one file with mean-image r > 0.95:")
print(pairs[pairs.same_file & (pairs.r > 0.95)].to_string(index=False))
print("highest within-file mean-image r:", round(float(pairs[pairs.same_file].r.max()), 3),
"| highest between-file r:", round(float(pairs[~pairs.same_file].r.max()), 3))
print("plane pairs between files with mean-image r > 0.99:", int((~pairs.same_file & (pairs.r > 0.99)).sum()))
seq = pd.Series({p: FP[p]["stims"] for p in FP})
dups = seq[seq.duplicated(keep=False)]
print("files sharing an identical trial stimulus sequence:")
for sq, grp in dups.groupby(dups.map(hash)):
print(" ", list(grp.index))
planes compared: 173
plane pairs with identical summed raw traces (first 300 frames): []
plane pairs within one file with mean-image r > 0.95:
a b r same_file
(sub-164/sub-164_ses-20200624T144839_ophys.nwb, 0) (sub-164/sub-164_ses-20200624T144839_ophys.nwb, 1) 0.994225 True
(sub-512/sub-512_ses-20210427T145643_ophys.nwb, 0) (sub-512/sub-512_ses-20210427T145643_ophys.nwb, 1) 0.957658 True
(sub-512/sub-512_ses-20210511T120706_ophys.nwb, 0) (sub-512/sub-512_ses-20210511T120706_ophys.nwb, 1) 0.962787 True
(sub-513/sub-513_ses-20210511T145725_ophys.nwb, 0) (sub-513/sub-513_ses-20210511T145725_ophys.nwb, 1) 0.960543 True
(sub-644/sub-644_ses-20210427T121241_ophys.nwb, 1) (sub-644/sub-644_ses-20210427T121241_ophys.nwb, 2) 0.956706 True
(sub-644/sub-644_ses-20210816T172315_ophys.nwb, 1) (sub-644/sub-644_ses-20210816T172315_ophys.nwb, 2) 0.950489 True
(sub-664/sub-664_ses-20210816T141916_ophys.nwb, 0) (sub-664/sub-664_ses-20210816T141916_ophys.nwb, 1) 0.961464 True
(sub-664/sub-664_ses-20210816T141916_ophys.nwb, 1) (sub-664/sub-664_ses-20210816T141916_ophys.nwb, 2) 0.961157 True
(sub-664/sub-664_ses-20210817T121338_ophys.nwb, 0) (sub-664/sub-664_ses-20210817T121338_ophys.nwb, 1) 0.952669 True
(sub-664/sub-664_ses-20210817T121338_ophys.nwb, 1) (sub-664/sub-664_ses-20210817T121338_ophys.nwb, 2) 0.958499 True
(sub-664/sub-664_ses-20210818T123228_ophys.nwb, 0) (sub-664/sub-664_ses-20210818T123228_ophys.nwb, 1) 0.950779 True
(sub-664/sub-664_ses-20210818T123228_ophys.nwb, 1) (sub-664/sub-664_ses-20210818T123228_ophys.nwb, 2) 0.955809 True
(sub-664/sub-664_ses-20210819T120706_ophys.nwb, 0) (sub-664/sub-664_ses-20210819T120706_ophys.nwb, 1) 0.954236 True
(sub-664/sub-664_ses-20210819T120706_ophys.nwb, 1) (sub-664/sub-664_ses-20210819T120706_ophys.nwb, 2) 0.950018 True
(sub-668/sub-668_ses-20210816T114339_ophys.nwb, 0) (sub-668/sub-668_ses-20210816T114339_ophys.nwb, 1) 0.952215 True
(sub-8/sub-8_ses-20200624T162352_ophys.nwb, 0) (sub-8/sub-8_ses-20200624T162352_ophys.nwb, 1) 0.996312 True
highest within-file mean-image r: 0.996 | highest between-file r: 0.989
plane pairs between files with mean-image r > 0.99: 0
files sharing an identical trial stimulus sequence:
['sub-164/sub-164_ses-20200624T144839_ophys.nwb', 'sub-8/sub-8_ses-20200624T162352_ophys.nwb']
fig4c-behavior-learning¶
Go/NoGo performance improves across training days, with no difference between OB-p and mPFC-p labelled mice, reaching 73.7% correct trials on day 3.
Per mouse and task day, percent correct = (hits + correct rejections) / scored CS trials,
excluding bad trials, with hits (a) as scored in the NWB outcome column and (b) relabeled
(reward within 10 s after the delay). One-way repeated-measures ANOVA on days and mixed ANOVA
(days within, projection between), with pingouin.
beh = []
for s in SES:
if s["day"] == 0:
continue
tr = s["trials"][s["keep"]]
for rd, col in [("a: as scored", "outcome"), ("b: relabeled", "outcome_relabel")]:
beh.append(dict(subject=s["subject"], proj=s["proj"], day=s["day"], reading=rd,
pct_correct=100 * tr[col].isin(["hit", "correct_rejection"]).mean(), n=len(tr)))
BEH = pd.DataFrame(beh)
print(BEH.pivot_table(index=["proj", "subject"], columns=["reading", "day"], values="pct_correct").round(1).to_string())
for mice in ["7 mice (without sub-668)", "all 8 mice"]:
d0 = BEH if mice == "all 8 mice" else BEH[BEH.subject != "668"]
for rd in ["a: as scored", "b: relabeled"]:
d = d0[d0.reading == rd]
rm = pg.rm_anova(d, dv="pct_correct", within="day", subject="subject")
mx = pg.mixed_anova(d, dv="pct_correct", within="day", between="proj", subject="subject")
print(f"\n{mice}, {rd}: day 3 mean {d[d.day == 3].pct_correct.mean():.2f}%; "
f"RM ANOVA F = {rm.F.iloc[0]:.3f}, p = {rm['p_unc'].iloc[0]:.4f}")
print(mx[["Source", "F", "p_unc"]].round(4).to_string(index=False))
print(" day means:", d.groupby("day").pct_correct.mean().round(2).to_dict())
reading a: as scored b: relabeled
day 1 2 3 1 2 3
proj subject
OB 2400 67.0 50.5 59.6 64.0 50.5 58.6
2401 61.6 71.4 77.0 60.6 69.4 76.0
513 87.0 92.9 90.0 87.0 91.8 90.0
664 82.0 75.0 82.0 80.0 73.0 82.0
mPFC 2456 69.0 67.7 82.0 66.0 66.7 81.0
2457 62.6 63.0 66.0 60.6 62.0 66.0
644 57.6 87.0 82.0 57.6 85.0 81.0
668 47.0 76.8 90.0 45.0 76.8 89.0
7 mice (without sub-668), a: as scored: day 3 mean 76.94%; RM ANOVA F = 1.571, p = 0.2478
Source F p_unc
proj 0.2178 0.6603
day 1.6201 0.2458
Interaction 1.1886 0.3442
day means: {1: 69.55, 2: 72.5, 3: 76.94}
7 mice (without sub-668), b: relabeled: day 3 mean 76.37%; RM ANOVA F = 2.452, p = 0.1280
Source F p_unc
proj 0.2225 0.6570
day 2.6674 0.1179
Interaction 1.5269 0.2638
day means: {1: 67.97, 2: 71.2, 3: 76.37}
all 8 mice, a: as scored: day 3 mean 78.57%; RM ANOVA F = 2.929, p = 0.0866
Source F p_unc
proj 0.2860 0.6121
day 3.5932 0.0599
Interaction 2.5867 0.1164
day means: {1: 66.73, 2: 73.03, 3: 78.57}
all 8 mice, b: relabeled: day 3 mean 77.95%; RM ANOVA F = 3.742, p = 0.0499
Source F p_unc
proj 0.2842 0.6131
day 4.8301 0.0289
Interaction 3.0344 0.0858
day means: {1: 65.1, 2: 71.9, 3: 77.95}
Result: not reproduced. With 7 mice the day 3 mean is 76.9% (hits as scored) and 76.4% (relabeled), within 73.7 +/- 7.37, and the day means rise (69.6, 72.5, 76.9%). The day effect is not significant: repeated-measures F = 1.571 (p = 0.248) and 2.452 (p = 0.128), against the paper's F = 4.375 (p = 0.0374), and mixed-ANOVA day p = 0.246 and 0.118. Projection (p = 0.66) and interaction (p >= 0.26) are not significant, as in the paper. With all 8 mice and relabeled hits F = 3.742 (p = 0.0499), still outside 4.375 +/- 0.4375, with mixed-ANOVA day p = 0.029.
fig4c-anticipatory-licking¶
Anticipatory licking in response to the rewarded odorants increases across training.
Lick rate (licks per second, from lick_onset) on CS+ trials in (a) the delay, 2 to 5 s after
odor onset, and (b) odor and delay, 0 to 5 s.
lk = []
for s in SES:
if s["day"] == 0:
continue
tr = s["trials"][s["keep"]]
tr = tr[tr.trial_type == "GO"]
for rd, (a, b) in [("a: 2-5 s", (2, 5)), ("b: 0-5 s", (0, 5))]:
n = [np.sum((np.asarray(l) - on >= a) & (np.asarray(l) - on < b)) for l, on in zip(tr.lick_onset, tr.stim_onset)]
lk.append(dict(subject=s["subject"], proj=s["proj"], day=s["day"], reading=rd, rate=np.mean(n) / (b - a)))
LK = pd.DataFrame(lk)
print(LK.pivot_table(index=["proj", "subject"], columns=["reading", "day"], values="rate").round(2).to_string())
for mice in ["7 mice (without sub-668)", "all 8 mice"]:
d0 = LK if mice == "all 8 mice" else LK[LK.subject != "668"]
for rd in ["a: 2-5 s", "b: 0-5 s"]:
m = d0[d0.reading == rd].groupby("day").rate.mean()
print(f"{mice}, {rd}: mean lick rate by day {m.round(3).to_dict()}; day 3 > day 1: {m[3] > m[1]}")
reading a: 2-5 s b: 0-5 s
day 1 2 3 1 2 3
proj subject
OB 2400 0.34 1.47 2.25 0.43 1.51 2.40
2401 0.02 0.08 0.35 0.12 0.12 0.40
513 1.29 1.79 3.25 1.07 1.31 2.23
664 0.41 0.60 1.43 0.45 0.67 1.36
mPFC 2456 0.76 2.17 3.16 0.63 1.89 2.61
2457 0.58 0.80 1.50 0.80 0.76 1.33
644 0.00 0.58 1.38 0.00 0.65 1.44
668 0.02 0.62 1.17 0.06 0.81 1.22
7 mice (without sub-668), a: 2-5 s: mean lick rate by day {1: 0.485, 2: 1.07, 3: 1.904}; day 3 > day 1: True
7 mice (without sub-668), b: 0-5 s: mean lick rate by day {1: 0.498, 2: 0.986, 3: 1.684}; day 3 > day 1: True
all 8 mice, a: 2-5 s: mean lick rate by day {1: 0.427, 2: 1.014, 3: 1.812}; day 3 > day 1: True
all 8 mice, b: 0-5 s: mean lick rate by day {1: 0.443, 2: 0.964, 3: 1.626}; day 3 > day 1: True
Result: reproduced. With 7 mice, the mean CS+ lick rate 2 to 5 s after onset is 0.49, 1.07 and 1.90 licks/s on days 1 to 3, and 0.50, 0.99 and 1.68 over 0 to 5 s. Each of the 8 mice licks more on day 3 than on day 1 under both readings.
sub-668¶
The mouse the dandiset adds to the paper's 7. Its cells, red cells, tracking identifiers and day 3 performance against the Methods' exclusion threshold of 60% correct.
print(SAN[SAN.subject == "668"][["day", "cells", "red", "with_muse"]].to_string(index=False))
print(BEH[(BEH.subject == "668") & (BEH.day == 3)][["reading", "pct_correct"]].to_string(index=False))
print("lowest day 3 performance among the other 7:", BEH[(BEH.subject != "668") & (BEH.day == 3)].groupby("reading").pct_correct.min().round(1).to_dict())
day cells red with_muse
0 43 3 0
1 58 5 0
2 24 3 0
3 25 4 0
reading pct_correct
a: as scored 90.0
b: relabeled 89.0
lowest day 3 performance among the other 7: {'a: as scored': 59.6, 'b: relabeled': 58.6}
Pseudo-populations and the clock check¶
Per task day, cells pooled across mice: OB-p (red cells of OB mice), mPFC-p (red cells of mPFC
mice) and any-p (all cells of all mice). Trials are matched by CS (stim_annotation, go1, go2,
nogo1, nogo2) and by order of that CS, truncated to the smallest count across mice. For correct
trials, the correct trials (relabeled hits and correct rejections) are matched in the same way.
The clock check decodes CS identity from the any-p pseudo-population in a baseline window (2 s before onset) and in the odor phase: if the traces share the trial clock, the baseline is at chance and the odor phase is not.
def gng_pseudo(day, group, correct=False, exclude=("668",)):
ss = [s for s in SES if s["day"] == day and s["subject"] not in exclude]
masks = []
for s in ss:
if group == "any":
masks.append(np.ones(len(s["cells"]), bool))
else:
masks.append(((s["cells"].projection == group)).to_numpy())
keeps = []
for s in ss:
k = s["keep"].copy()
if correct:
k &= s["trials"].outcome_relabel.isin(["hit", "correct_rejection"]).to_numpy()
keeps.append(k)
tab, P = pcx.pseudo_population(ss, masks, "stim_annotation", keeps)
return tab.stim_annotation.to_numpy(), P, ss[0]["t"]
GROUPS = ["OB", "mPFC", "any"]
PH = list(pcx.PHASES)
for d in [1, 2, 3]:
for g in GROUPS:
for corr in [False, True]:
ann, P, t = gng_pseudo(d, g, corr)
print(f"day {d} {g:4s} correct={corr!s:5s}: {P.shape[0]} cells, {len(ann)} trials, per CS {pd.Series(ann).value_counts().min()}")
rng_c = np.random.default_rng(4000)
ann, P, t = gng_pseudo(3, "any")
chk = pcx.decode_gng(P, ann, t, 85, 50, rng_c, schemes=("identity",), phases=[(-2, 0), (0, 2)], aggs=("mean",))
print("clock check, day 3 any-p identity, 50 repeats: baseline (-2 to 0 s) "
f"{100 * chk['identity', 'mean'][:, 0].mean():.1f}%, odor phase {100 * chk['identity', 'mean'][:, 1].mean():.1f}% (chance 25%)")
for s in SES:
if s["day"] != 3 or s["subject"] == "668":
continue
a = s["trials"][s["keep"]].stim_annotation.to_numpy()
X = s["X"][:, s["keep"]]
r = pcx.decode_gng(X, a, s["t"], 10**9, 5, rng_c, schemes=("identity",), phases=[(-2, 0), (0, 2)], aggs=("mean",))["identity", "mean"].mean(0)
print(f" per session, sub-{s['subject']} day 3, all its cells: baseline {100 * r[0]:.1f}%, odor {100 * r[1]:.1f}%")
day 1 OB correct=False: 107 cells, 73 trials, per CS 17 day 1 OB correct=True : 107 cells, 21 trials, per CS 1
day 1 mPFC correct=False: 92 cells, 73 trials, per CS 17 day 1 mPFC correct=True : 92 cells, 21 trials, per CS 1
day 1 any correct=False: 1786 cells, 73 trials, per CS 17 day 1 any correct=True : 1786 cells, 21 trials, per CS 1
day 2 OB correct=False: 97 cells, 72 trials, per CS 16 day 2 OB correct=True : 97 cells, 31 trials, per CS 2
day 2 mPFC correct=False: 90 cells, 72 trials, per CS 16 day 2 mPFC correct=True : 90 cells, 31 trials, per CS 2
day 2 any correct=False: 1860 cells, 72 trials, per CS 16
day 2 any correct=True : 1860 cells, 31 trials, per CS 2 day 3 OB correct=False: 106 cells, 70 trials, per CS 9 day 3 OB correct=True : 106 cells, 30 trials, per CS 3
day 3 mPFC correct=False: 93 cells, 70 trials, per CS 9
day 3 mPFC correct=True : 93 cells, 30 trials, per CS 3 day 3 any correct=False: 1809 cells, 70 trials, per CS 9
day 3 any correct=True : 1809 cells, 30 trials, per CS 3
clock check, day 3 any-p identity, 50 repeats: baseline (-2 to 0 s) 29.4%, odor phase 45.7% (chance 25%) per session, sub-513 day 3, all its cells: baseline 26.4%, odor 73.4% per session, sub-644 day 3, all its cells: baseline 22.6%, odor 48.2%
per session, sub-664 day 3, all its cells: baseline 35.6%, odor 64.8% per session, sub-2400 day 3, all its cells: baseline 22.5%, odor 50.3%
per session, sub-2401 day 3, all its cells: baseline 32.2%, odor 59.6% per session, sub-2456 day 3, all its cells: baseline 29.0%, odor 33.4%
per session, sub-2457 day 3, all its cells: baseline 33.2%, odor 29.2%
The clock check per session¶
In the day 3 check above two mPFC mice (sub-2456 and sub-2457) decode no better in the odor phase
than at baseline with all their cells. To tell a misaligned clock from a late or weak response,
each session of days 1 to 3 is decoded (CS identity, all its cells, 5 repeats) in 1 s windows
from 5 s before to 15 s after onset, and the onset-aligned mean of the normalized traces (all
cells, all kept trials) of each day 3 session is printed frame by frame from 2 s before to 4 s
after onset. A misaligned clock would show decoding above chance before onset, or a response
time course shifted as a whole; the frame of the onset is also checked against the files'
stim_onset_frame in the data check.
rng_cs = np.random.default_rng(4010)
W1 = [(a, a + 1) for a in range(-5, 15)]
rows = []
for s in SES:
if s["day"] == 0 or s["subject"] == "668":
continue
a = s["trials"][s["keep"]].stim_annotation.to_numpy()
r = pcx.decode_gng(s["X"][:, s["keep"]], a, s["t"], 10**9, 5, rng_cs, schemes=("identity",), phases=W1, aggs=("mean",))["identity", "mean"].mean(0)
rows.append(dict(proj=s["proj"], subject=s["subject"], day=s["day"], **{f"{w[0]}": round(100 * v) for w, v in zip(W1, r)}))
CLK = pd.DataFrame(rows).sort_values(["proj", "subject", "day"])
print("identity accuracy (%) per session, 1 s windows labelled by their start (s from onset); chance 25%")
print(CLK.to_string(index=False))
pre = CLK[[f"{a}" for a in range(-5, 0)]].to_numpy()
print(f"before onset: {pre.min()} to {pre.max()}% (mean {pre.mean():.1f}); 0-1 s: {CLK['0'].min()} to {CLK['0'].max()}%; "
f"1-2 s: {CLK['1'].min()} to {CLK['1'].max()}%; 2-3 s: {CLK['2'].min()} to {CLK['2'].max()}%")
print("\nonset-aligned mean normalized trace, all cells and kept trials, day 3 (columns: frames from the onset frame, 0.22 s each)")
t_c = SES[0]["t"]
rows = []
for s in SES:
if s["day"] != 3 or s["subject"] == "668":
continue
m = s["X"][:, s["keep"]].mean((0, 1))
i0 = s["n_pre"]
base = m[(s["t"] >= -4) & (s["t"] < 0)]
after = np.where((s["t"] >= 0) & (m > base.mean() + 3 * base.std()))[0]
rows.append(dict(proj=s["proj"], subject=s["subject"], first_s_above_baseline_3sd=round(float(s["t"][after[0]]), 2) if len(after) else np.nan,
**{f"{k}": round(float(m[i0 + k]), 2) for k in range(-9, 19)}))
print(pd.DataFrame(rows).sort_values(["proj", "subject"]).to_string(index=False))
identity accuracy (%) per session, 1 s windows labelled by their start (s from onset); chance 25% proj subject day -5 -4 -3 -2 -1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 OB 2400 1 31 30 29 28 30 30 40 57 70 66 60 56 53 58 52 53 52 54 45 45 OB 2400 2 24 25 26 30 32 40 60 61 60 62 59 55 58 60 58 50 50 51 51 52 OB 2400 3 30 32 26 30 26 37 59 61 64 60 59 53 53 47 49 50 49 48 42 43 OB 2401 1 23 29 29 31 35 41 76 83 90 87 84 81 80 77 74 74 69 68 65 67 OB 2401 2 24 30 28 32 29 38 72 77 76 70 66 63 62 61 59 57 54 54 53 50 OB 2401 3 29 27 32 31 29 34 75 85 88 88 87 84 81 78 73 70 72 64 60 58 OB 513 1 31 29 25 26 29 36 79 85 86 91 90 83 84 84 82 76 78 77 68 68 OB 513 2 28 24 27 31 31 38 79 88 93 93 88 89 81 79 71 70 63 58 58 53 OB 513 3 30 31 27 25 26 47 82 81 88 91 92 85 83 79 77 68 63 61 59 53 OB 664 1 29 32 32 34 31 28 63 77 85 91 93 94 96 96 97 96 94 91 90 91 OB 664 2 30 30 28 30 31 34 81 94 96 96 95 99 99 98 98 98 95 92 89 87 OB 664 3 35 34 36 37 36 37 85 93 94 95 98 98 98 96 96 95 92 91 89 89 mPFC 2456 1 32 31 26 24 25 28 44 54 65 71 68 63 64 63 60 61 59 61 59 55 mPFC 2456 2 32 37 39 37 34 37 51 63 65 60 65 65 73 74 70 67 72 70 66 67 mPFC 2456 3 29 31 35 26 32 34 45 59 69 73 72 74 73 72 72 73 68 67 68 69 mPFC 2457 1 25 26 31 34 31 34 34 36 41 40 42 42 43 37 33 32 35 33 29 33 mPFC 2457 2 22 24 22 22 24 23 36 41 49 49 52 58 51 53 53 56 57 52 48 43 mPFC 2457 3 33 33 34 35 29 26 40 62 60 63 60 60 58 55 53 56 54 51 51 48 mPFC 644 1 29 20 25 27 31 34 58 70 73 72 68 71 66 68 65 61 56 58 60 54 mPFC 644 2 28 29 28 27 32 32 56 66 67 68 70 65 59 63 62 58 56 56 52 50 mPFC 644 3 26 25 25 25 24 29 65 73 78 82 77 78 81 79 77 72 71 65 65 64 before onset: 20 to 39% (mean 29.2); 0-1 s: 23 to 47%; 1-2 s: 34 to 85%; 2-3 s: 36 to 94% onset-aligned mean normalized trace, all cells and kept trials, day 3 (columns: frames from the onset frame, 0.22 s each) proj subject first_s_above_baseline_3sd -9 -8 -7 -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 OB 2400 0.00 0.70 0.71 0.71 0.71 0.72 0.72 0.73 0.74 0.75 0.77 0.78 0.79 0.79 0.79 0.79 0.79 0.77 0.75 0.74 0.73 0.73 0.75 0.75 0.76 0.76 0.76 0.76 0.77 OB 2401 0.00 0.68 0.68 0.67 0.67 0.67 0.67 0.68 0.69 0.71 0.73 0.75 0.77 0.78 0.80 0.81 0.82 0.82 0.83 0.83 0.84 0.86 0.89 0.91 0.91 0.91 0.91 0.91 0.91 OB 513 0.44 0.68 0.67 0.66 0.65 0.64 0.63 0.63 0.63 0.63 0.65 0.69 0.76 0.83 0.90 0.95 0.98 1.00 1.00 1.01 1.01 1.01 1.00 0.99 0.99 0.98 0.96 0.95 0.93 OB 664 0.44 0.68 0.68 0.68 0.67 0.67 0.67 0.67 0.67 0.68 0.70 0.72 0.75 0.80 0.85 0.90 0.94 0.98 1.01 1.03 1.05 1.06 1.07 1.08 1.08 1.07 1.06 1.05 1.03 mPFC 2456 2.44 0.70 0.69 0.69 0.69 0.68 0.69 0.69 0.71 0.72 0.73 0.74 0.74 0.73 0.73 0.72 0.72 0.72 0.72 0.73 0.74 0.77 0.80 0.82 0.84 0.86 0.87 0.88 0.90 mPFC 2457 0.89 0.82 0.81 0.81 0.80 0.80 0.80 0.81 0.82 0.84 0.85 0.87 0.88 0.88 0.89 0.89 0.88 0.87 0.86 0.86 0.86 0.87 0.88 0.88 0.88 0.87 0.87 0.86 0.86 mPFC 644 1.33 0.58 0.59 0.58 0.58 0.59 0.59 0.59 0.59 0.59 0.59 0.58 0.59 0.59 0.60 0.61 0.63 0.64 0.65 0.66 0.67 0.69 0.70 0.71 0.73 0.75 0.76 0.77 0.78
The per-session check is consistent with one clock for traces and trials in every session,
including sub-2456 and sub-2457, though it does not prove it. In every session the onset frame
taken from the timestamps is the file's own stim_onset_frame (data check), and decoding rises
mainly after onset. Before onset the per-session accuracies are 20 to 39% (mean 29.2%). No
per-session shuffled null was run; the shuffled levels of the pooled tables below (means 26 to
29%, 95th percentiles 36 to 39%) are only a rough reference for them, and some sessions sit above
those means before onset (sub-664 day 3 at 34 to 37%, sub-2456 day 2 at 32 to 39%). In 1 to 2 s
after onset sub-2456 and sub-2457 reach 34 to 51%, against 56 to 85% in the other mice except
sub-2400 day 1 (40%). Later in the trial sub-2456 reaches 73 to 74% on days 2 and 3, above any
sub-2400 session (at most 70%), while sub-2457 stays at or below 63%. On day 3 the mean traces of
sub-2457, sub-2400 and sub-2401 already drift upward before onset (sub-2457: 0.80 at frame -4,
0.84 at frame -1, 0.85 at frame 0) and keep rising after it (sub-2457 0.89 at frame 4, 0.9 s); the
trace of sub-2456 first exceeds its baseline by 3 SD at 2.44 s. A whole-trial offset would shift
the pre-onset windows too, and these stay below the accuracies reached after onset. So sub-2457,
and sub-2456 early in the trial, respond later or more weakly in the odor phase, which the data do
not explain further; their share of the day 3 mPFC-p cells (61 of 93) is shown by mouse under
fig4def-identity-decoding-gng.
def run_day(day, n_rep, seed, correct=False, schemes=("identity", "valence", "generalized"), exclude=("668",), groups=GROUPS):
rng = np.random.default_rng(seed)
out = {}
for g in groups:
ann, P, t = gng_pseudo(day, g, correct, exclude)
out[g] = pcx.decode_gng(P, ann, t, 85, n_rep, rng, schemes=schemes)
return out
DEC3 = run_day(3, 100, 4301)
DEC3C = run_day(3, 100, 4302, correct=True)
DEC3_8 = run_day(3, 100, 4303, exclude=())
DEC3C_8 = run_day(3, 100, 4304, correct=True, exclude=())
def table(dec, scheme, agg, chance):
rows = []
for g in dec:
A = dec[g][scheme, agg]
for pi, ph in enumerate(PH):
tt = stats.ttest_1samp(A[:, pi], chance, alternative="greater")
rows.append(dict(group=g, phase=ph, mean=100 * A[:, pi].mean(), sd=100 * A[:, pi].std(),
p_vs_chance_bonf=min(1, 4 * tt.pvalue)))
T = pd.DataFrame(rows)
btw = []
for pi, ph in enumerate(PH):
p = pcx.mwu(dec["OB"][scheme, agg][:, pi], dec["mPFC"][scheme, agg][:, pi])
btw.append(dict(phase=ph, OB_minus_mPFC=100 * (dec["OB"][scheme, agg][:, pi].mean() - dec["mPFC"][scheme, agg][:, pi].mean()),
p_OB_vs_mPFC_bonf=min(1, 4 * p)))
return T, pd.DataFrame(btw)
Trial counts and empirical chance¶
The paper tests identity against 25% and valence against 50%. The pseudo-population tables are not balanced, so the chance level of this procedure is computed: per table, the counts of each CS and of CS+ trials, and the accuracy of the same decoders (85 cells, mean aggregate) with the CS labels shuffled across pseudo-trials, 50 repeats. For correct trials a balanced variant is also run, each CS truncated to the smallest CS count (the paper excludes days 1 and 2 "due to imbalanced counts of correct trials across animals to properly construct pseudo-populations", Figure 4I-J legend), decoding valence and generalized valence (identity is not decoded on it: a stratified 3-fold split would leave 2 training trials and 1 test trial per CS).
rng_n = np.random.default_rng(4050)
null_rows = []
for label, excl in [("7 mice", ("668",)), ("all 8 mice", ())]:
for corr in [False, True]:
for g in GROUPS:
ann, P, t = gng_pseudo(3, g, corr, excl)
vc = pd.Series(ann).value_counts()
acc = {sc: [] for sc in ["identity", "valence", "generalized"]}
for r in range(50):
d = pcx.decode_gng(P, ann[rng_n.permutation(len(ann))], t, 85, 1, rng_n, aggs=("mean",))
for sc in acc:
acc[sc].append(d[sc, "mean"][0])
for sc in acc:
A = np.array(acc[sc])
null_rows.append(dict(mice=label, correct=corr, group=g, scheme=sc, trials=len(ann), per_CS=vc.to_dict(),
CS_plus_fraction=round(float(np.mean([a.startswith("go") for a in ann])), 3),
**{ph: round(100 * A[:, pi].mean(), 1) for pi, ph in enumerate(PH)},
null_95th=round(100 * np.percentile(A, 95), 1)))
NULL = pd.DataFrame(null_rows)
print("shuffled-label accuracy (%), day 3, mean over 50 repeats per phase, and the 95th percentile over all phases")
print(NULL.drop(columns=["per_CS", "trials", "CS_plus_fraction"]).to_string(index=False))
print(NULL.drop_duplicates(["mice", "correct"])[["mice", "correct", "trials", "per_CS", "CS_plus_fraction"]].to_string(index=False))
def balanced(ann):
"""Indices keeping the first n pseudo-trials of each CS, n the smallest CS count."""
n = pd.Series(ann).value_counts().min()
return np.concatenate([np.where(ann == a)[0][:n] for a in sorted(set(ann))])
def decode_balanced(P, ann, n_rep, rng, shuffle=False):
"""Valence and generalized valence on a balanced table: dict (scheme, agg) -> repeats x phases."""
from sklearn.model_selection import StratifiedKFold
out = {(sc, ag): np.zeros((n_rep, len(PH))) for sc in ["valence", "generalized"] for ag in ["mean", "max"]}
for r in range(n_rep):
a = ann[rng.permutation(len(ann))] if shuffle else ann
v = np.array([x.startswith("go") for x in a])
cells = rng.choice(P.shape[0], 85, replace=False)
folds = {"valence": list(StratifiedKFold(5, shuffle=True, random_state=int(rng.integers(2**31))).split(np.zeros(len(v)), v))}
for ag in ["mean", "max"]:
for pi, R in enumerate(pcx.phase_features(P[cells], t_c, list(pcx.PHASES.values()), ag)):
for sc in ["valence", "generalized"]:
out[sc, ag][r, pi] = pcx.decode_scheme(R, a, sc, folds)
return out
rng_b = np.random.default_rng(4060)
BAL = {}
for g in ["OB", "mPFC"]:
ann, P, t = gng_pseudo(3, g, True)
k = balanced(ann)
BAL[g] = decode_balanced(P[:, k], ann[k], 100, rng_b)
BAL[g, "null"] = decode_balanced(P[:, k], ann[k], 50, rng_b, shuffle=True)
print(f"\nbalanced correct trials, 7 mice: {len(k)} pseudo-trials, {pd.Series(ann[k]).value_counts().to_dict()}")
for sc in ["valence", "generalized"]:
for ag in ["mean", "max"]:
for g in ["OB", "mPFC"]:
A, N = BAL[g][sc, ag], BAL[g, "null"][sc, ag]
print(f" {sc:11s} {ag:4s} {g:4s} accuracy {np.round(100 * A.mean(0), 1)} | shuffled {np.round(100 * N.mean(0), 1)} | "
f"p against 50% (Bonferroni 4): {[f'{min(1, 4 * stats.ttest_1samp(A[:, pi], 0.5, alternative='greater').pvalue):.2g}' for pi in range(4)]}")
print(f" {sc:11s} {ag:4s} OB against mPFC, two-sided Mann-Whitney, Bonferroni 4: "
f"{[f'{min(1, 4 * pcx.mwu(BAL['OB'][sc, ag][:, pi], BAL['mPFC'][sc, ag][:, pi])):.2g}' for pi in range(4)]}")
shuffled-label accuracy (%), day 3, mean over 50 repeats per phase, and the 95th percentile over all phases
mice correct group scheme odor delay act-early act-late null_95th
7 mice False OB identity 27.8 25.9 26.7 27.0 35.7
7 mice False OB valence 51.5 51.5 51.7 51.0 62.9
7 mice False OB generalized 51.5 51.4 51.0 49.0 59.6
7 mice False mPFC identity 28.5 26.5 26.7 27.8 37.2
7 mice False mPFC valence 51.4 50.5 51.3 50.3 62.9
7 mice False mPFC generalized 49.8 48.9 47.9 48.7 57.7
7 mice False any identity 27.5 27.7 28.3 28.2 38.6
7 mice False any valence 51.1 51.9 50.2 52.3 62.9
7 mice False any generalized 49.6 50.1 48.6 49.2 58.0
7 mice True OB identity 44.0 44.4 44.4 44.7 60.0
7 mice True OB valence 65.5 65.8 65.9 65.9 80.0
7 mice True OB generalized 61.7 61.3 62.1 62.7 72.0
7 mice True mPFC identity 44.9 44.9 45.9 45.3 60.0
7 mice True mPFC valence 68.0 65.5 66.2 67.5 80.0
7 mice True mPFC generalized 64.1 62.5 62.9 64.1 74.7
7 mice True any identity 46.8 46.0 44.7 45.3 56.7
7 mice True any valence 66.5 66.4 66.7 67.6 80.0
7 mice True any generalized 62.4 63.0 64.8 63.9 73.1
all 8 mice False OB identity 28.4 28.3 28.0 27.5 37.2
all 8 mice False OB valence 51.5 50.4 50.3 51.5 61.4
all 8 mice False OB generalized 49.7 49.3 49.1 48.5 58.4
all 8 mice False mPFC identity 28.6 27.9 27.5 26.9 37.1
all 8 mice False mPFC valence 52.7 51.9 52.2 51.0 64.4
all 8 mice False mPFC generalized 49.4 48.5 50.1 48.3 58.2
all 8 mice False any identity 26.7 28.6 27.2 28.5 37.2
all 8 mice False any valence 49.7 51.6 50.7 52.5 61.4
all 8 mice False any generalized 48.8 48.6 49.1 49.7 58.2
all 8 mice True OB identity 45.6 45.1 46.1 45.3 60.0
all 8 mice True OB valence 65.9 66.9 66.4 67.0 80.0
all 8 mice True OB generalized 62.8 63.4 63.6 63.7 74.3
all 8 mice True mPFC identity 45.4 46.7 43.3 45.5 56.7
all 8 mice True mPFC valence 69.0 66.9 66.8 65.9 80.0
all 8 mice True mPFC generalized 62.4 62.0 63.6 63.5 73.4
all 8 mice True any identity 44.9 46.2 44.5 46.3 60.0
all 8 mice True any valence 67.5 66.6 66.3 67.3 76.8
all 8 mice True any generalized 63.7 62.8 63.1 62.0 72.0
mice correct trials per_CS CS_plus_fraction
7 mice False 70 {'nogo2': 22, 'go1': 21, 'nogo1': 18, 'go2': 9} 0.429
7 mice True 30 {'go1': 17, 'go2': 6, 'nogo1': 4, 'nogo2': 3} 0.767
all 8 mice False 70 {'nogo2': 22, 'go1': 21, 'nogo1': 18, 'go2': 9} 0.429
all 8 mice True 30 {'go1': 17, 'go2': 6, 'nogo1': 4, 'nogo2': 3} 0.767
balanced correct trials, 7 mice: 12 pseudo-trials, {'go1': 3, 'go2': 3, 'nogo1': 3, 'nogo2': 3}
valence mean OB accuracy [78.1 76. 56.1 54.5] | shuffled [44. 45.7 45.9 46.5] | p against 50% (Bonferroni 4): ['2.7e-50', '6.4e-54', '2.2e-07', '0.00065']
valence mean mPFC accuracy [27.8 55.5 58.2 76.9] | shuffled [51.3 50.1 47.2 41.7] | p against 50% (Bonferroni 4): ['1', '3.3e-06', '2.9e-10', '1.2e-62']
valence mean OB against mPFC, two-sided Mann-Whitney, Bonferroni 4: ['9.3e-34', '4.2e-26', '1', '2.3e-26']
valence max OB accuracy [78.9 70.4 55.8 55.2] | shuffled [46.3 42.5 48.7 47.5] | p against 50% (Bonferroni 4): ['1.1e-57', '5.9e-38', '2.2e-07', '1.1e-05']
valence max mPFC accuracy [31.4 47.3 66.5 86.8] | shuffled [51. 49.1 46.5 44.9] | p against 50% (Bonferroni 4): ['1', '1', '8.1e-37', '4.7e-77']
valence max OB against mPFC, two-sided Mann-Whitney, Bonferroni 4: ['7.7e-34', '1.8e-26', '1.6e-12', '1.9e-33']
generalized mean OB accuracy [63.7 59.9 50.6 47. ] | shuffled [47.3 48.3 51. 51.4] | p against 50% (Bonferroni 4): ['1.4e-35', '1.9e-28', '0.73', '1']
generalized mean mPFC accuracy [35.7 48.1 53.2 59.5] | shuffled [49.3 50.2 49.6 46.7] | p against 50% (Bonferroni 4): ['1', '1', '1e-18', '3.1e-40']
generalized mean OB against mPFC, two-sided Mann-Whitney, Bonferroni 4: ['7.6e-34', '6.3e-26', '6e-05', '1.2e-28']
generalized max OB accuracy [65.7 58.9 56.4 49.1] | shuffled [47.4 47.2 50.2 49.2] | p against 50% (Bonferroni 4): ['3.7e-40', '1.7e-23', '1.5e-17', '1']
generalized max mPFC accuracy [33.2 47.9 52. 62.6] | shuffled [50.4 48.9 47.8 46.2] | p against 50% (Bonferroni 4): ['1', '1', '0.00043', '3.3e-51']
generalized max OB against mPFC, two-sided Mann-Whitney, Bonferroni 4: ['7.4e-34', '5.1e-24', '1.9e-07', '3.8e-31']
fig4def-identity-decoding-gng¶
In expert mice (day 3), OB-p pseudo-populations decode odor identity above chance in all four task phases, peaking early (delay) and declining later, whereas mPFC-p pseudo-populations are near chance early and improve later in the trial.
Day 3, 4 CS (chance 25%), 85 cells, 100 repeats, aggregate (a) mean and (b) maximum over the phase. One-sample one-sided t-tests against 25%, Bonferroni over 4 phases.
for label, dec in [("7 mice", DEC3), ("all 8 mice", DEC3_8)]:
for agg in ["mean", "max"]:
T, Bt = table(dec, "identity", agg, 0.25)
ob = T[T.group == "OB"].set_index("phase")
mp = T[T.group == "mPFC"].set_index("phase")
cond = dict(OB_all_above=bool((ob.p_vs_chance_bonf < 0.05).all()), OB_peak=ob["mean"].idxmax(),
OB_late_below_delay=bool(ob.loc["act-late", "mean"] < ob.loc["delay", "mean"]),
mPFC_two_lowest=sorted(mp["mean"].nsmallest(2).index.tolist()), mPFC_peak=mp["mean"].idxmax())
print(f"\n{label}, aggregate {agg}")
print(T.pivot(index="group", columns="phase", values="mean")[PH].round(2).to_string())
print(T.pivot(index="group", columns="phase", values="p_vs_chance_bonf")[PH].to_string())
print(Bt.to_string(index=False))
print(cond)
print("\nshuffled-label identity accuracy, 7 mice (%):")
print(NULL[(NULL.mice == "7 mice") & ~NULL.correct & (NULL.scheme == "identity")][["group"] + PH + ["null_95th"]].to_string(index=False))
# by mouse: each mouse's own red cells on day 3, all of them, 20 repeats
rng_m = np.random.default_rng(4070)
rows = []
for s in SES:
m = s["cells"].red.to_numpy()
if s["day"] != 3 or m.sum() < 2:
continue
a = s["trials"][s["keep"]].stim_annotation.to_numpy()
r = pcx.decode_gng(s["X"][m][:, s["keep"]], a, s["t"], 10**9, 20, rng_m, schemes=("identity",), aggs=("mean",))["identity", "mean"].mean(0)
rows.append(dict(proj=s["proj"], subject=s["subject"], red_cells=int(m.sum()), **{ph: round(100 * v, 1) for ph, v in zip(PH, r)}))
print("\nby mouse, day 3, identity from the mouse's own red cells (mean aggregate, 20 repeats, chance 25%):")
print(pd.DataFrame(rows).sort_values(["proj", "subject"]).to_string(index=False))
print("day 3 mPFC-p cells per mouse (7 mice):", {s["subject"]: int(s["cells"].red.sum()) for s in SES if s["day"] == 3 and s["proj"] == "mPFC" and s["subject"] != "668"})
7 mice, aggregate mean
phase odor delay act-early act-late
group
OB 54.51 74.99 71.01 58.56
any 45.83 78.77 77.27 64.49
mPFC 36.41 52.70 65.79 60.21
phase odor delay act-early act-late
group
OB 4.240169e-71 8.147104e-96 7.889895e-97 4.783673e-85
any 1.379694e-42 4.211637e-81 1.444312e-77 1.076523e-65
mPFC 4.971598e-43 7.235950e-76 5.285213e-98 5.349405e-81
phase OB_minus_mPFC p_OB_vs_mPFC_bonf
odor 18.100000 7.255925e-33
delay 22.285714 1.708605e-33
act-early 5.228571 3.130160e-12
act-late -1.657143 1.171903e-01
{'OB_all_above': True, 'OB_peak': 'delay', 'OB_late_below_delay': True, 'mPFC_two_lowest': ['delay', 'odor'], 'mPFC_peak': 'act-early'}
7 mice, aggregate max
phase odor delay act-early act-late
group
OB 62.66 74.27 69.27 56.40
any 56.24 78.41 77.80 65.17
mPFC 37.33 54.30 62.67 61.67
phase odor delay act-early act-late
group
OB 5.262458e-77 1.158308e-99 2.919018e-106 3.236901e-82
any 4.018282e-50 7.722265e-83 2.808505e-81 4.396456e-69
mPFC 3.117820e-43 1.030539e-86 1.120494e-93 3.009334e-91
phase OB_minus_mPFC p_OB_vs_mPFC_bonf
odor 25.328571 1.272904e-33
delay 19.971429 1.407693e-33
act-early 6.600000 3.764362e-18
act-late -5.271429 2.720072e-11
{'OB_all_above': True, 'OB_peak': 'delay', 'OB_late_below_delay': True, 'mPFC_two_lowest': ['delay', 'odor'], 'mPFC_peak': 'act-early'}
all 8 mice, aggregate mean
phase odor delay act-early act-late
group
OB 53.49 74.01 69.57 58.94
any 45.39 79.43 77.09 63.73
mPFC 36.24 55.57 63.74 59.13
phase odor delay act-early act-late
group
OB 1.063746e-74 8.106844e-92 1.041314e-90 4.121307e-80
any 4.793438e-44 2.493557e-80 1.562090e-78 4.108279e-67
mPFC 7.394989e-41 2.951856e-84 4.132291e-85 9.136676e-83
phase OB_minus_mPFC p_OB_vs_mPFC_bonf
odor 17.242857 5.249933e-32
delay 18.442857 7.168668e-32
act-early 5.828571 1.125702e-10
act-late -0.185714 1.000000e+00
{'OB_all_above': True, 'OB_peak': 'delay', 'OB_late_below_delay': True, 'mPFC_two_lowest': ['delay', 'odor'], 'mPFC_peak': 'act-early'}
all 8 mice, aggregate max
phase odor delay act-early act-late
group
OB 62.13 72.84 68.73 55.7
any 56.37 78.99 76.71 63.9
mPFC 36.10 55.66 59.03 58.6
phase odor delay act-early act-late
group
OB 2.356071e-83 4.974694e-97 1.922138e-97 1.692463e-78
any 4.330093e-53 1.340576e-76 9.448347e-81 6.930883e-69
mPFC 1.249384e-44 6.887584e-86 2.012215e-88 8.055719e-89
phase OB_minus_mPFC p_OB_vs_mPFC_bonf
odor 26.028571 1.008522e-33
delay 17.185714 7.900141e-33
act-early 9.700000 9.936342e-25
act-late -2.900000 3.419895e-04
{'OB_all_above': True, 'OB_peak': 'delay', 'OB_late_below_delay': True, 'mPFC_two_lowest': ['delay', 'odor'], 'mPFC_peak': 'act-early'}
shuffled-label identity accuracy, 7 mice (%):
group odor delay act-early act-late null_95th
OB 27.8 25.9 26.7 27.0 35.7
mPFC 28.5 26.5 26.7 27.8 37.2
any 27.5 27.7 28.3 28.2 38.6
by mouse, day 3, identity from the mouse's own red cells (mean aggregate, 20 repeats, chance 25%):
proj subject red_cells odor delay act-early act-late
OB 2400 31 34.3 33.6 33.2 30.1
OB 2401 34 39.1 41.5 40.7 38.2
OB 513 20 43.8 56.3 49.2 36.1
OB 664 21 43.5 67.8 66.7 63.1
mPFC 2456 30 31.4 40.9 48.0 44.0
mPFC 2457 31 30.0 35.8 35.0 39.3
mPFC 644 32 35.5 57.6 53.7 52.8
mPFC 668 4 40.8 39.0 31.8 36.2
day 3 mPFC-p cells per mouse (7 mice): {'644': 32, '2456': 30, '2457': 31}
Result: reproduced. With 7 mice and the mean aggregate, OB-p reaches 54.5, 75.0, 71.0 and 58.6% in odor, delay, act-early and act-late, above 25% in every phase (corrected p <= 5e-71), highest in the delay and lower in act-late. mPFC-p reaches 36.4, 52.7, 65.8 and 60.2%: lowest in odor and delay, highest in act-early. The maximum aggregate and all 8 mice give the same pattern. mPFC-p is also above chance in every phase (odor 36.4%, corrected p = 5e-43), so "near chance" holds only in the sense of lowest. With labels shuffled, this procedure gives 26 to 29% (95th percentile 36 to 39%), a little above the paper's 25%. Every mean above is higher than the shuffled means, but the mPFC-p odor accuracy is not above the mPFC-p shuffled 95th percentile (37.2% with 7 mice, 37.1% with 8) except with 7 mice and the maximum aggregate: it is 36.4% (7 mice, mean aggregate), 36.2 and 36.1% (8 mice, mean and maximum) and 37.3% (7 mice, maximum). Against this procedure's null, mPFC-p odor decoding is thus at or barely above the shuffled level. OB-p exceeds mPFC-p in odor, delay and act-early (corrected p <= 3.1e-12) and not in act-late (p = 0.12, mean aggregate). By mouse, from each mouse's own red cells, each of the three mPFC mice decodes least in the odor phase (sub-2456 31.4%, sub-2457 30.0%, sub-644 35.5%), so the pattern is not carried by sub-2456 and sub-2457 alone; they supply 61 of the 93 day 3 mPFC-p cells.
fig4g-valence-any¶
Generalized odor valence can be decoded above chance from a general PCx (any-p) pseudo-population in all task phases in expert mice.
for label, dec in [("7 mice", DEC3), ("all 8 mice", DEC3_8)]:
for agg in ["mean", "max"]:
T, _ = table(dec, "generalized", agg, 0.5)
a = T[T.group == "any"]
print(f"{label}, {agg}: any-p generalized valence by phase", dict(zip(a.phase, a["mean"].round(2))),
"| Bonferroni p:", dict(zip(a.phase, a.p_vs_chance_bonf.map(lambda v: f"{v:.3g}"))))
7 mice, mean: any-p generalized valence by phase {'odor': 54.11, 'delay': 69.33, 'act-early': 64.53, 'act-late': 60.2} | Bonferroni p: {'odor': '9.09e-07', 'delay': '3.63e-37', 'act-early': '1.78e-30', 'act-late': '1.76e-23'}
7 mice, max: any-p generalized valence by phase {'odor': 55.2, 'delay': 65.57, 'act-early': 61.74, 'act-late': 60.18} | Bonferroni p: {'odor': '1.06e-07', 'delay': '1.62e-29', 'act-early': '3.94e-23', 'act-late': '6.42e-24'}
all 8 mice, mean: any-p generalized valence by phase {'odor': 53.26, 'delay': 69.52, 'act-early': 64.09, 'act-late': 59.05} | Bonferroni p: {'odor': '1.04e-05', 'delay': '3.72e-40', 'act-early': '1.32e-24', 'act-late': '6.47e-19'}
all 8 mice, max: any-p generalized valence by phase {'odor': 53.4, 'delay': 65.18, 'act-early': 62.05, 'act-late': 59.67} | Bonferroni p: {'odor': '8.22e-05', 'delay': '7.87e-28', 'act-early': '9.8e-21', 'act-late': '5.62e-22'}
Result: reproduced. Any-p generalized valence reaches 54.1, 69.3, 64.5 and 60.2% in the four phases (7 mice, mean aggregate), all above 50% (corrected p <= 9.1e-07). The maximum aggregate and all 8 mice also give corrected p < 0.05 in every phase.
fig4h-valence-timing¶
In expert mice OB-p pseudo-populations encode generalized valence in the odor and delay phases but fall to chance in the action phases, while mPFC-p pseudo-populations encode valence in the later but not the earliest phase; the two differ in all four phases.
for label, dec in [("7 mice", DEC3), ("all 8 mice", DEC3_8)]:
for agg in ["mean", "max"]:
T, Bt = table(dec, "generalized", agg, 0.5)
sig = T.set_index(["group", "phase"]).p_vs_chance_bonf < 0.05
cond = dict(OB_odor=sig["OB", "odor"], OB_delay=sig["OB", "delay"], OB_actlate_not=not sig["OB", "act-late"],
mPFC_odor_not=not sig["mPFC", "odor"], mPFC_delay=sig["mPFC", "delay"], mPFC_ae=sig["mPFC", "act-early"],
mPFC_al=sig["mPFC", "act-late"], n_phases_between=int((Bt.p_OB_vs_mPFC_bonf < 0.05).sum()))
print(f"\n{label}, aggregate {agg}")
print(T.pivot(index="group", columns="phase", values="mean")[PH].round(2).to_string())
print(T.pivot(index="group", columns="phase", values="p_vs_chance_bonf")[PH].to_string())
print(Bt.to_string(index=False))
print(cond)
7 mice, aggregate mean
phase odor delay act-early act-late
group
OB 62.63 66.89 47.68 56.18
any 54.11 69.33 64.53 60.20
mPFC 51.99 60.11 59.82 64.19
phase odor delay act-early act-late
group
OB 1.827068e-50 8.700663e-59 1.000000e+00 1.651362e-25
any 9.094495e-07 3.626433e-37 1.778254e-30 1.764301e-23
mPFC 4.124386e-10 3.660773e-44 1.872214e-50 3.030383e-69
phase OB_minus_mPFC p_OB_vs_mPFC_bonf
odor 10.636819 1.043165e-30
delay 6.776253 3.618020e-18
act-early -12.148961 3.702767e-31
act-late -8.004955 1.597234e-26
{'OB_odor': np.True_, 'OB_delay': np.True_, 'OB_actlate_not': False, 'mPFC_odor_not': False, 'mPFC_delay': np.True_, 'mPFC_ae': np.True_, 'mPFC_al': np.True_, 'n_phases_between': 4}
7 mice, aggregate max
phase odor delay act-early act-late
group
OB 64.85 62.91 53.77 56.67
any 55.20 65.57 61.74 60.18
mPFC 49.35 65.88 59.33 61.17
phase odor delay act-early act-late
group
OB 3.776000e-67 3.431295e-37 1.403025e-11 4.665941e-26
any 1.056883e-07 1.615496e-29 3.939602e-23 6.415003e-24
mPFC 1.000000e+00 1.839013e-57 8.578146e-47 2.968256e-61
phase OB_minus_mPFC p_OB_vs_mPFC_bonf
odor 15.505326 1.922948e-33
delay -2.978759 6.152601e-04
act-early -5.561168 8.937575e-15
act-late -4.503588 5.576759e-12
{'OB_odor': np.True_, 'OB_delay': np.True_, 'OB_actlate_not': False, 'mPFC_odor_not': True, 'mPFC_delay': np.True_, 'mPFC_ae': np.True_, 'mPFC_al': np.True_, 'n_phases_between': 4}
all 8 mice, aggregate mean
phase odor delay act-early act-late
group
OB 62.00 66.96 49.27 56.12
any 53.26 69.52 64.09 59.05
mPFC 52.78 57.98 60.26 64.30
phase odor delay act-early act-late
group
OB 1.914966e-50 1.687389e-63 1.000000e+00 6.012419e-25
any 1.038863e-05 3.723390e-40 1.319417e-24 6.465145e-19
mPFC 3.888409e-11 2.910155e-38 5.665113e-48 1.447390e-66
phase OB_minus_mPFC p_OB_vs_mPFC_bonf
odor 9.215655 1.737190e-28
delay 8.980108 2.198798e-27
act-early -10.981222 5.136398e-29
act-late -8.175053 4.197195e-27
{'OB_odor': np.True_, 'OB_delay': np.True_, 'OB_actlate_not': False, 'mPFC_odor_not': False, 'mPFC_delay': np.True_, 'mPFC_ae': np.True_, 'mPFC_al': np.True_, 'n_phases_between': 4}
all 8 mice, aggregate max
phase odor delay act-early act-late
group
OB 64.99 63.01 54.06 56.94
any 53.40 65.18 62.05 59.67
mPFC 49.34 62.05 58.31 61.50
phase odor delay act-early act-late
group
OB 5.579797e-61 3.935362e-42 4.931111e-15 3.462424e-26
any 8.216433e-05 7.868251e-28 9.796588e-21 5.619908e-22
mPFC 1.000000e+00 1.225642e-50 1.179399e-39 1.556585e-55
phase OB_minus_mPFC p_OB_vs_mPFC_bonf
odor 15.649180 2.301231e-33
delay 0.965289 4.760938e-01
act-early -4.246703 1.704078e-10
act-late -4.558853 3.188503e-11
{'OB_odor': np.True_, 'OB_delay': np.True_, 'OB_actlate_not': False, 'mPFC_odor_not': True, 'mPFC_delay': np.True_, 'mPFC_ae': np.True_, 'mPFC_al': np.True_, 'n_phases_between': 3}
Result: not reproduced. With 7 mice and the mean aggregate, OB-p reaches 62.6, 66.9, 47.7 and 56.2%: above 50% in odor and delay, at chance in act-early (corrected p = 1.0), but above chance in act-late (corrected p = 1.7e-25), where the claim has it at chance. mPFC-p reaches 52.0, 60.1, 59.8 and 64.2%, above chance in delay and both action phases and also in odor (corrected p = 4.1e-10). Under the maximum aggregate mPFC-p is at chance in odor (49.4%, p = 1.0), but OB-p is still above chance in act-late (56.7%, p = 4.7e-26). OB-p and mPFC-p differ in all four phases under both aggregates. The early OB-p and late mPFC-p shape holds; the pattern of above-chance phases does not.
fig4ij-valence-correct-trials¶
Restricted to correct trials, OB-p pseudo-populations encode valence well early and much less later, mPFC-p pseudo-populations encode it more accurately late than early, and the two differ in all four phases.
Valence (unconstrained), correct trials only, 5-fold stratified cross-validation on valence. Shown on the table matched as for all trials and on the table balanced over the 4 CS (see "Trial counts and empirical chance").
for label, dec in [("7 mice", DEC3C), ("all 8 mice", DEC3C_8)]:
for agg in ["mean", "max"]:
T, Bt = table(dec, "valence", agg, 0.5)
ob = T[T.group == "OB"].set_index("phase")["mean"]
mp = T[T.group == "mPFC"].set_index("phase")
cond = dict(OB_early_gt_late=bool(min(ob["odor"], ob["delay"]) > max(ob["act-early"], ob["act-late"])),
mPFC_late_gt_early=bool(min(mp.loc["act-early", "mean"], mp.loc["act-late", "mean"]) > max(mp.loc["odor", "mean"], mp.loc["delay", "mean"])),
mPFC_odor_not_above=bool(mp.loc["odor", "p_vs_chance_bonf"] >= 0.05),
n_phases_between=int((Bt.p_OB_vs_mPFC_bonf < 0.05).sum()))
print(f"\n{label}, aggregate {agg}")
print(T.pivot(index="group", columns="phase", values="mean")[PH].round(2).to_string())
print(T.pivot(index="group", columns="phase", values="p_vs_chance_bonf")[PH].to_string())
print(Bt.to_string(index=False))
print(cond)
print("\nshuffled-label valence accuracy, correct trials (%):")
print(NULL[NULL.correct & (NULL.scheme == "valence")][["mice", "group"] + PH + ["null_95th", "CS_plus_fraction"]].to_string(index=False))
print("\nbalanced reading (each CS truncated to 3 correct pseudo-trials, 12 in all; chance from the shuffle above):")
for ag in ["mean", "max"]:
ob, mp = 100 * BAL["OB"]["valence", ag].mean(0), 100 * BAL["mPFC"]["valence", ag].mean(0)
p_mp = [min(1, 4 * stats.ttest_1samp(BAL["mPFC"]["valence", ag][:, pi], 0.5, alternative="greater").pvalue) for pi in range(4)]
p_bt = [min(1, 4 * pcx.mwu(BAL["OB"]["valence", ag][:, pi], BAL["mPFC"]["valence", ag][:, pi])) for pi in range(4)]
cond = dict(OB_early_gt_late=bool(min(ob[0], ob[1]) > max(ob[2], ob[3])), mPFC_late_gt_early=bool(min(mp[2], mp[3]) > max(mp[0], mp[1])),
mPFC_odor_not_above=bool(p_mp[0] >= 0.05), n_phases_between=int(sum(p < 0.05 for p in p_bt)))
print(f" {ag}: OB {np.round(ob, 1)}, mPFC {np.round(mp, 1)}, mPFC p against 50% {[f'{p:.2g}' for p in p_mp]}, "
f"OB against mPFC p {[f'{p:.2g}' for p in p_bt]}")
print(" ", cond)
# How the balanced accuracies compare with the shuffled-label repeats of the same table.
print("\nbalanced reading, accuracy against the 50 shuffled-label repeats of the same table:")
for g in ["OB", "mPFC"]:
for ag in ["mean", "max"]:
A, N = BAL[g]["valence", ag], BAL[g, "null"]["valence", ag]
for pi, ph in enumerate(PH):
print(f" {g:4s} {ag:4s} {ph:9s}: accuracy {100 * A[:, pi].mean():.1f}%, shuffled mean {100 * N[:, pi].mean():.1f}% "
f"(5th to 95th percentile {100 * np.percentile(N[:, pi], 5):.1f} to {100 * np.percentile(N[:, pi], 95):.1f}%), "
f"shuffled repeats below the accuracy {np.mean(N[:, pi] < A[:, pi].mean()):.2f}, two-sided Mann-Whitney p = {pcx.mwu(A[:, pi], N[:, pi]):.2g}")
7 mice, aggregate mean
phase odor delay act-early act-late
group
OB 83.47 83.70 79.40 81.87
any 73.97 86.20 86.13 84.37
mPFC 72.60 80.67 80.37 82.70
phase odor delay act-early act-late
group
OB 1.158135e-89 4.664054e-92 7.551513e-93 1.016654e-84
any 9.333745e-49 2.247979e-76 5.991762e-79 2.232753e-81
mPFC 3.375713e-61 7.016227e-77 1.584630e-80 4.770804e-100
phase OB_minus_mPFC p_OB_vs_mPFC_bonf
odor 10.866667 1.489382e-25
delay 3.033333 3.547669e-04
act-early -0.966667 2.004022e-01
act-late -0.833333 1.000000e+00
{'OB_early_gt_late': True, 'mPFC_late_gt_early': False, 'mPFC_odor_not_above': False, 'n_phases_between': 2}
7 mice, aggregate max
phase odor delay act-early act-late
group
OB 86.03 82.60 80.73 79.60
any 76.23 84.80 85.67 84.50
mPFC 71.17 76.67 80.00 79.63
phase odor delay act-early act-late
group
OB 1.451680e-88 7.724164e-86 8.235290e-96 3.609672e-80
any 3.171176e-57 1.077811e-72 1.335243e-86 6.548939e-82
mPFC 5.732405e-61 1.557417e-77 2.185690e-87 2.353945e-95
phase OB_minus_mPFC p_OB_vs_mPFC_bonf
odor 14.866667 4.444032e-31
delay 5.933333 2.401416e-13
act-early 0.733333 7.516798e-01
act-late -0.033333 1.000000e+00
{'OB_early_gt_late': True, 'mPFC_late_gt_early': True, 'mPFC_odor_not_above': False, 'n_phases_between': 2}
all 8 mice, aggregate mean
phase odor delay act-early act-late
group
OB 83.77 84.07 78.77 82.03
any 72.40 85.13 84.90 84.37
mPFC 72.47 79.03 80.73 82.47
phase odor delay act-early act-late
group
OB 9.091891e-93 4.747817e-89 4.941747e-90 7.724900e-89
any 2.247202e-47 3.644949e-71 1.045848e-78 1.331871e-80
mPFC 2.908807e-64 5.924640e-88 1.281634e-96 9.838283e-98
phase OB_minus_mPFC p_OB_vs_mPFC_bonf
odor 11.300000 5.254463e-29
delay 5.033333 6.810456e-13
act-early -1.966667 2.533400e-04
act-late -0.433333 1.000000e+00
{'OB_early_gt_late': True, 'mPFC_late_gt_early': True, 'mPFC_odor_not_above': False, 'n_phases_between': 3}
all 8 mice, aggregate max
phase odor delay act-early act-late
group
OB 85.83 81.10 80.83 79.30
any 74.97 83.87 85.10 84.33
mPFC 69.70 75.53 80.47 79.07
phase odor delay act-early act-late
group
OB 1.011710e-93 2.651391e-81 8.849814e-91 1.029143e-84
any 1.056722e-50 3.057267e-72 1.116343e-78 9.603546e-81
mPFC 6.677044e-56 5.749841e-82 4.936304e-88 4.363807e-99
phase OB_minus_mPFC p_OB_vs_mPFC_bonf
odor 16.133333 8.274781e-33
delay 5.566667 5.999116e-14
act-early 0.366667 1.000000e+00
act-late 0.233333 1.000000e+00
{'OB_early_gt_late': True, 'mPFC_late_gt_early': True, 'mPFC_odor_not_above': False, 'n_phases_between': 2}
shuffled-label valence accuracy, correct trials (%):
mice group odor delay act-early act-late null_95th CS_plus_fraction
7 mice OB 65.5 65.8 65.9 65.9 80.0 0.767
7 mice mPFC 68.0 65.5 66.2 67.5 80.0 0.767
7 mice any 66.5 66.4 66.7 67.6 80.0 0.767
all 8 mice OB 65.9 66.9 66.4 67.0 80.0 0.767
all 8 mice mPFC 69.0 66.9 66.8 65.9 80.0 0.767
all 8 mice any 67.5 66.6 66.3 67.3 76.8 0.767
balanced reading (each CS truncated to 3 correct pseudo-trials, 12 in all; chance from the shuffle above):
mean: OB [78.1 76. 56.1 54.5], mPFC [27.8 55.5 58.2 76.9], mPFC p against 50% ['1', '3.3e-06', '2.9e-10', '1.2e-62'], OB against mPFC p ['9.3e-34', '4.2e-26', '1', '2.3e-26']
{'OB_early_gt_late': True, 'mPFC_late_gt_early': True, 'mPFC_odor_not_above': True, 'n_phases_between': 3}
max: OB [78.9 70.4 55.8 55.2], mPFC [31.4 47.3 66.5 86.8], mPFC p against 50% ['1', '1', '8.1e-37', '4.7e-77'], OB against mPFC p ['7.7e-34', '1.8e-26', '1.6e-12', '1.9e-33']
{'OB_early_gt_late': True, 'mPFC_late_gt_early': True, 'mPFC_odor_not_above': True, 'n_phases_between': 4}
balanced reading, accuracy against the 50 shuffled-label repeats of the same table:
OB mean odor : accuracy 78.1%, shuffled mean 44.0% (5th to 95th percentile 16.7 to 72.2%), shuffled repeats below the accuracy 0.96, two-sided Mann-Whitney p = 9.3e-20
OB mean delay : accuracy 76.0%, shuffled mean 45.7% (5th to 95th percentile 16.7 to 70.0%), shuffled repeats below the accuracy 0.98, two-sided Mann-Whitney p = 6.7e-20
OB mean act-early: accuracy 56.1%, shuffled mean 45.9% (5th to 95th percentile 21.2 to 73.3%), shuffled repeats below the accuracy 0.74, two-sided Mann-Whitney p = 5.3e-06
OB mean act-late : accuracy 54.5%, shuffled mean 46.5% (5th to 95th percentile 16.7 to 71.8%), shuffled repeats below the accuracy 0.64, two-sided Mann-Whitney p = 0.004
OB max odor : accuracy 78.9%, shuffled mean 46.3% (5th to 95th percentile 19.7 to 78.5%), shuffled repeats below the accuracy 0.94, two-sided Mann-Whitney p = 1.2e-18
OB max delay : accuracy 70.4%, shuffled mean 42.5% (5th to 95th percentile 14.8 to 66.7%), shuffled repeats below the accuracy 0.98, two-sided Mann-Whitney p = 8.6e-19
OB max act-early: accuracy 55.8%, shuffled mean 48.7% (5th to 95th percentile 24.8 to 73.3%), shuffled repeats below the accuracy 0.66, two-sided Mann-Whitney p = 0.0025
OB max act-late : accuracy 55.2%, shuffled mean 47.5% (5th to 95th percentile 19.7 to 71.8%), shuffled repeats below the accuracy 0.76, two-sided Mann-Whitney p = 0.00064
mPFC mean odor : accuracy 27.8%, shuffled mean 51.3% (5th to 95th percentile 28.2 to 81.8%), shuffled repeats below the accuracy 0.06, two-sided Mann-Whitney p = 3e-14
mPFC mean delay : accuracy 55.5%, shuffled mean 50.1% (5th to 95th percentile 23.0 to 71.8%), shuffled repeats below the accuracy 0.58, two-sided Mann-Whitney p = 0.08
mPFC mean act-early: accuracy 58.2%, shuffled mean 47.2% (5th to 95th percentile 18.2 to 73.3%), shuffled repeats below the accuracy 0.78, two-sided Mann-Whitney p = 0.00022
mPFC mean act-late : accuracy 76.9%, shuffled mean 41.7% (5th to 95th percentile 14.8 to 68.5%), shuffled repeats below the accuracy 1.00, two-sided Mann-Whitney p = 6.8e-22
mPFC max odor : accuracy 31.4%, shuffled mean 51.0% (5th to 95th percentile 26.7 to 75.2%), shuffled repeats below the accuracy 0.12, two-sided Mann-Whitney p = 1.4e-11
mPFC max delay : accuracy 47.3%, shuffled mean 49.1% (5th to 95th percentile 18.2 to 75.2%), shuffled repeats below the accuracy 0.48, two-sided Mann-Whitney p = 0.26
mPFC max act-early: accuracy 66.5%, shuffled mean 46.5% (5th to 95th percentile 17.8 to 70.0%), shuffled repeats below the accuracy 0.88, two-sided Mann-Whitney p = 2.3e-13
mPFC max act-late : accuracy 86.8%, shuffled mean 44.9% (5th to 95th percentile 16.7 to 70.3%), shuffled repeats below the accuracy 1.00, two-sided Mann-Whitney p = 4.8e-23
Result: blocked, methods underspecified (neither correct-trial table is credibly the paper's, and the claim's pass depends on which one is used). With trials matched by CS and order and truncated per CS, the correct-trial table has 30 trials, 77% of them CS+ (17, 6, 4 and 3 per CS), and decoding with shuffled labels gives 65.5 to 69.0% for valence instead of the paper's 50%: that procedure is not the paper's. Under it OB-p reaches 83.5, 83.7, 79.4 and 81.9% (7 mice, mean), mPFC-p 72.6, 80.7, 80.4 and 82.7%, mPFC-p odor is above 50%, and the two differ in 2 or 3 of 4 phases, which would not reproduce the claim. Balancing each CS to the smallest count, 3 correct trials, leaves 12 trials and a shuffled level of 42 to 51%. Under that reading, with the maximum aggregate, OB-p reaches 78.9, 70.4, 55.8 and 55.2%, higher in odor and delay than in both action phases; mPFC-p reaches 31.4, 47.3, 66.5 and 86.8%, higher in both action phases, and is not above 50% in odor (corrected p = 1); OB-p and mPFC-p differ in all 4 phases (corrected p <= 1.6e-12). With the mean aggregate all holds except act-early (p = 1). These accuracies rest on 12 pseudo-trials. On the balanced table mPFC-p reaches 27.8% (mean) and 31.4% (maximum) in the odor phase, about 20 points below the mean shuffled level of the same table (51.3 and 51.0%); only 6% and 12% of the shuffled repeats fall below these accuracies, and over repeats the difference has Mann-Whitney p = 3e-14 and 1.4e-11. The shuffled repeats on 12 trials spread widely (5th to 95th percentiles from about 15 to 82%), and the OB-p action-phase accuracies (54.5 to 56.1%) lie well inside that spread; a 12-trial decoder that predicts systematically below its shuffled level is misbehaving, and this does not show mPFC-p at chance. The paper also reports a correct-trial valence scheme in the stability analysis across days (Figure 5F), and matched by CS and order day 1 has only 1 correct trial per CS (trial counts above), so the paper's correct-trial pseudo-populations were probably not built by CS-order matching at all. A class-weighted decoder or balanced accuracy on the matched table would put chance near 50% while keeping the matching, but the paper does not describe it. The paper's construction cannot be identified. The first record gave not reproduced on the matched table and the second reproduced on the balanced one; the third verification round agreed with blocking the claim.
figs8-generalized-valence-correct¶
Generalized valence decoding in correct trials differs between OB-p and mPFC-p pseudo-populations in the odor and act-early phases but not in the delay and act-late phases.
for label, dec in [("7 mice", DEC3C), ("all 8 mice", DEC3C_8)]:
for agg in ["mean", "max"]:
T, Bt = table(dec, "generalized", agg, 0.5)
sig = dict(zip(Bt.phase, Bt.p_OB_vs_mPFC_bonf < 0.05))
ok = sig["odor"] and sig["act-early"] and not sig["delay"] and not sig["act-late"]
print(f"{label}, {agg}:")
print(Bt.to_string(index=False))
print(" pattern (odor and act-early differ, delay and act-late do not):", ok)
print("\nshuffled-label generalized valence accuracy, correct trials (%):")
print(NULL[NULL.correct & (NULL.scheme == "generalized")][["mice", "group"] + PH + ["null_95th"]].to_string(index=False))
print("\nbalanced reading (each CS truncated to 3 correct pseudo-trials, 12 in all):")
for ag in ["mean", "max"]:
p_bt = [min(1, 4 * pcx.mwu(BAL["OB"]["generalized", ag][:, pi], BAL["mPFC"]["generalized", ag][:, pi])) for pi in range(4)]
dif = 100 * (BAL["OB"]["generalized", ag].mean(0) - BAL["mPFC"]["generalized", ag].mean(0))
sig = dict(zip(PH, [p < 0.05 for p in p_bt]))
print(f" {ag}: OB minus mPFC {np.round(dif, 1)}, p {[f'{p:.2g}' for p in p_bt]}; pattern holds: "
f"{sig['odor'] and sig['act-early'] and not sig['delay'] and not sig['act-late']}")
7 mice, mean:
phase OB_minus_mPFC p_OB_vs_mPFC_bonf
odor 8.524008 4.300801e-33
delay -9.069246 2.512880e-33
act-early -2.600794 1.515803e-06
act-late -1.999405 1.751517e-02
pattern (odor and act-early differ, delay and act-late do not): False
7 mice, max:
phase OB_minus_mPFC p_OB_vs_mPFC_bonf
odor 7.294643 1.963348e-31
delay -10.196627 1.784674e-33
act-early -1.831944 1.840100e-01
act-late -1.327976 6.986146e-05
pattern (odor and act-early differ, delay and act-late do not): False
all 8 mice, mean:
phase OB_minus_mPFC p_OB_vs_mPFC_bonf
odor 8.805754 1.667092e-31
delay -8.253373 3.340517e-31
act-early -3.194841 3.132152e-07
act-late -2.820437 5.239370e-08
pattern (odor and act-early differ, delay and act-late do not): False
all 8 mice, max:
phase OB_minus_mPFC p_OB_vs_mPFC_bonf
odor 7.413492 4.705635e-30
delay -6.397222 1.861460e-28
act-early -1.211111 1.713002e-01
act-late -1.976587 4.104361e-06
pattern (odor and act-early differ, delay and act-late do not): False
shuffled-label generalized valence accuracy, correct trials (%):
mice group odor delay act-early act-late null_95th
7 mice OB 61.7 61.3 62.1 62.7 72.0
7 mice mPFC 64.1 62.5 62.9 64.1 74.7
7 mice any 62.4 63.0 64.8 63.9 73.1
all 8 mice OB 62.8 63.4 63.6 63.7 74.3
all 8 mice mPFC 62.4 62.0 63.6 63.5 73.4
all 8 mice any 63.7 62.8 63.1 62.0 72.0
balanced reading (each CS truncated to 3 correct pseudo-trials, 12 in all):
mean: OB minus mPFC [ 28. 11.8 -2.7 -12.5], p ['7.6e-34', '6.3e-26', '6e-05', '1.2e-28']; pattern holds: False
max: OB minus mPFC [ 32.5 11. 4.3 -13.5], p ['7.4e-34', '5.1e-24', '1.9e-07', '3.8e-31']; pattern holds: False
Result: not reproduced. OB-p and mPFC-p differ in the odor phase (corrected p = 4.3e-33), as the claim says, but also in the delay (p = 2.5e-33, mPFC-p higher by 9.1 points) and in act-late (p = 0.018). Act-early differs under the mean aggregate (p = 1.5e-06) and not under the maximum (p = 0.18). The predicted pattern holds under no reading, with 7 or 8 mice. This table's shuffled level is 61 to 64%, not 50%; with each CS balanced to 3 correct trials (shuffled level 46 to 51%) all four phases differ (corrected p <= 6e-05 under the mean, <= 1.9e-07 under the maximum), so the pattern fails under that reading too.
discussion-differences-grow¶
The differences in timing of identity and valence encoding between OB-p and mPFC-p ensembles increase over the course of learning.
Figure S7A and S9 legends: per projection, task phase and day (1 to 3), the accuracies of 50 size-matched pseudo-populations (85 cells); one accuracy is drawn per day and the slope over days fitted, 1000 times; the null draws the same way with the days shuffled. Two-sided Mann-Whitney U of observed against null slopes, Bonferroni over the 4 phases. Identity and generalized valence, aggregates mean and maximum.
DAYDEC = {d: run_day(d, 50, 4500 + d, schemes=("identity", "generalized"), groups=["OB", "mPFC"]) for d in [1, 2, 3]}
rng_s = np.random.default_rng(4600)
grow = []
days = np.array([1, 2, 3])
for scheme in ["identity", "generalized"]:
for agg in ["mean", "max"]:
for g in ["OB", "mPFC"]:
for pi, ph in enumerate(PH):
A = np.stack([DAYDEC[d][g][scheme, agg][:, pi] for d in [1, 2, 3]], 1) # 50 x 3
draw = A[rng_s.integers(0, 50, (1000, 3)), np.arange(3)]
obs = np.polyfit(days, draw.T, 1)[0]
shuf = np.array([rng_s.permutation(row) for row in draw])
null = np.polyfit(days, shuf.T, 1)[0]
p = pcx.mwu(obs, null)
grow.append(dict(scheme=scheme, agg=agg, group=g, phase=ph, day1=100 * A[:, 0].mean(), day2=100 * A[:, 1].mean(),
day3=100 * A[:, 2].mean(), median_slope=100 * np.median(obs), median_null=100 * np.median(null),
p_bonf=min(1, 4 * p)))
GROW = pd.DataFrame(grow)
GROW["positive"] = (GROW.p_bonf < 0.05) & (GROW.median_slope > GROW.median_null)
print(GROW.round(4).to_string(index=False))
for scheme in ["identity", "generalized"]:
for agg in ["mean", "max"]:
d = {(r.group, r.phase): bool(r.positive) for r in GROW[(GROW.scheme == scheme) & (GROW["agg"] == agg)].itertuples()}
ok = (d["OB", "odor"] or d["OB", "delay"]) and (d["mPFC", "act-early"] or d["mPFC", "act-late"])
print(f"{scheme}, {agg}: OB positive in odor or delay and mPFC positive in an action phase: {ok}")
print("\nOB-p minus mPFC-p mean accuracy (points) by day, the difference the statement is about (not tested by the criterion):")
DIFF = GROW.pivot_table(index=["scheme", "agg", "phase"], columns="group", values=["day1", "day2", "day3"])
for dd in ["day1", "day2", "day3"]:
DIFF[("diff", dd)] = DIFF[(dd, "OB")] - DIFF[(dd, "mPFC")]
DIFF = DIFF["diff"].reindex(PH, level="phase")
DIFF["abs_grows_1_to_3"] = DIFF.day3.abs() > DIFF.day1.abs()
print(DIFF.round(1).to_string())
scheme agg group phase day1 day2 day3 median_slope median_null p_bonf positive
identity mean OB odor 37.5105 41.2933 54.0571 8.0476 -0.1905 0.0000 True
identity mean OB delay 57.1467 58.3143 74.2000 8.5238 0.2857 0.0000 True
identity mean OB act-early 66.3752 50.3371 69.9143 2.0000 0.6667 0.0227 True
identity mean OB act-late 63.3790 45.7467 56.9143 -3.0476 0.0952 0.0000 False
identity mean mPFC odor 32.4629 26.9962 36.0286 1.9524 -0.1429 0.0000 True
identity mean mPFC delay 42.1238 47.4552 52.0286 5.2381 0.0476 0.0000 True
identity mean mPFC act-early 36.8819 53.5600 64.2000 13.6667 -0.0238 0.0000 True
identity mean mPFC act-late 40.2857 47.1486 58.5429 9.3810 -0.3095 0.0000 True
identity max OB odor 41.5562 51.2000 62.6857 10.2857 -0.2619 0.0000 True
identity max OB delay 57.0514 58.0019 73.9714 8.5238 -0.1190 0.0000 True
identity max OB act-early 67.3029 50.2267 68.4857 1.2857 -0.0000 0.0388 True
identity max OB act-late 61.4781 47.2838 55.2571 -3.1190 -0.7143 0.0000 False
identity max mPFC odor 34.0952 31.2038 38.4571 2.1905 0.0476 0.0000 True
identity max mPFC delay 40.7238 51.2210 52.3143 5.8095 0.2143 0.0000 True
identity max mPFC act-early 40.2838 50.1333 61.6857 10.8571 -0.6905 0.0000 True
identity max mPFC act-late 40.6648 43.6857 60.4000 10.1429 -0.8571 0.0000 True
generalized mean OB odor 56.5059 49.1051 61.6722 2.6073 -0.2926 0.0000 True
generalized mean OB delay 63.4916 53.1331 65.9882 1.1479 0.5033 0.0042 True
generalized mean OB act-early 64.0824 52.7472 48.8798 -7.9087 0.1412 0.0000 False
generalized mean OB act-late 63.5408 58.1577 56.7095 -3.4306 0.2641 0.0000 False
generalized mean mPFC odor 58.9149 45.6137 51.8555 -3.6798 0.6445 0.0000 False
generalized mean mPFC delay 53.6326 54.5680 58.5453 2.6755 -0.0021 0.0000 True
generalized mean mPFC act-early 58.4457 56.2645 59.6809 0.6193 0.0182 0.0000 True
generalized mean mPFC act-late 57.1025 66.4460 63.7155 3.3895 -0.2469 0.0000 True
generalized max OB odor 60.8503 47.1177 64.6102 1.6680 -0.3655 0.0000 True
generalized max OB delay 66.5950 52.2603 61.8285 -2.2485 0.1053 0.0000 False
generalized max OB act-early 62.8094 56.9863 53.8648 -4.5394 0.1198 0.0000 False
generalized max OB act-late 59.6991 62.7755 58.0095 -0.9824 0.0476 0.0000 False
generalized max mPFC odor 53.7263 48.3877 50.1534 -1.7542 0.2520 0.0000 False
generalized max mPFC delay 56.2703 58.9555 65.3490 4.6743 0.2077 0.0000 True
generalized max mPFC act-early 61.3426 55.6841 58.9802 -1.1061 -0.0384 0.0000 False
generalized max mPFC act-late 60.9291 68.9908 60.9554 -0.0954 0.1639 1.0000 False
identity, mean: OB positive in odor or delay and mPFC positive in an action phase: True
identity, max: OB positive in odor or delay and mPFC positive in an action phase: True
generalized, mean: OB positive in odor or delay and mPFC positive in an action phase: True
generalized, max: OB positive in odor or delay and mPFC positive in an action phase: False
OB-p minus mPFC-p mean accuracy (points) by day, the difference the statement is about (not tested by the criterion):
group day1 day2 day3 abs_grows_1_to_3
scheme agg phase
generalized max odor 7.1 -1.3 14.5 True
delay 10.3 -6.7 -3.5 False
act-early 1.5 1.3 -5.1 True
act-late -1.2 -6.2 -2.9 True
mean odor -2.4 3.5 9.8 True
delay 9.9 -1.4 7.4 False
act-early 5.6 -3.5 -10.8 True
act-late 6.4 -8.3 -7.0 True
identity max odor 7.5 20.0 24.2 True
delay 16.3 6.8 21.7 True
act-early 27.0 0.1 6.8 False
act-late 20.8 3.6 -5.1 False
mean odor 5.0 14.3 18.0 True
delay 15.0 10.9 22.2 True
act-early 29.5 -3.2 5.7 False
act-late 23.1 -1.4 -1.6 False
Result: reproduced, resting on an assumption (sub-668 left out; only the 7-mouse analysis was run here). For identity with the mean aggregate, OB-p accuracy rises over days in the odor (median slope 8.0 points per day) and delay (8.5) phases, and mPFC-p accuracy in act-early (13.7) and act-late (9.4), all above the shuffled null with corrected p < 0.05. The same holds for identity with the maximum and for generalized valence with the mean, but not for generalized valence with the maximum. Both groups also rise in most other phases (mPFC-p identity in odor 2.0 and delay 5.2 points per day), so the criterion's test shows accuracy growing in the named phases, not the OB-p and mPFC-p difference itself growing. The difference itself, which the criterion does not test, grows from day 1 to day 3 for identity in odor (OB-p minus mPFC-p 5.0, 14.3 and 18.0 points, mean aggregate) and delay (15.0, 10.9, 22.2) and shrinks in act-early (29.5, -3.2, 5.7) and act-late (23.1, -1.4, -1.6). With 1000 resampled slopes against 1000 null slopes the Mann-Whitney test is significant for almost any shift, so these p-values say little about size.
tracked-neuron-counts¶
Longitudinal tracking across the three Go/NoGo sessions follows 46 OB-p and 41 mPFC-p neurons in 4 OB-p and 3 mPFC-p tagged mice.
The code's criteria (__determine_omni_criteria__): a cell is tracked when its identifier
(subject_global_roi_muse) is present on days 0, 1, 2 and 3, and labeled when red in at least 3
of its sessions (all of the mouse's sessions, day 4 of GNG_2023b included, as the code counts
them). Counted per projection, with the code's other criteria.
ALL = []
for exp in ["GNG_2021_dataset", "GNG_2023b_dataset"]:
sub = S[S.experiment_name == exp].copy()
sub["day"] = sub.date.rank(method="dense").astype(int) - 1
for _, r in sub.iterrows():
f = pcx.open_h5(r.asset_id)
ps = f["processing/ophys/ImageSegmentation/PlaneSegmentation"]
if "subject_global_roi_muse" not in ps:
continue
ic = ps["iscell"][:, 0] > 0
ALL.append(pd.DataFrame(dict(subject=r.subject, proj=r.projection_area, day=r.day,
muse=ps["subject_global_roi_muse"][:][ic], persist=ps["num_sessions_persisted_muse"][:][ic],
red=ps["is_redcell_finalized"][:][ic].astype(int))))
ALL = pd.concat(ALL, ignore_index=True)
print("cells with an identifier:", len(ALL), "| duplicated identifiers within a session:",
int(ALL.duplicated(["subject", "day", "muse"]).sum()))
chk = ALL.groupby(["subject", "muse"]).agg(n=("day", "size"), persist=("persist", "first"))
print("num_sessions_persisted_muse equals the recomputed count:", bool((chk.n == chk.persist).all()))
CC = ALL.sort_values("day").groupby(["subject", "proj", "muse"]).agg(days=("day", lambda x: "|".join(map(str, x))),
reds=("red", list)).reset_index()
CC["omni"] = CC.days.str.startswith("0|1|2|3")
CC["nred"] = CC.reds.apply(sum)
CC["max_s"] = CC.subject.map(ALL.groupby("subject").day.nunique())
crit = {"min_3_sessions": CC.nred >= 3, "min_1_session": CC.nred >= 1,
"first_4_sessions": CC.reds.apply(lambda x: sum(x[:4]) == 4), "all_sessions": CC.nred == CC.max_s}
for name, c in crit.items():
sel = CC[c & CC.omni]
print(f"{name:17s}", sel.groupby("proj").size().to_dict(), "| per mouse:", sel.groupby(["proj", "subject"]).size().to_dict())
print("paper: 46 OB-p and 41 mPFC-p, 4 OB-p and 3 mPFC-p mice")
# The code counts red sessions over every session, which includes day 4 of GNG_2023b; the claims file's wording is
# "red in at least 3 of them" (the four sessions, day 0 to 3). Variant: red counted over days 0 to 3 only.
sel4 = CC[CC.omni & (CC.reds.apply(lambda x: sum(x[:4])) >= 3)]
print("variant, red in at least 3 of days 0 to 3:", sel4.groupby("proj").size().to_dict(), "| per mouse:", sel4.groupby(["proj", "subject"]).size().to_dict())
TRK = CC[crit["min_3_sessions"] & CC.omni][["subject", "proj", "muse"]].reset_index(drop=True)
cells with an identifier: 8413 | duplicated identifiers within a session: 0
num_sessions_persisted_muse equals the recomputed count: True
min_3_sessions {'OB': 46, 'mPFC': 41} | per mouse: {('OB', '2400'): 20, ('OB', '2401'): 16, ('OB', '513'): 10, ('mPFC', '2456'): 13, ('mPFC', '2457'): 19, ('mPFC', '644'): 9}
min_1_session {'OB': 73, 'mPFC': 64} | per mouse: {('OB', '2400'): 26, ('OB', '2401'): 33, ('OB', '513'): 12, ('OB', '664'): 2, ('mPFC', '2456'): 18, ('mPFC', '2457'): 28, ('mPFC', '644'): 18}
first_4_sessions {'OB': 35, 'mPFC': 30} | per mouse: {('OB', '2400'): 16, ('OB', '2401'): 9, ('OB', '513'): 10, ('mPFC', '2456'): 10, ('mPFC', '2457'): 15, ('mPFC', '644'): 5}
all_sessions {'OB': 26, 'mPFC': 20} | per mouse: {('OB', '2400'): 12, ('OB', '2401'): 4, ('OB', '513'): 10, ('mPFC', '2456'): 10, ('mPFC', '2457'): 5, ('mPFC', '644'): 5}
paper: 46 OB-p and 41 mPFC-p, 4 OB-p and 3 mPFC-p mice
variant, red in at least 3 of days 0 to 3: {'OB': 43, 'mPFC': 37} | per mouse: {('OB', '2400'): 19, ('OB', '2401'): 14, ('OB', '513'): 10, ('mPFC', '2456'): 11, ('mPFC', '2457'): 17, ('mPFC', '644'): 9}
Result: reproduced. The code's criterion gives exactly 46 OB-p and 41 mPFC-p tracked neurons. They come from 3 OB-p mice (sub-664 contributes none) and 3 mPFC-p mice. The code counts red sessions over every session, including day 4 of GNG_2023b; counted over days 0 to 3 only, as the claims file words it, the counts are 43 and 37, still within tolerance. The other criteria give 73 and 64 (red in at least 1 session), 35 and 30 (red in the first 4) and 26 and 20 (red in all sessions). The stored persistence counts agree with the identifiers.
Responses of the tracked neurons¶
For each tracked neuron and task day, its trials (good CS trials) and normalized fluorescence, found by its identifier in that day's session.
TR = {} # (subject, day) -> dict(X cells x trials x frames in TRK order, trials)
for s in SES:
if s["day"] == 0 or s["subject"] not in set(TRK.subject):
continue
ids = TRK[TRK.subject == s["subject"]].muse.to_numpy()
pos = pd.Series(np.arange(len(s["cells"])), index=s["cells"].muse.to_numpy())
TR[s["subject"], s["day"]] = dict(X=s["X"][pos.loc[ids].to_numpy()][:, s["keep"]], trials=s["trials"][s["keep"]].reset_index(drop=True),
t=s["t"], fs=s["fs"], X_all=s["X"][pos.loc[ids].to_numpy()], good=s["good"])
print({k: v["X"].shape for k, v in TR.items()})
t_g = SES[0]["t"]
PHW = list(pcx.PHASES.values())
def phase_means(X, trials, by):
"""Mean over the phase and over the trials of each level of `by`: dict level -> cells x phases."""
out = {}
for lev in sorted(trials[by].unique()):
m = (trials[by] == lev).to_numpy()
out[lev] = np.stack([X[:, m][:, :, (t_g >= a) & (t_g < b)].mean((1, 2)) for a, b in PHW], 1)
return out
{('513', 1): (10, 100, 91), ('513', 2): (10, 98, 91), ('513', 3): (10, 100, 91), ('644', 1): (9, 99, 91), ('644', 2): (9, 100, 91), ('644', 3): (9, 100, 91), ('2400', 1): (20, 100, 91), ('2400', 2): (20, 99, 91), ('2400', 3): (20, 99, 91), ('2401', 1): (16, 99, 91), ('2401', 2): (16, 98, 91), ('2401', 3): (16, 100, 91), ('2456', 1): (13, 100, 91), ('2456', 2): (13, 99, 91), ('2456', 3): (13, 100, 91), ('2457', 1): (19, 99, 91), ('2457', 2): (19, 100, 91), ('2457', 3): (19, 100, 91)}
figs10d-slope-no-difference¶
Tracked OB-p and mPFC-p neurons do not differ in the average slope of their session-averaged normalized fluorescence across the three Go/NoGo days.
Per tracked neuron and combination of valence (CS+, CS-) and phase, the mean normalized fluorescence on each of days 1 to 3, and its least-squares slope over days; a mixed ANOVA with the combination (8 levels) within neurons and projection between.
rows = []
for subj in TRK.subject.unique():
proj = TRK[TRK.subject == subj].proj.iloc[0]
pm = {d: phase_means(TR[subj, d]["X"], TR[subj, d]["trials"], "valence") for d in [1, 2, 3]}
n = TRK[TRK.subject == subj].shape[0]
for v in ["reward", "none"]:
for pi, ph in enumerate(PH):
Y = np.stack([pm[d][v][:, pi] for d in [1, 2, 3]], 1)
sl = np.polyfit([1, 2, 3], Y.T, 1)[0]
for c in range(n):
rows.append(dict(neuron=f"{subj}-{c}", subject=subj, proj=proj, combo=f"{v}|{ph}", slope=sl[c]))
SL = pd.DataFrame(rows)
aov = pg.mixed_anova(SL, dv="slope", within="combo", between="proj", subject="neuron")
print(aov[["Source", "DF1", "DF2", "F", "p_unc"]].to_string(index=False))
print("mean slope per projection:", SL.groupby("proj").slope.mean().round(4).to_dict(), "| neurons:", SL.groupby("proj").neuron.nunique().to_dict())
print("per mouse mean slope:", SL.groupby(["proj", "subject"]).slope.mean().round(4).to_dict())
print("paper: projection p = 0.36, combination p = 0.11, interaction p = 0.0031")
Source DF1 DF2 F p_unc
proj 1 85 0.881544 0.350440
combo 7 595 2.083430 0.043449
Interaction 7 595 3.069509 0.003491
mean slope per projection: {'OB': -0.006, 'mPFC': 0.0077} | neurons: {'OB': 46, 'mPFC': 41}
per mouse mean slope: {('OB', '2400'): -0.0238, ('OB', '2401'): -0.0026, ('OB', '513'): 0.024, ('mPFC', '2456'): -0.0096, ('mPFC', '2457'): -0.0, ('mPFC', '644'): 0.0489}
paper: projection p = 0.36, combination p = 0.11, interaction p = 0.0031
Result: reproduced. The mixed ANOVA on slopes gives projection F = 0.88, p = 0.35 (paper 0.36), combination p = 0.043 (paper 0.11) and interaction p = 0.0035 (paper 0.0031). The mean slopes are -0.006 (OB-p) and 0.008 (mPFC-p) per day.
figs10e-sparseness-slope-no-difference¶
Changes in lifetime sparseness across sessions show no clear effect of projection target.
Per tracked neuron, phase and day, lifetime sparseness over the 4 CS of binarized activity in that phase (the odor phase with the backward exclusion, the others without, as in the Methods; both window readings); slope over days 1 to 3; mixed ANOVA with phase within and projection between. A neuron never active in a phase on some day has no sparseness there and is left out (count printed).
def sparseness_slopes(reading, seed, fill=None):
"""Per tracked neuron and phase, the slope over days 1 to 3 of lifetime sparseness over the 4 CS."""
rng_b = np.random.default_rng(seed)
rows = []
for subj in TRK.subject.unique():
proj = TRK[TRK.subject == subj].proj.iloc[0]
sess = {s["day"]: s for s in SES if s["subject"] == subj}
Bs = {d: [pcx.binarize(TR[subj, d]["X_all"], t_g, TR[subj, d]["fs"], (a, b), a == 0, rng_b, reading=reading,
trial_mask=TR[subj, d]["good"])[:, sess[d]["keep"]] for a, b in PHW] for d in [1, 2, 3]}
for pi, ph in enumerate(PH):
vals = []
for d in [1, 2, 3]:
ann = TR[subj, d]["trials"].stim_annotation.to_numpy()
r = np.stack([Bs[d][pi][:, ann == a].mean(1) for a in ["go1", "go2", "nogo1", "nogo2"]], 1)
v = pcx.vinje_gallant(r, 1)
vals.append(v if fill is None else np.nan_to_num(v, nan=fill))
V = np.stack(vals, 1)
for c in range(V.shape[0]):
rows.append(dict(neuron=f"{subj}-{c}", subject=subj, proj=proj, phase=ph,
slope=np.polyfit([1, 2, 3], V[c], 1)[0] if np.isfinite(V[c]).all() else np.nan))
return pd.DataFrame(rows)
def proj_bound(L):
"""OB-p minus mPFC-p difference of per-neuron mean slope (over phases), with a Welch 95% interval."""
m = L.dropna(subset=["slope"]).groupby(["neuron", "proj"]).slope.mean().reset_index()
a, b = m[m.proj == "OB"].slope.to_numpy(), m[m.proj == "mPFC"].slope.to_numpy()
va, vb = a.var(ddof=1) / len(a), b.var(ddof=1) / len(b)
dfw = (va + vb) ** 2 / (va ** 2 / (len(a) - 1) + vb ** 2 / (len(b) - 1))
h = stats.t.ppf(0.975, dfw) * np.sqrt(va + vb)
return f"difference {a.mean() - b.mean():+.4f} per day, 95% interval {a.mean() - b.mean() - h:+.4f} to {a.mean() - b.mean() + h:+.4f} " \
f"(SD of neuron slopes {np.concatenate([a, b]).std(ddof=1):.4f}; n = {len(a)} and {len(b)})"
for reading in ["start", "centre"]:
LSS = sparseness_slopes(reading, 4700)
bad = LSS[LSS.slope.isna()].neuron.unique()
LSc = LSS[~LSS.neuron.isin(bad)]
print(f"reading {reading}: neurons with an undefined sparseness on some phase and day: {len(bad)} of {LSS.neuron.nunique()}; "
f"kept {LSc.groupby('proj').neuron.nunique().to_dict()}")
aov_e = pg.mixed_anova(LSc, dv="slope", within="phase", between="proj", subject="neuron")
print(aov_e[["Source", "DF1", "DF2", "F", "p_unc"]].to_string(index=False))
print(" mean slope per projection:", LSc.groupby("proj").slope.mean().round(4).to_dict())
print(" bound:", proj_bound(LSc))
for fill in [0.0, 1.0]:
LSf = sparseness_slopes(reading, 4700, fill)
a_f = pg.mixed_anova(LSf, dv="slope", within="phase", between="proj", subject="neuron").set_index("Source")
print(f" variant, undefined sparseness set to {fill:.0f} (all 87 neurons): projection p = {a_f.loc['proj', 'p_unc']:.4f}, "
f"phase p = {a_f.loc['phase', 'p_unc']:.4f}, interaction p = {a_f.loc['Interaction', 'p_unc']:.4f}")
print(" bound:", proj_bound(LSf))
print("paper: projection p = 0.364, phase p = 0.0491, interaction p = 0.765")
reading start: neurons with an undefined sparseness on some phase and day: 71 of 87; kept {'OB': 10, 'mPFC': 6}
Source DF1 DF2 F p_unc
proj 1 14 1.184377 0.294847
phase 3 42 1.973600 0.132576
Interaction 3 42 0.026941 0.993939
mean slope per projection: {'OB': 0.0029, 'mPFC': -0.0296}
bound: difference +0.0324 per day, 95% interval -0.0224 to +0.0873 (SD of neuron slopes 0.0581; n = 10 and 6)
variant, undefined sparseness set to 0 (all 87 neurons): projection p = 0.0820, phase p = 0.0383, interaction p = 0.1664
bound: difference +0.0382 per day, 95% interval -0.0054 to +0.0817 (SD of neuron slopes 0.1022; n = 46 and 41)
variant, undefined sparseness set to 1 (all 87 neurons): projection p = 0.3796, phase p = 0.2010, interaction p = 0.2591
bound: difference +0.0140 per day, 95% interval -0.0176 to +0.0457 (SD of neuron slopes 0.0740; n = 46 and 41)
reading centre: neurons with an undefined sparseness on some phase and day: 79 of 87; kept {'OB': 5, 'mPFC': 3}
Source DF1 DF2 F p_unc
proj 1 6 0.574954 0.477014
phase 3 18 0.308103 0.819215
Interaction 3 18 0.219138 0.881830
mean slope per projection: {'OB': 0.0335, 'mPFC': -0.0173}
bound: difference +0.0508 per day, 95% interval -0.1235 to +0.2251 (SD of neuron slopes 0.0889; n = 5 and 3)
variant, undefined sparseness set to 0 (all 87 neurons): projection p = 0.0479, phase p = 0.0007, interaction p = 0.1169
bound: difference +0.0410 per day, 95% interval -0.0002 to +0.0822 (SD of neuron slopes 0.0968; n = 46 and 41)
variant, undefined sparseness set to 1 (all 87 neurons): projection p = 0.4493, phase p = 0.1628, interaction p = 0.2026
bound: difference +0.0121 per day, 95% interval -0.0197 to +0.0439 (SD of neuron slopes 0.0740; n = 46 and 41)
paper: projection p = 0.364, phase p = 0.0491, interaction p = 0.765
Result: reproduced, resting on an assumption. Most tracked neurons are never active in some phase on some day, so their sparseness is undefined. Leaving those neurons out gives projection p = 0.29 (start reading, 16 neurons kept) and p = 0.48 (centre reading, 8 kept). With all 87 neurons and an undefined sparseness set to 1, p = 0.38 and 0.45; set to 0, p = 0.082 and 0.048. Only that last variant finds a projection effect. The test has little power: the OB-p minus mPFC-p difference of mean slope is +0.032 per day with a 95% interval of -0.022 to +0.087 (start, 16 neurons; neuron slopes have SD 0.058), and +0.014 (-0.018 to +0.046) with all 87 neurons and undefined values set to 1. So the data do not exclude a difference of several hundredths per day; the absence of an effect is only shown in the sense of the criterion.
fig5c-cv-higher-obp¶
Tracked OB-p neurons show a higher coefficient of variation of session-averaged fluorescence across days than mPFC-p neurons.
Per tracked neuron and combination, the CV over days 1 to 3 of the session-averaged normalized fluorescence (SD with ddof 0, a standard choice). The combination is odor (CS) by phase, 16 levels, as the amended criterion has it (questions/000785.yaml: the Results name "combinations of odors and task phases", and Figure S10F compares CV "across different odors and phases"); valence by phase, 8 levels, is shown as a variant only. Readings of the CV: (c) SD over the absolute mean or (d) SD over the mean. Mixed ANOVA, combination within, projection between. Per-condition two-sided Mann-Whitney U with Benjamini-Hochberg correction (Figure S10F) reported.
CVR = []
# The criterion uses odor (CS) by phase, 16 levels; valence by phase, 8 levels, is a variant only.
for comb, by in [("main: CS x phase", "stim_annotation"), ("variant: valence x phase", "valence")]:
rows = []
for subj in TRK.subject.unique():
proj = TRK[TRK.subject == subj].proj.iloc[0]
pm = {d: phase_means(TR[subj, d]["X"], TR[subj, d]["trials"], by) for d in [1, 2, 3]}
for lev in pm[1]:
for pi, ph in enumerate(PH):
Y = np.stack([pm[d][lev][:, pi] for d in [1, 2, 3]], 1)
for c in range(Y.shape[0]):
rows.append(dict(neuron=f"{subj}-{c}", subject=subj, proj=proj, combo=f"{lev}|{ph}",
sd=Y[c].std(), mean=Y[c].mean()))
D = pd.DataFrame(rows)
print(f"{comb}: {D.neuron.nunique()} neurons, {D.combo.nunique()} combinations, "
f"{(D['mean'] < 0).sum()} of {len(D)} means negative, {(D['mean'].abs() < 0.01).sum()} with |mean| < 0.01, "
f"mean range {D['mean'].min():.3f} to {D['mean'].max():.3f}")
for cvn, f in [("c: SD/|mean|", lambda d: d.sd / d["mean"].abs()), ("d: SD/mean", lambda d: d.sd / d["mean"])]:
D["cv"] = f(D)
aov_c = pg.mixed_anova(D, dv="cv", within="combo", between="proj", subject="neuron")
a = aov_c.set_index("Source")
med = D.groupby("proj").cv.median()
pcs = [pcx.mwu(D[(D.combo == cb) & (D.proj == "OB")].cv, D[(D.combo == cb) & (D.proj == "mPFC")].cv) for cb in D.combo.unique()]
rej, qv = pg.multicomp(np.array(pcs), method="fdr_bh")
CVR.append(dict(reading=comb + ", " + cvn, p_projection=a.loc["proj", "p_unc"], p_combo=a.loc["combo", "p_unc"],
p_interaction=a.loc["Interaction", "p_unc"], median_OB=med["OB"], median_mPFC=med["mPFC"],
mean_OB=D[D.proj == "OB"].cv.mean(), mean_mPFC=D[D.proj == "mPFC"].cv.mean(),
n_conditions_BH=int(rej.sum()), n_conditions=len(pcs)))
if cvn.startswith("c"):
pm_ = {k: round(float(v), 3) for k, v in D.groupby(["proj", "subject"]).cv.median().items()}
print(" median CV per mouse (" + cvn + "):", pm_)
print(" CV range", round(float(D.cv.min()), 3), "to", round(float(D.cv.max()), 3))
CVR = pd.DataFrame(CVR)
print(CVR.round(4).to_string(index=False))
ok = (CVR.p_projection < 0.05) & (CVR.median_OB > CVR.median_mPFC)
print("projection p < 0.05 with OB median higher, per reading:", dict(zip(CVR.reading, ok)))
print("criterion (CS x phase under both CV readings):", bool(ok[CVR.reading.str.startswith("main")].all()))
print("paper: projection p = 0.0127, combination p = 0.0372, interaction p = 0.43")
main: CS x phase: 87 neurons, 16 combinations, 0 of 1392 means negative, 0 with |mean| < 0.01, mean range 0.198 to 1.677
median CV per mouse (c: SD/|mean|): {('OB', '2400'): 0.224, ('OB', '2401'): 0.223, ('OB', '513'): 0.265, ('mPFC', '2456'): 0.195, ('mPFC', '2457'): 0.187, ('mPFC', '644'): 0.212}
CV range 0.002 to 0.771
variant: valence x phase: 87 neurons, 8 combinations, 0 of 696 means negative, 0 with |mean| < 0.01, mean range 0.240 to 1.395
median CV per mouse (c: SD/|mean|): {('OB', '2400'): 0.158, ('OB', '2401'): 0.165, ('OB', '513'): 0.17, ('mPFC', '2456'): 0.136, ('mPFC', '2457'): 0.145, ('mPFC', '644'): 0.158}
CV range 0.012 to 0.587
reading p_projection p_combo p_interaction median_OB median_mPFC mean_OB mean_mPFC n_conditions_BH n_conditions
main: CS x phase, c: SD/|mean| 0.0115 0.0124 0.4615 0.2300 0.1929 0.2437 0.2139 0 16
main: CS x phase, d: SD/mean 0.0115 0.0124 0.4615 0.2300 0.1929 0.2437 0.2139 0 16
variant: valence x phase, c: SD/|mean| 0.0672 0.3247 0.5887 0.1617 0.1452 0.1801 0.1589 0 8
variant: valence x phase, d: SD/mean 0.0672 0.3247 0.5887 0.1617 0.1452 0.1801 0.1589 0 8
projection p < 0.05 with OB median higher, per reading: {'main: CS x phase, c: SD/|mean|': True, 'main: CS x phase, d: SD/mean': True, 'variant: valence x phase, c: SD/|mean|': False, 'variant: valence x phase, d: SD/mean': False}
criterion (CS x phase under both CV readings): True
paper: projection p = 0.0127, combination p = 0.0372, interaction p = 0.43
Result: reproduced. Under the criterion's combination, odor (CS) by phase with 16 levels, the projection effect has p = 0.0115 (paper 0.0127) with the OB-p median CV higher (0.230 against 0.193); the combination effect has p = 0.012 (paper 0.037) and the interaction p = 0.46 (paper 0.43). Every session-averaged mean is positive (0.198 to 1.677), so the two CV readings give identical values. Each of the 3 OB-p mice has a higher median CV (0.223 to 0.265) than each of the 3 mPFC-p mice (0.187 to 0.212). The valence-by-phase variant, no longer part of the criterion, gives projection p = 0.067 with the OB-p median still higher (0.162 against 0.145). No per-condition test survives Benjamini-Hochberg correction (0 of 16), as in Figure S10F.
fig5e-transferability¶
Identity decoding transfers across sessions comparably in tracked OB-p and mPFC-p ensembles, whereas generalized valence decoding transfers better in mPFC-p ensembles, especially across distal sessions.
Per mouse, a linear SVM on its tracked projection neurons is trained on one (day, phase) and
tested on another, days 1 to 3 and the 4 phases (pcx.transfer_matrix: within a day, 5-fold
stratified cross-validation; across days, all trials). Only same-phase and adjacent-phase pairs
are grouped: within session, proximal (consecutive days) and distal (day 1 and day 3). Samples
of the two-sided Mann-Whitney U test (a) every qualifying entry of every mouse, (b) per mouse
means; Bonferroni over the 3 groups; aggregates mean and maximum. Matrices for valence and
correct-trial valence are computed too, for fig5f-stability.
rng_t = np.random.default_rng(4800)
TM = {}
for subj in TRK.subject.unique():
for agg in ["mean", "max"]:
for scheme, correct in [("identity", False), ("generalized", False), ("valence", False), ("valence", True)]:
resp, anns = [], []
for d in [1, 2, 3]:
v = TR[subj, d]
m = np.ones(len(v["trials"]), bool)
if correct:
m = v["trials"].outcome_relabel.isin(["hit", "correct_rejection"]).to_numpy()
resp.append(pcx.phase_features(v["X"][:, m], t_g, PHW, agg))
anns.append(v["trials"].stim_annotation.to_numpy()[m])
name = scheme + (" correct" if correct else "")
TM[subj, agg, name] = pcx.transfer_matrix(resp, anns, scheme if scheme != "valence" else "valence", rng_t)
print("matrices:", len(TM), "| shape", next(iter(TM.values())).shape,
"| entries not fitted (a class missing from training):", {k: int(np.isnan(v).sum()) for k, v in TM.items() if np.isnan(v).any()})
PROJ = TRK.drop_duplicates("subject").set_index("subject").proj
def qualifying(M):
out = {"within": [], "proximal": [], "distal": []}
for i in range(3):
for j in range(3):
for p in range(4):
for q in range(4):
if abs(p - q) > 1:
continue
k = {0: "within", 1: "proximal", 2: "distal"}[abs(i - j)]
out[k].append(M[i * 4 + p, j * 4 + q])
return out
matrices: 48 | shape (12, 12) | entries not fitted (a class missing from training): {}
res5e = []
for name in ["identity", "generalized"]:
for agg in ["mean", "max"]:
Q = {subj: qualifying(TM[subj, agg, name]) for subj in PROJ.index}
for grp in ["within", "proximal", "distal"]:
ob_a = np.concatenate([Q[s][grp] for s in PROJ.index if PROJ[s] == "OB"])
mp_a = np.concatenate([Q[s][grp] for s in PROJ.index if PROJ[s] == "mPFC"])
ob_b = [np.mean(Q[s][grp]) for s in PROJ.index if PROJ[s] == "OB"]
mp_b = [np.mean(Q[s][grp]) for s in PROJ.index if PROJ[s] == "mPFC"]
res5e.append(dict(scheme=name, agg=agg, group=grp, OB_mean=100 * ob_a.mean(), mPFC_mean=100 * mp_a.mean(),
n_OB=len(ob_a), n_mPFC=len(mp_a), p_entries_bonf=min(1, 3 * pcx.mwu(ob_a, mp_a)),
p_mice_bonf=min(1, 3 * pcx.mwu(ob_b, mp_b)),
per_mouse=dict((s, round(100 * np.mean(Q[s][grp]), 1)) for s in PROJ.index)))
R5E = pd.DataFrame(res5e)
print(R5E.drop(columns="per_mouse").round(4).to_string(index=False))
print(R5E[["scheme", "agg", "group", "per_mouse"]].to_string(index=False))
for agg in ["mean", "max"]:
for samp in ["p_entries_bonf", "p_mice_bonf"]:
idn = R5E[(R5E.scheme == "identity") & (R5E["agg"] == agg)].set_index("group")
gv = R5E[(R5E.scheme == "generalized") & (R5E["agg"] == agg)].set_index("group")
ok = (idn.loc["proximal", samp] >= 0.05) and (idn.loc["distal", samp] >= 0.05) and \
(gv.loc["distal", "mPFC_mean"] > gv.loc["distal", "OB_mean"]) and (gv.loc["distal", samp] < 0.05)
print(f"{agg}, {samp}: identity proximal and distal not different, generalized distal mPFC higher with p < 0.05: {ok}")
print("\nreading (a) leaving out one mouse at a time (corrected p of OB-p against mPFC-p; mPFC-p minus OB-p mean, points):")
rows = []
for out in PROJ.index:
keep_m = [s for s in PROJ.index if s != out]
r = dict(left_out=f"sub-{out} ({PROJ[out]})")
for name, grp in [("identity", "proximal"), ("identity", "distal"), ("generalized", "distal")]:
for agg in ["mean", "max"]:
Q = {s: qualifying(TM[s, agg, name]) for s in keep_m}
ob = np.concatenate([Q[s][grp] for s in keep_m if PROJ[s] == "OB"])
mp = np.concatenate([Q[s][grp] for s in keep_m if PROJ[s] == "mPFC"])
r[f"{name[:3]} {grp} {agg}"] = f"{min(1, 3 * pcx.mwu(ob, mp)):.2g} ({100 * (mp.mean() - ob.mean()):+.1f})"
rows.append(r)
print(pd.DataFrame(rows).to_string(index=False))
scheme agg group OB_mean mPFC_mean n_OB n_mPFC p_entries_bonf p_mice_bonf
identity mean within 35.3175 32.4351 90 90 0.0514 1.0
identity mean proximal 30.0468 30.1928 120 120 1.0000 1.0
identity mean distal 31.0687 30.0407 60 60 1.0000 1.0
identity max within 37.0673 32.7497 90 90 0.0005 1.0
identity max proximal 30.0473 30.4750 120 120 1.0000 1.0
identity max distal 32.0232 30.0079 60 60 0.5415 1.0
generalized mean within 55.2655 54.2440 90 90 1.0000 1.0
generalized mean proximal 51.7407 52.2833 120 120 1.0000 1.0
generalized mean distal 48.3396 55.8938 60 60 0.0000 0.6
generalized max within 55.8784 55.1882 90 90 1.0000 1.0
generalized max proximal 51.5654 53.1079 120 120 0.0593 1.0
generalized max distal 48.5682 55.6357 60 60 0.0000 0.6
scheme agg group per_mouse
identity mean within {'2400': 31.5, '2401': 36.7, '2456': 34.2, '2457': 27.9, '513': 37.8, '644': 35.2}
identity mean proximal {'2400': 27.6, '2401': 31.7, '2456': 32.4, '2457': 31.6, '513': 30.9, '644': 26.6}
identity mean distal {'2400': 24.0, '2401': 37.1, '2456': 33.3, '2457': 26.3, '513': 32.1, '644': 30.5}
identity max within {'2400': 31.0, '2401': 39.6, '2456': 34.0, '2457': 28.9, '513': 40.6, '644': 35.4}
identity max proximal {'2400': 28.1, '2401': 30.3, '2456': 32.8, '2457': 31.3, '513': 31.8, '644': 27.3}
identity max distal {'2400': 25.2, '2401': 38.3, '2456': 33.9, '2457': 26.3, '513': 32.5, '644': 29.8}
generalized mean within {'2400': 50.8, '2401': 52.7, '2456': 57.6, '2457': 48.8, '513': 62.3, '644': 56.3}
generalized mean proximal {'2400': 51.9, '2401': 46.1, '2456': 56.6, '2457': 50.9, '513': 57.3, '644': 49.4}
generalized mean distal {'2400': 47.3, '2401': 45.7, '2456': 60.6, '2457': 50.1, '513': 52.0, '644': 57.0}
generalized max within {'2400': 53.0, '2401': 52.2, '2456': 57.6, '2457': 50.3, '513': 62.4, '644': 57.6}
generalized max proximal {'2400': 52.0, '2401': 45.7, '2456': 56.5, '2457': 51.9, '513': 57.0, '644': 51.0}
generalized max distal {'2400': 48.3, '2401': 46.1, '2456': 61.7, '2457': 48.8, '513': 51.4, '644': 56.4}
mean, p_entries_bonf: identity proximal and distal not different, generalized distal mPFC higher with p < 0.05: True
mean, p_mice_bonf: identity proximal and distal not different, generalized distal mPFC higher with p < 0.05: False
max, p_entries_bonf: identity proximal and distal not different, generalized distal mPFC higher with p < 0.05: True
max, p_mice_bonf: identity proximal and distal not different, generalized distal mPFC higher with p < 0.05: False
reading (a) leaving out one mouse at a time (corrected p of OB-p against mPFC-p; mPFC-p minus OB-p mean, points):
left_out ide proximal mean ide proximal max ide distal mean ide distal max gen distal mean gen distal max
sub-2400 (OB) 0.77 (-1.1) 1 (-0.6) 0.0062 (-4.6) 0.00015 (-5.4) 2.5e-06 (+7.0) 9.1e-06 (+6.9)
sub-2401 (OB) 1 (+1.0) 1 (+0.6) 0.24 (+2.0) 0.88 (+1.1) 2.5e-06 (+6.2) 7.4e-05 (+5.8)
sub-2456 (mPFC) 1 (-0.9) 0.93 (-0.7) 0.59 (-2.7) 0.041 (-4.0) 6.2e-06 (+5.2) 0.0019 (+4.0)
sub-2457 (mPFC) 1 (-0.6) 1 (+0.0) 0.98 (+0.9) 1 (-0.1) 5.5e-12 (+10.4) 2.6e-12 (+10.5)
sub-513 (OB) 1 (+0.6) 0.58 (+1.3) 1 (-0.5) 1 (-1.8) 5.1e-10 (+9.4) 4e-08 (+8.5)
sub-644 (mPFC) 0.09 (+1.9) 0.082 (+2.0) 1 (-1.3) 0.74 (-1.9) 2.6e-05 (+7.0) 0.00019 (+6.7)
Result: reproduced. With every qualifying entry as a sample (reading a), identity transfer does not differ between OB-p and mPFC-p for proximal (30.0 against 30.2%, corrected p = 1.0) or distal sessions (31.1 against 30.0%, p = 1.0). Distal generalized valence is higher for mPFC-p (55.9 against 48.3%, corrected p < 0.0001). The maximum aggregate gives the same. With per-mouse means (3 against 3 mice) no comparison can reach significance (smallest corrected p = 0.6). Reading (a) treats correlated entries of 3 mice per group as independent. Leaving out one mouse at a time, distal generalized valence stays higher for mPFC-p (corrected p <= 0.0019 under both aggregates), but the identity part fails without sub-2400 (OB-p higher for distal sessions, corrected p = 0.0062 with the mean and 0.00015 with the maximum aggregate) and, under the maximum, without sub-2456 (p = 0.041). It holds in 5 of the 6 leave-one-out sets under the mean aggregate and in 4 of 6 under the maximum. Within session, OB-p identity is higher under the maximum (37.1 against 32.7%, p = 0.0005), in the direction of the paper's within-session result.
fig5f-stability¶
The temporal structure of valence coding across sessions is more stable in tracked mPFC-p than OB-p ensembles, while odor identity coding is not.
From the per-mouse transfer matrices: each 4 by 4 block (train day, test day) flattened, Pearson correlations between pairs of blocks. Readings: pairs (a) all pairs of the 9 blocks or (b) pairs sharing the training day; samples (c) every correlation of every mouse or (d) per mouse means. Two-sided Mann-Whitney U of OB-p against mPFC-p, Bonferroni over the 4 schemes.
def block_corrs(M, pairing):
blocks = {(i, j): M[i * 4:(i + 1) * 4, j * 4:(j + 1) * 4].ravel() for i in range(3) for j in range(3)}
keys = list(blocks)
out = []
for a in range(len(keys)):
for b in range(a + 1, len(keys)):
if pairing == "b" and keys[a][0] != keys[b][0]:
continue
x, y = blocks[keys[a]], blocks[keys[b]]
ok = np.isfinite(x) & np.isfinite(y) # entries that could not be fitted are left out
x, y = x[ok], y[ok]
out.append(np.corrcoef(x, y)[0, 1] if ok.sum() > 2 and x.std() > 0 and y.std() > 0 else np.nan)
return np.array(out)
res5f = []
for agg in ["mean", "max"]:
for pairing in ["a", "b"]:
for samp in ["c", "d"]:
for name in ["identity", "valence", "generalized", "valence correct"]:
C = {s: block_corrs(TM[s, agg, name], pairing) for s in PROJ.index}
if samp == "c":
ob = np.concatenate([C[s] for s in PROJ.index if PROJ[s] == "OB"])
mp = np.concatenate([C[s] for s in PROJ.index if PROJ[s] == "mPFC"])
else:
ob = np.array([np.nanmean(C[s]) for s in PROJ.index if PROJ[s] == "OB"])
mp = np.array([np.nanmean(C[s]) for s in PROJ.index if PROJ[s] == "mPFC"])
res5f.append(dict(agg=agg, reading=pairing + samp, scheme=name, OB_mean_r=np.nanmean(ob), mPFC_mean_r=np.nanmean(mp),
n_OB=int(np.isfinite(ob).sum()), n_mPFC=int(np.isfinite(mp).sum()), p_bonf=min(1, 4 * pcx.mwu(ob, mp))))
R5F = pd.DataFrame(res5f)
print(R5F.round(4).to_string(index=False))
for (agg, rd), d in R5F.groupby(["agg", "reading"]):
d = d.set_index("scheme")
ok = all((d.loc[n, "mPFC_mean_r"] > d.loc[n, "OB_mean_r"]) and (d.loc[n, "p_bonf"] < 0.05) for n in ["valence", "generalized", "valence correct"]) \
and d.loc["identity", "p_bonf"] >= 0.05
print(f"{agg}, reading {rd}: valence schemes mPFC higher with p < 0.05 and identity not different: {ok}")
agg reading scheme OB_mean_r mPFC_mean_r n_OB n_mPFC p_bonf mean ac identity 0.3578 0.3498 108 108 1.0000 mean ac valence 0.3179 0.3727 108 108 0.3788 mean ac generalized 0.1790 0.2933 108 108 0.1093 mean ac valence correct 0.1353 0.3194 108 108 0.0034 mean ad identity 0.3578 0.3498 3 3 1.0000 mean ad valence 0.3179 0.3727 3 3 1.0000 mean ad generalized 0.1790 0.2933 3 3 1.0000 mean ad valence correct 0.1353 0.3194 3 3 1.0000 mean bc identity 0.3836 0.3435 27 27 1.0000 mean bc valence 0.4071 0.4052 27 27 1.0000 mean bc generalized 0.2976 0.4224 27 27 0.3733 mean bc valence correct 0.3151 0.3540 27 27 1.0000 mean bd identity 0.3836 0.3435 3 3 1.0000 mean bd valence 0.4071 0.4052 3 3 1.0000 mean bd generalized 0.2976 0.4224 3 3 1.0000 mean bd valence correct 0.3151 0.3540 3 3 1.0000 max ac identity 0.2678 0.2885 108 108 1.0000 max ac valence 0.2878 0.3532 108 108 0.1289 max ac generalized 0.1451 0.3147 108 108 0.0015 max ac valence correct 0.1243 0.3034 108 108 0.0014 max ad identity 0.2678 0.2885 3 3 1.0000 max ad valence 0.2878 0.3532 3 3 1.0000 max ad generalized 0.1451 0.3147 3 3 1.0000 max ad valence correct 0.1243 0.3034 3 3 0.8000 max bc identity 0.2976 0.3171 27 27 1.0000 max bc valence 0.2998 0.3821 27 27 1.0000 max bc generalized 0.2056 0.3762 27 27 0.2879 max bc valence correct 0.1802 0.3729 27 27 0.0378 max bd identity 0.2976 0.3171 3 3 1.0000 max bd valence 0.2998 0.3821 3 3 1.0000 max bd generalized 0.2056 0.3762 3 3 1.0000 max bd valence correct 0.1802 0.3729 3 3 1.0000 max, reading ac: valence schemes mPFC higher with p < 0.05 and identity not different: False max, reading ad: valence schemes mPFC higher with p < 0.05 and identity not different: False max, reading bc: valence schemes mPFC higher with p < 0.05 and identity not different: False max, reading bd: valence schemes mPFC higher with p < 0.05 and identity not different: False mean, reading ac: valence schemes mPFC higher with p < 0.05 and identity not different: False mean, reading ad: valence schemes mPFC higher with p < 0.05 and identity not different: False mean, reading bc: valence schemes mPFC higher with p < 0.05 and identity not different: False mean, reading bd: valence schemes mPFC higher with p < 0.05 and identity not different: False
Result: not reproduced. Under no combination of readings do all three valence schemes differ, which the criterion requires. With all block pairs, every correlation as a sample and the maximum aggregate, mPFC-p is more stable for generalized valence (r 0.31 against 0.15, corrected p = 0.0015) and correct-trial valence (0.30 against 0.12, p = 0.0014), but not for valence (0.35 against 0.29, p = 0.13), and identity does not differ (p = 1.0). mPFC-p has the higher mean correlation in 22 of the 24 valence comparisons. With per-mouse means no test is significant.
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 |
|---|---|
| fig4c-behavior-learning | not reproduced (day effect not significant, F = 1.57) |
| fig4c-anticipatory-licking | reproduced |
| fig4def-identity-decoding-gng | reproduced |
| fig4g-valence-any | reproduced |
| fig4h-valence-timing | not reproduced (OB-p above chance in act-late) |
| fig4ij-valence-correct-trials | blocked: methods underspecified (neither correct-trial table is credibly the paper's, and the outcome depends on which is used) |
| figs8-generalized-valence-correct | not reproduced |
| discussion-differences-grow | reproduced, resting on an assumption (sub-668 left out) |
| tracked-neuron-counts | reproduced |
| figs10d-slope-no-difference | reproduced |
| figs10e-sparseness-slope-no-difference | reproduced, resting on an assumption |
| fig5c-cv-higher-obp | reproduced (odor by phase, as the amended criterion has it) |
| fig5e-transferability | reproduced |
| fig5f-stability | not reproduced (unconstrained valence not more stable) |
How the analysis differs from the paper's. The main analyses leave out sub-668, the fourth mPFC mouse, which the paper's 7 mice do not seem to include (an assumption). Pseudo-population trials are matched by CS and order and truncated to the smallest count, which leaves 9 trials for one CS on day 3 (shuffled-label identity accuracy 26 to 29% against the paper's 25%). The correct-trial table matched that way is 77% CS+, so its valence chance is about 66%, not the paper's 50%; a table balanced over the 4 CS (3 trials each, chance about 50%) is also run. On that table mPFC-p odor valence decoding falls about 20 points below the shuffled level, so neither table credibly repeats the paper's procedure, and fig4ij-valence-correct-trials is blocked. Within-session transfer uses 5-fold stratified cross-validation, which the paper does not state. Neurons without a defined lifetime sparseness are left out of the sparseness slopes (variants shown).
What was found about the dataset. The Go/NoGo experiment has 8 mice, one more mPFC-tagged mouse (sub-668, without tracking identifiers and with 24 to 58 cells per session) than the paper's 7. Its day 3 performance (90%) passes the paper's exclusion threshold, so the dandiset does not say why it is not in the paper. The stated imaging rate of the GNG_2023b files is 50 or 100 Hz where the timestamps give 4.51 to 4.52 Hz. The tracking identifiers reproduce the paper's 46 and 41 tracked projection neurons exactly. Two identity sessions (sub-164 and sub-8, both 2020-06-24) each hold a plane whose mean image nearly repeats another plane of the same file (r = 0.994 and 0.996); these are planes without red cells, which the paper's code skips, so the duplication is consistent with the code's rule but is not marked in the files. No recording is deposited twice across files.