Reproducing Daume et al. (2024) from dandiset 001187¶
Paper: Daume, Kaminski, Salimpour, Gomez Palacio Schjetnan, Anderson, Valiante, Mamelak and Rutishauser (2024), "Persistent activity during working memory maintenance predicts long-term memory formation in the human hippocampus", Neuron 112, 3957-3968, doi:10.1016/j.neuron.2024.09.013.
Dataset: DANDI:001187, version 0.240904.2347 (doi:10.48324/dandi.001187/0.240904.2347). This is the version the paper cites (Data and Code Availability; key resources table), and it is the only published version; the draft has the same 46 assets and size.
Claims: claims/001187/10.1016-j.neuron.2024.09.013.yaml, written from the accepted author
manuscript in PubMed Central (PMC11624075) with its supplement (Figures S1 to S4, Table S1),
and checked by a second reader. Method details the claims file lacks are taken from the paper
or its code (github.com/rutishauserlab/SBCAT-NO-release-NWB, commit 6d07204) and cited where
used, here and in sbcat.py.
| Claim | Tested or blocked |
|---|---|
| sessions-and-neurons, table-s1-counts | tested |
| behaviour-overall-accuracy, fig1c to fig1g, ltm-rt-confidence | tested |
| category-neuron-counts, fig2b, fig2c, fig2e, fig2f | tested (fig2c, fig2e, fig2f blocked after testing: the readings disagree) |
| fig3a to fig3h (nine claims) | tested |
| ms-neuron-counts, fig4b, fig4c, fig4d, fig4e, fig4f | tested (fig4f blocked after testing: the readings disagree) |
The new LTM pictures have no category in the dataset's metadata; for fig4d their categories are taken from their images in the files (see that section).
Every number below is computed from the streamed files. Seeds are fixed, one generator per claim section.
import time
import numpy as np
import pandas as pd
import sbcat
T0 = time.time()
pd.set_option("display.width", 200)
pd.set_option("display.max_columns", 30)
pd.set_option("display.max_rows", 200)
print("dandiset", sbcat.DANDISET, "version", sbcat.VERSION)
dandiset 001187 version 0.240904.2347
Data check¶
Every NWB file of the pinned version is streamed; the trial tables, the raw event times, the electrode locations and the spike times are read (not the waveforms or the stimulus images).
S = sbcat.load_all()
print(len(S), "sessions loaded in", round(time.time() - T0), "s")
46 sessions loaded in 49 s
rows = []
for si, s in enumerate(S):
ltm, wm = s["ltm"], s["wm"]
conf = ltm.confidence.values
resp_old = conf >= 4
rows.append(dict(
session=s["identifier"], subject=s["subject_id"], ses=s["session_id"], age=s["age"],
sex=s["sex"], institution=s["institution"], units=len(s["spikes"]),
hipp=int(sum(sbcat.area_of(l) == "hippocampus" for l in s["units"].location)),
amyg=int(sum(sbcat.area_of(l) == "amygdala" for l in s["units"].location)),
wm_trials=len(wm), load1=int((wm.loads == 1).sum()), load3=int((wm.loads == 3).sum()),
ltm_trials=len(ltm), ltm_old=int((ltm.new_old == 1).sum()),
conf_values="".join(str(v) for v in np.unique(conf)),
acc_mismatch=int(np.sum((resp_old == (ltm.new_old.values == 1)).astype(int)
!= ltm.response_accuracy.values)),
unsorted_units=len(s["unsorted_units"]),
variant=s["notes"].split("Experiment variant: ")[1][0]))
SES = pd.DataFrame(rows)
print(SES.to_string())
print("\nsessions", len(SES), "subjects", SES.subject.nunique(), "units", SES.units.sum(),
"hippocampus", SES.hipp.sum(), "amygdala", SES.amyg.sum())
print("locations:", sorted({l for s in S for l in s["units"].location}))
print("institutions in the files:", SES.institution.unique().tolist())
print("sessions by identifier suffix (site):",
pd.Series([s.split("_")[-1].lstrip("P0123456789") for s in SES.session]).value_counts().to_dict())
print("sessions with fewer than 400 LTM trials:",
SES.loc[SES.ltm_trials < 400, ["session", "ltm_trials", "ltm_old"]].values.tolist())
print("sessions with fewer than 140 WM trials:",
SES.loc[SES.wm_trials < 140, ["session", "wm_trials"]].values.tolist())
print("confidence values outside 1 to 6:",
[(s["identifier"], int(v), int(np.sum(s["ltm"].confidence == v)))
for s in S for v in np.unique(s["ltm"].confidence) if v < 1 or v > 6])
print("trials whose accuracy disagrees with 'old' = confidence 4 to 6:", SES.acc_mismatch.sum())
print("units with unsorted spike times:", SES.unsorted_units.sum(),
[(s["identifier"], s["unsorted_units"]) for s in S if s["unsorted_units"]])
allwm = pd.concat([s["wm"] for s in S])
allltm = pd.concat([s["ltm"] for s in S])
print("\nWM response time (s): %.3f to %.3f, median %.3f" % (allwm.response_time.min(),
allwm.response_time.max(), allwm.response_time.median()))
print("LTM response time (s): %.3f to %.3f, median %.3f" % (allltm.response_time.min(),
allltm.response_time.max(), allltm.response_time.median()))
print("maintenance length (probe - maintenance onset, s): %.3f to %.3f" % (
(allwm.timestamps_Probe - allwm.timestamps_Maintenance).min(),
(allwm.timestamps_Probe - allwm.timestamps_Maintenance).max()))
enc = allwm.timestamps_Encoding1_end - allwm.timestamps_Encoding1
print("encoding picture 1 duration (s): %.3f to %.3f" % (enc.min(), enc.max()))
print("maintenance onset - end of last picture (s): max abs %.4f" % np.max(np.abs(
allwm.timestamps_Maintenance - np.where(allwm.loads == 1, allwm.timestamps_Encoding1_end,
allwm.timestamps_Encoding3_end))))
print("picture categories (leading digit):", sorted(np.unique(allwm.PicIDs_Encoding1 // 100)))
print("LTM load values:", sorted(allltm.load.unique()), " num_times_shown:",
sorted(allltm.num_times_shown.unique()))
print("load of new pictures:", sorted(allltm.load[allltm.new_old == 0].unique()),
" num_times_shown of new:", sorted(allltm.num_times_shown[allltm.new_old == 0].unique()))
session subject ses age sex institution units hipp amyg wm_trials load1 load3 ltm_trials ltm_old conf_values acc_mismatch unsorted_units variant
0 sub-1_ses-2_P54CS 1 2 P59Y F Cedars-Sinai Medical Center 24 7 17 140 70 70 400 200 123456 0 0 2
1 sub-10_ses-1_P68CS 10 1 P54Y M Cedars-Sinai Medical Center 23 16 7 140 70 70 400 200 123456 0 0 1
2 sub-11_ses-1_P69CS 11 1 P41Y F Cedars-Sinai Medical Center 15 8 7 139 70 69 400 200 16 0 0 1
3 sub-12_ses-1_P70CS 12 1 P30Y F Cedars-Sinai Medical Center 15 1 14 140 70 70 400 200 13456 0 0 1
4 sub-12_ses-2_P70CS 12 2 P30Y F Cedars-Sinai Medical Center 6 1 5 140 70 70 161 78 123456 0 0 3
5 sub-13_ses-1_P71CS 13 1 P40Y M Cedars-Sinai Medical Center 3 0 3 140 70 70 400 200 123456 0 2 1
6 sub-14_ses-1_P73CS 14 1 P58Y F Cedars-Sinai Medical Center 22 5 17 140 70 70 400 200 1256 0 0 1
7 sub-15_ses-1_P74CS 15 1 P23Y M Cedars-Sinai Medical Center 9 0 9 140 70 70 400 200 123456 0 0 1
8 sub-16_ses-1_P76CS 16 1 P24Y F Cedars-Sinai Medical Center 31 6 25 140 70 70 395 197 123456 0 0 1
9 sub-16_ses-2_P76CS 16 2 P24Y F Cedars-Sinai Medical Center 4 0 4 140 70 70 400 200 123456 0 0 3
10 sub-17_ses-1_P77CS 17 1 P46Y F Cedars-Sinai Medical Center 45 4 41 140 70 70 390 197 123456 0 0 1
11 sub-18_ses-1_P78CS 18 1 P54Y F Cedars-Sinai Medical Center 27 13 14 140 70 70 384 190 123456 0 0 1
12 sub-19_ses-1_P79CS 19 1 P42Y F Cedars-Sinai Medical Center 45 17 28 140 70 70 400 200 1256 0 0 1
13 sub-19_ses-2_P79CS 19 2 P42Y F Cedars-Sinai Medical Center 32 13 19 140 70 70 400 200 123456 0 0 3
14 sub-2_ses-1_P55CS 2 1 P43Y F Cedars-Sinai Medical Center 22 1 21 140 70 70 400 200 123456 0 0 1
15 sub-2_ses-2_P55CS 2 2 P43Y F Cedars-Sinai Medical Center 33 8 25 140 70 70 400 200 123456 0 2 2
16 sub-20_ses-1_P80CS 20 1 P24Y O Cedars-Sinai Medical Center 62 13 49 140 70 70 400 200 123456 0 0 1
17 sub-21_ses-1_P82CS 21 1 P42Y M Cedars-Sinai Medical Center 34 17 17 140 70 70 400 200 123456 0 0 1
18 sub-22_ses-1_P088TWH 22 1 P26Y M Cedars-Sinai Medical Center 28 22 6 140 70 70 257 127 123456 0 0 1
19 sub-23_ses-1_P089TWH 23 1 P45Y F Cedars-Sinai Medical Center 40 22 18 140 70 70 187 89 13456 0 0 1
20 sub-24_ses-2_P090TWH 24 2 P20Y M Cedars-Sinai Medical Center 13 11 2 140 70 70 400 200 1234567 0 1 2
21 sub-24_ses-3_P090TWH 24 3 P20Y M Cedars-Sinai Medical Center 13 13 0 140 70 70 400 200 123456 0 0 3
22 sub-25_ses-1_P093TWH 25 1 P23Y M Cedars-Sinai Medical Center 7 4 3 140 70 70 400 200 123456 0 0 1
23 sub-26_ses-1_P096TWH 26 1 P58Y F Cedars-Sinai Medical Center 11 6 5 140 70 70 228 115 123456 0 0 1
24 sub-27_ses-1_P101TWH 27 1 P25Y F Cedars-Sinai Medical Center 21 16 5 140 70 70 400 200 1256 0 0 1
25 sub-27_ses-2_P101TWH 27 2 P25Y F Cedars-Sinai Medical Center 14 8 6 140 70 70 400 200 1256 0 0 3
26 sub-28_ses-1_P103TWH 28 1 P49Y M Cedars-Sinai Medical Center 31 20 11 140 70 70 399 199 1256 0 0 1
27 sub-29_ses-1_P106TWH 29 1 P26Y M Cedars-Sinai Medical Center 21 7 14 140 70 70 400 200 123456 0 0 1
28 sub-3_ses-2_P57CS 3 2 P46Y M Cedars-Sinai Medical Center 28 4 24 140 70 70 400 200 123456 0 0 2
29 sub-30_ses-1_P109TWH 30 1 P28Y M Cedars-Sinai Medical Center 22 15 7 140 70 70 400 200 123456 0 0 1
30 sub-31_ses-1_P110TWH 31 1 P38Y M Cedars-Sinai Medical Center 16 6 10 140 70 70 400 200 123456 0 0 1
31 sub-32_ses-2_P113TWH 32 2 P36Y M Cedars-Sinai Medical Center 18 11 7 140 70 70 400 200 123456 0 0 2
32 sub-33_ses-1_P116TWH 33 1 P28Y M Cedars-Sinai Medical Center 27 9 18 140 70 70 400 200 123456 0 0 1
33 sub-34_ses-1_P1802JHU 34 1 P62Y M Cedars-Sinai Medical Center 12 12 0 140 70 70 400 200 123456 0 0 1
34 sub-35_ses-1_P1809JHU 35 1 P45Y M Cedars-Sinai Medical Center 1 1 0 140 70 70 400 200 1346 0 0 2
35 sub-36_ses-1_P1811JHU 36 1 P27Y F Cedars-Sinai Medical Center 10 10 0 140 70 70 400 200 123456 0 0 1
36 sub-37_ses-1_P1814JHU 37 1 P48Y M Cedars-Sinai Medical Center 8 8 0 140 70 70 400 200 123456 0 0 1
37 sub-38_ses-1_P1903JHU 38 1 P30Y M Cedars-Sinai Medical Center 2 2 0 140 70 70 400 200 123456 0 0 1
38 sub-39_ses-1_P1912JHU 39 1 P49Y M Cedars-Sinai Medical Center 16 16 0 140 70 70 400 200 123456 0 0 1
39 sub-4_ses-1_P58CS 4 1 P32Y F Cedars-Sinai Medical Center 29 2 27 140 70 70 400 200 123456 0 0 1
40 sub-5_ses-1_P61CS 5 1 P52Y F Cedars-Sinai Medical Center 23 12 11 140 70 70 400 200 123456 0 0 1
41 sub-5_ses-2_P61CS 5 2 P52Y F Cedars-Sinai Medical Center 9 1 8 140 70 70 400 200 123456 0 0 2
42 sub-6_ses-1_P62CS 6 1 P25Y F Cedars-Sinai Medical Center 22 3 19 140 70 70 400 200 123456 0 0 1
43 sub-7_ses-1_P64CS 7 1 P63Y F Cedars-Sinai Medical Center 17 0 17 140 70 70 400 200 123456 0 0 1
44 sub-8_ses-1_P65CS 8 1 P55Y F Cedars-Sinai Medical Center 27 9 18 140 70 70 400 200 123456 0 0 1
45 sub-9_ses-1_P67CS 9 1 P38Y F Cedars-Sinai Medical Center 12 0 12 140 70 70 400 200 123456 0 0 1
sessions 46 subjects 39 units 950 hippocampus 380 amygdala 570
locations: [np.str_('amygdala_left'), np.str_('amygdala_right'), np.str_('hippocampus_left'), np.str_('hippocampus_right')]
institutions in the files: ['Cedars-Sinai Medical Center']
sessions by identifier suffix (site): {'CS': 26, 'TWH': 14, 'JHU': 6}
sessions with fewer than 400 LTM trials: [['sub-12_ses-2_P70CS', 161, 78], ['sub-16_ses-1_P76CS', 395, 197], ['sub-17_ses-1_P77CS', 390, 197], ['sub-18_ses-1_P78CS', 384, 190], ['sub-22_ses-1_P088TWH', 257, 127], ['sub-23_ses-1_P089TWH', 187, 89], ['sub-26_ses-1_P096TWH', 228, 115], ['sub-28_ses-1_P103TWH', 399, 199]]
sessions with fewer than 140 WM trials: [['sub-11_ses-1_P69CS', 139]]
confidence values outside 1 to 6: [('sub-24_ses-2_P090TWH', 7, 1)]
trials whose accuracy disagrees with 'old' = confidence 4 to 6: 0
units with unsorted spike times: 5 [('sub-13_ses-1_P71CS', [1, 2]), ('sub-2_ses-2_P55CS', [19, 29]), ('sub-24_ses-2_P090TWH', [10])]
WM response time (s): 0.135 to 56.289, median 1.265
LTM response time (s): 0.001 to 129.615, median 1.859
maintenance length (probe - maintenance onset, s): 2.530 to 3.203
encoding picture 1 duration (s): 1.567 to 2.036
maintenance onset - end of last picture (s): max abs 0.0001
picture categories (leading digit): [np.uint16(1), np.uint16(2), np.uint16(3), np.uint16(4), np.uint16(5)]
LTM load values: [np.uint8(0), np.uint8(1), np.uint8(3)] num_times_shown: [np.uint8(0), np.uint8(1), np.uint8(2)]
load of new pictures: [np.uint8(0)] num_times_shown of new: [np.uint8(0)]
Event clock. The trial tables and the spikes are checked against each other below, by the response of the units to picture onset (the category selection decodes the picture category from spikes aligned to the WM table's picture onsets; shifting the onsets removes it), see the cell after the category selection.
Units and the rate filter (claims U)¶
rows = []
for si, s in enumerate(S):
for ui, loc in enumerate(s["units"].location):
wmr, ltmr = sbcat.global_rates(s["spikes"][ui], s["raw_WM"], s["raw_LTM"])
rows.append(dict(si=si, ui=ui, session=s["identifier"], patient=s["subject_id"],
location=loc, area=sbcat.area_of(loc), rate_wm=wmr, rate_ltm=ltmr))
UN = pd.DataFrame(rows)
UN["keep"] = (UN.rate_wm >= 0.1) & (UN.rate_ltm >= 0.1)
print("global WM rate (Hz): %.3f to %.2f; LTM rate: %.3f to %.2f" % (
UN.rate_wm.min(), UN.rate_wm.max(), UN.rate_ltm.min(), UN.rate_ltm.max()))
print(UN.groupby("area").keep.agg(["size", "sum"]))
K = UN[UN.keep].reset_index(drop=True)
print("kept", len(K), "removed", int((~UN.keep).sum()))
global WM rate (Hz): 0.000 to 15.15; LTM rate: 0.000 to 15.71
size sum
area
amygdala 570 532
hippocampus 380 351
kept 883 removed 67
Duplicate recordings. Two sessions could hold the same recording deposited twice. For every pair of sessions, the trial tables and the spike trains are compared.
dups = []
sig = [(s["identifier"], s["wm"].timestamps_Encoding1.values, s["wm"].PicIDs_Encoding1.values,
[len(x) for x in s["spikes"]]) for s in S]
for i in range(len(S)):
for j in range(i + 1, len(S)):
same_pics = np.array_equal(sig[i][2], sig[j][2])
same_times = len(sig[i][1]) == len(sig[j][1]) and np.allclose(sig[i][1] - sig[i][1][0],
sig[j][1] - sig[j][1][0])
common_counts = len(set(sig[i][3]) & set(sig[j][3]) - {0})
if same_times or common_counts > 2:
dups.append((sig[i][0], sig[j][0], same_pics, same_times, common_counts))
print("session pairs with identical WM timing or more than 2 units of identical spike counts:", dups)
same_order = pd.Series([tuple(s["wm"].PicIDs_Encoding1) for s in S]).duplicated(keep=False)
print("sessions sharing the same picture sequence (expected for one task variant):",
int(same_order.sum()))
session pairs with identical WM timing or more than 2 units of identical spike counts: [] sessions sharing the same picture sequence (expected for one task variant): 45
Checks of the description against the data, from the outputs above. The confidence column is described as 1 to 6 with no coding; the accuracy column agrees in every trial with 1 to 3 meaning "new" and 4 to 6 "old" (shown). One trial has the value 7 (shown); it counts as "old" under that coding, which agrees with its accuracy. The LTM table's load is 0 for new pictures and num_times_shown 0 for new pictures (shown). Response times are in seconds (0.135 to 56 s in WM; up to 130 s in LTM, where the picture stays until a response). The maintenance period lasts 2.53 to 3.20 s (the Methods say 2.55 to 2.85 s) and starts at the end of the last picture. Picture 1 lasts 1.57 to 2.04 s where the Methods say 2 s. The files name Cedars-Sinai for every session, which the identifiers contradict (shown). No session pair shares its trial timing or spike counts, so no recording is deposited twice; the 45 sessions sharing one picture sequence are the same task version. The same units are taken to be recorded in both tasks of a session (one sorting per session, as the Methods say). The clock check after the category selection supports a shared clock of spikes and trial tables where sessions have enough units.
Claim sessions-and-neurons¶
After excluding two sessions, 46 sessions are analysed, in which 883 single units pass the 0.1 Hz rate filter, 351 in the hippocampus and 532 in the amygdala, of 950 isolated.
S1 = sbcat.table_s1()
print("sessions in the dandiset:", len(S), "(Table S1 lists", len(S1), "kept sessions)")
print("isolated units:", len(UN), " Table S1 recorded total:", S1.h_rec.sum() + S1.a_rec.sum())
print("after the rate filter: hippocampus", int(K.area.eq("hippocampus").sum()),
" amygdala", int(K.area.eq("amygdala").sum()))
print("removed by the filter:", int((~UN.keep).sum()), "(%.1f%%)" % (100 * (~UN.keep).mean()))
print("Table S1 sums: hippocampus", S1.h_rec.sum(), " amygdala", S1.a_rec.sum())
sessions in the dandiset: 46 (Table S1 lists 46 kept sessions) isolated units: 950 Table S1 recorded total: 973 after the rate filter: hippocampus 351 amygdala 532 removed by the filter: 67 (7.1%) Table S1 sums: hippocampus 386 amygdala 587
Result: reproduced. The dandiset holds 46 sessions and 950 units; the rate filter removes 67 (7.1%) and leaves 351 hippocampal and 532 amygdala units, as the paper states. The recorded counts of Table S1 sum to 973.
Claim table-s1-counts¶
Per session, the numbers of recorded units in the hippocampus and the amygdala are those of Table S1.
Sessions are matched by the label in the file identifier (P54CS with session 2 is P54cs_2).
SES["label"] = [sbcat.s1_label(x) for x in SES.session]
kept_counts = K.groupby(["session", "area"]).size().unstack(fill_value=0)
SES["hipp_kept"] = SES.session.map(kept_counts.get("hippocampus", {})).fillna(0).astype(int)
SES["amyg_kept"] = SES.session.map(kept_counts.get("amygdala", {})).fillna(0).astype(int)
SES["wm_acc"] = [100 * s["wm"].response_accuracy.mean() for s in S]
SES["ltm_acc"] = [100 * s["ltm"].response_accuracy.mean() for s in S]
TS1 = SES.merge(S1, on="label", how="outer", indicator=True)
print("matched:", (TS1._merge == "both").sum(), " only in dandiset:",
TS1.label[TS1._merge == "left_only"].tolist(), " only in Table S1:",
TS1.label[TS1._merge == "right_only"].tolist())
TS1 = TS1[TS1._merge == "both"].copy()
TS1["match_before"] = (TS1.hipp == TS1.h_rec) & (TS1.amyg == TS1.a_rec)
TS1["match_after"] = (TS1.hipp_kept == TS1.h_rec) & (TS1.amyg_kept == TS1.a_rec)
TS1["match_either"] = TS1.match_before | TS1.match_after
print("sessions matching before the filter:", int(TS1.match_before.sum()), "after:",
int(TS1.match_after.sum()), "under either:", int(TS1.match_either.sum()), "of", len(TS1))
print(TS1.loc[~TS1.match_either, ["label", "session", "hipp", "hipp_kept", "h_rec", "amyg",
"amyg_kept", "a_rec"]].to_string())
dwm, dltm = TS1.wm_acc_x - TS1.wm_acc_y, TS1.ltm_acc_x - TS1.ltm_acc_y
print("\naccuracy against Table S1 (a check of the session match): max |WM diff| %.2f, "
"max |LTM diff| %.2f points" % (dwm.abs().max(), dltm.abs().max()))
print(TS1.loc[(dwm.abs() > 0.15) | (dltm.abs() > 0.15),
["label", "wm_acc_x", "wm_acc_y", "ltm_acc_x", "ltm_acc_y", "ltm_trials"]].round(2).to_string())
matched: 46 only in dandiset: [] only in Table S1: []
sessions matching before the filter: 42 after: 21 under either: 42 of 46
label session hipp hipp_kept h_rec amyg amyg_kept a_rec
9 P1809jh sub-35_ses-1_P1809JHU 1 1 6 0 0 0
20 P61cs_2 sub-5_ses-2_P61CS 1 1 2 8 8 8
25 P68cs sub-10_ses-1_P68CS 16 14 16 7 7 17
39 P82cs sub-21_ses-1_P82CS 17 16 17 17 15 24
accuracy against Table S1 (a check of the session match): max |WM diff| 0.18, max |LTM diff| 1.52 points
label wm_acc_x wm_acc_y ltm_acc_x ltm_acc_y ltm_trials
2 P103T 96.43 96.4 61.65 61.5 399
26 P69cs 74.82 75.0 64.75 64.8 400
32 P76cs 99.29 99.3 78.99 78.5 395
40 P88T 99.29 99.3 77.82 76.3 257
41 P89T 97.14 97.1 56.15 57.0 187
Result: partially reproduced. 42 of the 46 sessions match Table S1's recorded counts before the rate filter (21 after it). Four differ: P1809jh (1 hippocampal unit against 6), P61cs_2 (1 against 2), P68cs (7 amygdala units against 17) and P82cs (17 against 24); the 23 missing units are the difference between Table S1's 973 and the 950 of the text. The session match is confirmed by the accuracies, which differ from Table S1 by at most 0.18 points (WM) and 1.52 points (LTM, in sessions with incomplete LTM tables).
Behaviour¶
Per session measures (claims S, L). High confidence is a rating of 1 or 6 (sure), low confidence 2 to 5. Sessions "with confidence ratings" leave out the one session whose ratings are only 1 and 6 (printed below), the patient the paper says "did not use confidence ratings" (Results, paragraph 2); the paper's code drops it the same way, as its low-confidence accuracy is undefined (plot_behavior.m).
from scipy.stats import norm
rows = []
for s in S:
wm, ltm = s["wm"], s["ltm"]
conf = ltm.confidence.values
old = ltm.new_old.values == 1
said_old = conf >= 4
acc = ltm.response_accuracy.values.astype(float)
hi = (conf == 1) | (conf == 6)
unsure = (conf == 2) | (conf == 5)
guess = (conf == 3) | (conf == 4)
lo = ~hi
rt = ltm.response_time.values
rt5 = np.where(rt > 5, np.nan, rt)
wrt = wm.response_time.values
wrt5 = np.where(wrt > 5, np.nan, wrt)
hit, fa = said_old[old].mean(), said_old[~old].mean()
nh, nf = old.sum(), (~old).sum()
hit_c = min(max(hit, 1 / (2 * nh)), 1 - 1 / (2 * nh))
fa_c = min(max(fa, 1 / (2 * nf)), 1 - 1 / (2 * nf))
L = ltm.load.values
nts = ltm.num_times_shown.values
rows.append(dict(
session=s["identifier"], wm_acc=wm.response_accuracy.mean(), ltm_acc=acc.mean(),
hit=hit, fa=fa, dprime=norm.ppf(hit_c) - norm.ppf(fa_c), rate_corrected=(hit != hit_c) or (fa != fa_c),
wm_acc_l1=wm.response_accuracy[wm.loads == 1].mean(), wm_acc_l3=wm.response_accuracy[wm.loads == 3].mean(),
wm_rt_l1=np.nanmean(wrt5[wm.loads == 1]), wm_rt_l3=np.nanmean(wrt5[wm.loads == 3]),
wm_rt_l1_all=np.mean(wrt[wm.loads == 1]), wm_rt_l3_all=np.mean(wrt[wm.loads == 3]),
n_hi=hi.sum(), n_unsure=unsure.sum(), n_guess=guess.sum(),
acc_hi=acc[hi].mean() if hi.any() else np.nan,
acc_lo_pooled=acc[lo].mean() if lo.any() else np.nan,
acc_lo_avg=np.nanmean([acc[unsure].mean() if unsure.any() else np.nan,
acc[guess].mean() if guess.any() else np.nan]) if lo.any() else np.nan,
rt_hi_all=rt[hi].mean(), rt_lo_pooled_all=rt[lo].mean() if lo.any() else np.nan,
rt_lo_avg_all=np.nanmean([rt[unsure].mean() if unsure.any() else np.nan,
rt[guess].mean() if guess.any() else np.nan]) if lo.any() else np.nan,
rt_hi_5=np.nanmean(rt5[hi]), rt_lo_pooled_5=np.nanmean(rt5[lo]) if lo.any() else np.nan,
rt_lo_avg_5=np.nanmean([np.nanmean(rt5[unsure]) if unsure.any() else np.nan,
np.nanmean(rt5[guess]) if guess.any() else np.nan]) if lo.any() else np.nan,
hit_l1=said_old[old & (L == 1)].mean(), hit_l3=said_old[old & (L == 3)].mean(),
hit_twice=said_old[old & (nts == 2)].mean(), hit_once=said_old[old & (nts == 1)].mean()))
BEH = pd.DataFrame(rows)
noconf = BEH.session[BEH.n_hi == [len(s["ltm"]) for s in S]].tolist()
print("sessions whose ratings are all high confidence:", noconf)
BEHC = BEH[~BEH.session.isin(noconf)]
print("sessions with confidence ratings:", len(BEHC))
print("sessions without guessing ratings:", BEHC.session[BEHC.n_guess == 0].tolist())
print(BEH.describe().T[["count", "mean", "std", "min", "max"]].round(3).to_string())
sessions whose ratings are all high confidence: ['sub-11_ses-1_P69CS'] sessions with confidence ratings: 45 sessions without guessing ratings: ['sub-14_ses-1_P73CS', 'sub-19_ses-1_P79CS', 'sub-27_ses-1_P101TWH', 'sub-27_ses-2_P101TWH', 'sub-28_ses-1_P103TWH']
count mean std min max wm_acc 46.0 0.933 0.076 0.707 1.000 ltm_acc 46.0 0.703 0.099 0.558 0.900 hit 46.0 0.664 0.192 0.180 0.935 fa 46.0 0.259 0.132 0.025 0.595 dprime 46.0 1.189 0.620 0.353 2.617 wm_acc_l1 46.0 0.951 0.074 0.729 1.000 wm_acc_l3 46.0 0.916 0.085 0.671 1.000 wm_rt_l1 46.0 1.393 0.511 0.616 2.745 wm_rt_l3 46.0 1.525 0.449 0.697 2.882 wm_rt_l1_all 46.0 1.706 1.053 0.616 6.416 wm_rt_l3_all 46.0 1.689 0.658 0.697 3.625 n_hi 46.0 234.587 107.569 6.000 400.000 n_unsure 46.0 74.283 52.555 0.000 229.000 n_guess 46.0 73.739 85.247 0.000 335.000 acc_hi 46.0 0.770 0.134 0.564 1.000 acc_lo_pooled 45.0 0.614 0.102 0.370 0.889 acc_lo_avg 45.0 0.625 0.107 0.369 0.889 rt_hi_all 46.0 2.193 1.122 0.667 6.107 rt_lo_pooled_all 45.0 3.565 1.980 0.925 9.573 rt_lo_avg_all 45.0 3.655 2.032 0.921 9.702 rt_hi_5 46.0 1.830 0.576 0.652 3.514 rt_lo_pooled_5 45.0 2.618 0.648 0.925 3.773 rt_lo_avg_5 45.0 2.659 0.651 0.921 3.814 hit_l1 46.0 0.686 0.212 0.176 0.978 hit_l3 46.0 0.658 0.190 0.174 0.941 hit_twice 46.0 0.721 0.189 0.200 0.983 hit_once 46.0 0.640 0.199 0.157 0.914
/tmp/ipykernel_2496/1844796046.py:38: RuntimeWarning: Mean of empty slice rt_lo_avg_5=np.nanmean([np.nanmean(rt5[unsure]) if unsure.any() else np.nan,
Claim behaviour-overall-accuracy¶
Patients answered 93.3% of WM trials and 70.3% of LTM trials correctly (d' 1.19), both above the 50% chance level.
rng = np.random.default_rng(101)
for col, exp, tol in [("wm_acc", 93.3, 1.1), ("ltm_acc", 70.3, 1.4)]:
v = 100 * BEH[col]
t, p, df = sbcat.perm_ttest_1samp(v, 50, rng)
print(f"{col}: mean {v.mean():.2f} % (SD {v.std(ddof=1):.2f}), expected {exp} +- {tol}, "
f"within: {abs(v.mean() - exp) <= tol}; against 50%: t({df}) = {t:.2f}, perm p = {p:.3g} (below 0.0001: {p < 1e-4})")
print(f"d': mean {BEH.dprime.mean():.3f} (SD {BEH.dprime.std(ddof=1):.3f}), expected 1.19 +- 0.09, "
f"within: {abs(BEH.dprime.mean() - 1.19) <= 0.09}; sessions with a hit or FA rate of 0 or 1 "
f"(1/(2N) applied): {int(BEH.rate_corrected.sum())}")
print("smallest p a 10,000-permutation test gives here: %.3g" % (2 * 0.5 / 10001))
wm_acc: mean 93.33 % (SD 7.60), expected 93.3 +- 1.1, within: True; against 50%: t(45) = 38.67, perm p = 0.0001 (below 0.0001: True)
ltm_acc: mean 70.32 % (SD 9.89), expected 70.3 +- 1.4, within: True; against 50%: t(45) = 13.93, perm p = 0.0001 (below 0.0001: True) d': mean 1.189 (SD 0.620), expected 1.19 +- 0.09, within: True; sessions with a hit or FA rate of 0 or 1 (1/(2N) applied): 0 smallest p a 10,000-permutation test gives here: 0.0001
Result: reproduced. Mean WM accuracy 93.33% (SD 7.60), LTM accuracy 70.32% (SD 9.89) and d' 1.189 (SD 0.620) are within tolerance, and both accuracies exceed 50% at the smallest p a 10,000-permutation test gives (below 0.0001).
Claim fig1c-wm-accuracy-load¶
WM accuracy is higher in load 1 than in load 3 trials.
rng = np.random.default_rng(102)
t, p, df = sbcat.perm_ttest_paired(BEH.wm_acc_l1, BEH.wm_acc_l3, rng)
print(f"load 1 {100*BEH.wm_acc_l1.mean():.2f} %, load 3 {100*BEH.wm_acc_l3.mean():.2f} %; "
f"t({df}) = {t:.2f} (paper 4.89), perm p = {p:.3g} (below 0.0001: {p < 1e-4}); sessions with load 1 higher: "
f"{int((BEH.wm_acc_l1 > BEH.wm_acc_l3).sum())}, equal {int((BEH.wm_acc_l1 == BEH.wm_acc_l3).sum())}")
load 1 95.09 %, load 3 91.58 %; t(45) = 4.91 (paper 4.89), perm p = 0.0001 (below 0.0001: True); sessions with load 1 higher: 32, equal 8
Result: reproduced. Load 1 accuracy 95.09% against 91.58% for load 3, t(45) = 4.91 (paper 4.89), permutation p below 0.0001.
Claim fig1d-wm-rt-load¶
WM responses are faster in load 1 than in load 3 trials.
from scipy.stats import t as st_t
rng = np.random.default_rng(103)
for lab, a, b in [("RT > 5 s missing (main)", "wm_rt_l1", "wm_rt_l3"),
("all RTs (variant)", "wm_rt_l1_all", "wm_rt_l3_all")]:
t, p, df = sbcat.perm_ttest_paired(BEH[a], BEH[b], rng)
print(f"{lab}: load 1 {BEH[a].mean():.3f} s, load 3 {BEH[b].mean():.3f} s; t({df}) = {t:.2f} "
f"(paper -4.29), perm p = {p:.3g} (below 0.0001: {p < 1e-4})")
print("WM trials with RT > 5 s:", int(sum((s["wm"].response_time > 5).sum() for s in S)))
# The criterion's bar, p < 0.0001, lies at the resolution of a 10,000-permutation test, so the
# p that test estimates is computed here with 2,000,000 sign flips (two-sided, |t| at least the
# observed), and the 10,000-permutation p is shown over 100 seeds.
d = (BEH.wm_rt_l1 - BEH.wm_rt_l3).values
t_obs = sbcat.t_paired(d)
rng = np.random.default_rng(1031)
exceed = sum(int(np.sum(np.abs(sbcat.t_paired(rng.choice([-1.0, 1.0], size=(100000, d.size)) * d))
>= abs(t_obs))) for _ in range(20))
print(f"main reading, 2,000,000 permutations: {exceed} with |t| >= {abs(t_obs):.3f}, "
f"p = {exceed / 2000000:.2e} (95% upper bound {(exceed + 1.96 * np.sqrt(exceed)) / 2000000:.2e}); "
f"parametric t(45) p = {2 * st_t.sf(abs(t_obs), 45):.2e}")
p10k = np.array([sbcat.perm_ttest_paired(BEH.wm_rt_l1, BEH.wm_rt_l3, np.random.default_rng(s))[1]
for s in range(100)])
print(f"10,000 permutations over 100 seeds: p below 0.0001 in {int(np.sum(p10k < 1e-4))}, "
f"median p {np.median(p10k):.3g}, largest {p10k.max():.3g}")
RT > 5 s missing (main): load 1 1.393 s, load 3 1.525 s; t(45) = -4.28 (paper -4.29), perm p = 0.0003 (below 0.0001: False) all RTs (variant): load 1 1.706 s, load 3 1.689 s; t(45) = 0.20 (paper -4.29), perm p = 0.859 (below 0.0001: False) WM trials with RT > 5 s: 197
main reading, 2,000,000 permutations: 119 with |t| >= 4.279, p = 5.95e-05 (95% upper bound 7.02e-05); parametric t(45) p = 9.67e-05
10,000 permutations over 100 seeds: p below 0.0001 in 63, median p 0.0001, largest 0.0007
Result: reproduced. With response times above 5 s set to missing, load 1 is faster (1.393 against 1.525 s), t(45) = -4.28 as in the paper (-4.29). The criterion's bar, p < 0.0001, lies at the resolution of a 10,000-permutation test: the draw printed first gives p = 0.0003, and over 100 seeds 63 draws give p below 0.0001. With 2,000,000 permutations the p the test estimates is 6.0e-05 (95% upper bound 7.0e-05), below 0.0001, so the claim is graded reproduced. With all response times (variant), there is no difference (t = 0.20).
Claim fig1e-ltm-confidence-accuracy¶
LTM recognition is more accurate in high-confidence than in low-confidence trials.
rng = np.random.default_rng(104)
for lab, col in [("(a) unsure and guessing pooled", "acc_lo_pooled"),
("(b) mean of unsure and guessing accuracy", "acc_lo_avg")]:
t, p, df = sbcat.perm_ttest_paired(BEHC.acc_hi, BEHC[col], rng)
print(f"{lab}: high {100*BEHC.acc_hi.mean():.2f} %, low {100*BEHC[col].mean():.2f} %; "
f"t({df}) = {t:.2f} (paper 8.66), perm p = {p:.3g} (below 0.0001: {p < 1e-4})")
(a) unsure and guessing pooled: high 77.31 %, low 61.40 %; t(44) = 8.51 (paper 8.66), perm p = 0.0001 (below 0.0001: True) (b) mean of unsure and guessing accuracy: high 77.31 %, low 62.48 %; t(44) = 7.34 (paper 8.66), perm p = 0.0001 (below 0.0001: True)
Result: reproduced. High-confidence accuracy 77.31% against 61.40% (pooled low, t(44) = 8.51) or 62.48% (averaged, t(44) = 7.34), both with permutation p below 0.0001, in 45 sessions.
Claim ltm-rt-confidence¶
LTM responses are faster with high confidence (mean 1.83 s) than with low confidence (2.62 s).
rng = np.random.default_rng(105)
for rtr, suf in [("(a) all RTs", "all"), ("(b) RT > 5 s missing", "5")]:
for lr, low in [("pooled", "pooled"), ("averaged", "avg")]:
h, l = BEHC[f"rt_hi_{suf}"], BEHC[f"rt_lo_{low}_{suf}"]
t, p, df = sbcat.perm_ttest_paired(h, l, rng)
print(f"{rtr}, low {lr}: high {h.mean():.3f} s (SD {h.std(ddof=1):.2f}; 1.83 +- 0.085: "
f"{abs(h.mean()-1.83) <= 0.085}), low {l.mean():.3f} s (SD {l.std(ddof=1):.2f}; 2.62 +- 0.098: "
f"{abs(l.mean()-2.62) <= 0.098}); t({df}) = {t:.2f} (paper -11.13), perm p = {p:.3g} (below 0.0001: {p < 1e-4})")
(a) all RTs, low pooled: high 2.205 s (SD 1.13; 1.83 +- 0.085: False), low 3.565 s (SD 1.98; 2.62 +- 0.098: False); t(44) = -7.30 (paper -11.13), perm p = 0.0001 (below 0.0001: True) (a) all RTs, low averaged: high 2.205 s (SD 1.13; 1.83 +- 0.085: False), low 3.655 s (SD 2.03; 2.62 +- 0.098: False); t(44) = -7.58 (paper -11.13), perm p = 0.0001 (below 0.0001: True) (b) RT > 5 s missing, low pooled: high 1.838 s (SD 0.58; 1.83 +- 0.085: True), low 2.618 s (SD 0.65; 2.62 +- 0.098: True); t(44) = -11.37 (paper -11.13), perm p = 0.0001 (below 0.0001: True) (b) RT > 5 s missing, low averaged: high 1.838 s (SD 0.58; 1.83 +- 0.085: True), low 2.659 s (SD 0.65; 2.62 +- 0.098: True); t(44) = -11.22 (paper -11.13), perm p = 0.0001 (below 0.0001: True)
Result: reproduced. With response times above 5 s set to missing (reading b), the means are 1.838 s (high) and 2.618 s (pooled low) or 2.659 s (averaged low), within tolerance, with t(44) = -11.37 or -11.22 (paper -11.13) and p below 0.0001. With all response times (reading a), the means are 2.205 and 3.565 s, outside tolerance, though high is still faster (p below 0.0001).
Claim fig1f-ltm-load¶
Pictures held in load 1 WM trials are later recognized better than pictures held in load 3 trials.
rng = np.random.default_rng(106)
t, p, df = sbcat.perm_ttest_paired(BEH.hit_l1, BEH.hit_l3, rng)
print(f"hit rate load 1 {100*BEH.hit_l1.mean():.2f} %, load 3 {100*BEH.hit_l3.mean():.2f} %; "
f"t({df}) = {t:.2f} (paper 2.42), perm p = {p:.4f} (paper 0.018)")
hit rate load 1 68.59 %, load 3 65.77 %; t(45) = 2.65 (paper 2.42), perm p = 0.0097 (paper 0.018)
Result: reproduced. Hit rate 68.59% for load 1 pictures against 65.77% for load 3, t(45) = 2.65, p = 0.0097 (paper t = 2.42, p = 0.018).
Claim fig1g-ltm-probe¶
Pictures that were also used as WM probes, and so shown twice, are later recognized better than pictures shown once.
rng = np.random.default_rng(107)
t, p, df = sbcat.perm_ttest_paired(BEH.hit_twice, BEH.hit_once, rng)
print(f"hit rate shown twice {100*BEH.hit_twice.mean():.2f} %, once {100*BEH.hit_once.mean():.2f} %; "
f"t({df}) = {t:.2f} (paper 7.25), perm p = {p:.3g} (below 0.0001: {p < 1e-4})")
hit rate shown twice 72.10 %, once 63.99 %; t(45) = 6.80 (paper 7.25), perm p = 0.0001 (below 0.0001: True)
Result: reproduced. Hit rate 72.10% for pictures shown twice against 63.99% for pictures shown once, t(45) = 6.80, p below 0.0001.
Category and memory-selective neurons (selections C and M)¶
Each kept unit is tested as the paper's code does (NWB_calcCatSelective_SB.m, NWB_calcMemSelective_SB.m), with 10,000 permutations. Seeds are standard choices.
rng = np.random.default_rng(201)
t0 = time.time()
cat_res, mem_res = [], []
for si, s in enumerate(S):
times, cats = sbcat.category_rates(s)
for _, u in K[K.si == si].iterrows():
sp = s["spikes"][u.ui]
rate = sbcat.count(sp, times, 0.2, 1.2) / 1.0
cat_res.append(sbcat.category_test(rate, cats, rng))
rng = np.random.default_rng(202)
for si, s in enumerate(S):
for _, u in K[K.si == si].iterrows():
mem_res.append(sbcat.memory_test(s, s["spikes"][u.ui], rng))
K["cat"] = [r[0] for r in cat_res]
K["pref"] = [int(r[1]) for r in cat_res]
K["p_anova"] = [r[2] for r in cat_res]
K["p_cat_t"] = [r[3] for r in cat_res]
K["p_ms"] = [r[0] for r in mem_res]
K["ms"] = K.p_ms < 0.05
K["ms_type"] = np.where(~K.ms, "", np.where([r[1] > 0 for r in mem_res], "FS", "NS"))
print("selection time %.0f s" % (time.time() - t0))
print(K.groupby("area")[["cat", "ms"]].sum())
print("units whose ANOVA was undefined (no spikes in any window):", int(K.p_anova.isna().sum()))
selection time 307 s
cat ms
area
amygdala 222 69
hippocampus 102 53
units whose ANOVA was undefined (no spikes in any window): 0
Clock check. If the trial tables share the spikes' clock, the category of the picture on the screen is decodable from spikes aligned to the table's onsets and not from spikes aligned to onsets shifted away from the picture. The same holds for old against new in the LTM task. Per session, the fraction of units with a parametric one-way ANOVA (WM categories) or t-test (LTM old against new, correct trials) at p < 0.05, for the onsets as given and shifted by -5 s (into the preceding trial; a contrast between labels, not an offset).
from scipy import stats as st
rows = []
for si, s in enumerate(S):
times, cats = sbcat.category_rates(s)
ltm = s["ltm"]
ok = ltm.response_accuracy.values == 1
tl, old = ltm.timestamps_PicOnset.values[ok], ltm.new_old.values[ok] == 1
for shift in (0.0, -5.0):
nw = nl = 0
for _, u in K[K.si == si].iterrows():
sp = s["spikes"][u.ui]
r = sbcat.count(sp, times + shift, 0.2, 1.2)
if r.std() > 0 and st.f_oneway(*[r[cats == c] for c in np.unique(cats)]).pvalue < 0.05:
nw += 1
c = sbcat.count(sp, tl + shift, 0.2, 1.2)
if c.std() > 0 and st.ttest_ind(c[old], c[~old]).pvalue < 0.05:
nl += 1
rows.append(dict(session=s["identifier"], shift=shift, units=int((K.si == si).sum()),
wm_sig=nw, ltm_sig=nl))
CLK = pd.DataFrame(rows).pivot(index="session", columns="shift", values=["units", "wm_sig", "ltm_sig"])
print(CLK.to_string())
tot = pd.DataFrame(rows).groupby("shift")[["units", "wm_sig", "ltm_sig"]].sum()
print(tot)
print("sessions where the true WM onsets give no more significant units than the shifted ones:",
CLK.index[CLK[("wm_sig", 0.0)] <= CLK[("wm_sig", -5.0)]].tolist())
print("sessions where the true LTM onsets give no more significant units than the shifted ones:",
CLK.index[CLK[("ltm_sig", 0.0)] <= CLK[("ltm_sig", -5.0)]].tolist())
units wm_sig ltm_sig
shift -5.0 0.0 -5.0 0.0 -5.0 0.0
session
sub-10_ses-1_P68CS 21 21 1 4 0 3
sub-11_ses-1_P69CS 15 15 0 6 0 1
sub-12_ses-1_P70CS 15 15 0 5 1 6
sub-12_ses-2_P70CS 6 6 0 0 0 0
sub-13_ses-1_P71CS 3 3 1 0 0 0
sub-14_ses-1_P73CS 22 22 0 8 1 2
sub-15_ses-1_P74CS 8 8 1 6 0 0
sub-16_ses-1_P76CS 30 30 1 15 0 1
sub-16_ses-2_P76CS 4 4 0 0 0 0
sub-17_ses-1_P77CS 43 43 1 13 2 16
sub-18_ses-1_P78CS 25 25 1 1 3 2
sub-19_ses-1_P79CS 45 45 0 20 0 6
sub-19_ses-2_P79CS 32 32 3 14 2 3
sub-1_ses-2_P54CS 21 21 1 8 2 2
sub-20_ses-1_P80CS 62 62 1 25 5 15
sub-21_ses-1_P82CS 31 31 1 23 3 3
sub-22_ses-1_P088TWH 24 24 0 3 1 1
sub-23_ses-1_P089TWH 35 35 0 19 1 3
sub-24_ses-2_P090TWH 9 9 0 0 0 0
sub-24_ses-3_P090TWH 12 12 1 0 3 1
sub-25_ses-1_P093TWH 7 7 0 0 0 0
sub-26_ses-1_P096TWH 11 11 1 4 0 0
sub-27_ses-1_P101TWH 21 21 1 11 3 3
sub-27_ses-2_P101TWH 14 14 0 10 0 6
sub-28_ses-1_P103TWH 27 27 1 7 2 3
sub-29_ses-1_P106TWH 20 20 1 7 0 1
sub-2_ses-1_P55CS 21 21 0 8 2 3
sub-2_ses-2_P55CS 27 27 1 15 0 3
sub-30_ses-1_P109TWH 19 19 1 1 4 2
sub-31_ses-1_P110TWH 13 13 1 1 0 0
sub-32_ses-2_P113TWH 18 18 0 3 1 3
sub-33_ses-1_P116TWH 20 20 1 9 1 1
sub-34_ses-1_P1802JHU 12 12 0 5 0 1
sub-35_ses-1_P1809JHU 1 1 0 0 0 1
sub-36_ses-1_P1811JHU 9 9 1 1 0 0
sub-37_ses-1_P1814JHU 8 8 0 1 0 3
sub-38_ses-1_P1903JHU 0 0 0 0 0 0
sub-39_ses-1_P1912JHU 13 13 0 6 1 3
sub-3_ses-2_P57CS 28 28 1 15 1 5
sub-4_ses-1_P58CS 24 24 1 9 1 4
sub-5_ses-1_P61CS 23 23 1 12 0 4
sub-5_ses-2_P61CS 9 9 1 7 0 3
sub-6_ses-1_P62CS 22 22 0 6 0 2
sub-7_ses-1_P64CS 14 14 0 2 0 0
sub-8_ses-1_P65CS 27 27 0 13 0 3
sub-9_ses-1_P67CS 12 12 0 5 1 1
units wm_sig ltm_sig
shift
-5.0 883 26 41
0.0 883 328 120
sessions where the true WM onsets give no more significant units than the shifted ones: ['sub-12_ses-2_P70CS', 'sub-13_ses-1_P71CS', 'sub-16_ses-2_P76CS', 'sub-18_ses-1_P78CS', 'sub-24_ses-2_P090TWH', 'sub-24_ses-3_P090TWH', 'sub-25_ses-1_P093TWH', 'sub-30_ses-1_P109TWH', 'sub-31_ses-1_P110TWH', 'sub-35_ses-1_P1809JHU', 'sub-36_ses-1_P1811JHU', 'sub-38_ses-1_P1903JHU']
sessions where the true LTM onsets give no more significant units than the shifted ones: ['sub-12_ses-2_P70CS', 'sub-13_ses-1_P71CS', 'sub-15_ses-1_P74CS', 'sub-16_ses-2_P76CS', 'sub-18_ses-1_P78CS', 'sub-1_ses-2_P54CS', 'sub-21_ses-1_P82CS', 'sub-22_ses-1_P088TWH', 'sub-24_ses-2_P090TWH', 'sub-24_ses-3_P090TWH', 'sub-25_ses-1_P093TWH', 'sub-26_ses-1_P096TWH', 'sub-27_ses-1_P101TWH', 'sub-30_ses-1_P109TWH', 'sub-31_ses-1_P110TWH', 'sub-33_ses-1_P116TWH', 'sub-36_ses-1_P1811JHU', 'sub-38_ses-1_P1903JHU', 'sub-7_ses-1_P64CS', 'sub-9_ses-1_P67CS']
Peri-onset rates (asked for in verification round 1). For every session, the mean rate of all its units around every WM picture onset (encoding pictures and probe) and every LTM picture onset, in 100 ms bins from -0.5 to 1.5 s, at the true onsets and at onsets shifted by -5 s. A shared clock shows as a change after the true onsets that the shifted onsets lack. Per session, the units whose count 0.1 to 0.6 s after onset differs from the count in the 0.5 s before (paired t-test over onsets, p < 0.01) are counted at both. The PSTHs are printed for the sessions listed above as having no advantage in the WM test.
EDGES = np.round(np.arange(-0.5, 1.5001, 0.1), 2)
def psth(spikes_list, onsets):
"""Mean rate (Hz) of the units in 100 ms bins around the onsets."""
h = np.zeros(len(EDGES) - 1)
for sp in spikes_list:
h += np.diff(np.searchsorted(sp, onsets[:, None] + EDGES[None, :]), axis=1).sum(0)
return h / (len(spikes_list) * len(onsets) * 0.1)
NOADV = CLK.index[CLK[("wm_sig", 0.0)] <= CLK[("wm_sig", -5.0)]].tolist()
rows, curves = [], []
for si, s in enumerate(S):
sp = [s["spikes"][u.ui] for _, u in K[K.si == si].iterrows()]
times, _ = sbcat.category_rates(s)
r = dict(session=s["identifier"], no_wm_advantage=s["identifier"] in NOADV, units=len(sp))
for task, on in (("WM", np.sort(times)), ("LTM", np.sort(s["ltm"].timestamps_PicOnset.values))):
for shift, lab in ((0.0, "true"), (-5.0, "-5 s")):
h = psth(sp, on + shift)
r[f"{task} {lab}"] = sum(
st.ttest_rel(sbcat.count(x, on + shift, 0.1, 0.6), sbcat.count(x, on + shift, -0.5, 0.0)).pvalue < 0.01
for x in sp if len(x))
if r["no_wm_advantage"]:
curves.append(pd.Series(h, index=[f"{e:.1f}" for e in EDGES[:-1]],
name=(s["identifier"], task, lab)))
rows.append(r)
CLK2 = pd.DataFrame(rows)
print("units whose count 0.1 to 0.6 s after onset differs from the count in the 0.5 s before "
"(paired t-test over onsets, p < 0.01), per session:")
print(CLK2.round(3).to_string(index=False))
for task in ("WM", "LTM"):
more = CLK2[f"{task} true"] > CLK2[f"{task} -5 s"]
print(f"{task}: units responding at the true onsets {int(CLK2[f'{task} true'].sum())}, at the shifted "
f"{int(CLK2[f'{task} -5 s'].sum())}; sessions with more at the true onsets {int(more.sum())} of "
f"{len(CLK2)}, of the {len(NOADV)} without a WM advantage {int(more[CLK2.no_wm_advantage].sum())}")
print("\nPSTHs (Hz, bin start in s) for the sessions without a WM advantage:")
print(pd.DataFrame(curves).round(2).to_string())
/tmp/ipykernel_2496/1013795535.py:9: RuntimeWarning: invalid value encountered in divide return h / (len(spikes_list) * len(onsets) * 0.1)
units whose count 0.1 to 0.6 s after onset differs from the count in the 0.5 s before (paired t-test over onsets, p < 0.01), per session:
session no_wm_advantage units WM true WM -5 s LTM true LTM -5 s
sub-1_ses-2_P54CS False 21 4 2 4 0
sub-10_ses-1_P68CS False 21 0 0 3 0
sub-11_ses-1_P69CS False 15 2 1 4 0
sub-12_ses-1_P70CS False 15 2 0 5 0
sub-12_ses-2_P70CS True 6 1 1 1 0
sub-13_ses-1_P71CS True 3 0 0 1 0
sub-14_ses-1_P73CS False 22 8 0 2 0
sub-15_ses-1_P74CS False 8 3 0 2 0
sub-16_ses-1_P76CS False 30 12 1 6 2
sub-16_ses-2_P76CS True 4 0 0 1 0
sub-17_ses-1_P77CS False 43 13 3 15 0
sub-18_ses-1_P78CS True 25 3 0 3 0
sub-19_ses-1_P79CS False 45 12 0 18 4
sub-19_ses-2_P79CS False 32 2 0 7 1
sub-2_ses-1_P55CS False 21 3 0 1 0
sub-2_ses-2_P55CS False 27 2 0 7 0
sub-20_ses-1_P80CS False 62 20 2 30 2
sub-21_ses-1_P82CS False 31 11 0 10 0
sub-22_ses-1_P088TWH False 24 6 0 5 0
sub-23_ses-1_P089TWH False 35 5 1 6 1
sub-24_ses-2_P090TWH True 9 1 1 0 0
sub-24_ses-3_P090TWH True 12 2 0 5 0
sub-25_ses-1_P093TWH True 7 0 0 1 0
sub-26_ses-1_P096TWH False 11 0 0 0 0
sub-27_ses-1_P101TWH False 21 3 1 7 0
sub-27_ses-2_P101TWH False 14 1 1 6 1
sub-28_ses-1_P103TWH False 27 7 2 12 0
sub-29_ses-1_P106TWH False 20 2 0 7 0
sub-3_ses-2_P57CS False 28 10 0 10 2
sub-30_ses-1_P109TWH True 19 5 0 5 0
sub-31_ses-1_P110TWH True 13 4 0 1 0
sub-32_ses-2_P113TWH False 18 0 0 4 0
sub-33_ses-1_P116TWH False 20 1 1 2 0
sub-34_ses-1_P1802JHU False 12 0 0 2 0
sub-35_ses-1_P1809JHU True 1 0 0 0 0
sub-36_ses-1_P1811JHU True 9 0 0 2 0
sub-37_ses-1_P1814JHU False 8 0 0 0 0
sub-38_ses-1_P1903JHU True 0 0 0 0 0
sub-39_ses-1_P1912JHU False 13 5 0 6 0
sub-4_ses-1_P58CS False 24 7 0 6 0
sub-5_ses-1_P61CS False 23 16 2 18 0
sub-5_ses-2_P61CS False 9 2 0 3 0
sub-6_ses-1_P62CS False 22 4 1 11 0
sub-7_ses-1_P64CS False 14 0 0 1 0
sub-8_ses-1_P65CS False 27 8 2 8 0
sub-9_ses-1_P67CS False 12 6 0 5 1
WM: units responding at the true onsets 193, at the shifted 22; sessions with more at the true onsets 30 of 46, of the 12 without a WM advantage 4
LTM: units responding at the true onsets 253, at the shifted 14; sessions with more at the true onsets 41 of 46, of the 12 without a WM advantage 9
PSTHs (Hz, bin start in s) for the sessions without a WM advantage:
-0.5 -0.4 -0.3 -0.2 -0.1 -0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4
sub-12_ses-2_P70CS WM true 2.53 2.54 2.39 2.77 2.58 2.73 2.69 2.38 2.45 2.75 2.74 2.73 2.63 2.56 2.75 2.93 2.69 2.76 2.81 2.80
-5 s 2.71 2.62 2.48 2.67 2.62 2.58 2.81 2.69 2.64 2.76 2.62 2.63 2.67 2.71 2.76 2.51 2.79 2.61 2.75 2.78
LTM true 2.38 2.67 2.18 2.49 2.20 2.20 2.15 2.16 2.25 2.61 2.42 2.13 2.43 1.97 2.47 2.66 2.76 2.47 2.49 2.47
-5 s 2.52 2.47 2.67 2.59 2.37 2.18 2.32 2.44 2.44 2.48 2.43 2.59 2.67 2.44 2.38 2.56 2.40 2.56 2.30 2.59
sub-13_ses-1_P71CS WM true 2.98 3.29 3.34 3.40 3.00 3.24 3.18 2.59 3.04 3.52 4.13 3.71 3.50 3.43 3.32 2.91 3.21 3.17 3.15 3.52
-5 s 3.13 3.42 3.02 3.02 3.29 3.33 3.13 3.09 3.34 3.33 3.30 3.12 3.11 3.37 3.06 3.27 3.54 3.25 3.16 2.83
LTM true 2.76 3.10 2.93 2.85 2.78 2.92 2.39 2.44 2.39 3.20 3.37 3.38 3.38 3.08 3.32 2.78 2.81 3.03 3.08 2.68
-5 s 2.98 2.86 2.72 3.07 3.27 2.92 3.26 3.08 2.83 3.10 3.11 2.94 3.16 3.25 3.58 3.13 3.32 2.95 2.98 3.03
sub-16_ses-2_P76CS WM true 0.79 0.62 0.85 0.75 0.84 0.80 0.84 0.72 0.46 0.54 0.53 0.68 0.66 0.89 0.72 0.67 0.73 0.73 0.65 0.73
-5 s 0.77 0.73 0.76 0.70 0.76 0.73 0.75 0.70 0.71 0.79 0.73 0.64 0.77 0.70 0.74 0.76 0.63 0.64 0.70 0.67
LTM true 0.78 0.94 0.80 0.81 0.78 0.83 0.93 0.79 0.42 0.42 0.64 0.63 0.61 0.94 0.66 0.76 0.76 0.71 0.69 0.81
-5 s 0.81 0.81 0.71 0.84 0.74 0.62 0.62 0.73 0.80 0.72 0.78 0.81 0.67 0.62 0.74 0.82 0.74 0.62 0.86 0.76
sub-18_ses-1_P78CS WM true 2.63 2.69 2.55 2.69 2.61 2.63 2.48 2.64 2.80 2.80 2.67 2.58 2.61 2.63 2.76 2.76 2.62 2.70 2.62 2.66
-5 s 2.54 2.61 2.67 2.65 2.66 2.56 2.66 2.74 2.65 2.70 2.65 2.81 2.63 2.70 2.74 2.74 2.77 2.79 2.78 2.77
LTM true 2.42 2.43 2.54 2.49 2.56 2.55 2.53 2.44 2.44 2.68 2.61 2.49 2.29 2.36 2.52 2.43 2.43 2.31 2.32 2.34
-5 s 2.51 2.37 2.41 2.48 2.48 2.48 2.39 2.51 2.38 2.36 2.48 2.45 2.46 2.47 2.44 2.40 2.39 2.48 2.39 2.37
sub-24_ses-2_P090TWH WM true 1.47 1.56 1.55 1.56 1.67 1.55 1.63 1.32 1.34 1.42 1.62 1.96 1.70 1.57 1.66 1.67 1.57 1.59 1.59 1.61
-5 s 1.58 1.53 1.44 1.58 1.54 1.49 1.58 1.54 1.69 1.65 1.40 1.44 1.51 1.55 1.47 1.64 1.57 1.53 1.51 1.74
LTM true 1.78 1.67 1.83 1.86 1.72 1.82 1.73 1.71 1.58 1.62 1.77 1.82 1.93 1.91 1.84 1.78 1.92 1.79 1.79 1.75
-5 s 1.90 1.81 1.69 1.72 1.72 1.74 1.68 1.81 1.71 1.62 1.80 1.71 1.85 1.89 1.74 1.84 1.82 1.72 1.77 1.70
sub-24_ses-3_P090TWH WM true 1.18 1.13 1.19 1.13 1.16 1.06 0.99 1.08 0.99 0.88 1.07 1.16 1.15 1.26 1.15 1.13 1.18 1.20 1.11 1.13
-5 s 1.11 1.18 1.12 1.12 1.13 1.04 1.18 1.13 1.16 1.11 0.98 1.12 1.04 1.13 1.12 1.16 1.14 1.14 1.02 1.16
LTM true 1.39 1.31 1.44 1.26 1.30 1.24 1.36 1.19 1.21 1.11 1.20 1.10 1.32 1.39 1.27 1.38 1.39 1.37 1.28 1.39
-5 s 1.34 1.12 1.34 1.32 1.29 1.36 1.17 1.25 1.29 1.28 1.30 1.32 1.34 1.29 1.25 1.29 1.34 1.28 1.26 1.25
sub-25_ses-1_P093TWH WM true 3.31 3.52 3.54 3.27 3.51 3.65 3.44 3.62 3.65 3.52 3.54 3.36 3.60 3.39 3.63 3.55 3.56 3.50 3.59 3.37
-5 s 3.58 3.40 3.36 3.53 3.33 3.43 3.11 3.18 3.45 3.59 3.36 3.41 3.53 3.59 3.38 3.36 3.68 3.42 3.33 3.46
LTM true 2.68 2.65 2.79 2.88 2.71 2.76 2.56 2.66 2.65 2.58 2.81 2.63 2.85 3.01 2.71 2.72 2.68 2.87 2.75 2.79
-5 s 2.49 2.49 2.59 2.61 2.73 2.45 2.48 2.41 2.58 2.47 2.56 2.68 2.73 2.62 2.42 2.48 2.62 2.48 2.69 2.46
sub-30_ses-1_P109TWH WM true 1.87 1.81 1.94 1.86 1.84 1.90 1.90 1.90 1.79 1.70 1.70 1.76 1.63 1.48 1.61 1.77 1.90 1.77 1.82 1.82
-5 s 1.85 1.79 1.70 1.85 1.90 1.76 1.83 1.86 1.74 1.91 1.86 1.76 1.87 1.89 1.81 1.72 1.70 1.62 1.75 1.72
LTM true 1.51 1.58 1.57 1.57 1.57 1.66 1.58 1.52 1.36 1.34 1.45 1.33 1.34 1.21 1.22 1.18 1.28 1.30 1.44 1.42
-5 s 1.46 1.38 1.38 1.53 1.38 1.44 1.43 1.46 1.43 1.43 1.49 1.56 1.42 1.46 1.44 1.57 1.49 1.40 1.37 1.40
sub-31_ses-1_P110TWH WM true 0.81 0.96 0.96 0.96 1.01 1.00 1.01 1.00 1.10 1.05 0.99 1.00 1.03 1.09 1.06 1.03 0.97 0.95 0.94 0.95
-5 s 0.92 0.99 0.90 0.86 0.94 0.98 0.84 0.97 0.99 0.95 1.04 1.03 0.92 0.94 0.98 0.95 0.98 1.02 0.96 0.93
LTM true 0.71 0.68 0.69 0.79 0.72 0.82 0.86 0.81 0.84 0.82 0.88 0.92 0.85 0.84 0.77 0.79 0.75 0.81 0.81 0.76
-5 s 0.82 0.79 0.82 0.78 0.88 0.80 0.79 0.81 0.83 0.87 0.74 0.83 0.79 0.81 0.76 0.74 0.75 0.89 0.76 0.78
sub-35_ses-1_P1809JHU WM true 0.19 0.21 0.36 0.14 0.31 0.29 0.26 0.29 0.26 0.29 0.36 0.43 0.36 0.40 0.21 0.17 0.31 0.38 0.24 0.33
-5 s 0.29 0.43 0.24 0.24 0.40 0.33 0.24 0.12 0.31 0.29 0.29 0.24 0.29 0.24 0.19 0.38 0.17 0.26 0.24 0.33
LTM true 0.35 0.40 0.32 0.28 0.25 0.12 0.38 0.32 0.40 0.20 0.25 0.28 0.32 0.60 0.52 0.55 0.20 0.30 0.40 0.35
-5 s 0.28 0.22 0.42 0.50 0.35 0.42 0.42 0.45 0.25 0.40 0.50 0.25 0.38 0.18 0.38 0.30 0.30 0.45 0.45 0.55
sub-36_ses-1_P1811JHU WM true 1.89 1.88 1.99 1.94 1.96 1.94 2.15 1.94 2.36 2.15 1.89 2.16 2.06 2.13 2.03 2.03 2.09 1.89 1.99 1.83
-5 s 1.91 1.93 1.83 1.94 1.94 1.93 1.93 1.94 1.96 2.07 1.99 2.03 2.10 1.84 2.01 2.16 2.14 2.14 1.97 2.01
LTM true 1.52 1.59 1.60 1.65 1.54 1.75 1.63 1.62 1.74 1.97 1.81 1.95 1.92 1.75 1.70 1.56 1.66 1.49 1.81 1.64
-5 s 1.61 1.56 1.74 1.60 1.77 1.62 1.51 1.56 1.60 1.71 1.66 1.52 1.72 1.48 1.54 1.57 1.67 1.71 1.56 1.58
sub-38_ses-1_P1903JHU WM true NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
-5 s NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
LTM true NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
-5 s NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Across sessions, 193 units respond to WM picture onsets at the true times against 22 at the shifted ones, and 253 against 14 at LTM onsets. Of the 12 sessions without a WM advantage in the category test, nine have more responding units at the true onsets in the WM or the LTM task, four of them by a single unit. The other three cannot show it: sub-38 (P1903JHU) has no unit after the rate filter, sub-35 (P1809JHU) one, and sub-24 session 2 (P090TWH) has one responding unit at both the true and the shifted WM onsets and none in the LTM task. Their clock is assumed to be shared, as for the others; these three sessions hold 10 of the 883 units.
Claim category-neuron-counts¶
104 hippocampal units (29.65%) and 220 amygdala units (41.35%) are category neurons.
for area, exp in [("hippocampus", 104), ("amygdala", 220)]:
k = K[K.area == area]
n = int(k.cat.sum())
print(f"{area}: {n} of {len(k)} ({100*n/len(k):.2f} %), expected {exp} +- {0.1*exp:.1f}: "
f"{abs(n-exp) <= 0.1*exp}")
print(" preferred categories:", k[k.cat].pref.value_counts().sort_index().to_dict())
for area in ("hippocampus", "amygdala"):
k = K[K.area == area]
print(area, "with the second test at a one-sided 0.05 read as two-sided 0.05 (variant):",
int(((k.p_anova < 0.05) & (k.p_cat_t < 0.05)).sum()))
byp = K[K.cat].groupby(["area", "patient"]).size().unstack(0, fill_value=0)
print("category neurons by patient (hippocampus, amygdala):")
print(byp.T.to_string())
hippocampus: 102 of 351 (29.06 %), expected 104 +- 10.4: True
preferred categories: {1: 37, 2: 15, 3: 26, 4: 14, 5: 10}
amygdala: 222 of 532 (41.73 %), expected 220 +- 22.0: True
preferred categories: {1: 66, 2: 39, 3: 23, 4: 58, 5: 36}
hippocampus with the second test at a one-sided 0.05 read as two-sided 0.05 (variant): 96
amygdala with the second test at a one-sided 0.05 read as two-sided 0.05 (variant): 205
category neurons by patient (hippocampus, amygdala):
patient 1 10 11 12 14 15 16 17 19 2 20 21 22 23 26 27 28 29 3 30 31 32 33 34 36 37 39 4 5 6 7 8 9
area
amygdala 5 1 4 5 8 6 12 11 24 21 20 12 0 11 0 10 3 6 14 0 1 1 5 0 0 0 0 10 13 5 2 7 5
hippocampus 3 3 2 0 0 0 4 2 10 2 4 11 3 7 4 11 4 1 1 2 0 2 3 4 1 1 6 0 6 0 0 5 0
Result: reproduced. 102 hippocampal (29.06%) and 222 amygdala (41.73%) category neurons, within 10% of 104 and 220.
Tables of category neurons¶
For each category neuron, one row per encoding picture of every WM trial with its spike counts in the maintenance (0 to 2.5 s after maintenance onset), baseline (-0.9 to -0.3 s before picture 1) and picture 1 (0 to 2 s) windows, and, for pictures shown in the LTM test, that trial's accuracy and confidence (sbcat.picture_table, sbcat.add_counts).
Outliers for the GLMs of Figures 2 and 3 (claims O, as amended after a reader's answer in
questions/001187.yaml): O-G, each neuron's mean normalized rate over all rows of its table
before trial selection, as NWB_computeGLM.m computes it, the neuron removed when its mean lies
outside the mean +- 3 SD of the neuron means (Methods, Statistics, "differed ±3 SD from the
mean"); O-C, the code's rule (above 3 SD of the neuron means, no centring), as a variant; and
no removal. Neurons with a zero baseline are dropped under all three.
PT = {si: sbcat.picture_table(S[si]) for si in sorted(K.si.unique())}
CN = K[K.cat].copy()
CN["neuron"] = [f"{a}_{b}" for a, b in zip(CN.si, CN.ui)]
NPT = {}
for _, u in CN.iterrows():
pt = sbcat.add_counts(PT[u.si], S[u.si]["spikes"][u.ui])
pt["pref"] = (pt.cat == u.pref).astype(int)
pt["neuron"], pt["patient"], pt["area"] = u.neuron, u.patient, u.area
NPT[u.neuron] = pt
print("category neurons:", len(NPT), " picture rows per neuron:",
sorted({len(p) for p in NPT.values()}))
print("pictures shown in the LTM test per session: %d to %d" % (
min(p.in_ltm.sum() for p in PT.values()), max(p.in_ltm.sum() for p in PT.values())))
def trial_rows(pt):
"""One row per WM trial; pref is true when any encoding picture is of the preferred
category."""
return pt.groupby("trial").agg(r_maint=("r_maint", "first"), r_bsl=("r_bsl", "first"),
c_maint=("c_maint", "first"), c_bsl=("c_bsl", "first"),
r_enc1=("r_enc1", "first"), acc=("acc_WM", "first"),
load=("load", "first"), pref=("pref", "max"),
neuron=("neuron", "first"), patient=("patient", "first"),
area=("area", "first")).reset_index()
def code_rows(pt):
"""The rows of the paper's code (NWB_computeGLM.m): one per encoding picture later shown
in the LTM test, pref per picture."""
return pt[pt.in_ltm].rename(columns={"acc_WM": "acc"}).reset_index(drop=True)
def wm_table(neurons, rows, base, value="r_maint"):
"""Normalized rates (claims B) for the given neurons. rows 'trial' or 'code'; base 'B1'
(mean baseline over all WM trials of the neuron) or 'B2' (over the rows of the code's
table). Neurons with a zero baseline are dropped (their values are infinite)."""
out = []
for n in neurons:
pt = NPT[n]
tr = trial_rows(pt)
d = tr if rows == "trial" else code_rows(pt)
b = tr.r_bsl.mean() if base == "B1" else code_rows(pt).r_bsl.mean()
if b == 0:
continue
d = d.copy()
d["FR"] = sbcat.normalize(d[value], b)
out.append(d)
return pd.concat(out, ignore_index=True)
def fit_readings(neurons, select, formula, readings, value="r_maint"):
"""Fit the GLM under each reading; readings are (rows, base) pairs. Outliers by O-G
(main, claims O) and O-C (variant), both on the neuron means over all rows of the table
before selection, as NWB_computeGLM.m takes them, and none."""
res = []
for rows, base in readings:
full = wm_table(neurons, rows, base, value)
d = select(full)
for orule in ("O-G", "O-C", "none"):
bad = (sbcat.og_remove(full) if orule == "O-G" else
sbcat.oc_remove(full) if orule == "O-C" else set())
dd = d[~d.neuron.isin(bad)]
m = sbcat.mixedlm(dd, formula)
for term, r in m.iterrows():
res.append(dict(rows=rows, base=base, outliers=orule, term=term, beta=r.beta,
SE=r.SE, p=r.p, neurons=m.attrs["neurons"], n=m.attrs["n"],
removed=len(bad), converged=m.attrs["converged"]))
return pd.DataFrame(res)
def show(res, terms=None):
r = res if terms is None else res[res.term.isin(terms)]
print(r.round({"beta": 2, "SE": 2, "p": 6}).to_string(index=False))
HIPP_CN = CN.neuron[CN.area == "hippocampus"].tolist()
AMYG_CN = CN.neuron[CN.area == "amygdala"].tolist()
READ4 = [("trial", "B1"), ("trial", "B2"), ("code", "B1"), ("code", "B2")]
category neurons: 324 picture rows per neuron: [277, 280] pictures shown in the LTM test per session: 78 to 200
Claim fig2b-hippocampus-persistent¶
Hippocampal category neurons are persistently active above baseline during maintenance and fire more when an image of their preferred category is held in WM.
All correct WM trials, both loads; FR ~ pref with the random intercepts of G. Readings: rows (a) one per trial or (b) the code's rows, baseline B1 or B2; outliers O-G (main), O-C and none shown beside.
R2B = fit_readings(HIPP_CN, lambda d: d[d.acc == 1], "pref", READ4)
show(R2B)
rows base outliers term beta SE p neurons n removed converged trial B1 O-G Intercept 20.22 6.12 0.000957 101 13315 1 True trial B1 O-G pref 14.11 2.82 0.000001 101 13315 1 True trial B1 O-C Intercept 19.39 5.56 0.000492 100 13179 2 True trial B1 O-C pref 13.12 2.60 0.000000 100 13179 2 True trial B1 none Intercept 24.24 6.83 0.000389 102 13414 0 True trial B1 none pref 12.87 2.94 0.000012 102 13414 0 True trial B2 O-G Intercept 22.38 5.79 0.000113 100 13179 2 True trial B2 O-G pref 11.86 2.66 0.000008 100 13179 2 True trial B2 O-C Intercept 22.38 5.79 0.000113 100 13179 2 True trial B2 O-C pref 11.86 2.66 0.000008 100 13179 2 True trial B2 none Intercept 26.37 7.64 0.000562 102 13414 0 True trial B2 none pref 16.64 3.39 0.000001 102 13414 0 True code B1 O-G Intercept 22.98 6.04 0.000141 101 17580 1 True code B1 O-G pref 8.82 2.67 0.000959 101 17580 1 True code B1 O-C Intercept 21.61 5.29 0.000044 100 17386 2 True code B1 O-C pref 8.48 2.59 0.001078 100 17386 2 True code B1 none Intercept 26.96 6.25 0.000016 102 17712 0 True code B1 none pref 7.92 2.80 0.004730 102 17712 0 True code B2 O-G Intercept 25.42 6.01 0.000024 100 17496 2 True code B2 O-G pref 6.90 2.81 0.014164 100 17496 2 True code B2 O-C Intercept 25.42 6.01 0.000024 100 17496 2 True code B2 O-C pref 6.90 2.81 0.014164 100 17496 2 True code B2 none Intercept 30.60 7.28 0.000026 102 17712 0 True code B2 none pref 12.04 3.30 0.000266 102 17712 0 True
Result: partially reproduced. Under every reading with O-G both terms are positive at p < 0.05 and at least one beta is outside tolerance: one row per trial with baseline B1 gives intercept 20.22 (p = 0.00096, outside 17.86 +- 1.79) and preferred 14.11 (p = 0.000001, outside 12.47 +- 1.25); with B2, 22.38 and 11.86 (the preferred beta within tolerance); with the code's rows, 22.98 and 8.82 (B1) or 25.42 and 6.90 (B2). O-G removes 1 or 2 of the 102 neurons. The code's rule (O-C, variant) with one row per trial and B1 gives 19.39 and 13.12, both within tolerance; with B2 it removes the same neurons as O-G.
Claim fig2c-hippocampus-correct-load¶
When the preferred category is held, hippocampal category neurons fire more in correct than incorrect trials and more in load 1 than load 3 trials.
Trials holding a preferred picture, correct and incorrect, both loads (one row per trial); acc (incorrect the reference) and l1 (load 1 against load 3). Readings: (a) main effects, (b) with their interaction; baseline B1 or B2.
def pref_trials(d):
d = d[d.pref == 1].copy()
d["l1"] = (d.load == 1).astype(int)
# -0.5/+0.5 coding: with the interaction, acc_c and l1_c are main effects (averaged over
# the other factor), where acc and l1 in "acc * l1" are effects at the reference level
d["acc_c"], d["l1_c"] = d.acc - 0.5, d.l1 - 0.5
return d
R2C = pd.concat([fit_readings(HIPP_CN, pref_trials, f,
[("trial", "B1"), ("trial", "B2")]).assign(model=lab)
for lab, f in [("(a) main", "acc + l1"), ("(b) interaction", "acc * l1"),
("(b) centred, variant", "acc_c * l1_c")]])
show(R2C[["model", "rows", "base", "outliers", "term", "beta", "SE", "p", "neurons", "n"]])
d = pref_trials(wm_table(HIPP_CN, "trial", "B1"))
print("rows by accuracy and load (B1):", d.groupby(["acc", "l1"]).size().to_dict())
model rows base outliers term beta SE p neurons n
(a) main trial B1 O-G Intercept 12.17 10.87 0.263091 101 5683
(a) main trial B1 O-G acc 18.48 9.42 0.049866 101 5683
(a) main trial B1 O-G l1 18.64 5.14 0.000292 101 5683
(a) main trial B1 O-C Intercept 11.18 9.79 0.253656 100 5627
(a) main trial B1 O-C acc 18.68 8.49 0.027819 100 5627
(a) main trial B1 O-C l1 13.63 4.66 0.003438 100 5627
(a) main trial B1 none Intercept 16.84 11.09 0.128988 102 5738
(a) main trial B1 none acc 15.73 9.54 0.099313 102 5738
(a) main trial B1 none l1 20.04 5.28 0.000150 102 5738
(a) main trial B2 O-G Intercept 15.13 10.05 0.132388 100 5628
(a) main trial B2 O-G acc 16.46 8.76 0.060407 100 5628
(a) main trial B2 O-G l1 12.94 4.79 0.006894 100 5628
(a) main trial B2 O-C Intercept 15.13 10.05 0.132388 100 5628
(a) main trial B2 O-C acc 16.46 8.76 0.060407 100 5628
(a) main trial B2 O-C l1 12.94 4.79 0.006894 100 5628
(a) main trial B2 none Intercept 16.76 14.19 0.237433 102 5738
(a) main trial B2 none acc 20.91 11.72 0.074494 102 5738
(a) main trial B2 none l1 23.74 6.49 0.000255 102 5738
(b) interaction trial B1 O-G Intercept 16.87 11.39 0.138633 101 5683
(b) interaction trial B1 O-G acc 13.42 10.12 0.184875 101 5683
(b) interaction trial B1 O-G l1 -14.24 24.61 0.562969 101 5683
(b) interaction trial B1 O-G acc:l1 34.40 25.18 0.171990 101 5683
(b) interaction trial B1 O-C Intercept 15.15 10.26 0.139861 100 5627
(b) interaction trial B1 O-C acc 14.39 9.12 0.114505 100 5627
(b) interaction trial B1 O-C l1 -14.20 22.17 0.522073 100 5627
(b) interaction trial B1 O-C acc:l1 29.12 22.69 0.199390 100 5627
(b) interaction trial B1 none Intercept 19.31 11.62 0.096698 102 5738
(b) interaction trial B1 none acc 13.06 10.26 0.203139 102 5738
(b) interaction trial B1 none l1 3.08 24.57 0.900072 102 5738
(b) interaction trial B1 none acc:l1 17.78 25.17 0.479799 102 5738
(b) interaction trial B2 O-G Intercept 19.66 10.55 0.062323 100 5628
(b) interaction trial B2 O-G acc 11.56 9.42 0.219952 100 5628
(b) interaction trial B2 O-G l1 -18.66 22.81 0.413379 100 5628
(b) interaction trial B2 O-G acc:l1 33.08 23.35 0.156592 100 5628
(b) interaction trial B2 O-C Intercept 19.66 10.55 0.062323 100 5628
(b) interaction trial B2 O-C acc 11.56 9.42 0.219952 100 5628
(b) interaction trial B2 O-C l1 -18.66 22.81 0.413379 100 5628
(b) interaction trial B2 O-C acc:l1 33.08 23.35 0.156592 100 5628
(b) interaction trial B2 none Intercept 19.91 14.81 0.178986 102 5738
(b) interaction trial B2 none acc 17.50 12.60 0.165031 102 5738
(b) interaction trial B2 none l1 2.00 30.17 0.947044 102 5738
(b) interaction trial B2 none acc:l1 22.80 30.91 0.460755 102 5738
(b) centred, variant trial B1 O-G Intercept 25.06 8.76 0.004239 101 5683
(b) centred, variant trial B1 O-G acc_c 30.62 12.95 0.018093 101 5683
(b) centred, variant trial B1 O-G l1_c 2.96 12.58 0.813873 101 5683
(b) centred, variant trial B1 O-G acc_c:l1_c 34.40 25.18 0.171990 101 5683
(b) centred, variant trial B1 O-C Intercept 22.53 7.89 0.004314 100 5627
(b) centred, variant trial B1 O-C acc_c 28.96 11.67 0.013114 100 5627
(b) centred, variant trial B1 O-C l1_c 0.37 11.33 0.974229 100 5627
(b) centred, variant trial B1 O-C acc_c:l1_c 29.12 22.69 0.199390 100 5627
(b) centred, variant trial B1 none Intercept 31.82 8.92 0.000364 102 5738
(b) centred, variant trial B1 none acc_c 21.95 12.98 0.090959 102 5738
(b) centred, variant trial B1 none l1_c 11.98 12.57 0.340745 102 5738
(b) centred, variant trial B1 none acc_c:l1_c 17.78 25.17 0.479799 102 5738
(b) centred, variant trial B2 O-G Intercept 24.38 8.07 0.002533 100 5628
(b) centred, variant trial B2 O-G acc_c 28.09 12.01 0.019345 100 5628
(b) centred, variant trial B2 O-G l1_c -2.12 11.66 0.855478 100 5628
(b) centred, variant trial B2 O-G acc_c:l1_c 33.08 23.35 0.156592 100 5628
(b) centred, variant trial B2 O-C Intercept 24.38 8.07 0.002533 100 5628
(b) centred, variant trial B2 O-C acc_c 28.09 12.01 0.019345 100 5628
(b) centred, variant trial B2 O-C l1_c -2.12 11.66 0.855478 100 5628
(b) centred, variant trial B2 O-C acc_c:l1_c 33.08 23.35 0.156592 100 5628
(b) centred, variant trial B2 none Intercept 35.36 11.68 0.002471 102 5738
(b) centred, variant trial B2 none acc_c 28.90 15.96 0.070187 102 5738
(b) centred, variant trial B2 none l1_c 13.40 15.44 0.385316 102 5738
(b) centred, variant trial B2 none acc_c:l1_c 22.80 30.91 0.460755 102 5738
rows by accuracy and load (B1): {(0, 0): 335, (0, 1): 59, (1, 0): 3975, (1, 1): 1369}
Result: blocked (methods underspecified). The readings the criterion names give different outcomes, and the claims file blocks such a claim. With main effects only (reading a) and O-G, baseline B1 gives accuracy 18.48 (p = 0.0499) and load 18.64 (p = 0.0003), both positive at p < 0.05 with both betas above tolerance (16.22 +- 1.62 and 13.769 +- 1.377); B2 gives load 12.94 (p = 0.0069, within tolerance) and accuracy 16.46 (p = 0.060). Both grade the claim partially reproduced. With the interaction term (reading b), the load term is negative and not significant (-14.24, p = 0.56 with B1; -18.66, p = 0.41 with B2), which grades it not reproduced. In "acc * l1" with 0/1 coding, that term is the load effect in incorrect trials (59 rows with load 1), not a main effect; with -0.5/+0.5 coding (a variant, not a reading of the claims file) the load main effect is 2.96 (p = 0.81) with B1 and -2.12 (p = 0.86) with B2, and accuracy 30.62 (p = 0.018) and 28.09 (p = 0.019). Whether reading (b) is the paper's model is asked of a reader (questions/001187.yaml). O-C gives accuracy 18.68 (p = 0.028) and load 13.63 (p = 0.0034) under reading (a) with B1.
Claim fig2e-amygdala-persistent¶
Amygdala category neurons are also persistently active during maintenance and fire more for the preferred category.
R2E = fit_readings(AMYG_CN, lambda d: d[d.acc == 1], "pref", READ4)
show(R2E)
rows base outliers term beta SE p neurons n removed converged trial B1 O-G Intercept 10.50 3.00 0.000460 220 29509 2 True trial B1 O-G pref 6.88 1.45 0.000002 220 29509 2 True trial B1 O-C Intercept 10.50 3.00 0.000460 220 29509 2 True trial B1 O-C pref 6.88 1.45 0.000002 220 29509 2 True trial B1 none Intercept 11.47 4.63 0.013304 222 29786 0 True trial B1 none pref 12.75 2.40 0.000000 222 29786 0 True trial B2 O-G Intercept 10.06 2.32 0.000014 219 29372 3 True trial B2 O-G pref 6.55 1.40 0.000003 219 29372 3 True trial B2 O-C Intercept 9.34 2.67 0.000463 217 29092 5 True trial B2 O-C pref 5.89 1.34 0.000012 217 29092 5 True trial B2 none Intercept 12.12 3.97 0.002286 222 29786 0 True trial B2 none pref 11.16 2.00 0.000000 222 29786 0 True code B1 O-G Intercept 13.06 3.14 0.000033 220 40771 2 True code B1 O-G pref 5.62 1.57 0.000343 220 40771 2 True code B1 O-C Intercept 11.44 3.20 0.000349 218 40388 4 True code B1 O-C pref 5.50 1.44 0.000141 218 40388 4 True code B1 none Intercept 15.67 4.56 0.000588 222 41161 0 True code B1 none pref 8.51 2.17 0.000090 222 41161 0 True code B2 O-G Intercept 11.26 2.77 0.000049 217 40177 5 True code B2 O-G pref 5.61 1.43 0.000089 217 40177 5 True code B2 O-C Intercept 10.68 2.65 0.000057 216 39982 6 True code B2 O-C pref 5.08 1.39 0.000252 216 39982 6 True code B2 none Intercept 15.60 3.89 0.000061 222 41161 0 True code B2 none pref 7.87 1.90 0.000034 222 41161 0 True
Result: blocked (methods underspecified). The two row readings the criterion names give different outcomes, and the claims file blocks such a claim. With one row per trial (reading a) and O-G, both terms are positive at p < 0.05 with both betas within tolerance (9.78 +- 0.98 and 6.91 +- 0.69): intercept 10.50 and preferred 6.88 with B1 (p = 0.00046 and 0.000002), 10.06 and 6.55 with B2 (p = 0.000014 and 0.000003), which grades it reproduced. With the code's rows (reading b) the intercept is above tolerance and the preferred beta below it (13.06 and 5.62 with B1, 11.26 and 5.61 with B2), which grades it partially reproduced. O-C gives the same as O-G with one row per trial and B1, and 9.34 and 5.89 with B2.
Claim fig2f-amygdala-load-not-accuracy¶
When the preferred category is held, amygdala category neurons fire more in load 1 than load 3 trials, but not more in correct than incorrect trials.
R2F = pd.concat([fit_readings(AMYG_CN, pref_trials, f,
[("trial", "B1"), ("trial", "B2")]).assign(model=lab)
for lab, f in [("(a) main", "acc + l1"), ("(b) interaction", "acc * l1"),
("(b) centred, variant", "acc_c * l1_c")]])
show(R2F[["model", "rows", "base", "outliers", "term", "beta", "SE", "p", "neurons", "n"]])
model rows base outliers term beta SE p neurons n
(a) main trial B1 O-G Intercept 20.81 6.22 0.000824 220 12327
(a) main trial B1 O-G acc -6.49 5.47 0.236145 220 12327
(a) main trial B1 O-G l1 11.55 2.71 0.000021 220 12327
(a) main trial B1 O-C Intercept 20.81 6.22 0.000824 220 12327
(a) main trial B1 O-C acc -6.49 5.47 0.236145 220 12327
(a) main trial B1 O-C l1 11.55 2.71 0.000021 220 12327
(a) main trial B1 none Intercept 26.38 12.97 0.041980 222 12441
(a) main trial B1 none acc -7.20 11.20 0.520673 222 12441
(a) main trial B1 none l1 19.02 5.53 0.000581 222 12441
(a) main trial B2 O-G Intercept 20.56 5.67 0.000291 219 12270
(a) main trial B2 O-G acc -6.39 5.23 0.221682 219 12270
(a) main trial B2 O-G l1 9.51 2.59 0.000247 219 12270
(a) main trial B2 O-C Intercept 19.20 5.58 0.000587 217 12160
(a) main trial B2 O-C acc -6.58 4.99 0.186812 217 12160
(a) main trial B2 O-C l1 9.92 2.48 0.000065 217 12160
(a) main trial B2 none Intercept 24.91 10.27 0.015353 222 12441
(a) main trial B2 none acc -6.04 8.89 0.497358 222 12441
(a) main trial B2 none l1 16.43 4.39 0.000180 222 12441
(b) interaction trial B1 O-G Intercept 21.72 6.58 0.000965 220 12327
(b) interaction trial B1 O-G acc -7.44 5.92 0.209026 220 12327
(b) interaction trial B1 O-G l1 5.57 14.41 0.699309 220 12327
(b) interaction trial B1 O-G acc:l1 6.20 14.68 0.672564 220 12327
(b) interaction trial B1 O-C Intercept 21.72 6.58 0.000965 220 12327
(b) interaction trial B1 O-C acc -7.44 5.92 0.209026 220 12327
(b) interaction trial B1 O-C l1 5.57 14.41 0.699309 220 12327
(b) interaction trial B1 O-C acc:l1 6.20 14.68 0.672564 220 12327
(b) interaction trial B1 none Intercept 28.53 13.68 0.037124 222 12441
(b) interaction trial B1 none acc -9.47 12.12 0.434525 222 12441
(b) interaction trial B1 none l1 4.76 29.50 0.871813 222 12441
(b) interaction trial B1 none acc:l1 14.78 30.04 0.622753 222 12441
(b) interaction trial B2 O-G Intercept 21.51 6.03 0.000361 219 12270
(b) interaction trial B2 O-G acc -7.41 5.66 0.190788 219 12270
(b) interaction trial B2 O-G l1 3.19 13.76 0.816862 219 12270
(b) interaction trial B2 O-G acc:l1 6.56 14.01 0.639572 219 12270
(b) interaction trial B2 O-C Intercept 20.24 5.92 0.000625 217 12160
(b) interaction trial B2 O-C acc -7.69 5.40 0.154507 217 12160
(b) interaction trial B2 O-C l1 3.05 13.11 0.816050 217 12160
(b) interaction trial B2 O-C acc:l1 7.13 13.36 0.593518 217 12160
(b) interaction trial B2 none Intercept 26.88 10.84 0.013173 222 12441
(b) interaction trial B2 none acc -8.13 9.62 0.398202 222 12441
(b) interaction trial B2 none l1 3.32 23.41 0.887200 222 12441
(b) interaction trial B2 none acc:l1 13.59 23.84 0.568724 222 12441
(b) centred, variant trial B1 O-G Intercept 22.33 4.92 0.000006 220 12327
(b) centred, variant trial B1 O-G acc_c -4.34 7.46 0.560794 220 12327
(b) centred, variant trial B1 O-G l1_c 8.67 7.33 0.237201 220 12327
(b) centred, variant trial B1 O-G acc_c:l1_c 6.20 14.68 0.672564 220 12327
(b) centred, variant trial B1 O-C Intercept 22.33 4.92 0.000006 220 12327
(b) centred, variant trial B1 O-C acc_c -4.34 7.46 0.560794 220 12327
(b) centred, variant trial B1 O-C l1_c 8.67 7.33 0.237201 220 12327
(b) centred, variant trial B1 O-C acc_c:l1_c 6.20 14.68 0.672564 220 12327
(b) centred, variant trial B1 none Intercept 29.86 10.36 0.003963 222 12441
(b) centred, variant trial B1 none acc_c -2.08 15.28 0.891555 222 12441
(b) centred, variant trial B1 none l1_c 12.15 15.01 0.418213 222 12441
(b) centred, variant trial B1 none acc_c:l1_c 14.78 30.04 0.622753 222 12441
(b) centred, variant trial B2 O-G Intercept 21.04 4.34 0.000001 219 12270
(b) centred, variant trial B2 O-G acc_c -4.13 7.12 0.562301 219 12270
(b) centred, variant trial B2 O-G l1_c 6.47 7.00 0.355618 219 12270
(b) centred, variant trial B2 O-G acc_c:l1_c 6.56 14.01 0.639572 219 12270
(b) centred, variant trial B2 O-C Intercept 19.70 4.37 0.000007 217 12160
(b) centred, variant trial B2 O-C acc_c -4.12 6.79 0.543712 217 12160
(b) centred, variant trial B2 O-C l1_c 6.62 6.67 0.321574 217 12160
(b) centred, variant trial B2 O-C acc_c:l1_c 7.13 13.36 0.593518 217 12160
(b) centred, variant trial B2 none Intercept 27.88 8.20 0.000678 222 12441
(b) centred, variant trial B2 none acc_c -1.33 12.13 0.912459 222 12441
(b) centred, variant trial B2 none l1_c 10.12 11.91 0.395752 222 12441
(b) centred, variant trial B2 none acc_c:l1_c 13.59 23.84 0.568724 222 12441
Result: blocked (methods underspecified). The readings the criterion names give different outcomes, and the claims file blocks such a claim. The accuracy effect has p >= 0.05 under every reading and outlier rule (with O-G p from 0.19 to 0.24, betas -6.39 to -7.44; paper -6.13, p = 0.24). With main effects (reading a), B1 and O-G the load effect is 11.55 (p = 0.00002), within 12.309 +- 1.231, which grades the claim reproduced. With B2 it is 9.51 (p = 0.00025), below tolerance, and with the interaction term (reading b) it is not significant (p = 0.70 with B1, 0.82 with B2); these grade it partially reproduced. As for fig2c, the load term of reading (b) is the effect in incorrect trials; with -0.5/+0.5 coding (a variant) the load main effect is 8.67 (p = 0.24) with B1 and 6.47 (p = 0.36) with B2. O-C gives the same as O-G with B1.
The table of Figure 3 (NWB_computeGLM.m)¶
One row per WM picture later shown in the LTM test; rate 0 to 2.5 s after maintenance onset, normalized to the mean baseline over all the neuron's rows (B, as the code); then rows kept when the WM trial was correct and the picture is of the preferred category. Confidence is recoded as the Methods say (sbcat.conf3_code). The session whose ratings are all sure is left out of these confidence analyses (Results, paragraph 2); the code keeps it, shown as a variant. Area: hipp = 1 for hippocampus, amygdala the reference.
NOCONF_SI = [si for si, s in enumerate(S) if s["identifier"] in noconf]
def fig3_full(neurons, value="r_maint"):
d = wm_table(neurons, "code", "B2", value)
d["hipp"] = (d.area == "hippocampus").astype(int)
d["conf3"] = sbcat.conf3_code(d.conf)
d["si"] = [int(n.split("_")[0]) for n in d.neuron]
return d
def fig3_select(d, pref=1, keep_noconf=False):
d = d[(d.acc == 1) & (d.pref == pref) & d.conf.notna()]
if not keep_noconf:
d = d[~d.si.isin(NOCONF_SI)]
return d
ALL_CN = HIPP_CN + AMYG_CN
F3FULL = fig3_full(ALL_CN)
F3 = fig3_select(F3FULL)
print("rows", len(F3), "neurons", F3.neuron.nunique(), "by area:",
F3.groupby("area").neuron.nunique().to_dict())
print("rows by LTM accuracy and confidence:", F3.groupby(["LTMacc", "conf3"]).size().to_dict())
print("neurons dropped for a zero baseline:", len(ALL_CN) - F3FULL.neuron.nunique())
print("FR (%% change) range: %.1f to %.1f" % (F3.FR.min(), F3.FR.max()))
def fig3_fit(data_full, formula, select=fig3_select, outlier_pool=None, label=""):
"""Fit under O-G (main, claims O), O-C (variant) and none. Both rules take each neuron's
mean over all its rows of the full table, before trial selection, as NWB_computeGLM.m
does; outlier_pool is that full table when it is not data_full (outliers found over both
areas for a model of one area)."""
d = select(data_full)
pool = data_full if outlier_pool is None else outlier_pool
res = []
for orule in ("O-G", "O-C", "none"):
bad = (sbcat.og_remove(pool) if orule == "O-G" else
sbcat.oc_remove(pool) if orule == "O-C" else set())
dd = d[~d.neuron.isin(bad)]
m = sbcat.mixedlm(dd, formula)
for term, r in m.iterrows():
res.append(dict(reading=label, outliers=orule, term=term, beta=r.beta, SE=r.SE, p=r.p,
neurons=m.attrs["neurons"], n=m.attrs["n"], removed=len(bad),
converged=m.attrs["converged"]))
return pd.DataFrame(res)
rows 11500 neurons 318 by area: {'amygdala': 218, 'hippocampus': 100}
rows by LTM accuracy and confidence: {(0.0, 1.0): 1584, (0.0, 2.0): 656, (0.0, 3.0): 385, (1.0, 1.0): 805, (1.0, 2.0): 1559, (1.0, 3.0): 6511}
neurons dropped for a zero baseline: 0
FR (% change) range: -100.0 to 10700.0
Claim fig3a-area-interactions¶
In a GLM over category neurons of both areas, no main effect of LTM accuracy, confidence or area is significant, nor the LTM accuracy by confidence interaction, but every interaction with area is, so the relation of maintenance activity to later memory differs between hippocampus and amygdala.
FR ~ LTMacc * conf3 * hipp. Expected: conf3:hipp 16.88 +- 1.69, LTMacc:hipp 59.78 +- 5.98, LTMacc:conf3:hipp -28.64 +- 2.86.
R3A = pd.concat([
fig3_fit(F3FULL, "LTMacc * conf3 * hipp", label="main"),
fig3_fit(F3FULL, "LTMacc * conf3 * hipp",
select=lambda d: fig3_select(d, keep_noconf=True), label="with the all-sure session")])
show(R3A)
reading outliers term beta SE p neurons n removed converged
main O-G Intercept 11.65 8.51 0.170777 313 11340 5 True
main O-G LTMacc -4.29 11.82 0.716735 313 11340 5 True
main O-G conf3 1.79 4.58 0.696336 313 11340 5 True
main O-G LTMacc:conf3 2.34 5.69 0.680136 313 11340 5 True
main O-G hipp -17.60 14.86 0.236028 313 11340 5 True
main O-G LTMacc:hipp 70.57 21.67 0.001131 313 11340 5 True
main O-G conf3:hipp 19.12 8.15 0.019063 313 11340 5 True
main O-G LTMacc:conf3:hipp -32.52 10.35 0.001678 313 11340 5 True
main O-C Intercept 7.49 8.30 0.366613 310 11226 8 True
main O-C LTMacc 0.13 11.57 0.991079 310 11226 8 True
main O-C conf3 3.40 4.47 0.447993 310 11226 8 True
main O-C LTMacc:conf3 0.26 5.56 0.963076 310 11226 8 True
main O-C hipp -11.49 14.52 0.428989 310 11226 8 True
main O-C LTMacc:hipp 56.61 21.17 0.007505 310 11226 8 True
main O-C conf3:hipp 16.60 7.98 0.037586 310 11226 8 True
main O-C LTMacc:conf3:hipp -27.83 10.11 0.005927 310 11226 8 True
main none Intercept 17.76 13.20 0.178491 318 11500 0 True
main none LTMacc -8.98 17.60 0.610130 318 11500 0 True
main none conf3 5.05 6.74 0.453634 318 11500 0 True
main none LTMacc:conf3 0.08 8.43 0.992171 318 11500 0 True
main none hipp -14.83 23.14 0.521539 318 11500 0 True
main none LTMacc:hipp 110.03 32.07 0.000604 318 11500 0 True
main none conf3:hipp 18.33 12.01 0.126892 318 11500 0 True
main none LTMacc:conf3:hipp -43.78 15.31 0.004250 318 11500 0 True
with the all-sure session O-G Intercept 14.25 8.41 0.089951 319 11520 5 True
with the all-sure session O-G LTMacc -6.48 11.77 0.582108 319 11520 5 True
with the all-sure session O-G conf3 0.94 4.56 0.836819 319 11520 5 True
with the all-sure session O-G LTMacc:conf3 3.19 5.67 0.574609 319 11520 5 True
with the all-sure session O-G hipp -21.30 14.69 0.147186 319 11520 5 True
with the all-sure session O-G LTMacc:hipp 73.60 21.60 0.000657 319 11520 5 True
with the all-sure session O-G conf3:hipp 20.23 8.12 0.012730 319 11520 5 True
with the all-sure session O-G LTMacc:conf3:hipp -33.74 10.33 0.001093 319 11520 5 True
with the all-sure session O-C Intercept 10.26 8.20 0.210632 316 11406 8 True
with the all-sure session O-C LTMacc -2.21 11.52 0.847672 316 11406 8 True
with the all-sure session O-C conf3 2.49 4.45 0.575987 316 11406 8 True
with the all-sure session O-C LTMacc:conf3 1.16 5.55 0.834402 316 11406 8 True
with the all-sure session O-C hipp -15.49 14.37 0.281066 316 11406 8 True
with the all-sure session O-C LTMacc:hipp 59.96 21.11 0.004511 316 11406 8 True
with the all-sure session O-C conf3:hipp 17.84 7.95 0.024898 316 11406 8 True
with the all-sure session O-C LTMacc:conf3:hipp -29.16 10.10 0.003876 316 11406 8 True
with the all-sure session none Intercept 19.86 12.97 0.125684 324 11680 0 True
with the all-sure session none LTMacc -10.61 17.45 0.543362 324 11680 0 True
with the all-sure session none conf3 4.39 6.67 0.511002 324 11680 0 True
with the all-sure session none LTMacc:conf3 0.69 8.37 0.934525 324 11680 0 True
with the all-sure session none hipp -18.13 22.77 0.425975 324 11680 0 True
with the all-sure session none LTMacc:hipp 112.29 31.83 0.000421 324 11680 0 True
with the all-sure session none conf3:hipp 19.20 11.90 0.106871 324 11680 0 True
with the all-sure session none LTMacc:conf3:hipp -44.66 15.22 0.003343 324 11680 0 True
Result: partially reproduced. With O-G (5 neurons removed, 313 remain) the three interactions with area are significant with the paper's signs (LTM accuracy x area 70.57, p = 0.0011; confidence x area 19.12, p = 0.019; three-way -32.52, p = 0.0017) and no main effect or the accuracy x confidence term is (smallest p 0.24), but all three betas are larger than the paper's and outside tolerance (59.78 +- 5.98, 16.88 +- 1.69, -28.64 +- 2.86). With the all-sure session kept, as the code does, 73.60, 20.23 and -33.74. The code's rule (O-C, variant, 8 removed) gives 56.61, 16.60 and -27.83, all within tolerance, and with the all-sure session kept 59.96, 17.84 and -29.16.
Claim fig3b-hippocampus-predicts-ltm¶
In the hippocampus, maintenance activity of category neurons for the preferred category predicts later LTM accuracy and confidence, with an interaction between the two, so activity is higher for pictures later remembered than forgotten.
FR ~ LTMacc * conf3 on hippocampal neurons; outliers found over both areas (a) or within the hippocampus (b). Expected: conf3 20.30 +- 2.03, LTMacc 67.90 +- 6.79, LTMacc:conf3 -30.80 +- 3.08.
def area_sel(area, keep_noconf=False):
return lambda d: fig3_select(d[d.area == area], keep_noconf=keep_noconf)
H3FULL = F3FULL[F3FULL.area == "hippocampus"]
A3FULL = F3FULL[F3FULL.area == "amygdala"]
R3B = pd.concat([
fig3_fit(H3FULL, "LTMacc * conf3", select=area_sel("hippocampus"),
outlier_pool=F3FULL, label="(a) outliers over both areas"),
fig3_fit(H3FULL, "LTMacc * conf3", select=area_sel("hippocampus"),
label="(b) outliers within the area"),
fig3_fit(H3FULL, "LTMacc * conf3",
select=area_sel("hippocampus", True), label="(b) with the all-sure session")])
show(R3B)
reading outliers term beta SE p neurons n removed converged (a) outliers over both areas O-G Intercept -6.56 13.34 0.623038 98 3410 5 True (a) outliers over both areas O-G LTMacc 67.37 20.19 0.000854 98 3410 5 True (a) outliers over both areas O-G conf3 21.25 7.48 0.004503 98 3410 5 True (a) outliers over both areas O-G LTMacc:conf3 -30.69 9.61 0.001421 98 3410 5 True (a) outliers over both areas O-C Intercept -4.34 12.36 0.725724 97 3374 8 True (a) outliers over both areas O-C LTMacc 57.52 19.63 0.003403 97 3374 8 True (a) outliers over both areas O-C conf3 20.25 7.30 0.005576 97 3374 8 True (a) outliers over both areas O-C LTMacc:conf3 -27.98 9.32 0.002711 97 3374 8 True (a) outliers over both areas none Intercept -5.63 22.82 0.805198 100 3451 0 True (a) outliers over both areas none LTMacc 112.78 28.35 0.000071 100 3451 0 True (a) outliers over both areas none conf3 27.86 10.45 0.007735 100 3451 0 True (a) outliers over both areas none LTMacc:conf3 -48.70 13.48 0.000306 100 3451 0 True (b) outliers within the area O-G Intercept -6.56 13.34 0.623038 98 3410 2 True (b) outliers within the area O-G LTMacc 67.37 20.19 0.000854 98 3410 2 True (b) outliers within the area O-G conf3 21.25 7.48 0.004503 98 3410 2 True (b) outliers within the area O-G LTMacc:conf3 -30.69 9.61 0.001421 98 3410 2 True (b) outliers within the area O-C Intercept -6.56 13.34 0.623038 98 3410 2 True (b) outliers within the area O-C LTMacc 67.37 20.19 0.000854 98 3410 2 True (b) outliers within the area O-C conf3 21.25 7.48 0.004503 98 3410 2 True (b) outliers within the area O-C LTMacc:conf3 -30.69 9.61 0.001421 98 3410 2 True (b) outliers within the area none Intercept -5.63 22.82 0.805198 100 3451 0 True (b) outliers within the area none LTMacc 112.78 28.35 0.000071 100 3451 0 True (b) outliers within the area none conf3 27.86 10.45 0.007735 100 3451 0 True (b) outliers within the area none LTMacc:conf3 -48.70 13.48 0.000306 100 3451 0 True (b) with the all-sure session O-G Intercept -7.64 12.89 0.553544 100 3466 2 True (b) with the all-sure session O-G LTMacc 68.18 19.96 0.000643 100 3466 2 True (b) with the all-sure session O-G conf3 21.51 7.39 0.003614 100 3466 2 True (b) with the all-sure session O-G LTMacc:conf3 -31.05 9.52 0.001116 100 3466 2 True (b) with the all-sure session O-C Intercept -7.64 12.89 0.553544 100 3466 2 True (b) with the all-sure session O-C LTMacc 68.18 19.96 0.000643 100 3466 2 True (b) with the all-sure session O-C conf3 21.51 7.39 0.003614 100 3466 2 True (b) with the all-sure session O-C LTMacc:conf3 -31.05 9.52 0.001116 100 3466 2 True (b) with the all-sure session none Intercept -6.66 22.43 0.766425 102 3507 0 True (b) with the all-sure session none LTMacc 113.11 28.06 0.000057 102 3507 0 True (b) with the all-sure session none conf3 27.96 10.33 0.006814 102 3507 0 True (b) with the all-sure session none LTMacc:conf3 -48.85 13.35 0.000258 102 3507 0 True
Result: reproduced. With O-G, whether outliers are found over both areas (5 removed) or within the hippocampus (2 removed), the same 98 hippocampal neurons remain, and confidence 21.25 (p = 0.0045), LTM accuracy 67.37 (p = 0.00085) and their interaction -30.69 (p = 0.0014) are significant with the paper's signs and within tolerance (20.30 +- 2.03, 67.90 +- 6.79, -30.80 +- 3.08). With the all-sure session kept, 21.51, 68.18 and -31.05. The code's rule (O-C) gives the same within the area; over both areas it gives 20.25, 57.52 and -27.98, LTM accuracy below tolerance.
Claim fig3b-amygdala-no-prediction¶
In the amygdala, maintenance activity of category neurons does not predict later LTM accuracy or confidence.
R3BA = pd.concat([
fig3_fit(A3FULL, "LTMacc * conf3", select=area_sel("amygdala"),
outlier_pool=F3FULL, label="(a) outliers over both areas"),
fig3_fit(A3FULL, "LTMacc * conf3", select=area_sel("amygdala"),
label="(b) outliers within the area"),
fig3_fit(A3FULL, "LTMacc * conf3",
select=area_sel("amygdala", True), label="(b) with the all-sure session")])
show(R3BA)
reading outliers term beta SE p neurons n removed converged (a) outliers over both areas O-G Intercept 11.56 7.99 0.147648 215 7930 5 True (a) outliers over both areas O-G LTMacc -4.08 11.16 0.714886 215 7930 5 True (a) outliers over both areas O-G conf3 1.81 4.33 0.675673 215 7930 5 True (a) outliers over both areas O-G LTMacc:conf3 2.28 5.37 0.670671 215 7930 5 True (a) outliers over both areas O-C Intercept 7.68 7.97 0.335257 213 7852 8 True (a) outliers over both areas O-C LTMacc -0.12 11.01 0.991422 213 7852 8 True (a) outliers over both areas O-C conf3 3.31 4.25 0.437143 213 7852 8 True (a) outliers over both areas O-C LTMacc:conf3 0.37 5.29 0.944679 213 7852 8 True (a) outliers over both areas none Intercept 17.21 12.55 0.170085 218 8049 0 True (a) outliers over both areas none LTMacc -8.22 16.99 0.628426 218 8049 0 True (a) outliers over both areas none conf3 5.22 6.55 0.425472 218 8049 0 True (a) outliers over both areas none LTMacc:conf3 -0.24 8.15 0.976400 218 8049 0 True (b) outliers within the area O-G Intercept 7.68 7.97 0.335257 213 7852 5 True (b) outliers within the area O-G LTMacc -0.12 11.01 0.991422 213 7852 5 True (b) outliers within the area O-G conf3 3.31 4.25 0.437143 213 7852 5 True (b) outliers within the area O-G LTMacc:conf3 0.37 5.29 0.944679 213 7852 5 True (b) outliers within the area O-C Intercept 7.85 7.46 0.292809 212 7814 6 True (b) outliers within the area O-C LTMacc -0.22 10.38 0.983426 212 7814 6 True (b) outliers within the area O-C conf3 2.62 4.01 0.513710 212 7814 6 True (b) outliers within the area O-C LTMacc:conf3 0.57 4.98 0.909321 212 7814 6 True (b) outliers within the area none Intercept 17.21 12.55 0.170085 218 8049 0 True (b) outliers within the area none LTMacc -8.22 16.99 0.628426 218 8049 0 True (b) outliers within the area none conf3 5.22 6.55 0.425472 218 8049 0 True (b) outliers within the area none LTMacc:conf3 -0.24 8.15 0.976400 218 8049 0 True (b) with the all-sure session O-G Intercept 10.60 7.94 0.181624 217 7976 5 True (b) with the all-sure session O-G LTMacc -2.53 11.02 0.818647 217 7976 5 True (b) with the all-sure session O-G conf3 2.39 4.26 0.574734 217 7976 5 True (b) with the all-sure session O-G LTMacc:conf3 1.30 5.30 0.806999 217 7976 5 True (b) with the all-sure session O-C Intercept 10.79 7.45 0.147531 216 7938 6 True (b) with the all-sure session O-C LTMacc -2.72 10.41 0.793885 216 7938 6 True (b) with the all-sure session O-C conf3 1.69 4.02 0.674151 216 7938 6 True (b) with the all-sure session O-C LTMacc:conf3 1.54 5.01 0.758664 216 7938 6 True (b) with the all-sure session none Intercept 19.54 12.34 0.113358 222 8173 0 True (b) with the all-sure session none LTMacc -10.05 16.87 0.551336 222 8173 0 True (b) with the all-sure session none conf3 4.51 6.50 0.487906 222 8173 0 True (b) with the all-sure session none LTMacc:conf3 0.46 8.11 0.955156 222 8173 0 True
Result: reproduced. No effect reaches p < 0.05 in the amygdala under any reading or outlier rule (smallest p 0.43). With O-G and outliers over both areas, confidence 1.81 (p = 0.68), LTM accuracy -4.08 (p = 0.71), interaction 2.28 (p = 0.67).
Claims fig3c-hippocampus-high-confidence and fig3d-amygdala-no-difference¶
Across hippocampal category neurons, maintenance firing for the preferred category is higher for pictures later remembered than forgotten with high confidence, but not with low confidence.
Across amygdala category neurons, maintenance firing does not differ between later remembered and forgotten pictures, with high or low confidence.
Rows of the Figure 3 table (correct WM trials, preferred pictures later tested, the all-sure session left out). High: remembered rating 6 against forgotten rating 1; low: remembered 4 or 5 against forgotten 2 or 3. Per neuron the mean rate per condition; neurons without rows or without spikes in a condition, with a zero baseline, or outside mean +- 3 SD of the neuron and condition values of the test (O-M) are removed; paired permutation t-test (P). Readings: (a) normalized rate, (b) spikes per second.
CONDS = {"high": ([6], [1]), "low": ([4, 5], [2, 3])}
def remembered_forgotten(area, level, value, rng, data=None):
d = F3 if data is None else data
d = d[d.area == area]
rem, forg = CONDS[level]
col = "FR" if value == "norm" else "r_maint"
a = d[d.conf.isin(rem)].groupby("neuron").agg(v=(col, "mean"), c=("c_maint", "sum"))
b = d[d.conf.isin(forg)].groupby("neuron").agg(v=(col, "mean"), c=("c_maint", "sum"))
j = a.join(b, lsuffix="_r", rsuffix="_f", how="inner")
n_both = len(j)
j = j[(j.c_r > 0) & (j.c_f > 0)]
n_spk = len(j)
vals = j[["v_r", "v_f"]].values
out = np.any(np.abs(vals - vals.mean()) > 3 * vals.std(ddof=1), axis=1)
j = j[~out]
t, p, df = sbcat.perm_ttest_paired(j.v_r, j.v_f, rng)
return dict(area=area, level=level, value=value, with_both=n_both, with_spikes=n_spk,
n=len(j), mean_rem=j.v_r.mean(), mean_forg=j.v_f.mean(),
diff=(j.v_r - j.v_f).mean(), t=t, df=df, p=p), j.index.tolist()
rng = np.random.default_rng(301)
R3CD, KEEP3C = [], {}
for area in ("hippocampus", "amygdala"):
for level in ("high", "low"):
for value in ("norm", "Hz"):
r, kept = remembered_forgotten(area, level, value, rng)
R3CD.append(r)
KEEP3C[(area, level, value)] = kept
R3CD = pd.DataFrame(R3CD)
F3ALL = fig3_select(F3FULL, keep_noconf=True)
R3CDV = pd.DataFrame([remembered_forgotten(a, l, v, np.random.default_rng(303), data=F3ALL)[0]
for a in ("hippocampus", "amygdala") for l in ("high", "low")
for v in ("norm", "Hz")])
print("category neurons with rows in the Figure 3 table: hippocampus",
F3[F3.area == "hippocampus"].neuron.nunique(), "amygdala", F3[F3.area == "amygdala"].neuron.nunique())
/tmp/ipykernel_2496/1060714452.py:11: Pandas4Warning: The 'lsuffix' and 'rsuffix' keywords in DataFrame.join are deprecated and will be removed in a future version. Use the 'suffixes' keyword instead. j = a.join(b, lsuffix="_r", rsuffix="_f", how="inner") /tmp/ipykernel_2496/1060714452.py:11: Pandas4Warning: The 'lsuffix' and 'rsuffix' keywords in DataFrame.join are deprecated and will be removed in a future version. Use the 'suffixes' keyword instead. j = a.join(b, lsuffix="_r", rsuffix="_f", how="inner") /tmp/ipykernel_2496/1060714452.py:11: Pandas4Warning: The 'lsuffix' and 'rsuffix' keywords in DataFrame.join are deprecated and will be removed in a future version. Use the 'suffixes' keyword instead. j = a.join(b, lsuffix="_r", rsuffix="_f", how="inner") /tmp/ipykernel_2496/1060714452.py:11: Pandas4Warning: The 'lsuffix' and 'rsuffix' keywords in DataFrame.join are deprecated and will be removed in a future version. Use the 'suffixes' keyword instead. j = a.join(b, lsuffix="_r", rsuffix="_f", how="inner") /tmp/ipykernel_2496/1060714452.py:11: Pandas4Warning: The 'lsuffix' and 'rsuffix' keywords in DataFrame.join are deprecated and will be removed in a future version. Use the 'suffixes' keyword instead. j = a.join(b, lsuffix="_r", rsuffix="_f", how="inner") /tmp/ipykernel_2496/1060714452.py:11: Pandas4Warning: The 'lsuffix' and 'rsuffix' keywords in DataFrame.join are deprecated and will be removed in a future version. Use the 'suffixes' keyword instead. j = a.join(b, lsuffix="_r", rsuffix="_f", how="inner") /tmp/ipykernel_2496/1060714452.py:11: Pandas4Warning: The 'lsuffix' and 'rsuffix' keywords in DataFrame.join are deprecated and will be removed in a future version. Use the 'suffixes' keyword instead. j = a.join(b, lsuffix="_r", rsuffix="_f", how="inner") /tmp/ipykernel_2496/1060714452.py:11: Pandas4Warning: The 'lsuffix' and 'rsuffix' keywords in DataFrame.join are deprecated and will be removed in a future version. Use the 'suffixes' keyword instead. j = a.join(b, lsuffix="_r", rsuffix="_f", how="inner") /tmp/ipykernel_2496/1060714452.py:11: Pandas4Warning: The 'lsuffix' and 'rsuffix' keywords in DataFrame.join are deprecated and will be removed in a future version. Use the 'suffixes' keyword instead. j = a.join(b, lsuffix="_r", rsuffix="_f", how="inner") /tmp/ipykernel_2496/1060714452.py:11: Pandas4Warning: The 'lsuffix' and 'rsuffix' keywords in DataFrame.join are deprecated and will be removed in a future version. Use the 'suffixes' keyword instead. j = a.join(b, lsuffix="_r", rsuffix="_f", how="inner")
category neurons with rows in the Figure 3 table: hippocampus 100 amygdala 218
/tmp/ipykernel_2496/1060714452.py:11: Pandas4Warning: The 'lsuffix' and 'rsuffix' keywords in DataFrame.join are deprecated and will be removed in a future version. Use the 'suffixes' keyword instead. j = a.join(b, lsuffix="_r", rsuffix="_f", how="inner") /tmp/ipykernel_2496/1060714452.py:11: Pandas4Warning: The 'lsuffix' and 'rsuffix' keywords in DataFrame.join are deprecated and will be removed in a future version. Use the 'suffixes' keyword instead. j = a.join(b, lsuffix="_r", rsuffix="_f", how="inner") /tmp/ipykernel_2496/1060714452.py:11: Pandas4Warning: The 'lsuffix' and 'rsuffix' keywords in DataFrame.join are deprecated and will be removed in a future version. Use the 'suffixes' keyword instead. j = a.join(b, lsuffix="_r", rsuffix="_f", how="inner") /tmp/ipykernel_2496/1060714452.py:11: Pandas4Warning: The 'lsuffix' and 'rsuffix' keywords in DataFrame.join are deprecated and will be removed in a future version. Use the 'suffixes' keyword instead. j = a.join(b, lsuffix="_r", rsuffix="_f", how="inner") /tmp/ipykernel_2496/1060714452.py:11: Pandas4Warning: The 'lsuffix' and 'rsuffix' keywords in DataFrame.join are deprecated and will be removed in a future version. Use the 'suffixes' keyword instead. j = a.join(b, lsuffix="_r", rsuffix="_f", how="inner") /tmp/ipykernel_2496/1060714452.py:11: Pandas4Warning: The 'lsuffix' and 'rsuffix' keywords in DataFrame.join are deprecated and will be removed in a future version. Use the 'suffixes' keyword instead. j = a.join(b, lsuffix="_r", rsuffix="_f", how="inner")
print(R3CD[R3CD.area == "hippocampus"].round(4).to_string(index=False))
print("variant with the all-sure session (as the paper's code keeps it):")
print(R3CDV[R3CDV.area == "hippocampus"].round(4).to_string(index=False))
print("paper: high t(82) = 2.16, p = 0.028; low t(68) = -1.38, p = 0.17")
area level value with_both with_spikes n mean_rem mean_forg diff t df p
hippocampus high norm 80 73 69 17.4443 10.7162 6.7281 1.1700 68 0.2551
hippocampus high Hz 80 73 71 3.1032 2.8906 0.2126 1.7903 70 0.0779
hippocampus low norm 72 68 66 25.9737 37.1657 -11.1919 -1.0855 65 0.2987
hippocampus low Hz 72 68 67 2.7449 3.0730 -0.3281 -1.6817 66 0.1029
variant with the all-sure session (as the paper's code keeps it):
area level value with_both with_spikes n mean_rem mean_forg diff t df p
hippocampus high norm 82 75 70 14.0844 8.6876 5.3967 1.0087 69 0.3303
hippocampus high Hz 82 75 73 3.1118 2.8842 0.2277 1.9608 72 0.0537
hippocampus low norm 72 68 66 25.9737 37.1657 -11.1919 -1.0855 65 0.2831
hippocampus low Hz 72 68 67 2.7449 3.0730 -0.3281 -1.6817 66 0.1021
paper: high t(82) = 2.16, p = 0.028; low t(68) = -1.38, p = 0.17
Neurons lost at each step (asked for in verification round 1), for each area and confidence level: category neurons, those with a non-zero baseline, outside the all-sure session, with rows in the Figure 3 table (correct WM trials, preferred pictures later tested and rated), with rows in the remembered and in the forgotten condition, with both, with spikes in both, and after O-M; then the rows per neuron and condition among the neurons with both. As a diagnostic, not a reading of the claims file, the same test on the rows of incorrect WM trials too.
rows = []
for area in ("hippocampus", "amygdala"):
cn = CN[CN.area == area].neuron
full = F3FULL[F3FULL.area == area]
for level in ("high", "low"):
rem, forg = CONDS[level]
d = F3[F3.area == area]
a = d[d.conf.isin(rem)].groupby("neuron").agg(n=("FR", "size"), c=("c_maint", "sum"))
b = d[d.conf.isin(forg)].groupby("neuron").agg(n=("FR", "size"), c=("c_maint", "sum"))
j = a.join(b, lsuffix="_r", rsuffix="_f", how="inner")
rows.append(dict(area=area, level=level, category=len(cn), nonzero_baseline=full.neuron.nunique(),
not_all_sure=full[~full.si.isin(NOCONF_SI)].neuron.nunique(),
with_rows=d.neuron.nunique(), remembered=len(a), forgotten=len(b),
both=len(j), spikes_both=int(((j.c_r > 0) & (j.c_f > 0)).sum()),
after_OM_norm=len(KEEP3C[(area, level, "norm")]),
after_OM_Hz=len(KEEP3C[(area, level, "Hz")]),
rows_rem_median=j.n_r.median(), rows_rem_min=j.n_r.min(),
rows_forg_median=j.n_f.median(), rows_forg_min=j.n_f.min(),
one_forgotten_row=int((j.n_f == 1).sum())))
print(pd.DataFrame(rows).to_string(index=False))
F3INC = F3FULL[(F3FULL.pref == 1) & F3FULL.conf.notna() & ~F3FULL.si.isin(NOCONF_SI)]
print("\ndiagnostic, correct and incorrect WM trials:")
print(pd.DataFrame([remembered_forgotten(a, l, v, np.random.default_rng(304), data=F3INC)[0]
for a in ("hippocampus", "amygdala") for l in ("high", "low")
for v in ("norm", "Hz")]).round(4).to_string(index=False))
/tmp/ipykernel_2496/6135190.py:10: Pandas4Warning: The 'lsuffix' and 'rsuffix' keywords in DataFrame.join are deprecated and will be removed in a future version. Use the 'suffixes' keyword instead. j = a.join(b, lsuffix="_r", rsuffix="_f", how="inner") /tmp/ipykernel_2496/6135190.py:10: Pandas4Warning: The 'lsuffix' and 'rsuffix' keywords in DataFrame.join are deprecated and will be removed in a future version. Use the 'suffixes' keyword instead. j = a.join(b, lsuffix="_r", rsuffix="_f", how="inner") /tmp/ipykernel_2496/6135190.py:10: Pandas4Warning: The 'lsuffix' and 'rsuffix' keywords in DataFrame.join are deprecated and will be removed in a future version. Use the 'suffixes' keyword instead. j = a.join(b, lsuffix="_r", rsuffix="_f", how="inner")
area level category nonzero_baseline not_all_sure with_rows remembered forgotten both spikes_both after_OM_norm after_OM_Hz rows_rem_median rows_rem_min rows_forg_median rows_forg_min one_forgotten_row hippocampus high 102 102 100 100 98 82 80 73 69 71 19.5 1 5.0 1 13 hippocampus low 102 102 100 100 90 80 72 68 66 67 4.0 1 3.5 1 20 amygdala high 222 222 218 218 210 165 161 150 146 147 25.0 1 5.0 1 22 amygdala low 222 222 218 218 199 173 158 150 146 146 6.0 1 4.0 1 43 diagnostic, correct and incorrect WM trials:
/tmp/ipykernel_2496/6135190.py:10: Pandas4Warning: The 'lsuffix' and 'rsuffix' keywords in DataFrame.join are deprecated and will be removed in a future version. Use the 'suffixes' keyword instead. j = a.join(b, lsuffix="_r", rsuffix="_f", how="inner") /tmp/ipykernel_2496/1060714452.py:11: Pandas4Warning: The 'lsuffix' and 'rsuffix' keywords in DataFrame.join are deprecated and will be removed in a future version. Use the 'suffixes' keyword instead. j = a.join(b, lsuffix="_r", rsuffix="_f", how="inner") /tmp/ipykernel_2496/1060714452.py:11: Pandas4Warning: The 'lsuffix' and 'rsuffix' keywords in DataFrame.join are deprecated and will be removed in a future version. Use the 'suffixes' keyword instead. j = a.join(b, lsuffix="_r", rsuffix="_f", how="inner") /tmp/ipykernel_2496/1060714452.py:11: Pandas4Warning: The 'lsuffix' and 'rsuffix' keywords in DataFrame.join are deprecated and will be removed in a future version. Use the 'suffixes' keyword instead. j = a.join(b, lsuffix="_r", rsuffix="_f", how="inner") /tmp/ipykernel_2496/1060714452.py:11: Pandas4Warning: The 'lsuffix' and 'rsuffix' keywords in DataFrame.join are deprecated and will be removed in a future version. Use the 'suffixes' keyword instead. j = a.join(b, lsuffix="_r", rsuffix="_f", how="inner") /tmp/ipykernel_2496/1060714452.py:11: Pandas4Warning: The 'lsuffix' and 'rsuffix' keywords in DataFrame.join are deprecated and will be removed in a future version. Use the 'suffixes' keyword instead. j = a.join(b, lsuffix="_r", rsuffix="_f", how="inner") /tmp/ipykernel_2496/1060714452.py:11: Pandas4Warning: The 'lsuffix' and 'rsuffix' keywords in DataFrame.join are deprecated and will be removed in a future version. Use the 'suffixes' keyword instead. j = a.join(b, lsuffix="_r", rsuffix="_f", how="inner") /tmp/ipykernel_2496/1060714452.py:11: Pandas4Warning: The 'lsuffix' and 'rsuffix' keywords in DataFrame.join are deprecated and will be removed in a future version. Use the 'suffixes' keyword instead. j = a.join(b, lsuffix="_r", rsuffix="_f", how="inner")
area level value with_both with_spikes n mean_rem mean_forg diff t df p hippocampus high norm 80 73 68 13.3407 9.4129 3.9277 0.7396 67 0.4637 hippocampus high Hz 80 73 71 3.0950 2.9065 0.1885 1.5720 70 0.1201 hippocampus low norm 75 71 69 27.6462 39.5301 -11.8839 -1.0726 68 0.2961 hippocampus low Hz 75 71 69 2.7166 2.9516 -0.2350 -1.2483 68 0.2143 amygdala high norm 161 150 146 15.2512 14.6538 0.5974 0.1367 145 0.8920 amygdala high Hz 161 150 147 2.4009 2.4160 -0.0151 -0.1937 146 0.8482 amygdala low norm 160 154 150 19.0645 13.0561 6.0084 1.2342 149 0.2289 amygdala low Hz 160 154 150 2.3809 2.4085 -0.0276 -0.3442 149 0.7166
/tmp/ipykernel_2496/1060714452.py:11: Pandas4Warning: The 'lsuffix' and 'rsuffix' keywords in DataFrame.join are deprecated and will be removed in a future version. Use the 'suffixes' keyword instead. j = a.join(b, lsuffix="_r", rsuffix="_f", how="inner")
Result: not reproduced. In the hippocampus, remembered and forgotten do not differ with high confidence under either reading (normalized: t(68) = 1.17, p = 0.26; spikes per second: t(70) = 1.79, p = 0.078), nor with low confidence (p = 0.30 and 0.10). Keeping the all-sure session, as the code does, gives p = 0.33 and 0.054. 69 to 71 neurons enter the high-confidence test against 83 in the paper. The table of losses shows where they go: of 102 category neurons, 100 are outside the all-sure session and have rows, 98 have a remembered high-confidence row, 82 a forgotten one, 80 both, 73 spikes in both, and O-M removes 4 or 2 more. The forgotten condition has a median of 5 rows per neuron, and 13 neurons have one. Since 80 neurons have both conditions before any removal, fewer than the 83 the paper tests, the paper's rows likely differ from the claims file's (correct WM trials, preferred pictures later tested). Taking incorrect WM trials too (a diagnostic) leaves 80 neurons with both conditions and gives p = 0.46 and 0.12.
print(R3CD[R3CD.area == "amygdala"].round(4).to_string(index=False))
print("variant with the all-sure session:")
print(R3CDV[R3CDV.area == "amygdala"].round(4).to_string(index=False))
print("paper: high t(158) = 0.84, p = 0.41; low t(152) = 1.15, p = 0.26")
area level value with_both with_spikes n mean_rem mean_forg diff t df p
amygdala high norm 161 150 146 14.8278 15.7999 -0.9722 -0.2145 145 0.8454
amygdala high Hz 161 150 147 2.3857 2.4261 -0.0404 -0.5002 146 0.6370
amygdala low norm 158 150 146 18.8811 13.7053 5.1758 1.0248 145 0.2999
amygdala low Hz 158 150 146 2.4178 2.4758 -0.0580 -0.6681 145 0.5090
variant with the all-sure session:
area level value with_both with_spikes n mean_rem mean_forg diff t df p
amygdala high norm 165 154 150 15.6786 17.2502 -1.5716 -0.3366 149 0.7410
amygdala high Hz 165 154 151 2.4384 2.4713 -0.0329 -0.3969 150 0.7036
amygdala low norm 158 150 146 18.8811 13.7053 5.1758 1.0248 145 0.3143
amygdala low Hz 158 150 146 2.4178 2.4758 -0.0580 -0.6681 145 0.4895
paper: high t(158) = 0.84, p = 0.41; low t(152) = 1.15, p = 0.26
Result: reproduced. In the amygdala no comparison has p < 0.05 (high p = 0.85 and 0.64, low p = 0.30 and 0.51; 146 to 147 neurons).
Claims fig3e-early-delay-cluster and fig3f-amygdala-no-cluster¶
In hippocampal category neurons, firing differs between pictures later remembered and forgotten with high confidence early in the maintenance period, from 0 to 650 ms.
In amygdala category neurons, no period of the maintenance period shows a significant difference between later remembered and forgotten pictures.
Neurons and conditions of the high-confidence test of fig3c (and fig3d), per reading of the rate. Time-resolved rates over 0 to 2.5 s after maintenance onset: (a) 200 ms windows stepped by 25 ms, centres 0 to 2.5 s (windows reach 100 ms past the period at both ends), or (b) 50 ms bins, centres 25 ms to 2.475 s. Normalized rates use each neuron's mean baseline rate of the Figure 3 table. Cluster-based permutation test (sbcat.cluster_test), 10,000 sign flips, cluster-forming threshold two-sided 0.05, cluster p judged at 0.025.
BINNINGS = {"(a) 200/25 ms": (np.arange(0, 2.5001, 0.025), 0.2),
"(b) 50 ms": (np.arange(0.025, 2.5, 0.05), 0.05)}
BASE3 = {n: g.r_bsl.mean() for n, g in F3FULL.groupby("neuron")}
NEURON_SPIKES = {n: S[u.si]["spikes"][u.ui] for n, u in CN.set_index("neuron").iterrows()}
def time_resolved(area, value, binning, rng):
centres, width = BINNINGS[binning]
neurons = KEEP3C[(area, "high", value)]
d = F3[(F3.area == area) & F3.neuron.isin(neurons)]
A, B = [], []
for n in neurons:
g = d[d.neuron == n]
rates = []
for confs in ([6], [1]):
t0 = g.t_maint[g.conf.isin(confs)].values
r = sbcat.binned_counts(NEURON_SPIKES[n], t0, centres, width).mean(0) / width
rates.append(sbcat.normalize(r, BASE3[n]) if value == "norm" else r)
A.append(rates[0])
B.append(rates[1])
t, cl = sbcat.cluster_test(np.array(A), np.array(B), rng)
return centres, t, cl, len(neurons)
R3EF, TCURVE = [], {}
t0 = time.time()
for area in ("hippocampus", "amygdala"):
for value in ("norm", "Hz"):
for binning in BINNINGS:
rng = np.random.default_rng(302)
centres, t, cl, n = time_resolved(area, value, binning, rng)
TCURVE[(area, value, binning)] = pd.Series(t, index=np.round(centres, 3))
for c in cl:
R3EF.append(dict(area=area, value=value, binning=binning, neurons=n,
sign="rem > forg" if c["sign"] == 1 else "rem < forg",
start_s=centres[c["start"]], end_s=centres[c["end"]],
cluster_sum=c["sum"], p=c["p"]))
if not cl:
R3EF.append(dict(area=area, value=value, binning=binning, neurons=n, sign="none"))
print(area, value, binning, "neurons", n, "max |t| %.2f" % np.max(np.abs(t)),
"clusters", len(cl))
R3EF = pd.DataFrame(R3EF)
print("cluster tests took %.0f s" % (time.time() - t0))
hippocampus norm (a) 200/25 ms neurons 69 max |t| 4.05 clusters 6
hippocampus norm (b) 50 ms neurons 69 max |t| 3.43 clusters 3
hippocampus Hz (a) 200/25 ms neurons 71 max |t| 4.41 clusters 3
hippocampus Hz (b) 50 ms neurons 71 max |t| 3.60 clusters 4
amygdala norm (a) 200/25 ms neurons 146 max |t| 2.15 clusters 1
amygdala norm (b) 50 ms neurons 146 max |t| 2.25 clusters 2
amygdala Hz (a) 200/25 ms neurons 147 max |t| 2.20 clusters 3
amygdala Hz (b) 50 ms neurons 147 max |t| 1.85 clusters 0 cluster tests took 8 s
r = R3EF[R3EF.area == "hippocampus"]
print(r.round(4).to_string(index=False))
print("paper: 0 to 650 ms, cluster p = 0.0042")
area value binning neurons sign start_s end_s cluster_sum p hippocampus norm (a) 200/25 ms 69 rem > forg 0.000 0.025 5.9626 0.2481 hippocampus norm (a) 200/25 ms 69 rem > forg 0.650 0.650 2.1001 0.4789 hippocampus norm (a) 200/25 ms 69 rem > forg 0.900 1.050 20.1614 0.0196 hippocampus norm (a) 200/25 ms 69 rem > forg 1.725 1.725 2.2840 0.4120 hippocampus norm (a) 200/25 ms 69 rem > forg 1.800 1.850 7.1142 0.1915 hippocampus norm (a) 200/25 ms 69 rem < forg 2.425 2.425 -2.4105 0.3942 hippocampus norm (b) 50 ms 69 rem > forg 0.225 0.225 2.1332 0.4631 hippocampus norm (b) 50 ms 69 rem > forg 0.875 1.025 11.1504 0.0001 hippocampus norm (b) 50 ms 69 rem > forg 1.775 1.775 2.4010 0.2519 hippocampus Hz (a) 200/25 ms 71 rem > forg 0.000 0.125 16.2675 0.0610 hippocampus Hz (a) 200/25 ms 71 rem > forg 0.875 1.025 23.0593 0.0187 hippocampus Hz (a) 200/25 ms 71 rem > forg 1.725 1.825 11.0270 0.1315 hippocampus Hz (b) 50 ms 71 rem > forg 0.025 0.025 2.3150 0.3816 hippocampus Hz (b) 50 ms 71 rem > forg 0.725 0.725 2.0700 0.5853 hippocampus Hz (b) 50 ms 71 rem > forg 0.925 0.975 6.4498 0.0026 hippocampus Hz (b) 50 ms 71 rem > forg 1.475 1.475 2.3649 0.3456 paper: 0 to 650 ms, cluster p = 0.0042
The time-resolved t (remembered against forgotten, high confidence, hippocampus) under the four readings, at every 100 ms (asked for in verification round 1), with the cluster-forming threshold. With 200 ms windows the time is the window centre, so the windows centred before 0.1 s take in up to 100 ms of the last encoding picture.
for b, step in zip(BINNINGS, (4, 2)):
TC = pd.DataFrame({v: TCURVE[("hippocampus", v, b)] for v in ("norm", "Hz")})
print(f"binning {b}, t every 100 ms (time in s):")
print(TC.iloc[::step].round(2).T.to_string())
for v in ("norm", "Hz"):
n = R3EF[(R3EF.area == "hippocampus") & (R3EF.value == v)].neurons.iloc[0]
early = TC[v][TC.index <= 0.65]
print(f" {v}: cluster-forming threshold |t| > {sbcat.stats.t.ppf(0.975, n - 1):.2f}; "
f"0 to 650 ms t from {early.min():.2f} to {early.max():.2f}, mean {early.mean():.2f}, "
f"above the threshold in {int((early > sbcat.stats.t.ppf(0.975, n - 1)).sum())} of {len(early)} points; "
f"largest at {early.idxmax():.3f} s; largest |t| over the delay {TC[v].abs().max():.2f} "
f"at {TC[v].abs().idxmax():.3f} s")
binning (a) 200/25 ms, t every 100 ms (time in s):
0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0 2.1 2.2 2.3 2.4 2.5
norm 3.09 0.65 -0.04 0.53 0.48 0.72 1.45 0.12 -0.33 2.02 2.87 0.98 -0.93 -0.74 0.46 0.10 -0.01 1.41 2.44 0.90 -0.95 -0.22 -0.20 -0.81 -1.43 -1.28
Hz 3.36 2.07 1.49 1.41 0.48 -0.13 -0.30 -0.06 0.80 3.14 2.56 0.50 -0.95 -0.46 1.90 0.98 0.01 1.61 2.46 0.67 -0.49 -0.09 -0.04 -1.13 -1.52 -0.58
norm: cluster-forming threshold |t| > 2.00; 0 to 650 ms t from -0.30 to 3.09, mean 0.83, above the threshold in 3 of 27 points; largest at 0.000 s; largest |t| over the delay 4.05 at 0.950 s
Hz: cluster-forming threshold |t| > 1.99; 0 to 650 ms t from -0.66 to 3.47, mean 1.08, above the threshold in 6 of 27 points; largest at 0.025 s; largest |t| over the delay 4.41 at 0.975 s
binning (b) 50 ms, t every 100 ms (time in s):
0.025 0.125 0.225 0.325 0.425 0.525 0.625 0.725 0.825 0.925 1.025 1.125 1.225 1.325 1.425 1.525 1.625 1.725 1.825 1.925 2.025 2.125 2.225 2.325 2.425
norm 1.52 -0.12 2.13 1.04 -0.32 -0.26 0.37 0.81 -0.93 2.58 3.43 0.36 -1.29 -0.48 0.65 -0.91 0.81 -0.26 1.89 0.40 -0.89 0.09 -0.47 -0.16 -1.02
Hz 2.32 0.28 1.63 1.57 -0.19 -1.17 -0.49 2.07 -0.57 3.60 0.97 1.36 -1.15 0.54 1.88 -0.88 0.92 1.07 1.50 -0.51 -0.47 -0.11 0.19 -0.55 -1.51
norm: cluster-forming threshold |t| > 2.00; 0 to 650 ms t from -0.53 to 2.13, mean 0.54, above the threshold in 1 of 13 points; largest at 0.225 s; largest |t| over the delay 3.43 at 1.025 s
Hz: cluster-forming threshold |t| > 1.99; 0 to 650 ms t from -1.17 to 2.32, mean 0.58, above the threshold in 1 of 13 points; largest at 0.025 s; largest |t| over the delay 3.60 at 0.925 s
Result: partially reproduced. Under every reading a cluster with remembered above forgotten has cluster p < 0.025, but it lies from about 0.875 to 1.05 s (p = 0.0001 to 0.0196), not from 0 to 650 ms. Clusters starting at maintenance onset do not reach significance (smallest p 0.061, 0 to 0.125 s, spikes per second, 200 ms windows). The time-resolved t shows why: in 0 to 650 ms it exceeds the cluster-forming threshold (about 2.0) at 3 of 27 points (normalized) and 6 of 27 (spikes per second) with 200 ms windows, with its largest values at onset (3.09 at 0 s, normalized; 3.47 at 0.025 s, spikes per second; windows that take in 100 and 75 ms of the last encoding picture), and at one of 13 points with 50 ms bins (2.13 and 2.32), too few contiguous points to form a significant cluster. The largest |t| over the whole delay lies at 0.925 to 1.025 s under every reading (4.05 and 4.41 with 200 ms windows, 3.43 and 3.60 with 50 ms bins). The criterion's partial grade is met, but the data do not support an early effect.
r = R3EF[R3EF.area == "amygdala"]
print(r.round(4).to_string(index=False))
print("smallest cluster p per reading:")
print(r.groupby(["value", "binning"]).p.min())
area value binning neurons sign start_s end_s cluster_sum p
amygdala norm (a) 200/25 ms 146 rem > forg 0.000 0.000 2.1489 0.4732
amygdala norm (b) 50 ms 146 rem > forg 0.325 0.325 2.2464 0.3986
amygdala norm (b) 50 ms 146 rem > forg 1.275 1.275 2.2241 0.4159
amygdala Hz (a) 200/25 ms 147 rem > forg 0.375 0.375 2.1406 0.4577
amygdala Hz (a) 200/25 ms 147 rem > forg 1.250 1.250 2.2048 0.4341
amygdala Hz (a) 200/25 ms 147 rem < forg 0.775 0.775 -2.0011 0.5375
amygdala Hz (b) 50 ms 147 none NaN NaN NaN NaN
smallest cluster p per reading:
value binning
Hz (a) 200/25 ms 0.434057
(b) 50 ms NaN
norm (a) 200/25 ms 0.473153
(b) 50 ms 0.398560
Name: p, dtype: float64
Result: reproduced. In the amygdala no cluster has p < 0.025 under any reading (smallest cluster p 0.40, normalized, 50 ms bins).
Claim fig3g-nonpreferred-no-effect¶
Maintenance activity of category neurons while non-preferred pictures are held does not predict later LTM accuracy or confidence.
The Figure 3a model on non-preferred rows: (a) every non-preferred picture of the code's table, (b) only pictures of trials that held no preferred picture.
trial_has_pref = {n: set(NPT[n].trial[NPT[n].pref == 1]) for n in ALL_CN}
def nonpref_b(d):
d = fig3_select(d, pref=0)
keep = [t not in trial_has_pref[n] for n, t in zip(d.neuron, d.trial)]
return d[keep]
R3G = pd.concat([
fig3_fit(F3FULL, "LTMacc * conf3 * hipp", select=lambda d: fig3_select(d, pref=0),
label="(a) all non-preferred pictures"),
fig3_fit(F3FULL, "LTMacc * conf3 * hipp", select=nonpref_b,
label="(b) trials without a preferred picture")])
show(R3G)
r = R3G[(R3G.term != "Intercept") & (R3G.outliers.isin(["O-G", "O-C"]))]
print("smallest p of a fixed effect other than the intercept, per reading and outlier rule:")
print(r.groupby(["reading", "outliers"]).p.min())
reading outliers term beta SE p neurons n removed converged
(a) all non-preferred pictures O-G Intercept 13.55 4.47 0.002430 313 45803 5 True
(a) all non-preferred pictures O-G LTMacc -4.17 5.53 0.450803 313 45803 5 True
(a) all non-preferred pictures O-G conf3 -2.56 1.96 0.190992 313 45803 5 True
(a) all non-preferred pictures O-G LTMacc:conf3 3.93 2.57 0.125762 313 45803 5 True
(a) all non-preferred pictures O-G hipp 13.63 8.00 0.088657 313 45803 5 True
(a) all non-preferred pictures O-G LTMacc:hipp -1.26 10.20 0.901905 313 45803 5 True
(a) all non-preferred pictures O-G conf3:hipp 2.40 3.55 0.499715 313 45803 5 True
(a) all non-preferred pictures O-G LTMacc:conf3:hipp -1.80 4.70 0.702252 313 45803 5 True
(a) all non-preferred pictures O-C Intercept 10.71 4.37 0.014257 310 45323 8 True
(a) all non-preferred pictures O-C LTMacc -1.99 5.28 0.706814 310 45323 8 True
(a) all non-preferred pictures O-C conf3 -1.87 1.87 0.315295 310 45323 8 True
(a) all non-preferred pictures O-C LTMacc:conf3 3.01 2.45 0.218367 310 45323 8 True
(a) all non-preferred pictures O-C hipp 13.90 7.60 0.067301 310 45323 8 True
(a) all non-preferred pictures O-C LTMacc:hipp -2.68 9.75 0.783602 310 45323 8 True
(a) all non-preferred pictures O-C conf3:hipp 2.38 3.39 0.483910 310 45323 8 True
(a) all non-preferred pictures O-C LTMacc:conf3:hipp -1.57 4.49 0.727047 310 45323 8 True
(a) all non-preferred pictures none Intercept 15.74 5.28 0.002873 318 46443 0 True
(a) all non-preferred pictures none LTMacc -4.84 6.42 0.450987 318 46443 0 True
(a) all non-preferred pictures none conf3 -1.83 2.27 0.420039 318 46443 0 True
(a) all non-preferred pictures none LTMacc:conf3 3.82 2.97 0.198581 318 46443 0 True
(a) all non-preferred pictures none hipp 15.81 9.40 0.092400 318 46443 0 True
(a) all non-preferred pictures none LTMacc:hipp -2.01 11.78 0.864756 318 46443 0 True
(a) all non-preferred pictures none conf3:hipp 1.94 4.11 0.636927 318 46443 0 True
(a) all non-preferred pictures none LTMacc:conf3:hipp -1.77 5.43 0.744908 318 46443 0 True
(b) trials without a preferred picture O-G Intercept 11.70 5.09 0.021628 313 28129 5 True
(b) trials without a preferred picture O-G LTMacc -3.23 6.68 0.628423 313 28129 5 True
(b) trials without a preferred picture O-G conf3 -2.61 2.38 0.273628 313 28129 5 True
(b) trials without a preferred picture O-G LTMacc:conf3 4.06 3.10 0.189988 313 28129 5 True
(b) trials without a preferred picture O-G hipp 3.50 9.13 0.701257 313 28129 5 True
(b) trials without a preferred picture O-G LTMacc:hipp 13.50 12.44 0.278042 313 28129 5 True
(b) trials without a preferred picture O-G conf3:hipp 6.90 4.36 0.113714 313 28129 5 True
(b) trials without a preferred picture O-G LTMacc:conf3:hipp -8.87 5.76 0.123305 313 28129 5 True
(b) trials without a preferred picture O-C Intercept 9.30 4.94 0.059953 310 27851 8 True
(b) trials without a preferred picture O-C LTMacc -1.48 6.42 0.817420 310 27851 8 True
(b) trials without a preferred picture O-C conf3 -2.00 2.29 0.382758 310 27851 8 True
(b) trials without a preferred picture O-C LTMacc:conf3 3.26 2.98 0.273929 310 27851 8 True
(b) trials without a preferred picture O-C hipp 3.63 8.78 0.678988 310 27851 8 True
(b) trials without a preferred picture O-C LTMacc:hipp 11.96 11.99 0.318539 310 27851 8 True
(b) trials without a preferred picture O-C conf3:hipp 6.72 4.21 0.110336 310 27851 8 True
(b) trials without a preferred picture O-C LTMacc:conf3:hipp -8.12 5.55 0.143302 310 27851 8 True
(b) trials without a preferred picture none Intercept 13.75 5.95 0.020817 318 28535 0 True
(b) trials without a preferred picture none LTMacc -3.43 7.76 0.658809 318 28535 0 True
(b) trials without a preferred picture none conf3 -1.94 2.77 0.482147 318 28535 0 True
(b) trials without a preferred picture none LTMacc:conf3 3.51 3.59 0.328619 318 28535 0 True
(b) trials without a preferred picture none hipp 3.57 10.59 0.736342 318 28535 0 True
(b) trials without a preferred picture none LTMacc:hipp 18.23 14.40 0.205676 318 28535 0 True
(b) trials without a preferred picture none conf3:hipp 7.83 5.06 0.121407 318 28535 0 True
(b) trials without a preferred picture none LTMacc:conf3:hipp -11.08 6.66 0.096329 318 28535 0 True
smallest p of a fixed effect other than the intercept, per reading and outlier rule:
reading outliers
(a) all non-preferred pictures O-C 0.067301
O-G 0.088657
(b) trials without a preferred picture O-C 0.110336
O-G 0.113714
Name: p, dtype: float64
Result: reproduced. With O-G no fixed effect other than the intercept has p < 0.05 in either set of rows (smallest p 0.089 for all non-preferred pictures, 0.11 for trials without a preferred picture), nor with O-C (0.067 and 0.11).
Claim fig3h-encoding-no-effect¶
Activity of category neurons during the presentation of the first encoding picture, for preferred pictures, does not predict later LTM accuracy or confidence.
Rate 0 to 2 s after the onset of encoding picture 1, normalized as B; correct WM trials; (a) trials whose first picture is of the preferred category, with that picture's LTM outcome, or (b) trials holding a preferred picture in any slot, with that picture's LTM outcome.
E3FULL = fig3_full(ALL_CN, value="r_enc1")
R3H = pd.concat([
fig3_fit(E3FULL, "LTMacc * conf3 * hipp",
select=lambda d: fig3_select(d[d.slot == 1]), label="(a) picture 1 preferred"),
fig3_fit(E3FULL, "LTMacc * conf3 * hipp", select=fig3_select,
label="(b) preferred picture in any slot")])
show(R3H)
r = R3H[(R3H.term != "Intercept") & (R3H.outliers.isin(["O-G", "O-C"]))]
print("smallest p of a fixed effect other than the intercept, per reading and outlier rule:")
print(r.groupby(["reading", "outliers"]).p.min())
reading outliers term beta SE p neurons n removed converged
(a) picture 1 preferred O-G Intercept 59.57 19.25 0.001979 313 5421 5 True
(a) picture 1 preferred O-G LTMacc 11.76 27.36 0.667362 313 5421 5 True
(a) picture 1 preferred O-G conf3 -4.63 10.51 0.659373 313 5421 5 True
(a) picture 1 preferred O-G LTMacc:conf3 5.21 13.08 0.690364 313 5421 5 True
(a) picture 1 preferred O-G hipp 33.61 32.25 0.297387 313 5421 5 True
(a) picture 1 preferred O-G LTMacc:hipp -17.87 48.60 0.713062 313 5421 5 True
(a) picture 1 preferred O-G conf3:hipp -12.94 17.91 0.469795 313 5421 5 True
(a) picture 1 preferred O-G LTMacc:conf3:hipp 8.66 22.82 0.704285 313 5421 5 True
(a) picture 1 preferred O-C Intercept 58.51 18.91 0.001982 312 5410 6 True
(a) picture 1 preferred O-C LTMacc 12.33 26.91 0.646757 312 5410 6 True
(a) picture 1 preferred O-C conf3 -4.49 10.35 0.664128 312 5410 6 True
(a) picture 1 preferred O-C LTMacc:conf3 4.99 12.87 0.698445 312 5410 6 True
(a) picture 1 preferred O-C hipp 29.72 31.69 0.348408 312 5410 6 True
(a) picture 1 preferred O-C LTMacc:hipp -40.97 48.05 0.393903 312 5410 6 True
(a) picture 1 preferred O-C conf3:hipp -11.98 17.65 0.497447 312 5410 6 True
(a) picture 1 preferred O-C LTMacc:conf3:hipp 15.95 22.52 0.478963 312 5410 6 True
(a) picture 1 preferred none Intercept 77.37 40.44 0.055789 318 5505 0 True
(a) picture 1 preferred none LTMacc 1.90 56.13 0.972991 318 5505 0 True
(a) picture 1 preferred none conf3 -16.97 21.18 0.422852 318 5505 0 True
(a) picture 1 preferred none LTMacc:conf3 21.83 26.70 0.413603 318 5505 0 True
(a) picture 1 preferred none hipp 50.66 69.06 0.463225 318 5505 0 True
(a) picture 1 preferred none LTMacc:hipp 43.61 99.65 0.661667 318 5505 0 True
(a) picture 1 preferred none conf3:hipp 12.07 36.11 0.738135 318 5505 0 True
(a) picture 1 preferred none LTMacc:conf3:hipp -36.56 46.65 0.433237 318 5505 0 True
(b) preferred picture in any slot O-G Intercept 41.84 11.36 0.000231 313 11332 5 True
(b) preferred picture in any slot O-G LTMacc -14.79 15.30 0.333697 313 11332 5 True
(b) preferred picture in any slot O-G conf3 -6.68 5.91 0.258490 313 11332 5 True
(b) preferred picture in any slot O-G LTMacc:conf3 12.96 7.35 0.077848 313 11332 5 True
(b) preferred picture in any slot O-G hipp 10.08 18.87 0.593191 313 11332 5 True
(b) preferred picture in any slot O-G LTMacc:hipp 0.65 27.61 0.981174 313 11332 5 True
(b) preferred picture in any slot O-G conf3:hipp -1.59 10.49 0.879411 313 11332 5 True
(b) preferred picture in any slot O-G LTMacc:conf3:hipp -0.49 13.22 0.970520 313 11332 5 True
(b) preferred picture in any slot O-C Intercept 41.34 11.20 0.000225 312 11308 6 True
(b) preferred picture in any slot O-C LTMacc -14.75 15.10 0.328673 312 11308 6 True
(b) preferred picture in any slot O-C conf3 -6.67 5.83 0.252627 312 11308 6 True
(b) preferred picture in any slot O-C LTMacc:conf3 12.94 7.25 0.074331 312 11308 6 True
(b) preferred picture in any slot O-C hipp 5.87 18.62 0.752628 312 11308 6 True
(b) preferred picture in any slot O-C LTMacc:hipp -2.92 27.37 0.915133 312 11308 6 True
(b) preferred picture in any slot O-C conf3:hipp 0.72 10.36 0.944830 312 11308 6 True
(b) preferred picture in any slot O-C LTMacc:conf3:hipp -0.56 13.09 0.966001 312 11308 6 True
(b) preferred picture in any slot none Intercept 51.49 22.91 0.024606 318 11500 0 True
(b) preferred picture in any slot none LTMacc -16.55 29.55 0.575392 318 11500 0 True
(b) preferred picture in any slot none conf3 -12.30 11.28 0.275572 318 11500 0 True
(b) preferred picture in any slot none LTMacc:conf3 19.80 14.14 0.161662 318 11500 0 True
(b) preferred picture in any slot none hipp 37.00 40.08 0.355941 318 11500 0 True
(b) preferred picture in any slot none LTMacc:hipp 30.13 53.88 0.576051 318 11500 0 True
(b) preferred picture in any slot none conf3:hipp 8.39 20.12 0.676588 318 11500 0 True
(b) preferred picture in any slot none LTMacc:conf3:hipp -23.71 25.71 0.356378 318 11500 0 True
smallest p of a fixed effect other than the intercept, per reading and outlier rule:
reading outliers
(a) picture 1 preferred O-C 0.348408
O-G 0.297387
(b) preferred picture in any slot O-C 0.074331
O-G 0.077848
Name: p, dtype: float64
Result: reproduced. With O-G no fixed effect other than the intercept has p < 0.05 under either reading (smallest p 0.30 with picture 1 preferred, 0.078 with a preferred picture in any slot), nor with O-C (0.35 and 0.074). No reading shows an effect of LTM accuracy or confidence.
Claim ms-neuron-counts¶
53 of the 351 hippocampal units (15.10%) are memory-selective, 25 of them (47%) firing more to familiar than novel pictures.
for area in ("hippocampus", "amygdala"):
k = K[K.area == area]
print(f"{area}: {int(k.ms.sum())} of {len(k)} MS ({100*k.ms.mean():.2f} %), FS {int((k.ms_type == 'FS').sum())}, "
f"NS {int((k.ms_type == 'NS').sum())}")
print("expected hippocampus 53 +- 5.3 MS and 25 +- 2.5 FS; amygdala 68 in Table S1 (report)")
print("MS neurons by patient (hippocampus):", K[(K.area == "hippocampus") & K.ms].patient.value_counts().to_dict())
# Table S1 per-session category and MS counts, as a report for table-s1-counts
cnt = K.groupby(["session", "area"])[["cat", "ms"]].sum().unstack(fill_value=0)
rep = TS1[["label", "session", "h_cat", "a_cat", "h_ms", "a_ms"]].copy()
rep["h_cat_here"] = rep.session.map(cnt[("cat", "hippocampus")]).fillna(0).astype(int)
rep["a_cat_here"] = rep.session.map(cnt[("cat", "amygdala")]).fillna(0).astype(int)
rep["h_ms_here"] = rep.session.map(cnt[("ms", "hippocampus")]).fillna(0).astype(int)
rep["a_ms_here"] = rep.session.map(cnt[("ms", "amygdala")]).fillna(0).astype(int)
for a in ("h_cat", "a_cat", "h_ms", "a_ms"):
print(f"Table S1 {a}: sessions equal {int((rep[a] == rep[a + '_here']).sum())} of {len(rep)}, "
f"total {rep[a].sum()} in the table, {rep[a + '_here'].sum()} here")
hippocampus: 53 of 351 MS (15.10 %), FS 26, NS 27
amygdala: 69 of 532 MS (12.97 %), FS 28, NS 41
expected hippocampus 53 +- 5.3 MS and 25 +- 2.5 FS; amygdala 68 in Table S1 (report)
MS neurons by patient (hippocampus): {'20': 7, '27': 7, '10': 3, '23': 3, '37': 3, '39': 3, '17': 2, '2': 2, '21': 2, '22': 2, '24': 2, '28': 2, '30': 2, '32': 2, '5': 2, '6': 2, '11': 1, '14': 1, '18': 1, '19': 1, '33': 1, '34': 1, '4': 1}
Table S1 h_cat: sessions equal 42 of 46, total 104 in the table, 102 here
Table S1 a_cat: sessions equal 40 of 46, total 220 in the table, 222 here
Table S1 h_ms: sessions equal 40 of 46, total 53 in the table, 53 here
Table S1 a_ms: sessions equal 44 of 46, total 68 in the table, 69 here
Result: reproduced. 53 of 351 hippocampal units are memory-selective (15.10%), 26 of them familiarity-selective, within tolerance of 53 and 25.
Claim fig4b-ms-confidence-auc¶
Hippocampal memory-selective neurons separate old from new pictures better for high-confidence than for low-confidence decisions (higher ROC AUC), so they carry a memory-strength signal.
Spike counts 0.2 to 1.2 s after LTM picture onset. FS neurons: all true negatives against true positives rated 6 (high) and rated 4 or 5 (low); NS neurons: all true positives against true negatives rated 1 (high) and 2 or 3 (low); the AUC is oriented so that the preferred response above 0.5 is selectivity (sbcat.roc_auc). The all-sure session is left out. Neurons kept: (a) at least ten correct novel and ten correct familiar trials, (b) at least ten trials in each group compared; a neuron needs trials in both groups of each comparison; then O-M on the two AUC values.
MSH = K[(K.area == "hippocampus") & K.ms].copy()
rows = []
for _, u in MSH.iterrows():
s = S[u.si]
ltm = s["ltm"]
c = sbcat.count(s["spikes"][u.ui], ltm.timestamps_PicOnset.values, 0.2, 1.2)
conf, old = ltm.confidence.values, ltm.new_old.values == 1
tp, tn = old & (conf >= 4), ~old & (conf <= 3)
if u.ms_type == "FS":
fixed, high, low = c[tn], c[tp & (conf == 6)], c[tp & ((conf == 4) | (conf == 5))]
auc = lambda grp: sbcat.roc_auc(grp, fixed)
else:
fixed, high, low = c[tp], c[tn & (conf == 1)], c[tn & ((conf == 2) | (conf == 3))]
auc = lambda grp: sbcat.roc_auc(grp, fixed)
ok = len(high) > 0 and len(low) > 0 and np.r_[fixed, high, low].max() > 0
rows.append(dict(neuron=f"{u.si}_{u.ui}", session=u.session, type=u.ms_type,
n_tp=int(tp.sum()), n_tn=int(tn.sum()), n_fixed=len(fixed), n_high=len(high),
n_low=len(low), auc_high=auc(high) if ok else np.nan,
auc_low=auc(low) if ok else np.nan, noconf=u.si in NOCONF_SI))
AUC = pd.DataFrame(rows)
print("hippocampal MS neurons:", len(AUC), " in the all-sure session:", int(AUC.noconf.sum()),
" without trials in a compared group:", int(AUC.auc_high.isna().sum()))
rng = np.random.default_rng(401)
R4B = []
for lab, sel in [("(a) >= 10 TN and >= 10 TP", lambda a: (a.n_tp >= 10) & (a.n_tn >= 10)),
("(b) >= 10 in each group compared",
lambda a: (a.n_fixed >= 10) & (a.n_high >= 10) & (a.n_low >= 10))]:
a = AUC[sel(AUC) & ~AUC.noconf & AUC.auc_high.notna()]
v = a[["auc_high", "auc_low"]].values
out = np.any(np.abs(v - v.mean()) > 3 * v.std(ddof=1), axis=1)
a = a[~out]
t, p, df = sbcat.perm_ttest_paired(a.auc_high, a.auc_low, rng)
R4B.append(dict(reading=lab, neurons=len(a), outliers=int(out.sum()), FS=int((a.type == "FS").sum()),
auc_high=a.auc_high.mean(), auc_low=a.auc_low.mean(), t=t, df=df, p=p))
print(pd.DataFrame(R4B).round(4).to_string(index=False))
print("paper: t(40) = 2.89, p = 0.0039, 41 neurons")
print("AUC range: %.3f to %.3f" % (np.nanmin(AUC[["auc_high", "auc_low"]].values),
np.nanmax(AUC[["auc_high", "auc_low"]].values)))
hippocampal MS neurons: 53 in the all-sure session: 1 without trials in a compared group: 1
reading neurons outliers FS auc_high auc_low t df p
(a) >= 10 TN and >= 10 TP 49 3 25 0.5975 0.5577 3.8667 48 0.0005
(b) >= 10 in each group compared 40 0 21 0.5994 0.5621 3.5480 39 0.0009
paper: t(40) = 2.89, p = 0.0039, 41 neurons
AUC range: 0.230 to 0.853
Result: reproduced. The AUC is higher for high than low confidence under both readings: 0.5975 against 0.5577 (t(48) = 3.87, p = 0.0005, 49 neurons) and 0.5994 against 0.5621 (t(39) = 3.55, p = 0.0009, 40 neurons; paper 41).
Claim fig4c-overlap-chance¶
20 hippocampal neurons are both memory-selective and category neurons, an overlap no greater than chance.
rng = np.random.default_rng(402)
H = K[K.area == "hippocampus"]
obs = int((H.cat & H.ms).sum())
ncat, ms = int(H.cat.sum()), H.ms.values
null = np.array([ms[rng.choice(len(H), ncat, replace=False)].sum() for _ in range(1000)])
p = np.mean(null >= obs)
print(f"overlap {obs} (expected 20 +- 2) of {int(ms.sum())} MS and {ncat} category neurons; "
f"null mean {null.mean():.2f}, range {null.min()} to {null.max()}; p = {p:.3f} (paper 0.11)")
overlap 19 (expected 20 +- 2) of 53 MS and 102 category neurons; null mean 15.55, range 7 to 26; p = 0.179 (paper 0.11)
Result: reproduced. 19 neurons are both memory-selective and category neurons (expected 20 +- 2); the null overlap has mean 15.55 and p = 0.179, not below 0.05.
Claim fig4d-category-no-memory-signal¶
During LTM retrieval, hippocampal category neurons code neither familiarity nor confidence for pictures of their preferred category.
The new pictures' categories are not in the dataset's metadata (see below). Their images are in the files, and viewing them gives the category of each: blocks of 40 IDs per category, in the order of the old pictures' leading digit.
LTM trials showing a picture of the neuron's preferred category; rate 0.2 to 1.2 s after picture onset. GLM on correct trials (all-sure session left out): FR ~ conf * old with the random intercepts of G. Readings: (D1) confidence coding (a) the code's or (b) certainty; (D2) rate (a) spikes per second or (b) normalized to the neuron's mean WM baseline (B1). The t-test: per neuron the mean rate of preferred old against preferred new pictures, (D3) (a) correct trials or (b) all trials, under both D2 readings, after O-M; paired permutation t-test.
The category of a new LTM picture is not in the dataset's metadata. New pictures have IDs 1001 to 1200 (old ones keep their WM IDs, whose leading digit is the category), and their images in the files (stimulus/templates/StimulusTemplates) are named only by ID. The three task variants show different sets of new pictures. In this revision all 600 new images (200 per variant, from the sessions below) were viewed one by one: in each variant IDs 1001 to 1040 show people (faces), 1041 to 1080 animals, 1081 to 1120 cars (variants 1 and 3) or tools (variant 2), 1121 to 1160 food and fruit, and 1161 to 1200 landscapes (with city views in variant 3), the same order as the leading digits 1 to 5 of the old pictures. No image was found outside its block. The cell below shows, per variant, eight old pictures of each leading digit and all 40 new pictures of the matching block, from the files, so the mapping can be checked; it also compares the images of two sessions of each variant, and then the new images of every session with those of the viewed session of its variant. The cell after it checks the mapping against the category neurons' responses: for each category neuron, the block with the highest mean response to new pictures is compared with its preferred category, against the same for old pictures and for a grouping by ID modulo 5.
import hashlib
from IPython.display import Image as ShowImage, display
VARIANT = {si: s["notes"].split("Experiment variant: ")[1][0] for si, s in enumerate(S)}
print("sessions per task variant:", pd.Series(VARIANT).value_counts().sort_index().to_dict())
SHEET_SESSIONS = {"1": ["sub-10/sub-10_ses-1_ecephys+image.nwb", "sub-11/sub-11_ses-1_ecephys+image.nwb"],
"2": ["sub-1/sub-1_ses-2_ecephys+image.nwb", "sub-2/sub-2_ses-2_ecephys+image.nwb"],
"3": ["sub-16/sub-16_ses-2_ecephys+image.nwb", "sub-12/sub-12_ses-2_ecephys+image.nwb"]}
new_ids = list(range(1001, 1201))
md5 = lambda a: hashlib.md5(a.tobytes()).digest()
REF = {}
for v, (p1, p2) in SHEET_SESSIONS.items():
old_ids = [100 * k + j for k in range(1, 6) for j in range(1, 9)]
im1 = sbcat.read_images(p1, new_ids + old_ids)
im2 = sbcat.read_images(p2, new_ids)
REF[v] = {k: md5(a) for k, a in im1.items() if k > 1000}
same = sum(REF[v].get(k) == md5(a) for k, a in im2.items())
print(f"variant {v}: {p1} has {sum(k > 1000 for k in im1)} new images; {p2} has {len(im2)}, "
f"{same} identical to the first")
display(ShowImage(data=sbcat.contact_sheet(im1, old_ids, new_ids), format="jpeg"))
# Every session's new images against those of the viewed session of its variant (asked for in
# verification round 2: the sessions not viewed).
rows = []
for si, s in enumerate(S):
im = sbcat.read_images(s["path"], new_ids)
shown = set(s["ltm"].PicIDs[s["ltm"].new_old == 0].astype(int))
rows.append(dict(variant=VARIANT[si], new_images=len(im),
identical=sum(REF[VARIANT[si]].get(k) == md5(a) for k, a in im.items()),
new_shown=len(shown), shown_without_image=len(shown - set(im))))
IMG = pd.DataFrame(rows)
print(IMG.groupby("variant").agg(sessions=("new_images", "size"), new_images=("new_images", "sum"),
identical=("identical", "sum"), new_shown=("new_shown", "sum"),
shown_without_image=("shown_without_image", "sum")).to_string())
print("sessions with a new image differing from the viewed one:", int((IMG.identical < IMG.new_images).sum()))
sessions per task variant: {'1': 34, '2': 7, '3': 5}
variant 1: sub-10/sub-10_ses-1_ecephys+image.nwb has 200 new images; sub-11/sub-11_ses-1_ecephys+image.nwb has 200, 200 identical to the first
variant 2: sub-1/sub-1_ses-2_ecephys+image.nwb has 200 new images; sub-2/sub-2_ses-2_ecephys+image.nwb has 200, 200 identical to the first
variant 3: sub-16/sub-16_ses-2_ecephys+image.nwb has 200 new images; sub-12/sub-12_ses-2_ecephys+image.nwb has 83, 83 identical to the first
sessions new_images identical new_shown shown_without_image variant 1 34 6526 6526 6526 0 2 7 1400 1400 1400 0 3 5 883 883 883 0 sessions with a new image differing from the viewed one: 0
def new_cat_block(ids):
"""Category of a new LTM picture: blocks of 40 IDs, from viewing the images (above)."""
return (np.asarray(ids, int) - 1001) // 40 + 1
match = {"old pictures, category from the ID": 0, "new pictures, blocks of 40": 0,
"new pictures, ID modulo 5": 0}
for _, u in CN.iterrows():
s = S[u.si]
l = s["ltm"]
c = sbcat.count(NEURON_SPIKES[u.neuron], l.timestamps_PicOnset.values, 0.2, 1.2)
new = l.new_old.values == 0
ids = l.PicIDs.values.astype(int)
for lab, sel, g in [("old pictures, category from the ID", ~new, ids // 100),
("new pictures, blocks of 40", new, new_cat_block(ids)),
("new pictures, ID modulo 5", new, (ids - 1001) % 5 + 1)]:
m = [c[sel & (g == k)].mean() if np.any(sel & (g == k)) else -1 for k in range(1, 6)]
match[lab] += int(np.argmax(m) + 1 == u.pref)
for k, v in match.items():
print(f"{k}: the best group is the preferred category for {v} of {len(CN)} category neurons "
f"({100*v/len(CN):.1f} %; chance 20 %)")
print("new picture IDs:", int(min(s["ltm"].PicIDs[s["ltm"].new_old == 0].min() for s in S)), "to",
int(max(s["ltm"].PicIDs[s["ltm"].new_old == 0].max() for s in S)))
old pictures, category from the ID: the best group is the preferred category for 196 of 324 category neurons (60.5 %; chance 20 %) new pictures, blocks of 40: the best group is the preferred category for 188 of 324 category neurons (58.0 %; chance 20 %) new pictures, ID modulo 5: the best group is the preferred category for 53 of 324 category neurons (16.4 %; chance 20 %) new picture IDs: 1001 to 1200
rows = []
for n in HIPP_CN:
u = CN.set_index("neuron").loc[n]
s = S[u.si]
ltm = s["ltm"]
ids = ltm.PicIDs.values.astype(int)
cat_ltm = np.where(ltm.new_old.values == 1, ids // 100, new_cat_block(ids))
sel = cat_ltm == u.pref
c = sbcat.count(NEURON_SPIKES[n], ltm.timestamps_PicOnset.values[sel], 0.2, 1.2)
b = trial_rows(NPT[n]).r_bsl.mean()
rows.append(pd.DataFrame(dict(neuron=n, patient=u.patient, si=u.si, c=c, Hz=c / 1.0,
norm=sbcat.normalize(c / 1.0, b) if b > 0 else np.nan,
conf=ltm.confidence.values[sel], old=ltm.new_old.values[sel],
acc=ltm.response_accuracy.values[sel])))
L4 = pd.concat(rows, ignore_index=True)
L4["conf_code"] = sbcat.conf3_code(L4.conf)
L4["conf_cert"] = sbcat.conf3_certainty(L4.conf)
print("rows", len(L4), "neurons", L4.neuron.nunique(), " correct", int(L4.acc.sum()),
" neurons with a zero WM baseline:", L4[L4.norm.isna()].neuron.nunique())
rows 7598 neurons 102 correct 5521 neurons with a zero WM baseline: 0
res = []
for d1 in ("conf_code", "conf_cert"):
for d2 in ("Hz", "norm"):
d = L4[(L4.acc == 1) & ~L4.si.isin(NOCONF_SI) & L4[d2].notna()].copy()
d["FR"], d["confv"], d["old"] = d[d2], d[d1], d.old.astype(int)
for orule in ("O-M", "O-C", "none"):
bad = (sbcat.om_remove(d, ["old"], zero_col="c") if orule == "O-M" else
sbcat.oc_remove(d) if orule == "O-C" else set())
m = sbcat.mixedlm(d[~d.neuron.isin(bad)], "confv * old")
for term, r in m.iterrows():
res.append(dict(D1=d1, D2=d2, outliers=orule, term=term, beta=r.beta, p=r.p,
neurons=m.attrs["neurons"], n=m.attrs["n"], converged=m.attrs["converged"]))
R4D = pd.DataFrame(res)
print(R4D.round(4).to_string(index=False))
print("smallest p of a non-intercept effect per reading (O-M):")
print(R4D[(R4D.term != "Intercept") & (R4D.outliers == "O-M")].groupby(["D1", "D2"]).p.min())
rng = np.random.default_rng(403)
res = []
for d3 in ("correct", "all"):
for d2 in ("Hz", "norm"):
d = L4[L4[d2].notna()]
if d3 == "correct":
d = d[d.acc == 1]
a = d[d.old == 1].groupby("neuron").agg(v=(d2, "mean"), c=("c", "sum"))
b = d[d.old == 0].groupby("neuron").agg(v=(d2, "mean"), c=("c", "sum"))
j = a.join(b, lsuffix="_o", rsuffix="_n", how="inner")
j = j[(j.c_o > 0) & (j.c_n > 0)]
v = j[["v_o", "v_n"]].values
j = j[~np.any(np.abs(v - v.mean()) > 3 * v.std(ddof=1), axis=1)]
t, p, df = sbcat.perm_ttest_paired(j.v_o, j.v_n, rng)
res.append(dict(D3=d3, D2=d2, neurons=len(j), old=j.v_o.mean(), new=j.v_n.mean(), t=t, df=df, p=p))
print(pd.DataFrame(res).round(4).to_string(index=False))
print("paper: GLM confidence p = 0.28, familiarity p = 0.71, interaction p = 0.57; t(94) = -0.28, p = 0.78")
D1 D2 outliers term beta p neurons n converged
conf_code Hz O-M Intercept 3.5104 0.0000 94 5226 True
conf_code Hz O-M confv 0.0391 0.6602 94 5226 True
conf_code Hz O-M old -0.2081 0.5398 94 5226 True
conf_code Hz O-M confv:old 0.0867 0.5588 94 5226 True
conf_code Hz O-C Intercept 3.0997 0.0000 93 5052 True
conf_code Hz O-C confv 0.0541 0.5236 93 5052 True
conf_code Hz O-C old -0.2844 0.3770 93 5052 True
conf_code Hz O-C confv:old 0.1057 0.4531 93 5052 True
conf_code Hz none Intercept 3.7635 0.0000 100 5408 True
conf_code Hz none confv 0.0515 0.5636 100 5408 True
conf_code Hz none old -0.2644 0.4345 100 5408 True
conf_code Hz none confv:old 0.1012 0.4944 100 5408 True
conf_code norm O-M Intercept 89.8503 0.0022 94 5224 True
conf_code norm O-M confv 3.3017 0.6861 94 5224 True
conf_code norm O-M old -38.3010 0.2198 94 5224 True
conf_code norm O-M confv:old 11.2213 0.4096 94 5224 True
conf_code norm O-C Intercept 84.0484 0.0030 98 5303 True
conf_code norm O-C confv 6.3755 0.4422 98 5303 True
conf_code norm O-C old -9.3142 0.7674 98 5303 True
conf_code norm O-C confv:old 0.1927 0.9888 98 5303 True
conf_code norm none Intercept 112.5895 0.0056 100 5408 True
conf_code norm none confv 9.4450 0.3801 100 5408 True
conf_code norm none old 7.5541 0.8533 100 5408 True
conf_code norm none confv:old -3.6508 0.8381 100 5408 True
conf_cert Hz O-M Intercept 3.6669 0.0000 94 5226 True
conf_cert Hz O-M confv -0.0391 0.6602 94 5226 True
conf_cert Hz O-M old -0.3646 0.2516 94 5226 True
conf_cert Hz O-M confv:old 0.1650 0.1686 94 5226 True
conf_cert Hz O-C Intercept 3.3162 0.0000 93 5052 True
conf_cert Hz O-C confv -0.0541 0.5236 93 5052 True
conf_cert Hz O-C old -0.5009 0.1000 93 5052 True
conf_cert Hz O-C confv:old 0.2140 0.0626 93 5052 True
conf_cert Hz none Intercept 3.9695 0.0000 100 5408 True
conf_cert Hz none confv -0.0515 0.5636 100 5408 True
conf_cert Hz none old -0.4704 0.1416 100 5408 True
conf_cert Hz none confv:old 0.2041 0.0907 100 5408 True
conf_cert norm O-M Intercept 103.0573 0.0019 94 5224 True
conf_cert norm O-M confv -3.3017 0.6861 94 5224 True
conf_cert norm O-M old -51.5079 0.0788 94 5224 True
conf_cert norm O-M confv:old 17.8247 0.1067 94 5224 True
conf_cert norm O-C Intercept 109.5502 0.0007 98 5303 True
conf_cert norm O-C confv -6.3755 0.4422 98 5303 True
conf_cert norm O-C old -34.8161 0.2428 98 5303 True
conf_cert norm O-C confv:old 12.9436 0.2500 98 5303 True
conf_cert norm none Intercept 150.3696 0.0010 100 5408 True
conf_cert norm none confv -9.4450 0.3801 100 5408 True
conf_cert norm none old -30.2261 0.4343 100 5408 True
conf_cert norm none confv:old 15.2393 0.2957 100 5408 True
smallest p of a non-intercept effect per reading (O-M):
D1 D2
conf_cert Hz 0.168552
norm 0.078808
conf_code Hz 0.539817
norm 0.219825
Name: p, dtype: float64
D3 D2 neurons old new t df p
correct Hz 96 3.6819 3.5981 0.8835 95 0.3895
correct norm 96 77.9891 85.3034 -0.8194 95 0.4115
all Hz 98 3.7264 3.6338 1.2807 97 0.2199
all norm 98 85.7459 84.8189 0.1079 97 0.9246
paper: GLM confidence p = 0.28, familiarity p = 0.71, interaction p = 0.57; t(94) = -0.28, p = 0.78
/tmp/ipykernel_2496/3637752638.py:26: Pandas4Warning: The 'lsuffix' and 'rsuffix' keywords in DataFrame.join are deprecated and will be removed in a future version. Use the 'suffixes' keyword instead. j = a.join(b, lsuffix="_o", rsuffix="_n", how="inner")
Result: reproduced. The categories of the new pictures come from their images: in all three task variants IDs 1001 to 1200 form blocks of 40 per category, in the order of the old pictures' leading digits (contact sheets above). Every session's new images are identical to those of the viewed session of its variant (8809 images over 46 sessions, none differing), and every new picture shown in a session has its image in the file. The category neurons' responses agree: the best block is the preferred category for 58.0% of them, against 60.5% for old pictures and 16.4% for a grouping by ID modulo 5. With these categories no GLM effect reaches p < 0.05 under any reading (smallest p 0.079 with O-M, conf_cert and normalized rates; 0.063 with O-C), and no old against new t-test does (p 0.22 to 0.92, 96 or 98 neurons; paper t(94) = -0.28, p = 0.78).
Claims fig4e-fs-strong-maintenance and fig4f-ns-no-effect¶
Familiarity-selective hippocampal neurons respond more during LTM retrieval to familiar pictures that were held with strong, compared with weak, maintenance activity of a simultaneously recorded category neuron.
The response of novelty-selective hippocampal neurons to familiar pictures does not depend on whether the paired category neuron's maintenance activity was strong or weak.
Pairs of a hippocampal MS neuron and a hippocampal category neuron of the same session. Per category neuron, its maintenance rates in correct WM trials holding a preferred picture later shown in the LTM test, median-split within load 1 and within load 3 (a rate equal to the median is weak). The MS neuron's rate 0.2 to 1.2 s after onset of those pictures in the LTM test. Readings: (E1) the random intercept within patient is (a) the MS neuron or (b) the pair; (E2) (a) all LTM trials of those pictures or (b) those answered old; (E3) a neuron both MS and category (a) paired with itself or (b) not; (E4) rate (a) spikes per second or (b) normalized to the MS neuron's mean WM baseline.
MSN = K[(K.area == "hippocampus") & K.ms].copy()
MSN["neuron"] = [f"{a}_{b}" for a, b in zip(MSN.si, MSN.ui)]
def pair_rows(split="load"):
"""One row per (MS neuron, category neuron) pair and preferred picture. The category
neuron's maintenance rates are median-split within each load (Methods) or, as a variant,
over both loads pooled (split="pooled")."""
prow = []
for _, m in MSN.iterrows():
sp = S[m.si]["spikes"][m.ui]
trs = sbcat.add_counts(PT[m.si], sp)
mbase = trs.groupby("trial").r_bsl.first().mean()
for n in CN.neuron[(CN.area == "hippocampus") & (CN.si == m.si)]:
pt = code_rows(NPT[n])
pt = pt[(pt.acc == 1) & (pt.pref == 1)].copy()
if len(pt) == 0:
continue
med = (pt.groupby("load").r_maint.transform("median") if split == "load"
else pt.r_maint.median())
pt["strong"] = (pt.r_maint > med).astype(int)
c = sbcat.count(sp, pt.t_ltm.values, 0.2, 1.2)
prow.append(pd.DataFrame(dict(ms=m.neuron, cat=n, pair=f"{m.neuron}|{n}", patient=m.patient,
type=m.ms_type, self=m.neuron == n, strong=pt.strong.values,
load=pt.load.values, LTMacc=pt.LTMacc.values, c=c, Hz=c / 1.0,
norm=sbcat.normalize(c / 1.0, mbase) if mbase > 0 else np.nan)))
return pd.concat(prow, ignore_index=True)
P4 = pair_rows()
pairs = P4.drop_duplicates("pair")
print("pairs:", len(pairs), " FS:", int((pairs.type == "FS").sum()), " NS:", int((pairs.type == "NS").sum()),
" self-pairs:", int(pairs.self.sum()), "(FS", int((pairs.self & (pairs.type == "FS")).sum()), ")")
print("without self-pairs:", int((~pairs.self).sum()), " FS:", int(((pairs.type == "FS") & ~pairs.self).sum()),
" NS:", int(((pairs.type == "NS") & ~pairs.self).sum()))
print("rows per pair: %d to %d; strong share %.3f" % (P4.groupby("pair").size().min(),
P4.groupby("pair").size().max(), P4.strong.mean()))
print("expected: 198 +- 20 pairs, 76 +- 8 FS pairs (paper: 122 NS)")
def pair_tests(typ, rng, data=None):
glm, tt = [], []
for e2 in ("all", "answered old"):
for e3 in ("with self", "without self"):
for e4 in ("Hz", "norm"):
d = P4 if data is None else data
d = d[(d.type == typ) & d[e4].notna()]
if e2 == "answered old":
d = d[d.LTMacc == 1]
if e3 == "without self":
d = d[~d.self]
d = d.assign(FR=d[e4])
for e1 in ("MS neuron", "pair"):
dd = d.assign(neuron=d.ms if e1 == "MS neuron" else d.pair)
bad = sbcat.om_remove(dd.assign(neuron=d.pair), ["strong"], zero_col="c")
m = sbcat.mixedlm(dd[~d.pair.isin(bad)], "strong")
glm.append(dict(E1=e1, E2=e2, E3=e3, E4=e4, beta=m.loc["strong", "beta"],
p=m.loc["strong", "p"], converged=m.attrs["converged"], pairs=d.pair[~d.pair.isin(bad)].nunique(),
n=m.attrs["n"]))
a = d[d.strong == 1].groupby("pair").agg(v=("FR", "mean"), c=("c", "sum"))
b = d[d.strong == 0].groupby("pair").agg(v=("FR", "mean"), c=("c", "sum"))
j = a.join(b, lsuffix="_s", rsuffix="_w", how="inner")
j = j[(j.c_s > 0) & (j.c_w > 0)]
v = j[["v_s", "v_w"]].values
j = j[~np.any(np.abs(v - v.mean()) > 3 * v.std(ddof=1), axis=1)]
t, p, df = sbcat.perm_ttest_paired(j.v_s, j.v_w, rng)
tt.append(dict(E2=e2, E3=e3, E4=e4, pairs=len(j), strong=j.v_s.mean(), weak=j.v_w.mean(),
t=t, df=df, p=p))
return pd.DataFrame(glm), pd.DataFrame(tt)
G4E, T4E = pair_tests("FS", np.random.default_rng(404))
G4F, T4F = pair_tests("NS", np.random.default_rng(405))
pairs: 197 FS: 84 NS: 113 self-pairs: 19 (FS 10 ) without self-pairs: 178 FS: 74 NS: 104 rows per pair: 15 to 41; strong share 0.425 expected: 198 +- 20 pairs, 76 +- 8 FS pairs (paper: 122 NS)
/tmp/ipykernel_2496/174583337.py:62: Pandas4Warning: The 'lsuffix' and 'rsuffix' keywords in DataFrame.join are deprecated and will be removed in a future version. Use the 'suffixes' keyword instead. j = a.join(b, lsuffix="_s", rsuffix="_w", how="inner")
/tmp/ipykernel_2496/174583337.py:62: Pandas4Warning: The 'lsuffix' and 'rsuffix' keywords in DataFrame.join are deprecated and will be removed in a future version. Use the 'suffixes' keyword instead. j = a.join(b, lsuffix="_s", rsuffix="_w", how="inner")
/tmp/ipykernel_2496/174583337.py:62: Pandas4Warning: The 'lsuffix' and 'rsuffix' keywords in DataFrame.join are deprecated and will be removed in a future version. Use the 'suffixes' keyword instead. j = a.join(b, lsuffix="_s", rsuffix="_w", how="inner")
/tmp/ipykernel_2496/174583337.py:62: Pandas4Warning: The 'lsuffix' and 'rsuffix' keywords in DataFrame.join are deprecated and will be removed in a future version. Use the 'suffixes' keyword instead. j = a.join(b, lsuffix="_s", rsuffix="_w", how="inner")
/tmp/ipykernel_2496/174583337.py:62: Pandas4Warning: The 'lsuffix' and 'rsuffix' keywords in DataFrame.join are deprecated and will be removed in a future version. Use the 'suffixes' keyword instead. j = a.join(b, lsuffix="_s", rsuffix="_w", how="inner")
/tmp/ipykernel_2496/174583337.py:62: Pandas4Warning: The 'lsuffix' and 'rsuffix' keywords in DataFrame.join are deprecated and will be removed in a future version. Use the 'suffixes' keyword instead. j = a.join(b, lsuffix="_s", rsuffix="_w", how="inner")
/tmp/ipykernel_2496/174583337.py:62: Pandas4Warning: The 'lsuffix' and 'rsuffix' keywords in DataFrame.join are deprecated and will be removed in a future version. Use the 'suffixes' keyword instead. j = a.join(b, lsuffix="_s", rsuffix="_w", how="inner")
/tmp/ipykernel_2496/174583337.py:62: Pandas4Warning: The 'lsuffix' and 'rsuffix' keywords in DataFrame.join are deprecated and will be removed in a future version. Use the 'suffixes' keyword instead. j = a.join(b, lsuffix="_s", rsuffix="_w", how="inner")
/home/runner/work/_temp/executed/.venv/lib/python3.13/site-packages/statsmodels/regression/mixed_linear_model.py:2698: RuntimeWarning: invalid value encountered in sqrt return np.sqrt(np.diag(self.cov_params())[0:p])
/tmp/ipykernel_2496/174583337.py:62: Pandas4Warning: The 'lsuffix' and 'rsuffix' keywords in DataFrame.join are deprecated and will be removed in a future version. Use the 'suffixes' keyword instead. j = a.join(b, lsuffix="_s", rsuffix="_w", how="inner")
/tmp/ipykernel_2496/174583337.py:62: Pandas4Warning: The 'lsuffix' and 'rsuffix' keywords in DataFrame.join are deprecated and will be removed in a future version. Use the 'suffixes' keyword instead. j = a.join(b, lsuffix="_s", rsuffix="_w", how="inner")
/home/runner/work/_temp/executed/.venv/lib/python3.13/site-packages/statsmodels/regression/mixed_linear_model.py:2698: RuntimeWarning: invalid value encountered in sqrt return np.sqrt(np.diag(self.cov_params())[0:p])
/tmp/ipykernel_2496/174583337.py:62: Pandas4Warning: The 'lsuffix' and 'rsuffix' keywords in DataFrame.join are deprecated and will be removed in a future version. Use the 'suffixes' keyword instead. j = a.join(b, lsuffix="_s", rsuffix="_w", how="inner")
/tmp/ipykernel_2496/174583337.py:62: Pandas4Warning: The 'lsuffix' and 'rsuffix' keywords in DataFrame.join are deprecated and will be removed in a future version. Use the 'suffixes' keyword instead. j = a.join(b, lsuffix="_s", rsuffix="_w", how="inner")
/tmp/ipykernel_2496/174583337.py:62: Pandas4Warning: The 'lsuffix' and 'rsuffix' keywords in DataFrame.join are deprecated and will be removed in a future version. Use the 'suffixes' keyword instead. j = a.join(b, lsuffix="_s", rsuffix="_w", how="inner")
/tmp/ipykernel_2496/174583337.py:62: Pandas4Warning: The 'lsuffix' and 'rsuffix' keywords in DataFrame.join are deprecated and will be removed in a future version. Use the 'suffixes' keyword instead. j = a.join(b, lsuffix="_s", rsuffix="_w", how="inner")
/tmp/ipykernel_2496/174583337.py:62: Pandas4Warning: The 'lsuffix' and 'rsuffix' keywords in DataFrame.join are deprecated and will be removed in a future version. Use the 'suffixes' keyword instead. j = a.join(b, lsuffix="_s", rsuffix="_w", how="inner")
/tmp/ipykernel_2496/174583337.py:62: Pandas4Warning: The 'lsuffix' and 'rsuffix' keywords in DataFrame.join are deprecated and will be removed in a future version. Use the 'suffixes' keyword instead. j = a.join(b, lsuffix="_s", rsuffix="_w", how="inner")
print(G4E.round(4).to_string(index=False))
print(T4E.round(4).to_string(index=False))
print("paper: beta = 14.63, p = 0.00139; t(75) = 3.43, p = 0.0003")
print("GLM readings with strong > weak at p < 0.05:", int(((G4E.beta > 0) & (G4E.p < 0.05)).sum()), "of", len(G4E))
print("t-test readings with strong > weak at p < 0.05:", int(((T4E.t > 0) & (T4E.p < 0.05)).sum()), "of", len(T4E))
E1 E2 E3 E4 beta p converged pairs n
MS neuron all with self Hz -0.1686 0.0594 True 84 3143
pair all with self Hz -0.1465 0.0914 True 84 3143
MS neuron all with self norm -7.6190 0.3480 True 81 3029
pair all with self norm -6.5408 0.4147 True 81 3029
MS neuron all without self Hz -0.1666 0.0810 True 74 2770
pair all without self Hz -0.1426 0.1231 True 74 2770
MS neuron all without self norm -9.2360 0.2554 True 72 2693
pair all without self norm -7.9852 0.3169 True 72 2693
MS neuron answered old with self Hz -0.1852 0.0886 True 83 2396
pair answered old with self Hz -0.1677 0.1124 True 83 2396
MS neuron answered old with self norm -9.3630 0.3508 True 80 2306
pair answered old with self norm -8.3070 0.4031 True 80 2306
MS neuron answered old without self Hz -0.1671 0.1505 True 73 2111
pair answered old without self Hz -0.1533 0.1735 True 73 2111
MS neuron answered old without self norm -8.1415 0.3803 True 70 2021
pair answered old without self norm -6.9442 0.4448 True 70 2021
E2 E3 E4 pairs strong weak t df p
all with self Hz 84 2.8944 3.0364 -1.6010 83 0.1149
all with self norm 81 45.5471 51.6729 -1.2381 80 0.2189
all without self Hz 74 2.8939 3.0267 -1.3574 73 0.1807
all without self norm 72 34.2506 41.4262 -1.3707 71 0.1885
answered old with self Hz 83 3.0368 3.1822 -1.4601 82 0.1519
answered old with self norm 80 52.6881 60.4362 -1.4288 79 0.1583
answered old without self Hz 73 3.0407 3.1582 -1.0633 72 0.2939
answered old without self norm 70 29.6952 35.3525 -0.9954 69 0.3315
paper: beta = 14.63, p = 0.00139; t(75) = 3.43, p = 0.0003
GLM readings with strong > weak at p < 0.05: 0 of 16
t-test readings with strong > weak at p < 0.05: 0 of 8
Per-pair differences and a pooled median split (asked for in verification round 1). For the FS pairs under the first reading (all trials, self-pairs kept, spikes per second), the distribution over pairs of the mean MS rate after strong minus after weak maintenance; then both tests with the median split taken over load 1 and load 3 trials pooled, a variant the Methods do not describe ("median-split ... separately within load 1 and load 3 trials").
d = P4[P4.type == "FS"]
diff = (d[d.strong == 1].groupby("pair").Hz.mean() - d[d.strong == 0].groupby("pair").Hz.mean()).dropna()
print("FS pairs: %d; strong - weak (Hz): mean %.3f, median %.3f, quartiles %.3f and %.3f, "
"range %.2f to %.2f; positive %d, negative %d, zero %d" % (
len(diff), diff.mean(), diff.median(), diff.quantile(0.25), diff.quantile(0.75), diff.min(),
diff.max(), (diff > 0).sum(), (diff < 0).sum(), (diff == 0).sum()))
print("sign test p = %.3f" % sbcat.stats.binomtest(int((diff > 0).sum()), int((diff != 0).sum())).pvalue)
by_ms = diff.groupby(diff.index.str.split("|").str[0]).mean()
print("averaged per MS neuron (%d): positive %d, negative %d" % (len(by_ms), (by_ms > 0).sum(), (by_ms < 0).sum()))
P4POOL = pair_rows("pooled")
G4EP, T4EP = pair_tests("FS", np.random.default_rng(406), data=P4POOL)
print("\nmedian split over both loads pooled (variant):")
print(G4EP.round(4).to_string(index=False))
print(T4EP.round(4).to_string(index=False))
print("GLM readings with strong > weak at p < 0.05:", int(((G4EP.beta > 0) & (G4EP.p < 0.05)).sum()), "of", len(G4EP),
"; t-test readings:", int(((T4EP.t > 0) & (T4EP.p < 0.05)).sum()), "of", len(T4EP))
FS pairs: 84; strong - weak (Hz): mean -0.142, median -0.044, quartiles -0.625 and 0.344, range -2.56 to 2.52; positive 37, negative 47, zero 0 sign test p = 0.326 averaged per MS neuron (20): positive 9, negative 11
/tmp/ipykernel_2496/174583337.py:62: Pandas4Warning: The 'lsuffix' and 'rsuffix' keywords in DataFrame.join are deprecated and will be removed in a future version. Use the 'suffixes' keyword instead. j = a.join(b, lsuffix="_s", rsuffix="_w", how="inner")
/tmp/ipykernel_2496/174583337.py:62: Pandas4Warning: The 'lsuffix' and 'rsuffix' keywords in DataFrame.join are deprecated and will be removed in a future version. Use the 'suffixes' keyword instead. j = a.join(b, lsuffix="_s", rsuffix="_w", how="inner")
/tmp/ipykernel_2496/174583337.py:62: Pandas4Warning: The 'lsuffix' and 'rsuffix' keywords in DataFrame.join are deprecated and will be removed in a future version. Use the 'suffixes' keyword instead. j = a.join(b, lsuffix="_s", rsuffix="_w", how="inner")
/tmp/ipykernel_2496/174583337.py:62: Pandas4Warning: The 'lsuffix' and 'rsuffix' keywords in DataFrame.join are deprecated and will be removed in a future version. Use the 'suffixes' keyword instead. j = a.join(b, lsuffix="_s", rsuffix="_w", how="inner")
/tmp/ipykernel_2496/174583337.py:62: Pandas4Warning: The 'lsuffix' and 'rsuffix' keywords in DataFrame.join are deprecated and will be removed in a future version. Use the 'suffixes' keyword instead. j = a.join(b, lsuffix="_s", rsuffix="_w", how="inner")
/tmp/ipykernel_2496/174583337.py:62: Pandas4Warning: The 'lsuffix' and 'rsuffix' keywords in DataFrame.join are deprecated and will be removed in a future version. Use the 'suffixes' keyword instead. j = a.join(b, lsuffix="_s", rsuffix="_w", how="inner")
/tmp/ipykernel_2496/174583337.py:62: Pandas4Warning: The 'lsuffix' and 'rsuffix' keywords in DataFrame.join are deprecated and will be removed in a future version. Use the 'suffixes' keyword instead. j = a.join(b, lsuffix="_s", rsuffix="_w", how="inner")
median split over both loads pooled (variant):
E1 E2 E3 E4 beta p converged pairs n
MS neuron all with self Hz -0.1966 0.0278 True 84 3143
pair all with self Hz -0.1914 0.0274 True 84 3143
MS neuron all with self norm -12.6605 0.1183 True 81 3029
pair all with self norm -12.6382 0.1146 True 81 3029
MS neuron all without self Hz -0.1758 0.0650 True 74 2770
pair all without self Hz -0.1705 0.0650 True 74 2770
MS neuron all without self norm -10.1258 0.2110 True 72 2693
pair all without self norm -10.1741 0.2011 True 72 2693
MS neuron answered old with self Hz -0.2260 0.0373 True 83 2396
pair answered old with self Hz -0.2323 0.0277 True 83 2396
MS neuron answered old with self norm -13.5196 0.1985 True 81 2333
pair answered old with self norm -13.9118 0.1834 True 81 2333
MS neuron answered old without self Hz -0.1913 0.0985 True 73 2111
pair answered old without self Hz -0.2034 0.0704 True 73 2111
MS neuron answered old without self norm -11.0152 0.2334 True 70 2021
pair answered old without self norm -11.7117 0.1965 True 70 2021
E2 E3 E4 pairs strong weak t df p
all with self Hz 84 2.8630 3.0570 -1.9643 83 0.0533
all with self norm 81 39.8710 53.8592 -1.8427 80 0.0513
all without self Hz 74 2.8771 3.0409 -1.5520 73 0.1303
all without self norm 72 32.4745 42.2907 -1.7648 71 0.0795
answered old with self Hz 83 2.9966 3.2055 -1.8578 82 0.0693
answered old with self norm 81 58.1317 72.4452 -2.1088 80 0.0323
answered old without self Hz 73 3.0183 3.1769 -1.3417 72 0.1875
answered old without self norm 70 27.1600 37.1171 -1.6597 69 0.1071
GLM readings with strong > weak at p < 0.05: 0 of 16 ; t-test readings: 0 of 8
/tmp/ipykernel_2496/174583337.py:62: Pandas4Warning: The 'lsuffix' and 'rsuffix' keywords in DataFrame.join are deprecated and will be removed in a future version. Use the 'suffixes' keyword instead. j = a.join(b, lsuffix="_s", rsuffix="_w", how="inner")
Result: not reproduced. In familiarity-selective pairs, MS responses after strong maintenance are not higher than after weak under any reading: the GLM betas are negative (-0.14 to -0.19 Hz, -6.5 to -9.4 normalized; p 0.059 to 0.45), and so are the paired t-tests (t from -1.00 to -1.60, p 0.11 to 0.33). There are 197 pairs (expected 198 +- 20) and 84 FS pairs (expected 76 +- 8). Per pair, strong minus weak has median -0.044 Hz, with 37 pairs positive and 47 negative (sign test p = 0.33); averaged per MS neuron, 9 of 20 are positive. With the median split over both loads pooled (a variant), strong is again below weak in all 24 readings, at p < 0.05 in four GLM readings and one t-test reading.
print(G4F.round(4).to_string(index=False))
print(T4F.round(4).to_string(index=False))
print("paper: beta = 0.09, p = 0.98; t(121) = -0.48, p = 0.64")
print("GLM readings with p < 0.05:", int((G4F.p < 0.05).sum()), "of", len(G4F),
"; t-test readings with p < 0.05:", int((T4F.p < 0.05).sum()), "of", len(T4F))
E1 E2 E3 E4 beta p converged pairs n
MS neuron all with self Hz 0.0064 0.9048 True 107 3432
pair all with self Hz 0.0099 0.8533 True 107 3432
MS neuron all with self norm 2.5144 0.6597 True 105 3431
pair all with self norm 2.6864 0.6403 True 105 3431
MS neuron all without self Hz 0.0216 0.6939 True 100 3209
pair all without self Hz 0.0281 0.6054 True 100 3209
MS neuron all without self norm 3.0021 0.6251 True 97 3153
pair all without self norm 3.2900 0.5951 True 97 3153
MS neuron answered old with self Hz 0.0336 0.5864 True 93 2428
pair answered old with self Hz 0.0346 0.5718 True 93 2428
MS neuron answered old with self norm 2.9492 0.6947 True 91 2400
pair answered old with self norm 3.4391 0.6500 True 91 2400
MS neuron answered old without self Hz 0.0489 0.4368 True 84 2244
pair answered old without self Hz 0.0508 0.4161 True 84 2244
MS neuron answered old without self norm 3.5535 0.6641 True 83 2184
pair answered old without self norm 4.1967 0.6112 True 83 2184
E2 E3 E4 pairs strong weak t df p
all with self Hz 107 1.5590 1.6105 -1.0316 106 0.3101
all with self norm 105 -3.5208 -2.6424 -0.1635 104 0.8892
all without self Hz 100 1.5455 1.5723 -0.5385 99 0.5934
all without self norm 97 -4.0709 -4.0359 -0.0061 96 0.9812
answered old with self Hz 89 1.6974 1.5820 1.5111 88 0.1391
answered old with self norm 87 1.3822 -5.6990 1.0284 86 0.3151
answered old without self Hz 82 1.6962 1.5375 2.0368 81 0.0395
answered old without self norm 79 1.3650 -7.6170 1.2000 78 0.2457
paper: beta = 0.09, p = 0.98; t(121) = -0.48, p = 0.64
GLM readings with p < 0.05: 0 of 16 ; t-test readings with p < 0.05: 1 of 8
Result: blocked (methods underspecified). The readings the criterion names do not all give the same outcome, and the claims file blocks such a claim. No GLM reading reaches p < 0.05 (smallest 0.42), and seven of the eight t-test readings do not (p 0.14 to 0.98), but one does (pictures answered old, self-pairs dropped, spikes per second: t(81) = 2.04, p = 0.040), so the claim is neither reproduced (no p < 0.05 under every reading) nor not reproduced (p < 0.05 under every reading). Under all trials of the old pictures, self-pairs kept and spikes per second, the GLM gives beta 0.006 (p = 0.90) or 0.010 (p = 0.85) and the t-test t(106) = -1.03, p = 0.31, with 107 NS pairs (paper 122). The single p of 0.040 is one of 24 uncorrected tests.
Fits of the mixed models¶
statsmodels warned "invalid value in sqrt" during some fits (asked about in verification round
1). Each model is fitted with three optimizers and the fit with the highest likelihood is kept
(sbcat.mixedlm). Below, for every table of results, the number of kept fits that did not
report convergence and the number of rows with a missing SE or p.
FITS = {"fig2b": R2B, "fig2c": R2C, "fig2e": R2E, "fig2f": R2F, "fig3a": R3A, "fig3b hippocampus": R3B,
"fig3b amygdala": R3BA, "fig3g": R3G, "fig3h": R3H, "fig4d": R4D, "fig4e": G4E, "fig4f": G4F,
"fig4e pooled split": G4EP}
for k, r in FITS.items():
se = r["SE"].isna().sum() if "SE" in r else 0
print(f"{k}: {len(r)} rows, not converged {int((~r.converged.astype(bool)).sum())}, "
f"missing SE {int(se)}, missing p {int(r.p.isna().sum())}")
fig2b: 24 rows, not converged 0, missing SE 0, missing p 0 fig2c: 66 rows, not converged 0, missing SE 0, missing p 0 fig2e: 24 rows, not converged 0, missing SE 0, missing p 0 fig2f: 66 rows, not converged 0, missing SE 0, missing p 0 fig3a: 48 rows, not converged 0, missing SE 0, missing p 0 fig3b hippocampus: 36 rows, not converged 0, missing SE 0, missing p 0 fig3b amygdala: 36 rows, not converged 0, missing SE 0, missing p 0 fig3g: 48 rows, not converged 0, missing SE 0, missing p 0 fig3h: 48 rows, not converged 0, missing SE 0, missing p 0 fig4d: 48 rows, not converged 0, missing SE 0, missing p 0 fig4e: 16 rows, not converged 0, missing SE 0, missing p 0 fig4f: 16 rows, not converged 0, missing SE 0, missing p 0 fig4e pooled split: 16 rows, not converged 0, missing SE 0, missing p 0
Summary¶
| Claim | Outcome |
|---|---|
| sessions-and-neurons | reproduced |
| table-s1-counts | partially reproduced (42 of 46 sessions) |
| behaviour-overall-accuracy | reproduced |
| fig1c-wm-accuracy-load | reproduced |
| fig1d-wm-rt-load | reproduced (p = 6.0e-05 with 2,000,000 permutations) |
| fig1e-ltm-confidence-accuracy | reproduced |
| ltm-rt-confidence | reproduced |
| fig1f-ltm-load | reproduced |
| fig1g-ltm-probe | reproduced |
| category-neuron-counts | reproduced |
| fig2b-hippocampus-persistent | partially reproduced |
| fig2c-hippocampus-correct-load | blocked, methods underspecified (readings disagree) |
| fig2e-amygdala-persistent | blocked, methods underspecified (readings disagree) |
| fig2f-amygdala-load-not-accuracy | blocked, methods underspecified (readings disagree) |
| fig3a-area-interactions | partially reproduced |
| fig3b-hippocampus-predicts-ltm | reproduced |
| fig3b-amygdala-no-prediction | reproduced |
| fig3c-hippocampus-high-confidence | not reproduced |
| fig3d-amygdala-no-difference | reproduced |
| fig3e-early-delay-cluster | partially reproduced |
| fig3f-amygdala-no-cluster | reproduced |
| fig3g-nonpreferred-no-effect | reproduced |
| fig3h-encoding-no-effect | reproduced |
| ms-neuron-counts | reproduced |
| fig4b-ms-confidence-auc | reproduced |
| fig4c-overlap-chance | reproduced |
| fig4d-category-no-memory-signal | reproduced (categories of new pictures from their images) |
| fig4e-fs-strong-maintenance | not reproduced |
| fig4f-ns-no-effect | blocked, methods underspecified (readings disagree) |
A failure to reproduce here may be a failure of this attempt, not of the paper: see the reasoning and the differences from the paper's method.
How the analysis differs from the paper's. For the GLMs of Figures 2 and 3 the outlier rule is O-G, as the claims file has it after a reader's answer (questions/001187.yaml): the code's neuron means (NWB_computeGLM.m), with the Methods' "±3 SD from the mean"; the code's own rule (O-C, above 3 SD without centring) is shown as a variant, and gives the paper's Figure 3a betas within tolerance where O-G does not. The permutation t-tests keep the Methods rule (O-M). For Figure 2, which the code does not cover, the rows (one per trial or the code's), the baseline and, for Fig. 2c and 2f, the model (main effects or with the interaction) are open, and where they change the outcome the claim is blocked, as the claims file says. The session whose ratings are all sure is left out of confidence analyses, as the paper says; the code keeps it, shown as a variant. Mixed models are fitted by maximum likelihood in statsmodels, not MATLAB's fitglme. Permutation p-values follow statcond's formula. For Fig. 1d the permutation p is estimated with 2,000,000 permutations, as the criterion's bar (p < 0.0001) lies at the resolution of 10,000. For Fig. 4d the categories of the new pictures are taken from their images in the files, viewed one by one for this attempt.
What was found about the dataset. The 46 sessions, 950 units and the 351 and 532 units after the rate filter match the paper. Table S1 lists 23 more units in four sessions. All files give Cedars-Sinai as the institution, though the identifiers (TWH, JHU) and the paper place 20 sessions at Toronto Western and Johns Hopkins. Eight sessions have fewer than 400 LTM trials (161 to 399) and one has 139 WM trials. One LTM trial has confidence 7, outside the documented 1 to 6. The new LTM pictures (IDs 1001 to 1200) carry no category in the metadata; their images show blocks of 40 IDs per category in each task variant. Five units have spike times out of order in the files (sorted here before analysis). The confidence coding (1 to 3 new, 4 to 6 old) is not documented but agrees with the accuracy column in every trial.
print("notebook run time %.1f min" % ((time.time() - T0) / 60))
notebook run time 21.5 min