Reproducing Thompson & Gold (2026) from dandiset 002034¶
Paper. Thompson LW, Gold JI (2026). Limitations of pupil diameter as a proxy for modes of locus coeruleus activity. eLife reviewed preprint 112525, version 1 (2 October 2026), doi:10.7554/elife.112525. The claims file was written from the full text of that version as served by the publisher (main text, figure legends, Methods and the legends of Supplemental Figures 1 and 2).
Dandiset. DANDI:002034, version 0.261019.2146. The paper cites no version; its code's README names this one, and it is the only published version.
What the dandiset holds. 83 sessions (32 for monkey Oz, 51 for monkey Cicero, "Ci" in the paper), one NWB file each, with the trial table, the pupil trace of every trial and 105 sorted LC units. The paper reports 42 units from 32 sessions (Oz) and 63 units from 51 sessions (Ci).
Outside inputs. From the paper's code (https://github.com/lwthompson2/Thompson2026_LCPupilAnalysis,
commit cf3c0b7): its include lists of sessions and units, compared with the dandiset in the link
claim, and its printed statistics on this dandiset (Code/Results/manuscript_stats_nwb.txt), used
only as reference values in the link claim. No outside data enters any other claim.
Readings. Every method detail is the claims file's, which cites the Methods and the code; the
helper's docstring says where each parameter comes from. The deciding readings are the Methods' trial
rule and windows with the evoked pupil read as E1 (largest window mean minus baseline) or E2
(largest in absolute size, sign kept). Variants: the code's trial rule and windows with its own
evoked pupil (code), and two mixtures that isolate the evoked pupil window (code trials + E1,
Methods trials + code pupil).
No random numbers are drawn anywhere in this notebook.
| Claim | Status |
|---|---|
| include-list-link (link, added by this attempt) | tested |
| data-units-sessions | tested |
| fig2-row1-baseline-lc-pupil | tested |
| fig2-row2-evoked-lc-pupil | tested |
| fig2-row3-pupil-evoked-vs-baseline | tested |
| fig2-row4-lc-evoked-vs-baseline | tested |
| fig2-row5-baseline-lc-vs-evoked-pupil | tested |
| fig2-row6-baseline-pupil-vs-evoked-lc | tested |
| cross-epoch-no-reliable-relation | tested |
| range-baseline-pupil-evoked-lc | tested |
| range-baseline-lc-evoked-pupil | tested |
| figs1-raw-baselines-similar | tested |
| figs2-llr-pupil-baseline-evoked | tested |
| figs2-llr-lc-baseline-evoked | tested |
| figs2-llr-cross-epoch | tested |
| fig3-pooled-within-epoch | tested |
| fig3-pooled-cross-epoch-null | tested |
import re
import time
import warnings
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import lcpupil as L
warnings.filterwarnings("ignore", category=RuntimeWarning)
pd.set_option("display.width", 200)
pd.set_option("display.max_columns", 30)
pd.set_option("display.max_rows", 200)
T0 = time.time()
print("dandiset", L.DANDISET_ID, "version", L.DANDISET_VERSION)
meta = L.version_metadata()
print(meta["name"])
print(meta["description"])
print([r["url"] for r in meta.get("relatedResource", [])])
assets = L.list_assets()
sessions = L.load_all(assets)
print(f"{len(sessions)} files streamed in {time.time() - T0:.0f} s")
dandiset 002034 version 0.261019.2146
Locus coeruleus and pupil data supporting Thompson et al., 202 Cleaned, trial-delimited data for Thompson et al 2026 figure and stats regeneration. ['https://github.com/lwthompson2/Thompson2026_LCPupilAnalysis', 'https://doi.org/10.7554/eLife.112525']
83 files streamed in 31 s
Data check¶
The cell below prints what was loaded and checks the description against the values: counts of subjects, sessions, units and trials; the trial table's columns; the pupil series (units, rate, whether the Methods' preprocessing is already in it); trial durations and beep times against the Methods; spike times (sorted, how they are anchored); duplicated recordings; and whether spikes and pupil share the trial table's clock.
inv = pd.DataFrame([dict(monkey=s["monkey"], session=s["session"], path=p, n_trials=len(s["trials"]),
n_correct=int((s["trials"].correct == 1).sum()),
n_beep=int(np.isfinite(s["trials"].beep_time_ms).sum()),
n_units=len(s["units"]), samples_per_trial=s["pupil"].shape[1],
columns=",".join(s["trial_columns"]))
for s, p in zip(sessions, assets.path)])
print("files per subject folder:", assets.path.str.split("/").str[0].value_counts().to_dict())
print(inv.groupby("monkey")[["n_trials", "n_correct", "n_beep", "n_units"]].agg(["count", "sum", "min", "max"]))
print("subject_id matches folder:", all(p.split("/")[0] == "sub-" + m for p, m in zip(inv.path, inv.monkey)))
print("trial table columns in every file:", inv["columns"].unique())
print("pupil series attributes:", {str(s["pupil_attrs"]) for s in sessions})
print("samples per trial (padded with NaN):", inv.samples_per_trial.min(), "to", inv.samples_per_trial.max())
print("spike time policies:", {u["policy"] for s in sessions for u in s["units"]})
print("trial anchors at 100 s spacing in every file:",
all(np.allclose(s["trials"].start_time.values, 100 * np.arange(len(s["trials"]))) for s in sessions))
print("spike times sorted in every unit:", all(np.all(np.diff(u["spikes"]) >= 0) for s in sessions for u in s["units"]))
print("trial_time_index increasing in every file:", all(np.all(np.diff(s["trials"].trial_time_index) > 0) for s in sessions))
tti = np.array([s["trials"].trial_time_index.max() / 60000 for s in sessions])
print(f"last trial_time_index per session, read as ms: {tti.min():.1f} to {tti.max():.1f} min")
# Trial durations and beep times against the Methods (fixation 1-5 s; beep after 1-1.5 s of fixation)
rows = []
for s in sessions:
t = s["trials"]
d = (t.stop_time - t.start_time).values * 1000
b = t.beep_time_ms.values
nb = np.isfinite(b)
rows.append(dict(monkey=s["monkey"], dur_fix=d[~nb], dur_beep=d[nb], beep=b[nb], post=d[nb] - b[nb]))
for m in L.MONKEYS:
r = [x for x in rows if x["monkey"] == m]
dfx = np.concatenate([x["dur_fix"] for x in r]); bb = np.concatenate([x["beep"] for x in r])
post = np.concatenate([x["post"] for x in r])
print(f"{L.SHORT[m]}: fixation-only trial duration {np.percentile(dfx, [0, 5, 50, 95, 100]).round(0)} ms, "
f"{np.mean(dfx < 1000):.1%} under 1 s")
print(f" beep time from trial start {np.percentile(bb, [0, 5, 50, 95, 100]).round(0)} ms; "
f"{np.mean((bb >= 1000) & (bb <= 1500)):.1%} within 1-1.5 s; {np.sum(bb < 0)} before the start; "
f"{np.sum(post < 0)} after the trial's end; time from beep to end, median {np.median(post):.0f} ms")
pp = L.pupil_preprocessing_check(sessions)
print("\nPupil, per session over all stored samples:")
print(pp[["mean", "sd", "mean_trace_absmax", "boxcar_change"]].describe().loc[["min", "50%", "max"]].round(3))
nan_in = np.mean([np.isnan(s["pupil"][i, :int(round((s["trials"].stop_time[i] - s["trials"].start_time[i]) * 1000))]).mean()
for s in sessions for i in range(len(s["trials"]))])
print(f"NaN samples inside trials: {nan_in:.2%}")
# Duplicates: identical spike trains or identical pupil rows across files
import hashlib
hs, hp = {}, {}
for s in sessions:
for u in s["units"]:
hs.setdefault(hashlib.md5(np.round(u["spikes"], 4).tobytes()).hexdigest(), []).append((s["session"], u["source_unit_index"]))
for i, row in enumerate(s["pupil"]):
x = row[:300]
if np.isfinite(x).all():
hp.setdefault(hashlib.md5(np.round(x, 5).tobytes()).hexdigest(), set()).add(s["session"])
print("identical spike trains across units:", [v for v in hs.values() if len(v) > 1])
print("pupil rows shared between sessions:", sum(len(v) > 1 for v in hp.values()))
files per subject folder: {'sub-Cicero': 51, 'sub-Oz': 32}
n_trials n_correct n_beep n_units
count sum min max count sum min max count sum min max count sum min max
monkey
Cicero 51 10143 52 480 51 10143 52 480 51 2262 10 113 51 63 1 3
Oz 32 5543 72 371 32 5543 72 371 32 986 10 79 32 42 1 3
subject_id matches folder: True
trial table columns in every file: <StringArray>
['start_time,stop_time,correct,beep_time_ms,trial_time_index']
Length: 1, dtype: str
pupil series attributes: {"{'unit': 'a.u.', 'rate': np.float64(1000.0), 'description': 'Flattened [trial x time] pupil value from siteData{2}(:,:,4)'}"}
samples per trial (padded with NaN): 3191 to 5500
spike time policies: {'trial_anchor_seconds_from_trial_index_spacing_100s'}
trial anchors at 100 s spacing in every file: True
spike times sorted in every unit: True
trial_time_index increasing in every file: True
last trial_time_index per session, read as ms: 3.9 to 60.6 min
Oz: fixation-only trial duration [ 206. 391. 1969. 3778. 4111.] ms, 26.4% under 1 s
beep time from trial start [-252. 1043. 2201. 2775. 3278.] ms; 8.8% within 1-1.5 s; 4 before the start; 44 after the trial's end; time from beep to end, median 1075 ms
Ci: fixation-only trial duration [ 210. 801. 2565. 3791. 5499.] ms, 7.1% under 1 s
beep time from trial start [-840. 1415. 2302. 2776. 4014.] ms; 4.4% within 1-1.5 s; 4 before the start; 39 after the trial's end; time from beep to end, median 1088 ms
Pupil, per session over all stored samples:
mean sd mean_trace_absmax boxcar_change
min -0.047 0.798 0.010 0.034
50% 0.027 0.945 0.064 0.044
max 0.111 0.992 0.188 0.064
NaN samples inside trials: 0.36% identical spike trains across units: [] pupil rows shared between sessions: 0
The stored trace is consistent with the Methods' preprocessing having been applied before deposit: over each session the samples have mean near 0 and SD near 1 (z-scored, then reduced a little by the subtraction of the mean trace), the mean trace across trials stays near 0, and a further 151 ms boxcar changes the trace by about 5% of its SD (a raw 1 kHz trace would change more). This is consistent with, not proof of, the preprocessing. The analysis uses the stored trace as the code does. The trial start is taken as fixation onset, as in the code; the files do not say what event it is (see the check of spikes outside the trial below).
Clock check: per session, the LC rate 0 to 200 ms after the beep minus the 200 ms before it, and the pupil 300 to 800 ms after the beep minus the 100 ms before it, at the true beep times and at times 600 ms earlier (inside the same trials). A response at the true times and none at the shifted ones shows that spikes and pupil share the trial table's clock.
clk = L.clock_check(sessions)
ok = clk.dropna(subset=["p_lc_true"])
print(f"sessions with at least 6 usable beep trials: {len(ok)} of {len(clk)}; "
f"too few: {list(clk.session[clk.p_lc_true.isna()])}")
for m in ("Oz", "Ci"):
k = ok[ok.monkey == m]
print(f"{m}: LC response true {k.lc_true.median():.2f} sp/s (sessions p<0.05: {(k.p_lc_true < 0.05).sum()}/{len(k)}), "
f"shifted {k.lc_shifted.median():.2f} ({(k.p_lc_shifted < 0.05).sum()}/{len(k)}); "
f"pupil true {k.pupil_true.median():.3f} ({(k.p_pupil_true < 0.05).sum()}/{len(k)}), "
f"shifted {k.pupil_shifted.median():.3f} ({(k.p_pupil_shifted < 0.05).sum()}/{len(k)})")
noresp = ok[(ok.p_lc_true >= 0.05) & (ok.p_pupil_true >= 0.05)]
print("sessions where neither LC nor pupil responds at the true times (clock not established):", list(noresp.session))
sessions with at least 6 usable beep trials: 81 of 83; too few: ['Oz_022813_d9_8', 'Oz_030513_d11_8'] Oz: LC response true 2.32 sp/s (sessions p<0.05: 20/30), shifted 0.07 (1/30); pupil true 0.649 (26/30), shifted 0.043 (3/30) Ci: LC response true 1.79 sp/s (sessions p<0.05: 28/51), shifted 0.00 (0/51); pupil true 0.428 (48/51), shifted -0.011 (5/51) sessions where neither LC nor pupil responds at the true times (clock not established): ['Ci_LC_d14_980mm_120308', 'Oz_031513_d12_763_Fixn', 'Oz_061913_d10_058_Fixn']
Spikes outside the trial: where each stored spike falls against its trial (between the start and the end, before the start, after the end), the rate in the 200 ms before and after the end of the trial, and the beep trials whose 200 ms evoked rate window runs past the end of the trial.
n_tot = n_in = 0
pre, post = [], []
r_before, r_after = [], []
for s in sessions:
t = s["trials"]
st, en = t.start_time.values, t.stop_time.values
for u in s["units"]:
sp = u["spikes"]
n_tot += sp.size
k = np.searchsorted(st, sp, "right") - 1 # trial whose anchor precedes the spike
kk = np.clip(k, 0, None)
rel = np.where(k >= 0, sp - st[kk], -np.inf)
dur = (en - st)[kk]
inside = (rel >= 0) & (rel <= dur)
after = (k >= 0) & (rel > dur) & (rel - dur < 50) # within 50 s after the end of trial k
before = ~inside & ~after # the rest lie before the next trial's anchor
n_in += int(inside.sum())
post.append((rel - dur)[after])
nxt = np.clip(k + 1, 0, len(st) - 1)
pre.append((sp - st[nxt])[before])
a = np.searchsorted(sp, en - 0.2); b = np.searchsorted(sp, en); c = np.searchsorted(sp, en + 0.2)
r_before.append((b - a) / 0.2); r_after.append((c - b) / 0.2)
pre, post = np.concatenate(pre) * 1000, np.concatenate(post) * 1000
print(f"spikes: {n_tot}; inside a trial {n_in / n_tot:.1%}, before a trial start {pre.size / n_tot:.1%}, "
f"after a trial end {post.size / n_tot:.1%}")
print("before the start, ms from the start (0, 1, 50, 99, 100 percentiles):", np.percentile(pre, [0, 1, 50, 99, 100]).round(0))
print("after the end, ms from the end (0, 50, 99, 100 percentiles):", np.percentile(post, [0, 50, 99, 100]).round(0))
print(f"mean rate over units and trials, 200 ms before the end {np.mean(np.concatenate(r_before)):.2f} sp/s, "
f"200 ms after it {np.mean(np.concatenate(r_after)):.2f} sp/s")
fin = [np.isfinite(row[int(round((s["trials"].stop_time[j] - s["trials"].start_time[j]) * 1000)) + 1:]).sum()
for s in sessions for j, row in enumerate(s["pupil"])]
print("finite pupil samples after the end of a trial, over all trials:", int(np.sum(fin)))
PT = pd.concat([L.pupil_trial_measures(s).assign(monkey=s["monkey"]) for s in sessions])
PB = PT[np.isfinite(PT.beep_ms) & PT.correct]
for m in L.MONKEYS:
for rule in ("methods_ok", "code_ok"):
k = PB[(PB.monkey == m) & PB[rule].astype(bool)]
sh = (k.dur_ms - k.beep_ms) < L.EVOKED_FR_MS
print(f"{L.SHORT[m]} {rule[:-3]} rule: {len(k)} beep trials, {int(sh.sum())} with less than 200 ms "
f"from the beep to the end of the trial ({int(((k.dur_ms - k.beep_ms) < 0).sum())} with the beep after the end)")
spikes: 397286; inside a trial 58.9%, before a trial start 39.3%, after a trial end 1.8% before the start, ms from the start (0, 1, 50, 99, 100 percentiles): [-4.5933e+04 -3.0320e+03 -8.3900e+02 -1.7000e+01 -0.0000e+00] after the end, ms from the end (0, 50, 99, 100 percentiles): [ 0. 248. 41871. 49903.] mean rate over units and trials, 200 ms before the end 4.38 sp/s, 200 ms after it 0.85 sp/s
finite pupil samples after the end of a trial, over all trials: 0
Oz methods rule: 914 beep trials, 75 with less than 200 ms from the beep to the end of the trial (0 with the beep after the end) Oz code rule: 967 beep trials, 131 with less than 200 ms from the beep to the end of the trial (41 with the beep after the end) Ci methods rule: 2161 beep trials, 96 with less than 200 ms from the beep to the end of the trial (0 with the beep after the end) Ci code rule: 2248 beep trials, 187 with less than 200 ms from the beep to the end of the trial (39 with the beep after the end)
Spikes are stored outside the trials: about 40% lie before a trial's start, up to a few seconds before it (median about 0.8 s), but few lie after its end, and the rate falls from about 4.4 sp/s in the last 200 ms of a trial to under 1 sp/s in the 200 ms after it (numbers above). The spike record therefore runs from before the trial start to about its end. The pupil record has no samples after the end of the trial either. So on beep trials whose 200 ms evoked window runs past the end of the trial (printed above for each rule), the evoked rate is biased low. Both the Methods' rule and the code's keep such trials, so the main readings keep them as well; leaving them out is run as the variant "200 ms after beep" for every analysis below. It bears only on measures that use the evoked rate; for the pupil measures alone the trial set changes but no measure is biased.
That spikes are stored before the trial start does not tell what event the start marks. With the beep a median 2.2 s after the start and the Methods' beep after 1 to 1.5 s of fixation, the start may come before fixation onset, but the files hold no fixation marker to settle this. Every window is taken from the trial start, as in the code, which reproduces the paper's numbers.
Trial tables under each reading¶
build_tables applies the trial rule, the windows, the z-score exclusion and the drift residuals
(helper docstring). The counts of trials kept and dropped are printed for each reading.
READINGS = {
"M-E1": ("methods", "E1"),
"M-E2": ("methods", "E2"),
"code": ("code", "C"),
"code trials + E1": ("code", "E1"),
"Methods trials + code pupil": ("methods", "C"),
}
T = {}
for name, (rule, pupil) in READINGS.items():
B, F = L.build_tables(sessions, rule, pupil)
T[name] = (B, F, L.figure2_coefficients(B, F))
cand = B.groupby("unit_key").n_beep_candidates.first().sum()
print(f"{name:28s} beep rows {len(B):5d} of {cand} candidates (unit x trial), "
f"dropped by |z| >= 8: {int(B.dropped_z.sum())}, fixation rows {len(F)}, units {B.unit_key.nunique()}, "
f"sessions {B.session.nunique()}")
for rule in ("methods", "code"):
n_all = sum(int(np.isfinite(s["trials"].beep_time_ms).sum()) for s in sessions)
pt = pd.concat([L.pupil_trial_measures(s) for s in sessions])
pt = pt[np.isfinite(pt.beep_ms)]
col = "methods_ok" if rule == "methods" else "code_ok"
print(f"{rule} trial rule keeps {int(pt[col].astype(bool).sum())} of {n_all} beep trials")
# Variant: Methods' trials that also leave the whole 200 ms evoked rate window before the end of the
# trial (spikes are mostly not stored past the trial end; see the data check).
POST = {s["session"]: L.pupil_trial_measures(s).set_index("trial").eval("dur_ms - beep_ms") for s in sessions}
for name in ("M-E1", "M-E2"):
B, F, _ = T[name]
keep = np.array([POST[s][t] >= L.EVOKED_FR_MS for s, t in zip(B.session, B.trial)])
B2, F2 = B[keep].copy(), F.copy()
L.add_residuals(B2, F2)
T[name + ", 200 ms after beep"] = (B2, F2, L.figure2_coefficients(B2, F2))
print(f"{name + ', 200 ms after beep':28s} beep rows {keep.sum():5d} of {len(B)}")
B0 = T["M-E1"][0]
REMOVED = L.code_removed_units(B0)
REMOVED_SESSIONS = [k.split("|")[1] for k in REMOVED
if B0[B0.session == k.split("|")[1]].unit_key.nunique() == 1]
print("units the code drops as rows 43 and 65 of its stats table:", REMOVED)
print("sessions that leave with them:", REMOVED_SESSIONS)
for name in ("M-E1", "M-E2", "code"):
B = T[name][0]
print(name, "evoked pupil range", B.pe.min().round(2), "to", B.pe.max().round(2),
"; baseline pupil", B.pb.min().round(2), "to", B.pb.max().round(2),
"; baseline rate", B.sb.min().round(1), "to", B.sb.max().round(1), "sp/s; evoked rate",
B.se.min().round(1), "to", B.se.max().round(1), "sp/s")
M-E1 beep rows 3905 of 3908 candidates (unit x trial), dropped by |z| >= 8: 0, fixation rows 15770, units 105, sessions 83
M-E2 beep rows 3905 of 3908 candidates (unit x trial), dropped by |z| >= 8: 0, fixation rows 15770, units 105, sessions 83
code beep rows 3974 of 4083 candidates (unit x trial), dropped by |z| >= 8: 0, fixation rows 15770, units 105, sessions 83
code trials + E1 beep rows 3889 of 4083 candidates (unit x trial), dropped by |z| >= 8: 0, fixation rows 15770, units 105, sessions 83
Methods trials + code pupil beep rows 3905 of 3908 candidates (unit x trial), dropped by |z| >= 8: 0, fixation rows 15770, units 105, sessions 83
methods trial rule keeps 3075 of 3248 beep trials
code trial rule keeps 3215 of 3248 beep trials
M-E1, 200 ms after beep beep rows 3707 of 3905
M-E2, 200 ms after beep beep rows 3707 of 3905 units the code drops as rows 43 and 65 of its stats table: ['Cicero|CiCM101019d|1', 'Cicero|Ci_LC_d14_6mm_SC_123107|2'] sessions that leave with them: ['CiCM101019d'] M-E1 evoked pupil range -3.57 to 4.31 ; baseline pupil -4.1 to 3.37 ; baseline rate 0.0 to 55.2 sp/s; evoked rate -36.3 to 51.0 sp/s M-E2 evoked pupil range -4.27 to 4.31 ; baseline pupil -4.1 to 3.37 ; baseline rate 0.0 to 55.2 sp/s; evoked rate -36.3 to 51.0 sp/s code evoked pupil range -3.63 to 4.31 ; baseline pupil -3.0 to 3.37 ; baseline rate 0.0 to 55.2 sp/s; evoked rate -36.3 to 51.0 sp/s
include-list-link¶
The dandiset's sessions and units are those of the paper's code (its include lists), and the code's pipeline, run here on the dandiset, gives the statistics the code printed for it.
This is a registry check added by this attempt. Records are matched by session name (the file's
session_id plus .mat) and unit (source_unit_index minus 1, the code's unit). The code's
pipeline is the code reading, with the code's removal of rows 43 and 65 where the code applies it.
sess_list, unit_list = L.include_lists()
ds_sess = {(s["monkey"], s["session"] + ".mat") for s in sessions}
ds_units = {(s["monkey"], s["session"] + ".mat", u["source_unit_index"] - 1) for s in sessions for u in s["units"]}
ls = set(map(tuple, sess_list[["monkey", "session_file"]].values))
lu = {(a, b, int(c)) for a, b, c in unit_list[["monkey", "session_file", "unit"]].values}
print(f"include list: {len(ls)} sessions, {len(lu)} units; dandiset: {len(ds_sess)} sessions, {len(ds_units)} units")
print("listed sessions not in the dandiset:", sorted(ls - ds_sess), "; dandiset sessions not listed:", sorted(ds_sess - ls))
print("listed units not in the dandiset:", sorted(lu - ds_units), "; dandiset units not listed:", sorted(ds_units - lu))
print("unit_id values absent from the list's 1..107 numbering:", sorted(set(range(1, 108)) - set(unit_list.unit_id)))
include list: 83 sessions, 105 units; dandiset: 83 sessions, 105 units listed sessions not in the dandiset: [] ; dandiset sessions not listed: [] listed units not in the dandiset: [] ; dandiset units not listed: [] unit_id values absent from the list's 1..107 numbering: [43, 65]
txt = L.code_stats_text()
Bc, Fc, Cc = T["code"]
mine = {}
mine["beep trials"] = (len(Bc), int(re.search(r"included (\d+) beep trials", txt).group(1)))
mine["fixation trials"] = (len(Fc), int(re.search(r"and (\d+) non-beep", txt).group(1)))
# Figure 2 tests as the code prints them (its row numbering in brackets); Ci rows 1, 2, 4, 5, 6 over 63 units,
# row 3 over the code's sessions
labels = {1: "Baseline LC activity vs baseline pupil diameter (partial Spearman; residuals)",
2: "Baseline-subtracted evoked LC responses vs baseline-subtracted evoked pupil responses",
3: "Baseline-subtracted evoked pupil responses vs baseline pupil diameter (residuals)",
4: "Baseline-subtracted evoked LC responses vs baseline LC activity (residuals)",
5: "Baseline LC activity vs baseline-subtracted evoked pupil responses",
6: "Baseline pupil diameter vs baseline-subtracted evoked LC responses"}
pt_code = L.population_tests(Cc, (), REMOVED_SESSIONS)
cmp = []
for row, lab in labels.items():
for m in ("Oz", "Ci"):
g = re.search(re.escape(lab) + rf": {m} p = ([\d.e-]+) \(N = (\d+), median rho = ([-\d.]+)\)", txt)
r = pt_code[(pt_code.row == row) & (pt_code.monkey == m)].iloc[0]
cmp.append(dict(row=row, monkey=m, n=r.n, n_code=int(g.group(2)), median=r["median"],
median_code=float(g.group(3)), p=float(f"{r.p_T1:.3g}"), p_code=float(g.group(1))))
cmp = pd.DataFrame(cmp)
cmp["match"] = (cmp.n == cmp.n_code) & ((cmp["median"] - cmp.median_code).abs() <= 0.0015) & \
((cmp.p - cmp.p_code).abs() <= 0.1 * cmp.p_code)
print(cmp.to_string(index=False, float_format=lambda v: f"{v:.4g}"))
rng = L.range_correlations(Bc, Cc)
rc = []
for _, r in rng.iterrows():
key = ("Baseline pupil diameter vs evoked LC relationship as a function of evoked LC range" if r.analysis.startswith("row 6")
else "Baseline LC activity vs evoked pupil relationship as a function of evoked pupil range")
g = re.search(re.escape(key) + rf" \(Spearman rho = ([-\d.]+), p = ([\d.e-]+) for monkey {r.monkey}\)", txt)
rc.append(dict(monkey=r.monkey, analysis=r.analysis, rho=round(r.rho, 2), rho_code=float(g.group(1)),
p=float(f"{r.p:.3g}"), p_code=float(g.group(2))))
rc = pd.DataFrame(rc)
rc["match"] = ((rc.rho - rc.rho_code).abs() <= 0.005) & ((rc.p - rc.p_code).abs() <= 0.1 * rc.p_code)
print(rc.to_string(index=False))
ll = L.llr_counts(Bc, REMOVED, REMOVED_SESSIONS)
code_ll = {}
for lab, name in (("evoked FR vs baseline FR", "lc"), ("evoked pupil vs baseline FR", "pupil_on_lc"),
("evoked FR vs baseline pupil", "lc_on_pupil")):
blk = txt.split(f"For {lab},")[1]
for m in ("Oz", "Ci"):
code_ll[(m, name)] = re.search(rf"{m}: (\d+)/(\d+)", blk).groups()
blk = txt.split("For evoked pupil vs baseline pupil")[1]
for m in ("Oz", "Ci"):
code_ll[(m, "pupil")] = re.search(rf"{m}: (\d+)/(\d+)", blk).groups()
ll["code"] = [ "/".join(code_ll[(r.monkey, r.comparison)]) for r in ll.itertuples()]
ll["here"] = [f"{r.n_above}/{r.n}" for r in ll.itertuples()]
ll["match"] = ll.code == ll.here
print(ll[["monkey", "comparison", "here", "code", "match"]].to_string(index=False))
# Figure 3 pooled coefficients against the code's printed ones (three decimals), under the code's
# z-scoring (by within-session unit index) and per unit
f3blk = txt.split("Figure 3 pooled relationships")[1].split("Supplementary")[0]
f3keys = {3: "evoked pupil responses were correlated with baseline pupil",
4: "evoked FR responses were correlated with baseline FR",
1: "Baseline FR (Z-scored residuals) was correlated with baseline pupil",
2: "evoked FR responses were correlated with baseline-subtracted evoked pupil",
6: "evoked FR responses were correlated with baseline pupil",
5: "Baseline FR (Z-scored residuals) was correlated with baseline-subtracted evoked pupil"}
f3code = {}
for line in f3blk.splitlines():
g = re.search(r"rho = ([-\d.]+), p = <?([\d.]+) for monkey (\w+)", line)
if g:
col = next(c for c, k in f3keys.items() if k in line)
f3code[(g.group(3), col)] = float(g.group(1))
f3cmp = []
for grp, lab in (("unit", "code (within-session index)"), ("unit_key", "per unit")):
f3 = L.fig3_pooled(Bc, Fc, Cc, group=grp)
f3 = f3[f3.group == "all"].copy()
f3["zscore"] = lab
f3["rho_code"] = [f3code[(m, c)] for m, c in zip(f3.monkey, f3.column)]
f3["match"] = (f3.rho - f3.rho_code).abs() <= 0.0005 + 1e-9
f3cmp.append(f3)
f3cmp = pd.concat(f3cmp)
print("Figure 3 pooled (all units), here and in the code's printed output:")
print(f3cmp[["zscore", "monkey", "column", "n", "rho", "rho_code", "match"]].to_string(index=False, float_format=lambda v: f"{v:.4f}"))
print("Figure 3 values matching the code's printed output (to its 3 decimals):",
f3cmp.groupby("zscore", sort=False).match.agg(["sum", "size"]).to_dict("index"))
n_match = int(cmp.match.sum() + rc.match.sum() + ll.match.sum() + sum(a == b for a, b in mine.values()))
n_total = len(cmp) + len(rc) + len(ll) + len(mine)
print("trial counts here and in the code's output:", mine)
print(f"values matching the code's printed output: {n_match} of {n_total}")
row monkey n n_code median median_code p p_code match
1 Oz 42 42 0.07681 0.077 0.000521 0.000521 True
1 Ci 63 63 0.09669 0.097 1.14e-05 1.18e-05 True
2 Oz 42 42 0.08848 0.088 0.0135 0.0135 True
2 Ci 63 63 0.05329 0.053 0.00153 0.00153 True
3 Oz 32 32 -0.3311 -0.331 1.16e-06 1.16e-06 True
3 Ci 50 50 -0.3363 -0.336 1.13e-08 1.13e-08 True
4 Oz 42 42 -0.3808 -0.381 5.88e-07 5.88e-07 True
4 Ci 63 63 -0.3149 -0.315 1.48e-11 1.48e-11 True
5 Oz 42 42 0.03318 0.033 0.846 0.846 True
5 Ci 63 63 -0.01479 -0.015 0.897 0.897 True
6 Oz 42 42 0.03266 0.033 0.915 0.915 True
6 Ci 63 63 -0.0375 -0.037 0.0105 0.0105 True
monkey analysis rho rho_code p p_code match
Oz row 6 vs evoked LC range 0.02 0.02 0.8900 0.8900 True
Oz row 5 vs evoked pupil range -0.33 -0.33 0.0319 0.0319 True
Ci row 6 vs evoked LC range 0.05 0.05 0.6880 0.6880 True
Ci row 5 vs evoked pupil range 0.18 0.18 0.1570 0.1570 True
monkey comparison here code match
Oz pupil 7/32 7/32 True
Oz lc 2/42 2/42 True
Oz pupil_on_lc 4/42 4/42 True
Oz lc_on_pupil 2/42 2/42 True
Ci pupil 6/50 6/50 True
Ci lc 3/61 3/61 True
Ci pupil_on_lc 4/61 4/61 True
Ci lc_on_pupil 5/61 5/61 True
Figure 3 pooled (all units), here and in the code's printed output:
zscore monkey column n rho rho_code match
code (within-session index) Oz 1 7259 0.0880 0.0880 True
code (within-session index) Oz 2 1218 0.1175 0.1180 True
code (within-session index) Oz 3 922 -0.3808 -0.3810 True
code (within-session index) Oz 4 1218 -0.2418 -0.2420 True
code (within-session index) Oz 5 1218 -0.0177 -0.0180 True
code (within-session index) Oz 6 1218 -0.0259 -0.0260 True
code (within-session index) Ci 1 12485 0.0669 0.0670 True
code (within-session index) Ci 2 2756 0.0835 0.0840 True
code (within-session index) Ci 3 2200 -0.3241 -0.3240 True
code (within-session index) Ci 4 2756 -0.1695 -0.1690 True
code (within-session index) Ci 5 2756 -0.0020 -0.0020 True
code (within-session index) Ci 6 2756 -0.0193 -0.0190 True
per unit Oz 1 7259 0.0934 0.0880 False
per unit Oz 2 1218 0.1300 0.1180 False
per unit Oz 3 922 -0.3808 -0.3810 True
per unit Oz 4 1218 -0.2314 -0.2420 False
per unit Oz 5 1218 -0.0034 -0.0180 False
per unit Oz 6 1218 -0.0243 -0.0260 False
per unit Ci 1 12485 0.0634 0.0670 False
per unit Ci 2 2756 0.0832 0.0840 False
per unit Ci 3 2200 -0.3241 -0.3240 True
per unit Ci 4 2756 -0.1803 -0.1690 False
per unit Ci 5 2756 0.0018 -0.0020 False
per unit Ci 6 2756 -0.0179 -0.0190 False
Figure 3 values matching the code's printed output (to its 3 decimals): {'code (within-session index)': {'sum': 12, 'size': 12}, 'per unit': {'sum': 2, 'size': 12}}
trial counts here and in the code's output: {'beep trials': (3974, 3974), 'fixation trials': (15770, 15770)}
values matching the code's printed output: 26 of 26
Result: reproduced. Every session and unit on the code's include lists is in the dandiset and
every one in the dandiset is listed (83 sessions, 105 units). Run here on the dandiset, the code's
pipeline gives its printed trial counts, Figure 2 tests, range correlations and LLR counts (the
count of matches is printed above). The include list numbers its units 1 to 107 without 43 and
65, so the legacy removal of two units is already applied to the list; the code then removes rows
43 and 65 of its own 105-row table again, which drops the two units printed above (code_mismatch).
The code's twelve printed Figure 3 coefficients are matched to its three decimals when firing
rates are z-scored by within-session unit index across all sessions, which is what
zscore_tables.m does (it groups by unit, not unit_id); z-scored per unit, as the Figure 3
legend says, fewer match (both counts printed above).
data-units-sessions¶
The analysis used 42 LC single units from 32 sessions in monkey Oz and 63 units from 51 sessions in monkey Ci, recorded with pupil diameter during passive fixation with occasional startling beeps.
Expected: Oz 42 units and 32 sessions; Ci 63 units and 51 sessions; tolerance 0.
for name in ("M-E1", "code"):
B = T[name][0]
listed = B[[(m, s + ".mat", u) in lu for m, s, u in zip(B.monkey, B.session, B.unit)]]
g = listed.groupby("monkey").agg(units=("unit_key", "nunique"), sessions=("session", "nunique"),
beep_rows=("trial", "size"))
per_unit = listed.groupby("unit_key").size()
print(name, "\n", g, "\n beep trials per unit: min", per_unit.min(), "median", per_unit.median(), "max", per_unit.max())
print("removing the code's two units leaves:", T["code"][0][~T["code"][0].unit_key.isin(REMOVED)]
.groupby("monkey").agg(units=("unit_key", "nunique"), sessions=("session", "nunique")).to_dict())
M-E1
units sessions beep_rows
monkey
Cicero 63 51 2697
Oz 42 32 1208
beep trials per unit: min 7 median 31.0 max 109
code
units sessions beep_rows
monkey
Cicero 63 51 2756
Oz 42 32 1218
beep trials per unit: min 7 median 31.0 max 111
removing the code's two units leaves: {'units': {'Cicero': 61, 'Oz': 42}, 'sessions': {'Cicero': 50, 'Oz': 32}}
Result: reproduced. All four counts match: Oz 42 units in 32 sessions, Ci 63 units in 51 sessions, each with beep trials, spikes and pupil, under both trial rules. The code's double removal would give 61 units in 50 sessions for Ci.
Figure 2: rows 1 to 6¶
Per unit (rows 1, 2, 4, 5, 6) or per session (row 3) Spearman coefficients, and per monkey the
population test T1 (Wilcoxon signed rank against 0, the code's signrank), with T2 (rank sum
against as many zeros) as a variant. The table gives every reading; n_sig_pos and n_sig_neg
count units or sessions with p < 0.05 of each sign. The paper's p-values are beside ours.
PAPER_P = {(1, "Oz"): 8.6e-4, (1, "Ci"): 9.85e-6, (2, "Oz"): 0.0135, (2, "Ci"): 0.0018,
(3, "Oz"): 1.16e-6, (3, "Ci"): 5.02e-9, (4, "Oz"): 5.88e-7, (4, "Ci"): 1.04e-11,
(5, "Oz"): 0.894, (5, "Ci"): 0.904, (6, "Oz"): 0.915, (6, "Ci"): 0.008}
POP = {}
for name, (B, F, C) in T.items():
P = L.population_tests(C)
P["paper_p"] = [PAPER_P[(r, m)] for r, m in zip(P.row, P.monkey)]
P.insert(0, "reading", name)
POP[name] = P
POP[name + ", code's removal"] = L.population_tests(C, REMOVED, REMOVED_SESSIONS).assign(reading=name + ", code's removal")
FIG2 = pd.concat(POP.values(), ignore_index=True)
for row in range(1, 7):
print(f"Row {row}: {L.ROWS[row]}")
print(FIG2[FIG2.row == row][["reading", "monkey", "n", "median", "p_T1", "p_T2", "paper_p", "n_sig_pos", "n_sig_neg"]]
.to_string(index=False, float_format=lambda v: f"{v:.3g}"))
print()
Row 1: baseline LC vs baseline pupil (partial Spearman, given trial time)
reading monkey n median p_T1 p_T2 paper_p n_sig_pos n_sig_neg
M-E1 Ci 63 0.0926 1.38e-05 3.33e-05 9.85e-06 17 4
M-E1 Oz 42 0.0795 0.000546 0.000172 0.00086 12 3
M-E1, code's removal Ci 61 0.0926 2.6e-05 9.45e-05 NaN 17 4
M-E1, code's removal Oz 42 0.0795 0.000546 0.000172 NaN 12 3
M-E2 Ci 63 0.0926 1.38e-05 3.33e-05 9.85e-06 17 4
M-E2 Oz 42 0.0795 0.000546 0.000172 0.00086 12 3
M-E2, code's removal Ci 61 0.0926 2.6e-05 9.45e-05 NaN 17 4
M-E2, code's removal Oz 42 0.0795 0.000546 0.000172 NaN 12 3
code Ci 63 0.0967 1.14e-05 1.89e-06 9.85e-06 18 4
code Oz 42 0.0768 0.000521 0.000172 0.00086 13 3
code, code's removal Ci 61 0.0967 2.15e-05 5.93e-06 NaN 18 4
code, code's removal Oz 42 0.0768 0.000521 0.000172 NaN 13 3
code trials + E1 Ci 63 0.0931 1.29e-05 1.89e-06 9.85e-06 17 4
code trials + E1 Oz 42 0.0759 0.000546 0.000172 0.00086 13 3
code trials + E1, code's removal Ci 61 0.0931 2.52e-05 5.93e-06 NaN 17 4
code trials + E1, code's removal Oz 42 0.0759 0.000546 0.000172 NaN 13 3
Methods trials + code pupil Ci 63 0.0926 1.38e-05 3.33e-05 9.85e-06 17 4
Methods trials + code pupil Oz 42 0.0795 0.000546 0.000172 0.00086 12 3
Methods trials + code pupil, code's removal Ci 61 0.0926 2.6e-05 9.45e-05 NaN 17 4
Methods trials + code pupil, code's removal Oz 42 0.0795 0.000546 0.000172 NaN 12 3
M-E1, 200 ms after beep Ci 63 0.0926 1.51e-05 3.33e-05 9.85e-06 17 4
M-E1, 200 ms after beep Oz 42 0.0797 0.000627 0.000172 0.00086 13 3
M-E1, 200 ms after beep, code's removal Ci 61 0.0926 2.69e-05 9.45e-05 NaN 17 4
M-E1, 200 ms after beep, code's removal Oz 42 0.0797 0.000627 0.000172 NaN 13 3
M-E2, 200 ms after beep Ci 63 0.0926 1.51e-05 3.33e-05 9.85e-06 17 4
M-E2, 200 ms after beep Oz 42 0.0797 0.000627 0.000172 0.00086 13 3
M-E2, 200 ms after beep, code's removal Ci 61 0.0926 2.69e-05 9.45e-05 NaN 17 4
M-E2, 200 ms after beep, code's removal Oz 42 0.0797 0.000627 0.000172 NaN 13 3
Row 2: evoked LC vs evoked pupil
reading monkey n median p_T1 p_T2 paper_p n_sig_pos n_sig_neg
M-E1 Ci 63 0.0238 0.00284 0.00898 0.0018 4 0
M-E1 Oz 42 0.118 0.0106 0.0242 0.0135 6 1
M-E1, code's removal Ci 61 0.0205 0.0073 0.0191 NaN 4 0
M-E1, code's removal Oz 42 0.118 0.0106 0.0242 NaN 6 1
M-E2 Ci 63 0.0526 0.00259 0.00898 0.0018 1 0
M-E2 Oz 42 0.0918 0.0197 0.133 0.0135 5 1
M-E2, code's removal Ci 61 0.052 0.0067 0.0191 NaN 1 0
M-E2, code's removal Oz 42 0.0918 0.0197 0.133 NaN 5 1
code Ci 63 0.0533 0.00153 0.000122 0.0018 1 0
code Oz 42 0.0885 0.0135 0.0242 0.0135 7 1
code, code's removal Ci 61 0.0514 0.00393 0.000328 NaN 0 0
code, code's removal Oz 42 0.0885 0.0135 0.0242 NaN 7 1
code trials + E1 Ci 63 0.0423 0.00271 0.00898 0.0018 4 0
code trials + E1 Oz 42 0.107 0.0161 0.0603 0.0135 7 1
code trials + E1, code's removal Ci 61 0.0238 0.00699 0.0191 NaN 4 0
code trials + E1, code's removal Oz 42 0.107 0.0161 0.0603 NaN 7 1
Methods trials + code pupil Ci 63 0.0458 0.0115 0.00125 0.0018 0 0
Methods trials + code pupil Oz 42 0.0887 0.0113 0.0242 0.0135 6 1
Methods trials + code pupil, code's removal Ci 61 0.0436 0.0267 0.003 NaN 0 0
Methods trials + code pupil, code's removal Oz 42 0.0887 0.0113 0.0242 NaN 6 1
M-E1, 200 ms after beep Ci 63 0.0455 0.00221 0.0035 0.0018 2 0
M-E1, 200 ms after beep Oz 42 0.12 0.00849 0.0242 0.0135 6 1
M-E1, 200 ms after beep, code's removal Ci 61 0.028 0.0055 0.00793 NaN 2 0
M-E1, 200 ms after beep, code's removal Oz 42 0.12 0.00849 0.0242 NaN 6 1
M-E2, 200 ms after beep Ci 63 0.052 0.00412 0.00898 0.0018 0 0
M-E2, 200 ms after beep Oz 42 0.115 0.0113 0.00853 0.0135 5 1
M-E2, 200 ms after beep, code's removal Ci 61 0.0441 0.0104 0.0191 NaN 0 0
M-E2, 200 ms after beep, code's removal Oz 42 0.115 0.0113 0.00853 NaN 5 1
Row 3: evoked pupil vs baseline pupil residual (per session)
reading monkey n median p_T1 p_T2 paper_p n_sig_pos n_sig_neg
M-E1 Ci 51 -0.45 1.99e-09 6.14e-17 5.02e-09 1 34
M-E1 Oz 32 -0.328 7.86e-06 2.52e-07 1.16e-06 0 12
M-E1, code's removal Ci 50 -0.447 2.99e-09 1.31e-16 NaN 1 33
M-E1, code's removal Oz 32 -0.328 7.86e-06 2.52e-07 NaN 0 12
M-E2 Ci 51 -0.372 5.23e-09 1.05e-15 5.02e-09 1 29
M-E2 Oz 32 -0.37 1.06e-06 1.16e-10 1.16e-06 0 13
M-E2, code's removal Ci 50 -0.363 8.03e-09 2.23e-15 NaN 1 28
M-E2, code's removal Oz 32 -0.37 1.06e-06 1.16e-10 NaN 0 13
code Ci 51 -0.341 7.32e-09 2.16e-13 5.02e-09 1 30
code Oz 32 -0.331 1.16e-06 1.79e-09 1.16e-06 0 13
code, code's removal Ci 50 -0.336 1.13e-08 4.54e-13 NaN 1 29
code, code's removal Oz 32 -0.331 1.16e-06 1.79e-09 NaN 0 13
code trials + E1 Ci 51 -0.449 1.99e-09 6.14e-17 5.02e-09 1 33
code trials + E1 Oz 32 -0.328 7.86e-06 2.52e-07 1.16e-06 0 12
code trials + E1, code's removal Ci 50 -0.446 2.99e-09 1.31e-16 NaN 1 32
code trials + E1, code's removal Oz 32 -0.328 7.86e-06 2.52e-07 NaN 0 12
Methods trials + code pupil Ci 51 -0.354 6.92e-09 2.16e-13 5.02e-09 1 30
Methods trials + code pupil Oz 32 -0.352 8.75e-07 1.16e-10 1.16e-06 0 13
Methods trials + code pupil, code's removal Ci 50 -0.348 1.07e-08 4.54e-13 NaN 1 29
Methods trials + code pupil, code's removal Oz 32 -0.352 8.75e-07 1.16e-10 NaN 0 13
M-E1, 200 ms after beep Ci 51 -0.455 9.31e-10 6.14e-17 5.02e-09 0 33
M-E1, 200 ms after beep Oz 32 -0.367 1.54e-06 1.16e-10 1.16e-06 0 13
M-E1, 200 ms after beep, code's removal Ci 50 -0.449 1.38e-09 1.31e-16 NaN 0 32
M-E1, 200 ms after beep, code's removal Oz 32 -0.367 1.54e-06 1.16e-10 NaN 0 13
M-E2, 200 ms after beep Ci 51 -0.369 2.65e-09 1.05e-15 5.02e-09 0 29
M-E2, 200 ms after beep Oz 32 -0.355 7.95e-07 6.21e-12 1.16e-06 0 13
M-E2, 200 ms after beep, code's removal Ci 50 -0.362 4.01e-09 2.23e-15 NaN 0 28
M-E2, 200 ms after beep, code's removal Oz 32 -0.355 7.95e-07 6.21e-12 NaN 0 13
Row 4: evoked LC vs baseline LC residual
reading monkey n median p_T1 p_T2 paper_p n_sig_pos n_sig_neg
M-E1 Ci 63 -0.297 1.48e-11 1.21e-19 1.04e-11 0 31
M-E1 Oz 42 -0.382 1.19e-06 1.84e-09 5.88e-07 0 22
M-E1, code's removal Ci 61 -0.295 3.28e-11 5.49e-19 NaN 0 29
M-E1, code's removal Oz 42 -0.382 1.19e-06 1.84e-09 NaN 0 22
M-E2 Ci 63 -0.297 1.48e-11 1.21e-19 1.04e-11 0 31
M-E2 Oz 42 -0.382 1.19e-06 1.84e-09 5.88e-07 0 22
M-E2, code's removal Ci 61 -0.295 3.28e-11 5.49e-19 NaN 0 29
M-E2, code's removal Oz 42 -0.382 1.19e-06 1.84e-09 NaN 0 22
code Ci 63 -0.315 1.48e-11 1.94e-18 1.04e-11 0 31
code Oz 42 -0.381 5.88e-07 1.69e-10 5.88e-07 0 22
code, code's removal Ci 61 -0.297 3.28e-11 8.73e-18 NaN 0 29
code, code's removal Oz 42 -0.381 5.88e-07 1.69e-10 NaN 0 22
code trials + E1 Ci 63 -0.297 1.62e-11 1.94e-18 1.04e-11 0 31
code trials + E1 Oz 42 -0.381 1.19e-06 1.84e-09 5.88e-07 0 22
code trials + E1, code's removal Ci 61 -0.294 3.62e-11 8.73e-18 NaN 0 29
code trials + E1, code's removal Oz 42 -0.381 1.19e-06 1.84e-09 NaN 0 22
Methods trials + code pupil Ci 63 -0.297 1.48e-11 1.21e-19 1.04e-11 0 31
Methods trials + code pupil Oz 42 -0.382 1.19e-06 1.84e-09 5.88e-07 0 22
Methods trials + code pupil, code's removal Ci 61 -0.295 3.28e-11 5.49e-19 NaN 0 29
Methods trials + code pupil, code's removal Oz 42 -0.382 1.19e-06 1.84e-09 NaN 0 22
M-E1, 200 ms after beep Ci 63 -0.284 1.87e-11 1.94e-18 1.04e-11 0 30
M-E1, 200 ms after beep Oz 42 -0.384 3.72e-07 1.69e-10 5.88e-07 0 21
M-E1, 200 ms after beep, code's removal Ci 61 -0.272 4.18e-11 8.73e-18 NaN 0 28
M-E1, 200 ms after beep, code's removal Oz 42 -0.384 3.72e-07 1.69e-10 NaN 0 21
M-E2, 200 ms after beep Ci 63 -0.284 1.87e-11 1.94e-18 1.04e-11 0 30
M-E2, 200 ms after beep Oz 42 -0.384 3.72e-07 1.69e-10 5.88e-07 0 21
M-E2, 200 ms after beep, code's removal Ci 61 -0.272 4.18e-11 8.73e-18 NaN 0 28
M-E2, 200 ms after beep, code's removal Oz 42 -0.384 3.72e-07 1.69e-10 NaN 0 21
Row 5: evoked pupil vs baseline LC residual
reading monkey n median p_T1 p_T2 paper_p n_sig_pos n_sig_neg
M-E1 Ci 63 0.01 0.94 0.878 0.904 0 3
M-E1 Oz 42 0.00681 0.798 1 0.894 0 3
M-E1, code's removal Ci 61 0.011 0.733 0.639 NaN 0 3
M-E1, code's removal Oz 42 0.00681 0.798 1 NaN 0 3
M-E2 Ci 63 0.0124 0.951 0.442 0.904 2 2
M-E2 Oz 42 0.023 0.99 0.188 0.894 0 4
M-E2, code's removal Ci 61 0.0234 0.733 0.274 NaN 2 2
M-E2, code's removal Oz 42 0.023 0.99 0.188 NaN 0 4
code Ci 63 -0.0148 0.897 0.878 0.904 1 5
code Oz 42 0.0332 0.846 0.452 0.894 0 5
code, code's removal Ci 61 0.026 0.669 0.876 NaN 1 4
code, code's removal Oz 42 0.0332 0.846 0.452 NaN 0 5
code trials + E1 Ci 63 0.01 0.956 0.878 0.904 0 3
code trials + E1 Oz 42 0.00577 0.684 1 0.894 0 5
code trials + E1, code's removal Ci 61 0.0136 0.749 0.639 NaN 0 3
code trials + E1, code's removal Oz 42 0.00577 0.684 1 NaN 0 5
Methods trials + code pupil Ci 63 0.0338 0.701 0.645 0.904 1 4
Methods trials + code pupil Oz 42 0.0655 0.876 0.452 0.894 0 4
Methods trials + code pupil, code's removal Ci 61 0.0351 0.493 0.435 NaN 1 4
Methods trials + code pupil, code's removal Oz 42 0.0655 0.876 0.452 NaN 0 4
M-E1, 200 ms after beep Ci 63 0.00944 0.918 0.645 0.904 1 4
M-E1, 200 ms after beep Oz 42 -0.000252 0.595 1 0.894 0 5
M-E1, 200 ms after beep, code's removal Ci 61 0.0294 0.659 0.435 NaN 1 4
M-E1, 200 ms after beep, code's removal Oz 42 -0.000252 0.595 1 NaN 0 5
M-E2, 200 ms after beep Ci 63 0.0138 0.935 0.878 0.904 2 3
M-E2, 200 ms after beep Oz 42 0.0385 0.722 0.452 0.894 0 6
M-E2, 200 ms after beep, code's removal Ci 61 0.0174 0.674 0.639 NaN 2 2
M-E2, 200 ms after beep, code's removal Oz 42 0.0385 0.722 0.452 NaN 0 6
Row 6: evoked LC vs baseline pupil residual
reading monkey n median p_T1 p_T2 paper_p n_sig_pos n_sig_neg
M-E1 Ci 63 -0.0223 0.0344 0.00898 0.008 1 3
M-E1 Oz 42 0.0362 0.965 0.452 0.915 1 2
M-E1, code's removal Ci 61 -0.0223 0.0644 0.0191 NaN 1 3
M-E1, code's removal Oz 42 0.0362 0.965 0.452 NaN 1 2
M-E2 Ci 63 -0.0223 0.0344 0.00898 0.008 1 3
M-E2 Oz 42 0.0362 0.965 0.452 0.915 1 2
M-E2, code's removal Ci 61 -0.0223 0.0644 0.0191 NaN 1 3
M-E2, code's removal Oz 42 0.0362 0.965 0.452 NaN 1 2
code Ci 63 -0.0375 0.0105 0.00125 0.008 1 3
code Oz 42 0.0327 0.915 0.707 0.915 1 2
code, code's removal Ci 61 -0.0375 0.0187 0.003 NaN 1 3
code, code's removal Oz 42 0.0327 0.915 0.707 NaN 1 2
code trials + E1 Ci 63 -0.0266 0.0285 0.00898 0.008 1 3
code trials + E1 Oz 42 0.0362 0.837 0.26 0.915 1 3
code trials + E1, code's removal Ci 61 -0.0223 0.0538 0.0191 NaN 1 3
code trials + E1, code's removal Oz 42 0.0362 0.837 0.26 NaN 1 3
Methods trials + code pupil Ci 63 -0.0223 0.0344 0.00898 0.008 1 3
Methods trials + code pupil Oz 42 0.0362 0.965 0.452 0.915 1 2
Methods trials + code pupil, code's removal Ci 61 -0.0223 0.0644 0.0191 NaN 1 3
Methods trials + code pupil, code's removal Oz 42 0.0362 0.965 0.452 NaN 1 2
M-E1, 200 ms after beep Ci 63 -0.0223 0.029 0.0457 0.008 1 4
M-E1, 200 ms after beep Oz 42 -0.00154 0.798 1 0.915 2 2
M-E1, 200 ms after beep, code's removal Ci 61 -0.0223 0.0462 0.0858 NaN 1 4
M-E1, 200 ms after beep, code's removal Oz 42 -0.00154 0.798 1 NaN 2 2
M-E2, 200 ms after beep Ci 63 -0.0223 0.029 0.0457 0.008 1 4
M-E2, 200 ms after beep Oz 42 -0.00154 0.798 1 0.915 2 2
M-E2, 200 ms after beep, code's removal Ci 61 -0.0223 0.0462 0.0858 NaN 1 4
M-E2, 200 ms after beep, code's removal Oz 42 -0.00154 0.798 1 NaN 2 2
C = T["M-E1"][2]
fig, ax = plt.subplots(1, 6, figsize=(15, 3), sharey=True)
for k, a in enumerate(ax, start=1):
for j, m in enumerate(L.MONKEYS):
v = C[(C.row == k) & (C.monkey == m)]
a.scatter(np.full(len(v), j) + np.linspace(-0.2, 0.2, len(v)), v.r, s=8,
c=np.where(v.p < 0.05, "k", "0.7"))
a.hlines(v.r.median(), j - 0.3, j + 0.3, color="r")
a.axhline(0, color="0.5", lw=0.5)
a.set_xticks([0, 1], ["Oz", "Ci"])
a.set_title(f"row {k}", fontsize=9)
ax[0].set_ylabel("Spearman coefficient (M-E1)")
plt.tight_layout()
print("plotted coefficients range from", round(C.r.min(), 3), "to", round(C.r.max(), 3), "; none outside the axes")
plotted coefficients range from -0.916 to 0.621 ; none outside the axes
Result: reproduced (row 1). In both monkeys the median partial coefficient is above zero and T1 gives p < 0.05 (table above, Oz p = 5.5e-4, Ci p = 1.4e-5 under the Methods' trials, against the paper's 8.6e-4 and 9.85e-6). Row 1 does not depend on the evoked pupil, and every variant gives the same.
Result: reproduced (row 2). Under E1 and under E2 the median is above zero and T1 gives p < 0.05 in both monkeys (Oz p = 0.011 and 0.020, Ci p = 0.0028 and 0.0026; paper 0.0135 and 0.0018). The code reading gives Oz 0.0135 and Ci 0.0015.
Result: reproduced (row 3). Under E1 and E2 the median per-session coefficient is negative and T1 gives p < 1e-5 in both monkeys, over the paper's 32 and 51 sessions and over the code's 50.
Result: reproduced (row 4). The median per-unit coefficient is negative and T1 gives p < 1e-5 in both monkeys under every reading (Oz 1.2e-6, Ci 1.5e-11 under the Methods' trials).
Result: reproduced (row 5). T1 gives p >= 0.05 in both monkeys under E1 and E2 (Oz 0.80 and 0.99, Ci 0.94 and 0.95; paper 0.894 and 0.904), with medians within 0.025 of zero. T2 and the code's evoked pupil also give p >= 0.05.
Result: reproduced (row 6). Oz gives p >= 0.05 and Ci p < 0.05 with T1 (Oz 0.97, Ci 0.034 under the Methods' trials; code reading 0.915 and 0.0105; paper 0.915 and 0.008), the paper's pattern. Ci's median is small and negative (-0.022). With the code's removal of two Ci units, a variant here, Ci gives p = 0.064 under the Methods' trials and 0.019 under the code reading. The Ci result is therefore fragile: it rests on the paper's denominator of 63 units, which the claims file takes, and two units fewer move T1 across 0.05. Leaving out the beep trials whose 200 ms evoked window runs past the end of the trial (a variant, see the data check) gives Ci p = 0.029 with 63 units and 0.046 with 61.
cross-epoch-no-reliable-relation¶
Despite consistent within-epoch relationships between LC activity and pupil size, there are no reliable relationships between the two across epochs.
Decided from rows 1, 2, 5 and 6 above.
def row_state(P, row):
g = P[P.row == row].set_index("monkey")
return {m: (round(g.loc[m, "median"], 3), float(f"{g.loc[m, 'p_T1']:.3g}")) for m in ("Oz", "Ci")}
for name in ("M-E1", "M-E2", "code"):
P = POP[name]
within = all(P[(P.row == r)].p_T1.max() < 0.05 and (P[P.row == r]["median"] > 0).all() for r in (1, 2))
cross_same_sign = {r: bool((P[P.row == r].p_T1 < 0.05).all() and len(set(np.sign(P[P.row == r]["median"]))) == 1)
for r in (5, 6)}
print(name, "| rows 1 and 2 hold in both monkeys:", within, "| cross-epoch row significant with one sign in both:",
cross_same_sign, "| row 5", row_state(P, 5), "| row 6", row_state(P, 6))
M-E1 | rows 1 and 2 hold in both monkeys: True | cross-epoch row significant with one sign in both: {5: False, 6: False} | row 5 {'Oz': (np.float64(0.007), 0.798), 'Ci': (np.float64(0.01), 0.94)} | row 6 {'Oz': (np.float64(0.036), 0.965), 'Ci': (np.float64(-0.022), 0.0344)}
M-E2 | rows 1 and 2 hold in both monkeys: True | cross-epoch row significant with one sign in both: {5: False, 6: False} | row 5 {'Oz': (np.float64(0.023), 0.99), 'Ci': (np.float64(0.012), 0.951)} | row 6 {'Oz': (np.float64(0.036), 0.965), 'Ci': (np.float64(-0.022), 0.0344)}
code | rows 1 and 2 hold in both monkeys: True | cross-epoch row significant with one sign in both: {5: False, 6: False} | row 5 {'Oz': (np.float64(0.033), 0.846), 'Ci': (np.float64(-0.015), 0.897)} | row 6 {'Oz': (np.float64(0.033), 0.915), 'Ci': (np.float64(-0.038), 0.0105)}
Result: reproduced. Rows 1 and 2 hold in both monkeys, and neither cross-epoch row is significant with the same sign in both monkeys, under E1, E2 and the code reading.
range-baseline-pupil-evoked-lc and range-baseline-lc-evoked-pupil¶
The correlation between baseline pupil and evoked LC responses does not depend on the range of evoked LC responses in either monkey (Oz rho = 0.02, p = 0.89; Ci rho = 0.07, p = 0.589).
The correlation between baseline LC activity and evoked pupil responses does not depend on the range of evoked pupil responses in Ci (rho = 0.18, p = 0.16), but in Oz it becomes more negative as that range grows (rho = -0.33, p = 0.03). Expected Oz rho -0.33 +/- 0.033.
Across units, per monkey, the Spearman correlation of each unit's row 6 (row 5) coefficient with the range of its evoked firing rates (evoked pupil) over beep trials.
RNG = pd.concat([L.range_correlations(B, C).assign(reading=name) for name, (B, F, C) in T.items()]
+ [L.range_correlations(B[~B.unit_key.isin(REMOVED)], C[~C.unit_key.isin(REMOVED)])
.assign(reading=name + ", code's removal") for name, (B, F, C) in T.items() if name in ("M-E1", "M-E2", "code")],
ignore_index=True)
print(RNG[RNG.analysis.str.startswith("row 6")][["reading", "monkey", "n", "rho", "p"]].to_string(index=False, float_format=lambda v: f"{v:.3g}"))
reading monkey n rho p
M-E1 Oz 42 0.0438 0.783
M-E1 Ci 63 0.0665 0.604
M-E2 Oz 42 0.0438 0.783
M-E2 Ci 63 0.0665 0.604
code Oz 42 0.022 0.89
code Ci 63 0.0516 0.688
code trials + E1 Oz 42 0.0354 0.824
code trials + E1 Ci 63 0.0657 0.609
Methods trials + code pupil Oz 42 0.0438 0.783
Methods trials + code pupil Ci 63 0.0665 0.604
M-E1, 200 ms after beep Oz 42 0.0583 0.714
M-E1, 200 ms after beep Ci 63 -9.6e-05 0.999
M-E2, 200 ms after beep Oz 42 0.0583 0.714
M-E2, 200 ms after beep Ci 63 -9.6e-05 0.999
M-E1, code's removal Oz 42 0.0438 0.783
M-E1, code's removal Ci 61 0.115 0.379
M-E2, code's removal Oz 42 0.0438 0.783
M-E2, code's removal Ci 61 0.115 0.379
code, code's removal Oz 42 0.022 0.89
code, code's removal Ci 61 0.0873 0.503
Result: reproduced. The row 6 coefficient is not correlated with the range of evoked LC responses in either monkey (Oz rho = 0.04, p = 0.78; Ci rho = 0.07, p = 0.60 under the Methods' trials; code reading 0.02, p = 0.89 and 0.05, p = 0.69).
print(RNG[RNG.analysis.str.startswith("row 5")][["reading", "monkey", "n", "rho", "p"]].to_string(index=False, float_format=lambda v: f"{v:.3g}"))
reading monkey n rho p
M-E1 Oz 42 -0.041 0.796
M-E1 Ci 63 0.0128 0.921
M-E2 Oz 42 -0.134 0.398
M-E2 Ci 63 0.104 0.419
code Oz 42 -0.332 0.0319
code Ci 63 0.18 0.157
code trials + E1 Oz 42 -0.121 0.447
code trials + E1 Ci 63 0.00643 0.96
Methods trials + code pupil Oz 42 -0.199 0.207
Methods trials + code pupil Ci 63 0.0838 0.514
M-E1, 200 ms after beep Oz 42 0.0118 0.941
M-E1, 200 ms after beep Ci 63 0.0542 0.673
M-E2, 200 ms after beep Oz 42 -0.101 0.524
M-E2, 200 ms after beep Ci 63 0.0968 0.45
M-E1, code's removal Oz 42 -0.041 0.796
M-E1, code's removal Ci 61 0.0609 0.641
M-E2, code's removal Oz 42 -0.134 0.398
M-E2, code's removal Ci 61 0.117 0.369
code, code's removal Oz 42 -0.332 0.0319
code, code's removal Ci 61 0.166 0.202
Result: not reproduced. Under the Methods' evoked pupil, read as E1 or E2, Ci gives p >= 0.05 as the paper says, but Oz does not show the negative correlation (rho = -0.04, p = 0.80 under E1; rho = -0.13, p = 0.40 under E2). The code reading gives the paper's numbers (Oz rho = -0.33, p = 0.032; Ci rho = 0.18, p = 0.16), but neither mixture does (Oz rho = -0.12, p = 0.45 with the code's trials and E1; rho = -0.20, p = 0.21 with the Methods' trials and the code's evoked pupil): the Oz result needs both the code's trial rule, which keeps beep trials up to the padded end of the pupil record, and its 0 to 800 ms evoked pupil. Leaving out the beep trials whose 200 ms evoked window runs past the end of the trial (variant) gives Oz rho = 0.01, p = 0.94 (E1) and -0.10, p = 0.52 (E2), the same outcome.
figs1-raw-baselines-similar¶
Using raw baseline measures in place of drift residuals gives results similar to those of Figure 2.
The six Figure 2 coefficients with raw baselines; 12 row and monkey cells are compared with the paper's Figure 2 pattern (rows 1 to 4 significant in the reported direction in both monkeys, row 5 not significant in either, row 6 not significant in Oz and significant in Ci).
PATTERN = {1: ("+", "+"), 2: ("+", "+"), 3: ("-", "-"), 4: ("-", "-"), 5: ("ns", "ns"), 6: ("ns", "+-")}
def cell_matches(row, monkey, med, p):
want = PATTERN[row][0 if monkey == "Oz" else 1]
if want == "ns":
return p >= 0.05
if want == "+-":
return p < 0.05
return p < 0.05 and (med > 0 if want == "+" else med < 0)
S1 = []
for name, (B, F, C) in T.items():
P = L.population_tests(L.figure2_coefficients(B, F, baseline="raw"))
P["match"] = [cell_matches(r.row, r.monkey, r["median"], r.p_T1) for _, r in P.iterrows()]
P["match_T2"] = [cell_matches(r.row, r.monkey, r["median"], r.p_T2) for _, r in P.iterrows()]
P.insert(0, "reading", name)
S1.append(P)
S1 = pd.concat(S1, ignore_index=True)
print(S1[["reading", "row", "monkey", "n", "median", "p_T1", "p_T2", "match", "match_T2"]].to_string(index=False, float_format=lambda v: f"{v:.3g}"))
print(S1.groupby("reading", sort=False)[["match", "match_T2"]].sum())
reading row monkey n median p_T1 p_T2 match match_T2
M-E1 1 Ci 63 0.0926 1.38e-05 3.33e-05 True True
M-E1 1 Oz 42 0.0795 0.000546 0.000172 True True
M-E1 2 Ci 63 0.0238 0.00284 0.00898 True True
M-E1 2 Oz 42 0.118 0.0106 0.0242 True True
M-E1 3 Ci 51 -0.4 9.31e-10 1.59e-14 True True
M-E1 3 Oz 32 -0.272 3.05e-05 2.52e-07 True True
M-E1 4 Ci 63 -0.288 6.53e-11 1.21e-19 True True
M-E1 4 Oz 42 -0.346 1.84e-06 1.74e-08 True True
M-E1 5 Ci 63 0.00753 0.816 0.878 True True
M-E1 5 Oz 42 -0.027 0.544 0.452 True True
M-E1 6 Ci 63 -0.0059 0.136 0.442 False False
M-E1 6 Oz 42 0.0131 0.955 1 True True
M-E2 1 Ci 63 0.0926 1.38e-05 3.33e-05 True True
M-E2 1 Oz 42 0.0795 0.000546 0.000172 True True
M-E2 2 Ci 63 0.0526 0.00259 0.00898 True True
M-E2 2 Oz 42 0.0918 0.0197 0.133 True False
M-E2 3 Ci 51 -0.347 4.67e-09 2.61e-12 True True
M-E2 3 Oz 32 -0.27 3.86e-06 2.52e-07 True True
M-E2 4 Ci 63 -0.288 6.53e-11 1.21e-19 True True
M-E2 4 Oz 42 -0.346 1.84e-06 1.74e-08 True True
M-E2 5 Ci 63 0.0203 0.805 0.167 True True
M-E2 5 Oz 42 -0.0359 0.694 0.452 True True
M-E2 6 Ci 63 -0.0059 0.136 0.442 False False
M-E2 6 Oz 42 0.0131 0.955 1 True True
code 1 Ci 63 0.0967 1.14e-05 1.89e-06 True True
code 1 Oz 42 0.0768 0.000521 0.000172 True True
code 2 Ci 63 0.0533 0.00153 0.000122 True True
code 2 Oz 42 0.0885 0.0135 0.0242 True True
code 3 Ci 51 -0.32 9.14e-09 2.61e-12 True True
code 3 Oz 32 -0.286 2.69e-06 2.52e-07 True True
code 4 Ci 63 -0.279 8.58e-11 1.21e-19 True True
code 4 Oz 42 -0.346 1.53e-06 1.84e-09 True True
code 5 Ci 63 0.0192 0.753 0.442 True True
code 5 Oz 42 -0.0121 0.413 0.707 True True
code 6 Ci 63 -0.0348 0.023 0.0211 True True
code 6 Oz 42 0.038 0.778 0.452 True True
code trials + E1 1 Ci 63 0.0931 1.29e-05 1.89e-06 True True
code trials + E1 1 Oz 42 0.0759 0.000546 0.000172 True True
code trials + E1 2 Ci 63 0.0423 0.00271 0.00898 True True
code trials + E1 2 Oz 42 0.107 0.0161 0.0603 True False
code trials + E1 3 Ci 51 -0.4 9.87e-10 1.59e-14 True True
code trials + E1 3 Oz 32 -0.293 2.19e-05 2.33e-08 True True
code trials + E1 4 Ci 63 -0.288 6.53e-11 1.21e-19 True True
code trials + E1 4 Oz 42 -0.349 1.96e-06 1.74e-08 True True
code trials + E1 5 Ci 63 -0.00688 0.897 0.878 True True
code trials + E1 5 Oz 42 -0.027 0.413 0.452 True True
code trials + E1 6 Ci 63 -0.0059 0.131 0.442 False False
code trials + E1 6 Oz 42 0.0305 0.837 0.707 True True
Methods trials + code pupil 1 Ci 63 0.0926 1.38e-05 3.33e-05 True True
Methods trials + code pupil 1 Oz 42 0.0795 0.000546 0.000172 True True
Methods trials + code pupil 2 Ci 63 0.0458 0.0115 0.00125 True True
Methods trials + code pupil 2 Oz 42 0.0887 0.0113 0.0242 True True
Methods trials + code pupil 3 Ci 51 -0.32 5.53e-09 2.61e-12 True True
Methods trials + code pupil 3 Oz 32 -0.273 2.94e-06 2.52e-07 True True
Methods trials + code pupil 4 Ci 63 -0.288 6.53e-11 1.21e-19 True True
Methods trials + code pupil 4 Oz 42 -0.346 1.84e-06 1.74e-08 True True
Methods trials + code pupil 5 Ci 63 0.035 0.511 0.282 True True
Methods trials + code pupil 5 Oz 42 -0.0187 0.528 0.707 True True
Methods trials + code pupil 6 Ci 63 -0.0059 0.136 0.442 False False
Methods trials + code pupil 6 Oz 42 0.0131 0.955 1 True True
M-E1, 200 ms after beep 1 Ci 63 0.0926 1.51e-05 3.33e-05 True True
M-E1, 200 ms after beep 1 Oz 42 0.0797 0.000627 0.000172 True True
M-E1, 200 ms after beep 2 Ci 63 0.0455 0.00221 0.0035 True True
M-E1, 200 ms after beep 2 Oz 42 0.12 0.00849 0.0242 True True
M-E1, 200 ms after beep 3 Ci 51 -0.443 7.35e-10 1.59e-14 True True
M-E1, 200 ms after beep 3 Oz 32 -0.335 1.56e-05 1.79e-09 True True
M-E1, 200 ms after beep 4 Ci 63 -0.288 6.83e-11 1.94e-18 True True
M-E1, 200 ms after beep 4 Oz 42 -0.346 5.51e-07 1.69e-10 True True
M-E1, 200 ms after beep 5 Ci 63 0.022 0.779 0.442 True True
M-E1, 200 ms after beep 5 Oz 42 -0.0332 0.371 0.26 True True
M-E1, 200 ms after beep 6 Ci 63 -0.0184 0.13 0.167 False False
M-E1, 200 ms after beep 6 Oz 42 0.0305 0.837 0.707 True True
M-E2, 200 ms after beep 1 Ci 63 0.0926 1.51e-05 3.33e-05 True True
M-E2, 200 ms after beep 1 Oz 42 0.0797 0.000627 0.000172 True True
M-E2, 200 ms after beep 2 Ci 63 0.052 0.00412 0.00898 True True
M-E2, 200 ms after beep 2 Oz 42 0.115 0.0113 0.00853 True True
M-E2, 200 ms after beep 3 Ci 51 -0.353 3.33e-09 2.61e-12 True True
M-E2, 200 ms after beep 3 Oz 32 -0.301 2.04e-06 2.33e-08 True True
M-E2, 200 ms after beep 4 Ci 63 -0.288 6.83e-11 1.94e-18 True True
M-E2, 200 ms after beep 4 Oz 42 -0.346 5.51e-07 1.69e-10 True True
M-E2, 200 ms after beep 5 Ci 63 0.0277 0.789 0.282 True True
M-E2, 200 ms after beep 5 Oz 42 -0.0477 0.449 0.452 True True
M-E2, 200 ms after beep 6 Ci 63 -0.0184 0.13 0.167 False False
M-E2, 200 ms after beep 6 Oz 42 0.0305 0.837 0.707 True True
match match_T2
reading
M-E1 11 11
M-E2 11 10
code 12 12
code trials + E1 11 10
Methods trials + code pupil 11 11
M-E1, 200 ms after beep 11 11
M-E2, 200 ms after beep 11 11
# Why the code reading matches row 6 in Ci: the beep rows (unit x trial) the code's rule keeps and the
# Methods' rule drops, how close their beep is to the end of the trial, and their evoked rates
Bm, Bc, Fc = T["M-E1"][0], T["code"][0], T["code"][1]
km, kc = set(zip(Bm.unit_key, Bm.trial)), set(zip(Bc.unit_key, Bc.trial))
Bc = Bc.assign(post_ms=[POST[s][t] for s, t in zip(Bc.session, Bc.trial)],
code_only=[k in kc - km for k in zip(Bc.unit_key, Bc.trial)])
print(f"beep rows kept by the code's rule only: {len(kc - km)}; by the Methods' rule only: {len(km - kc)}")
x = Bc[Bc.code_only]
print("code-only rows by monkey:", x.groupby("monkey").size().to_dict(),
"; ms from the beep to the end of the trial (min, median, max):", np.percentile(x.post_ms, [0, 50, 100]).round(1))
print("code reading, beep rows with the beep after the end of the trial:", int((Bc.post_ms < 0).sum()),
"(such trials have no evoked pupil, since no pupil is stored past the end)")
print("mean raw evoked rate (sp/s) and baseline-subtracted evoked rate, code reading:")
print(Bc.groupby(["monkey", "code_only"])[["se_raw", "se"]].agg(["mean", "size"]).round(2))
# The code reading without beep trials whose 200 ms evoked rate window runs past the end of the trial
keep = (Bc.post_ms >= L.EVOKED_FR_MS).values
B2, F2 = T["code"][0][keep].copy(), Fc.copy()
L.add_residuals(B2, F2)
print(f"code reading, 200 ms after beep: {keep.sum()} of {len(Bc)} beep rows")
rows6 = []
for lab, (BB, FF) in (("code", (T["code"][0], Fc)), ("code, 200 ms after beep", (B2, F2))):
for base in ("residual", "raw"):
P = L.population_tests(L.figure2_coefficients(BB, FF, baseline=base))
P = P[P.row == 6].assign(reading=lab, baseline=base)
rows6.append(P)
rows6 = pd.concat(rows6)
print(rows6[["reading", "baseline", "monkey", "n", "median", "p_T1"]].to_string(index=False, float_format=lambda v: f"{v:.3g}"))
beep rows kept by the code's rule only: 85; by the Methods' rule only: 16
code-only rows by monkey: {'Cicero': 65, 'Oz': 20} ; ms from the beep to the end of the trial (min, median, max): [ 6.8 55.5 69. ]
code reading, beep rows with the beep after the end of the trial: 0 (such trials have no evoked pupil, since no pupil is stored past the end)
mean raw evoked rate (sp/s) and baseline-subtracted evoked rate, code reading:
se_raw se
mean size mean size
monkey code_only
Cicero False 6.99 2691 1.67 2691
True 3.15 65 -0.32 65
Oz False 5.96 1198 2.77 1198
True 4.75 20 1.43 20
code reading, 200 ms after beep: 3691 of 3974 beep rows
reading baseline monkey n median p_T1
code residual Ci 63 -0.0375 0.0105
code residual Oz 42 0.0327 0.915
code raw Ci 63 -0.0348 0.023
code raw Oz 42 0.038 0.778
code, 200 ms after beep residual Ci 63 -0.0223 0.028
code, 200 ms after beep residual Oz 42 0.0152 0.846
code, 200 ms after beep raw Ci 63 -0.0184 0.123
code, 200 ms after beep raw Oz 42 0.0406 0.886
Result: partially reproduced. With raw baselines, 11 of the 12 cells match the paper's Figure 2 pattern under E1 and under E2; the cell that differs is row 6 in Ci (median -0.006, p = 0.14), which is significant with residuals but not with raw baselines. The code reading matches all 12. The variant without beep trials whose 200 ms evoked window runs past the end of the trial also matches 11 of 12, with the same cell (row 6 in Ci, p = 0.13) differing.
The code reading's 12 of 12 rests on beep trials whose evoked rate is likely biased low. The code's rule keeps 85 beep rows (unit x trial) that the Methods' rule drops. On each, the beep falls 7 to 69 ms before the end of the trial (printed above), so most of the 0 to 200 ms evoked window lies past the end, where spikes are mostly not stored (data check), and their mean raw evoked rate is lower than that of the other rows in both monkeys. Without the beep trials whose 200 ms window runs past the end, the code reading also fails row 6 in Ci with raw baselines (p printed above, not below 0.05), and with residuals (Figure 2) row 6 in Ci stays significant at a larger p than the code's 0.0105. The code-rule trials whose beep falls after the end of the trial enter no table, since they have no evoked pupil.
figs2-llr-pupil-baseline-evoked, figs2-llr-lc-baseline-evoked, figs2-llr-cross-epoch¶
Linear against quadratic fits by maximum likelihood; LLR = 2 x the difference in log-likelihood, counted above 3.841. Per session for evoked pupil on baseline pupil, per unit otherwise. Expected: pupil Oz 7/32, Ci 6/51; LC Oz 2/42, Ci 3/63; evoked pupil on baseline LC Oz 4/42, Ci 4/63; evoked LC on baseline pupil Oz 2/42, Ci 5/63; tolerance one session or unit.
EXPECTED_LLR = {("Oz", "pupil"): 7, ("Ci", "pupil"): 6, ("Oz", "lc"): 2, ("Ci", "lc"): 3,
("Oz", "pupil_on_lc"): 4, ("Ci", "pupil_on_lc"): 4, ("Oz", "lc_on_pupil"): 2, ("Ci", "lc_on_pupil"): 5}
LLR = []
for name, (B, F, C) in T.items():
for rem_name, ru, rs in (("all", (), ()), ("code's removal", REMOVED, REMOVED_SESSIONS)):
x = L.llr_counts(B, ru, rs)
x.insert(0, "units", rem_name)
x.insert(0, "reading", name)
LLR.append(x)
LLR = pd.concat(LLR, ignore_index=True)
LLR["expected"] = [EXPECTED_LLR[(m, c)] for m, c in zip(LLR.monkey, LLR.comparison)]
LLR["within_1"] = (LLR.n_above - LLR.expected).abs() <= 1
LLR["fraction"] = LLR.n_above / LLR.n
print("fits with nothing to fit (too few trials or distinct values):",
int((LLR.n_groups - LLR.n).sum()), "over all readings")
print(LLR[LLR.comparison == "pupil"].drop(columns=["comparison"]).to_string(index=False, float_format=lambda v: f"{v:.3g}"))
fits with nothing to fit (too few trials or distinct values): 0 over all readings
reading units monkey n_above n n_groups max_llr expected within_1 fraction
M-E1 all Oz 6 32 32 12.8 7 True 0.188
M-E1 all Ci 7 51 51 10.5 6 True 0.137
M-E1 code's removal Oz 6 32 32 12.8 7 True 0.188
M-E1 code's removal Ci 7 50 50 10.5 6 True 0.14
M-E2 all Oz 5 32 32 7.9 7 False 0.156
M-E2 all Ci 5 51 51 7.49 6 True 0.098
M-E2 code's removal Oz 5 32 32 7.9 7 False 0.156
M-E2 code's removal Ci 5 50 50 7.49 6 True 0.1
code all Oz 7 32 32 8.79 7 True 0.219
code all Ci 6 51 51 13.8 6 True 0.118
code code's removal Oz 7 32 32 8.79 7 True 0.219
code code's removal Ci 6 50 50 13.8 6 True 0.12
code trials + E1 all Oz 6 32 32 12.8 7 True 0.188
code trials + E1 all Ci 8 51 51 10.5 6 False 0.157
code trials + E1 code's removal Oz 6 32 32 12.8 7 True 0.188
code trials + E1 code's removal Ci 8 50 50 10.5 6 False 0.16
Methods trials + code pupil all Oz 6 32 32 8.04 7 True 0.188
Methods trials + code pupil all Ci 7 51 51 11.8 6 True 0.137
Methods trials + code pupil code's removal Oz 6 32 32 8.04 7 True 0.188
Methods trials + code pupil code's removal Ci 7 50 50 11.8 6 True 0.14
M-E1, 200 ms after beep all Oz 3 32 32 7.93 7 False 0.0938
M-E1, 200 ms after beep all Ci 9 51 51 10.5 6 False 0.176
M-E1, 200 ms after beep code's removal Oz 3 32 32 7.93 7 False 0.0938
M-E1, 200 ms after beep code's removal Ci 9 50 50 10.5 6 False 0.18
M-E2, 200 ms after beep all Oz 2 32 32 7.9 7 False 0.0625
M-E2, 200 ms after beep all Ci 5 51 51 7.49 6 True 0.098
M-E2, 200 ms after beep code's removal Oz 2 32 32 7.9 7 False 0.0625
M-E2, 200 ms after beep code's removal Ci 5 50 50 7.49 6 True 0.1
Result: reproduced. Under E1 over the paper's sessions, 6 of 32 Oz sessions and 7 of 51 Ci sessions exceed 3.841, both within one of the paper's 7 and 6 and both under half; under E2, 5/32 (outside the tolerance) and 5/51. The code reading gives exactly 7/32 and 6/51.
These counts depend on the trial set: leaving out the beep trials whose 200 ms evoked rate window runs past the end of the trial (a variant aimed at the evoked rate, which this comparison does not use) gives 3/32 and 9/51 under E1 and 2/32 and 5/51 under E2, outside the tolerance in at least one monkey. The deciding reading keeps those trials, as the Methods' rule and the code do.
print(LLR[LLR.comparison == "lc"].drop(columns=["comparison"]).to_string(index=False, float_format=lambda v: f"{v:.3g}"))
reading units monkey n_above n n_groups max_llr expected within_1 fraction
M-E1 all Oz 3 42 42 5.75 2 True 0.0714
M-E1 all Ci 4 63 63 20 3 True 0.0635
M-E1 code's removal Oz 3 42 42 5.75 2 True 0.0714
M-E1 code's removal Ci 4 61 61 20 3 True 0.0656
M-E2 all Oz 3 42 42 5.75 2 True 0.0714
M-E2 all Ci 4 63 63 20 3 True 0.0635
M-E2 code's removal Oz 3 42 42 5.75 2 True 0.0714
M-E2 code's removal Ci 4 61 61 20 3 True 0.0656
code all Oz 2 42 42 6.77 2 True 0.0476
code all Ci 3 63 63 10.5 3 True 0.0476
code code's removal Oz 2 42 42 6.77 2 True 0.0476
code code's removal Ci 3 61 61 10.5 3 True 0.0492
code trials + E1 all Oz 3 42 42 5.86 2 True 0.0714
code trials + E1 all Ci 4 63 63 20.2 3 True 0.0635
code trials + E1 code's removal Oz 3 42 42 5.86 2 True 0.0714
code trials + E1 code's removal Ci 4 61 61 20.2 3 True 0.0656
Methods trials + code pupil all Oz 3 42 42 5.75 2 True 0.0714
Methods trials + code pupil all Ci 4 63 63 20 3 True 0.0635
Methods trials + code pupil code's removal Oz 3 42 42 5.75 2 True 0.0714
Methods trials + code pupil code's removal Ci 4 61 61 20 3 True 0.0656
M-E1, 200 ms after beep all Oz 2 42 42 5.75 2 True 0.0476
M-E1, 200 ms after beep all Ci 4 63 63 20 3 True 0.0635
M-E1, 200 ms after beep code's removal Oz 2 42 42 5.75 2 True 0.0476
M-E1, 200 ms after beep code's removal Ci 4 61 61 20 3 True 0.0656
M-E2, 200 ms after beep all Oz 2 42 42 5.75 2 True 0.0476
M-E2, 200 ms after beep all Ci 4 63 63 20 3 True 0.0635
M-E2, 200 ms after beep code's removal Oz 2 42 42 5.75 2 True 0.0476
M-E2, 200 ms after beep code's removal Ci 4 61 61 20 3 True 0.0656
Result: reproduced. Under the Methods' trials, 3 of 42 Oz units and 4 of 63 Ci units exceed 3.841, each within one of the paper's 2 and 3 (4 of 61 with the code's removal). The code reading gives 2/42 and 3/63.
X = LLR[LLR.comparison.isin(["pupil_on_lc", "lc_on_pupil"])]
print(X.drop(columns=["max_llr"]).to_string(index=False, float_format=lambda v: f"{v:.3g}"))
summ = X.groupby(["reading", "units"], sort=False).agg(all_within=("within_1", "all"), max_fraction=("fraction", "max"))
print(summ)
# How close the cross-epoch LLRs lie to the cutoff: units within 3.841 +/- 1, and the counts at 2.841 and 4.841
near = []
for name in ("M-E1", "M-E2", "code"):
B = T[name][0]
for comp in ("pupil_on_lc", "lc_on_pupil"):
x, y = L.LLR_PAIRS[comp]
for m in L.MONKEYS:
v = np.array([L.llr_quadratic(b[x], b[y]) for _, b in B[B.monkey == m].groupby("unit_key")])
near.append(dict(reading=name, comparison=comp, monkey=L.SHORT[m], n=len(v),
n_above=int((v > L.LLR_CRIT).sum()), expected=EXPECTED_LLR[(L.SHORT[m], comp)],
n_above_cut_minus_1=int((v > L.LLR_CRIT - 1).sum()), n_above_cut_plus_1=int((v > L.LLR_CRIT + 1).sum()),
llr_within_1_of_cut=" ".join(f"{a:.2f}" for a in np.sort(v[np.abs(v - L.LLR_CRIT) < 1]))))
print(pd.DataFrame(near).to_string(index=False))
print("units expected above 3.841 by chance at 5%: Oz", round(0.05 * 42, 1), "Ci", round(0.05 * 63, 1))
reading units monkey comparison n_above n n_groups expected within_1 fraction
M-E1 all Oz pupil_on_lc 5 42 42 4 True 0.119
M-E1 all Oz lc_on_pupil 2 42 42 2 True 0.0476
M-E1 all Ci pupil_on_lc 6 63 63 4 False 0.0952
M-E1 all Ci lc_on_pupil 6 63 63 5 True 0.0952
M-E1 code's removal Oz pupil_on_lc 5 42 42 4 True 0.119
M-E1 code's removal Oz lc_on_pupil 2 42 42 2 True 0.0476
M-E1 code's removal Ci pupil_on_lc 6 61 61 4 False 0.0984
M-E1 code's removal Ci lc_on_pupil 6 61 61 5 True 0.0984
M-E2 all Oz pupil_on_lc 6 42 42 4 False 0.143
M-E2 all Oz lc_on_pupil 2 42 42 2 True 0.0476
M-E2 all Ci pupil_on_lc 7 63 63 4 False 0.111
M-E2 all Ci lc_on_pupil 6 63 63 5 True 0.0952
M-E2 code's removal Oz pupil_on_lc 6 42 42 4 False 0.143
M-E2 code's removal Oz lc_on_pupil 2 42 42 2 True 0.0476
M-E2 code's removal Ci pupil_on_lc 7 61 61 4 False 0.115
M-E2 code's removal Ci lc_on_pupil 6 61 61 5 True 0.0984
code all Oz pupil_on_lc 4 42 42 4 True 0.0952
code all Oz lc_on_pupil 2 42 42 2 True 0.0476
code all Ci pupil_on_lc 4 63 63 4 True 0.0635
code all Ci lc_on_pupil 5 63 63 5 True 0.0794
code code's removal Oz pupil_on_lc 4 42 42 4 True 0.0952
code code's removal Oz lc_on_pupil 2 42 42 2 True 0.0476
code code's removal Ci pupil_on_lc 4 61 61 4 True 0.0656
code code's removal Ci lc_on_pupil 5 61 61 5 True 0.082
code trials + E1 all Oz pupil_on_lc 4 42 42 4 True 0.0952
code trials + E1 all Oz lc_on_pupil 2 42 42 2 True 0.0476
code trials + E1 all Ci pupil_on_lc 6 63 63 4 False 0.0952
code trials + E1 all Ci lc_on_pupil 6 63 63 5 True 0.0952
code trials + E1 code's removal Oz pupil_on_lc 4 42 42 4 True 0.0952
code trials + E1 code's removal Oz lc_on_pupil 2 42 42 2 True 0.0476
code trials + E1 code's removal Ci pupil_on_lc 6 61 61 4 False 0.0984
code trials + E1 code's removal Ci lc_on_pupil 6 61 61 5 True 0.0984
Methods trials + code pupil all Oz pupil_on_lc 5 42 42 4 True 0.119
Methods trials + code pupil all Oz lc_on_pupil 2 42 42 2 True 0.0476
Methods trials + code pupil all Ci pupil_on_lc 7 63 63 4 False 0.111
Methods trials + code pupil all Ci lc_on_pupil 6 63 63 5 True 0.0952
Methods trials + code pupil code's removal Oz pupil_on_lc 5 42 42 4 True 0.119
Methods trials + code pupil code's removal Oz lc_on_pupil 2 42 42 2 True 0.0476
Methods trials + code pupil code's removal Ci pupil_on_lc 7 61 61 4 False 0.115
Methods trials + code pupil code's removal Ci lc_on_pupil 6 61 61 5 True 0.0984
M-E1, 200 ms after beep all Oz pupil_on_lc 6 42 42 4 False 0.143
M-E1, 200 ms after beep all Oz lc_on_pupil 2 42 42 2 True 0.0476
M-E1, 200 ms after beep all Ci pupil_on_lc 5 63 63 4 True 0.0794
M-E1, 200 ms after beep all Ci lc_on_pupil 6 63 63 5 True 0.0952
M-E1, 200 ms after beep code's removal Oz pupil_on_lc 6 42 42 4 False 0.143
M-E1, 200 ms after beep code's removal Oz lc_on_pupil 2 42 42 2 True 0.0476
M-E1, 200 ms after beep code's removal Ci pupil_on_lc 5 61 61 4 True 0.082
M-E1, 200 ms after beep code's removal Ci lc_on_pupil 6 61 61 5 True 0.0984
M-E2, 200 ms after beep all Oz pupil_on_lc 8 42 42 4 False 0.19
M-E2, 200 ms after beep all Oz lc_on_pupil 2 42 42 2 True 0.0476
M-E2, 200 ms after beep all Ci pupil_on_lc 7 63 63 4 False 0.111
M-E2, 200 ms after beep all Ci lc_on_pupil 6 63 63 5 True 0.0952
M-E2, 200 ms after beep code's removal Oz pupil_on_lc 8 42 42 4 False 0.19
M-E2, 200 ms after beep code's removal Oz lc_on_pupil 2 42 42 2 True 0.0476
M-E2, 200 ms after beep code's removal Ci pupil_on_lc 7 61 61 4 False 0.115
M-E2, 200 ms after beep code's removal Ci lc_on_pupil 6 61 61 5 True 0.0984
all_within max_fraction
reading units
M-E1 all False 0.119048
code's removal False 0.119048
M-E2 all False 0.142857
code's removal False 0.142857
code all True 0.095238
code's removal True 0.095238
code trials + E1 all False 0.095238
code's removal False 0.098361
Methods trials + code pupil all False 0.119048
code's removal False 0.119048
M-E1, 200 ms after beep all False 0.142857
code's removal False 0.142857
M-E2, 200 ms after beep all False 0.190476
code's removal False 0.190476
reading comparison monkey n n_above expected n_above_cut_minus_1 n_above_cut_plus_1 llr_within_1_of_cut
M-E1 pupil_on_lc Oz 42 5 4 9 4 2.92 3.24 3.54 3.73 4.67
M-E1 pupil_on_lc Ci 63 6 4 9 3 2.88 2.90 3.47 4.54 4.64 4.81
M-E1 lc_on_pupil Oz 42 2 2 2 2
M-E1 lc_on_pupil Ci 63 6 5 9 6 3.03 3.08 3.21
M-E2 pupil_on_lc Oz 42 6 4 6 5 4.49
M-E2 pupil_on_lc Ci 63 7 4 8 5 3.55 4.11 4.54
M-E2 lc_on_pupil Oz 42 2 2 2 2
M-E2 lc_on_pupil Ci 63 6 5 9 6 3.03 3.08 3.21
code pupil_on_lc Oz 42 4 4 4 4
code pupil_on_lc Ci 63 4 4 5 2 2.90 3.88 4.39
code lc_on_pupil Oz 42 2 2 3 2 3.34
code lc_on_pupil Ci 63 5 5 7 5 2.89 3.03
units expected above 3.841 by chance at 5%: Oz 2.1 Ci 3.2
Result: not reproduced. Under no reading the criterion names (E1 or E2, all units or the code's removal) are all four counts within one of the paper's: evoked pupil on baseline LC gives 5/42 (Oz) and 6/63 (Ci) under E1 and 6/42 and 7/63 under E2, against 4/42 and 4/63, and the Oz count is above a tenth of the units under both, so the partial rule does not apply either. Evoked LC on baseline pupil matches (Oz 2/42, Ci 6/63 under both). The code reading gives exactly the paper's 4/42, 4/63, 2/42 and 5/63 (4/61 and 5/61 with its removal). The counts stay small (at most 7 of 63 and 6 of 42 units), so the statement that a linear fit is favoured holds; the claim's counts do not, under the Methods' evoked pupil.
The counts are close to the cutoff (second table, every unit whose LLR lies within one of 3.841). Under E1, a cutoff one higher would give Oz 4 and Ci 3 for evoked pupil on baseline LC, and one lower 9 and 9, so the counts move by one or more with small changes in the fits. With the beep trials whose 200 ms evoked window runs past the end of the trial left out (variant), the evoked pupil on baseline LC counts are 6/42 and 5/63 under E1 and 8/42 and 7/63 under E2, so the outcome is the same. The partial rule's bound (fewer than a tenth of the units) is strict next to the 5% false positive rate of the cutoff, which alone would give about 2.1 of 42 and 3.2 of 63 units; the bound is the claims file's and is applied as written.
fig3-pooled-within-epoch and fig3-pooled-cross-epoch-null¶
Firing rates z-scored per unit over its baseline, raw evoked and fixation-only rates; pupil as stored, which the data check shows to be z-scored per session already, so the main reading and the code's coincide for pupil. Residuals recomputed; Spearman over pooled trials per monkey. Columns:
print(L.FIG3_COLUMNS)
SIGN = {1: 1, 2: 1, 3: -1, 4: -1}
F3 = []
for name, (B, F, C) in T.items():
for grp in ("unit_key", "unit"):
x = L.fig3_pooled(B, F, C, group=grp)
x.insert(0, "zscore", "per unit" if grp == "unit_key" else "code (within-session index)")
x.insert(0, "reading", name)
F3.append(x)
F3 = pd.concat(F3, ignore_index=True)
W = F3[(F3.group == "all") & F3.column.isin([1, 2, 3, 4])].copy()
W["match"] = [(p < 0.05) and np.sign(r) == SIGN[c] for p, r, c in zip(W.p, W.rho, W.column)]
print(W[["reading", "zscore", "monkey", "column", "n", "rho", "p", "match"]].to_string(index=False, float_format=lambda v: f"{v:.3g}"))
print(W.groupby(["reading", "zscore"], sort=False).match.sum())
{1: 'baseline LC residual vs baseline pupil residual (beep + fixation trials)', 2: 'evoked LC vs evoked pupil', 3: 'evoked pupil vs baseline pupil residual (each session trial once)', 4: 'evoked LC vs baseline LC residual', 5: 'baseline LC residual vs evoked pupil', 6: 'evoked LC vs baseline pupil residual'}
reading zscore monkey column n rho p match
M-E1 per unit Oz 1 7249 0.0897 2.05e-14 True
M-E1 per unit Oz 2 1208 0.135 2.71e-06 True
M-E1 per unit Oz 3 914 -0.381 7.23e-33 True
M-E1 per unit Oz 4 1208 -0.222 5.67e-15 True
M-E1 per unit Ci 1 12426 0.0634 1.49e-12 True
M-E1 per unit Ci 2 2697 0.102 9.75e-08 True
M-E1 per unit Ci 3 2159 -0.39 1.99e-79 True
M-E1 per unit Ci 4 2697 -0.177 1.63e-20 True
M-E1 code (within-session index) Oz 1 7249 0.0841 7.2e-13 True
M-E1 code (within-session index) Oz 2 1208 0.12 2.78e-05 True
M-E1 code (within-session index) Oz 3 914 -0.381 7.23e-33 True
M-E1 code (within-session index) Oz 4 1208 -0.234 1.51e-16 True
M-E1 code (within-session index) Ci 1 12426 0.0671 6.97e-14 True
M-E1 code (within-session index) Ci 2 2697 0.0948 8.24e-07 True
M-E1 code (within-session index) Ci 3 2159 -0.39 1.99e-79 True
M-E1 code (within-session index) Ci 4 2697 -0.166 3.9e-18 True
M-E2 per unit Oz 1 7249 0.0897 2.05e-14 True
M-E2 per unit Oz 2 1208 0.122 2.24e-05 True
M-E2 per unit Oz 3 914 -0.389 1.94e-34 True
M-E2 per unit Oz 4 1208 -0.222 5.67e-15 True
M-E2 per unit Ci 1 12426 0.0634 1.49e-12 True
M-E2 per unit Ci 2 2697 0.0855 8.76e-06 True
M-E2 per unit Ci 3 2159 -0.335 7.95e-58 True
M-E2 per unit Ci 4 2697 -0.177 1.63e-20 True
M-E2 code (within-session index) Oz 1 7249 0.0841 7.2e-13 True
M-E2 code (within-session index) Oz 2 1208 0.109 0.000142 True
M-E2 code (within-session index) Oz 3 914 -0.389 1.94e-34 True
M-E2 code (within-session index) Oz 4 1208 -0.234 1.51e-16 True
M-E2 code (within-session index) Ci 1 12426 0.0671 6.97e-14 True
M-E2 code (within-session index) Ci 2 2697 0.0855 8.81e-06 True
M-E2 code (within-session index) Ci 3 2159 -0.335 7.95e-58 True
M-E2 code (within-session index) Ci 4 2697 -0.166 3.9e-18 True
code per unit Oz 1 7259 0.0934 1.57e-15 True
code per unit Oz 2 1218 0.13 5.36e-06 True
code per unit Oz 3 922 -0.381 3.41e-33 True
code per unit Oz 4 1218 -0.231 2.83e-16 True
code per unit Ci 1 12485 0.0634 1.34e-12 True
code per unit Ci 2 2756 0.0832 1.23e-05 True
code per unit Ci 3 2200 -0.324 5.51e-55 True
code per unit Ci 4 2756 -0.18 1.46e-21 True
code code (within-session index) Oz 1 7259 0.088 6e-14 True
code code (within-session index) Oz 2 1218 0.118 3.94e-05 True
code code (within-session index) Oz 3 922 -0.381 3.41e-33 True
code code (within-session index) Oz 4 1218 -0.242 1.15e-17 True
code code (within-session index) Ci 1 12485 0.0669 6.99e-14 True
code code (within-session index) Ci 2 2756 0.0835 1.13e-05 True
code code (within-session index) Ci 3 2200 -0.324 5.51e-55 True
code code (within-session index) Ci 4 2756 -0.169 3.29e-19 True
code trials + E1 per unit Oz 1 7239 0.0925 3.16e-15 True
code trials + E1 per unit Oz 2 1198 0.137 1.85e-06 True
code trials + E1 per unit Oz 3 907 -0.38 1.41e-32 True
code trials + E1 per unit Oz 4 1198 -0.223 5.88e-15 True
code trials + E1 per unit Ci 1 12420 0.063 2.09e-12 True
code trials + E1 per unit Ci 2 2691 0.103 8.94e-08 True
code trials + E1 per unit Ci 3 2153 -0.39 4.06e-79 True
code trials + E1 per unit Ci 4 2691 -0.178 1.17e-20 True
code trials + E1 code (within-session index) Oz 1 7239 0.0872 1.09e-13 True
code trials + E1 code (within-session index) Oz 2 1198 0.122 2.13e-05 True
code trials + E1 code (within-session index) Oz 3 907 -0.38 1.41e-32 True
code trials + E1 code (within-session index) Oz 4 1198 -0.234 2.08e-16 True
code trials + E1 code (within-session index) Ci 1 12420 0.0663 1.4e-13 True
code trials + E1 code (within-session index) Ci 2 2691 0.0953 7.33e-07 True
code trials + E1 code (within-session index) Ci 3 2153 -0.39 4.06e-79 True
code trials + E1 code (within-session index) Ci 4 2691 -0.167 2.7e-18 True
Methods trials + code pupil per unit Oz 1 7249 0.0897 2.05e-14 True
Methods trials + code pupil per unit Oz 2 1208 0.125 1.41e-05 True
Methods trials + code pupil per unit Oz 3 914 -0.381 5.36e-33 True
Methods trials + code pupil per unit Oz 4 1208 -0.222 5.67e-15 True
Methods trials + code pupil per unit Ci 1 12426 0.0634 1.49e-12 True
Methods trials + code pupil per unit Ci 2 2697 0.0781 4.87e-05 True
Methods trials + code pupil per unit Ci 3 2159 -0.328 2.12e-55 True
Methods trials + code pupil per unit Ci 4 2697 -0.177 1.63e-20 True
Methods trials + code pupil code (within-session index) Oz 1 7249 0.0841 7.2e-13 True
Methods trials + code pupil code (within-session index) Oz 2 1208 0.113 8.31e-05 True
Methods trials + code pupil code (within-session index) Oz 3 914 -0.381 5.36e-33 True
Methods trials + code pupil code (within-session index) Oz 4 1208 -0.234 1.51e-16 True
Methods trials + code pupil code (within-session index) Ci 1 12426 0.0671 6.97e-14 True
Methods trials + code pupil code (within-session index) Ci 2 2697 0.0777 5.39e-05 True
Methods trials + code pupil code (within-session index) Ci 3 2159 -0.328 2.12e-55 True
Methods trials + code pupil code (within-session index) Ci 4 2697 -0.166 3.9e-18 True
M-E1, 200 ms after beep per unit Oz 1 7164 0.0896 3e-14 True
M-E1, 200 ms after beep per unit Oz 2 1123 0.125 2.78e-05 True
M-E1, 200 ms after beep per unit Oz 3 839 -0.421 2.42e-37 True
M-E1, 200 ms after beep per unit Oz 4 1123 -0.225 2.64e-14 True
M-E1, 200 ms after beep per unit Ci 1 12313 0.0642 1.01e-12 True
M-E1, 200 ms after beep per unit Ci 2 2584 0.0935 1.95e-06 True
M-E1, 200 ms after beep per unit Ci 3 2063 -0.421 2.06e-89 True
M-E1, 200 ms after beep per unit Ci 4 2584 -0.176 1.8e-19 True
M-E1, 200 ms after beep code (within-session index) Oz 1 7164 0.084 1.1e-12 True
M-E1, 200 ms after beep code (within-session index) Oz 2 1123 0.109 0.000256 True
M-E1, 200 ms after beep code (within-session index) Oz 3 839 -0.421 2.42e-37 True
M-E1, 200 ms after beep code (within-session index) Oz 4 1123 -0.24 4.08e-16 True
M-E1, 200 ms after beep code (within-session index) Ci 1 12313 0.0677 5.53e-14 True
M-E1, 200 ms after beep code (within-session index) Ci 2 2584 0.0802 4.45e-05 True
M-E1, 200 ms after beep code (within-session index) Ci 3 2063 -0.421 2.06e-89 True
M-E1, 200 ms after beep code (within-session index) Ci 4 2584 -0.167 1.15e-17 True
M-E2, 200 ms after beep per unit Oz 1 7164 0.0896 3e-14 True
M-E2, 200 ms after beep per unit Oz 2 1123 0.117 8.18e-05 True
M-E2, 200 ms after beep per unit Oz 3 839 -0.417 1.46e-36 True
M-E2, 200 ms after beep per unit Oz 4 1123 -0.225 2.64e-14 True
M-E2, 200 ms after beep per unit Ci 1 12313 0.0642 1.01e-12 True
M-E2, 200 ms after beep per unit Ci 2 2584 0.0825 2.68e-05 True
M-E2, 200 ms after beep per unit Ci 3 2063 -0.349 5.12e-60 True
M-E2, 200 ms after beep per unit Ci 4 2584 -0.176 1.8e-19 True
M-E2, 200 ms after beep code (within-session index) Oz 1 7164 0.084 1.1e-12 True
M-E2, 200 ms after beep code (within-session index) Oz 2 1123 0.104 0.000499 True
M-E2, 200 ms after beep code (within-session index) Oz 3 839 -0.417 1.46e-36 True
M-E2, 200 ms after beep code (within-session index) Oz 4 1123 -0.24 4.08e-16 True
M-E2, 200 ms after beep code (within-session index) Ci 1 12313 0.0677 5.53e-14 True
M-E2, 200 ms after beep code (within-session index) Ci 2 2584 0.0801 4.58e-05 True
M-E2, 200 ms after beep code (within-session index) Ci 3 2063 -0.349 5.12e-60 True
M-E2, 200 ms after beep code (within-session index) Ci 4 2584 -0.167 1.15e-17 True
reading zscore
M-E1 per unit 8
code (within-session index) 8
M-E2 per unit 8
code (within-session index) 8
code per unit 8
code (within-session index) 8
code trials + E1 per unit 8
code (within-session index) 8
Methods trials + code pupil per unit 8
code (within-session index) 8
M-E1, 200 ms after beep per unit 8
code (within-session index) 8
M-E2, 200 ms after beep per unit 8
code (within-session index) 8
Name: match, dtype: int64
# Variant: raw baselines in place of residuals (the code's plot_S1_combined.m), per-unit z-score
for name in ("M-E1", "M-E2"):
B, F, C = T[name]
Bz, Fz = L.zscore_rates(B, F, "unit_key")
for m in L.MONKEYS:
b, f = Bz[Bz.monkey == m], Fz[Fz.monkey == m]
s = L.session_rows(b)
vals = [L.spearman(np.r_[b.sb, f.sb], np.r_[b.pb, f.pb]), L.spearman(b.se, b.pe), L.spearman(s.pb, s.pe), L.spearman(b.sb, b.se)]
print(name, "raw baselines", L.SHORT[m], [(round(r, 3), float(f"{p:.2g}")) for r, p in vals])
M-E1 raw baselines Oz [(0.024, 0.038), (0.135, 2.7e-06), (-0.331, 7.7e-25), (-0.237, 7.6e-17)] M-E1 raw baselines Ci [(0.005, 0.6), (0.102, 9.7e-08), (-0.382, 5.6e-76), (-0.213, 4.5e-29)]
M-E2 raw baselines Oz [(0.024, 0.038), (0.122, 2.2e-05), (-0.318, 7.4e-23), (-0.237, 7.6e-17)] M-E2 raw baselines Ci [(0.005, 0.6), (0.085, 8.8e-06), (-0.309, 7.8e-49), (-0.213, 4.5e-29)]
Result: reproduced. All four within-epoch columns give p < 0.05 with the sign of the corresponding Figure 2 row in both monkeys, under E1 and E2 (8 of 8 cells each), and under every variant reading and the code's z-scoring. With raw baselines in place of residuals (the code's plot_S1_combined.m, a variant), column 1 is not significant in Ci (rho = 0.005, p = 0.6).
Xn = F3[F3.column.isin([5, 6])].copy()
print(Xn[["reading", "zscore", "monkey", "group", "n_units", "column", "n", "rho", "p"]].to_string(index=False, float_format=lambda v: f"{v:.3g}"))
both = []
for (rd, z, g, c), d in Xn.groupby(["reading", "zscore", "group", "column"], sort=False):
both.append(dict(reading=rd, zscore=z, group=g, column=c,
sig_same_sign_both=bool((d.p < 0.05).all() and len(set(np.sign(d.rho))) == 1),
sig_in=",".join(d.monkey[d.p < 0.05])))
both = pd.DataFrame(both)
print(both.to_string(index=False))
print("cells significant with one sign in both monkeys:", int(both.sig_same_sign_both.sum()), "of", len(both))
reading zscore monkey group n_units column n rho p
M-E1 per unit Oz all 42 5 1208 0.00781 0.786
M-E1 per unit Oz all 42 6 1208 -0.0144 0.617
M-E1 per unit Oz positive 12 5 458 -0.0236 0.614
M-E1 per unit Oz positive 12 6 458 -0.0361 0.441
M-E1 per unit Oz negative 3 5 86 0.148 0.175
M-E1 per unit Oz negative 3 6 86 0.0125 0.909
M-E1 per unit Ci all 63 5 2697 0.0156 0.417
M-E1 per unit Ci all 63 6 2697 -0.0191 0.32
M-E1 per unit Ci positive 17 5 745 -0.0159 0.666
M-E1 per unit Ci positive 17 6 745 0.00595 0.871
M-E1 per unit Ci negative 4 5 217 0.12 0.0771
M-E1 per unit Ci negative 4 6 217 -0.17 0.0121
M-E1 code (within-session index) Oz all 42 5 1208 -0.000934 0.974
M-E1 code (within-session index) Oz all 42 6 1208 -0.0167 0.561
M-E1 code (within-session index) Oz positive 12 5 458 -0.0734 0.117
M-E1 code (within-session index) Oz positive 12 6 458 -0.0557 0.234
M-E1 code (within-session index) Oz negative 3 5 86 0.155 0.154
M-E1 code (within-session index) Oz negative 3 6 86 0.0403 0.713
M-E1 code (within-session index) Ci all 63 5 2697 0.0146 0.449
M-E1 code (within-session index) Ci all 63 6 2697 -0.0197 0.307
M-E1 code (within-session index) Ci positive 17 5 745 -0.0139 0.705
M-E1 code (within-session index) Ci positive 17 6 745 -0.00133 0.971
M-E1 code (within-session index) Ci negative 4 5 217 0.115 0.0897
M-E1 code (within-session index) Ci negative 4 6 217 -0.188 0.00546
M-E2 per unit Oz all 42 5 1208 0.00509 0.86
M-E2 per unit Oz all 42 6 1208 -0.0144 0.617
M-E2 per unit Oz positive 12 5 458 -0.0438 0.349
M-E2 per unit Oz positive 12 6 458 -0.0361 0.441
M-E2 per unit Oz negative 3 5 86 0.14 0.199
M-E2 per unit Oz negative 3 6 86 0.0125 0.909
M-E2 per unit Ci all 63 5 2697 0.00508 0.792
M-E2 per unit Ci all 63 6 2697 -0.0191 0.32
M-E2 per unit Ci positive 17 5 745 -0.043 0.241
M-E2 per unit Ci positive 17 6 745 0.00595 0.871
M-E2 per unit Ci negative 4 5 217 0.0591 0.386
M-E2 per unit Ci negative 4 6 217 -0.17 0.0121
M-E2 code (within-session index) Oz all 42 5 1208 -0.00991 0.731
M-E2 code (within-session index) Oz all 42 6 1208 -0.0167 0.561
M-E2 code (within-session index) Oz positive 12 5 458 -0.098 0.036
M-E2 code (within-session index) Oz positive 12 6 458 -0.0557 0.234
M-E2 code (within-session index) Oz negative 3 5 86 0.145 0.183
M-E2 code (within-session index) Oz negative 3 6 86 0.0403 0.713
M-E2 code (within-session index) Ci all 63 5 2697 0.00138 0.943
M-E2 code (within-session index) Ci all 63 6 2697 -0.0197 0.307
M-E2 code (within-session index) Ci positive 17 5 745 -0.0454 0.216
M-E2 code (within-session index) Ci positive 17 6 745 -0.00133 0.971
M-E2 code (within-session index) Ci negative 4 5 217 0.0585 0.391
M-E2 code (within-session index) Ci negative 4 6 217 -0.188 0.00546
code per unit Oz all 42 5 1218 -0.00344 0.904
code per unit Oz all 42 6 1218 -0.0243 0.397
code per unit Oz positive 13 5 501 -0.0328 0.464
code per unit Oz positive 13 6 501 -0.0468 0.296
code per unit Oz negative 3 5 86 0.109 0.316
code per unit Oz negative 3 6 86 0.00203 0.985
code per unit Ci all 63 5 2756 0.00184 0.923
code per unit Ci all 63 6 2756 -0.0179 0.348
code per unit Ci positive 18 5 791 -0.0588 0.0984
code per unit Ci positive 18 6 791 0.000282 0.994
code per unit Ci negative 4 5 218 0.0259 0.704
code per unit Ci negative 4 6 218 -0.16 0.0179
code code (within-session index) Oz all 42 5 1218 -0.0177 0.538
code code (within-session index) Oz all 42 6 1218 -0.0259 0.366
code code (within-session index) Oz positive 13 5 501 -0.0807 0.0711
code code (within-session index) Oz positive 13 6 501 -0.0594 0.184
code code (within-session index) Oz negative 3 5 86 0.11 0.315
code code (within-session index) Oz negative 3 6 86 0.0319 0.771
code code (within-session index) Ci all 63 5 2756 -0.00204 0.915
code code (within-session index) Ci all 63 6 2756 -0.0193 0.312
code code (within-session index) Ci positive 18 5 791 -0.0608 0.0874
code code (within-session index) Ci positive 18 6 791 -0.00483 0.892
code code (within-session index) Ci negative 4 5 218 0.0268 0.694
code code (within-session index) Ci negative 4 6 218 -0.179 0.00806
code trials + E1 per unit Oz all 42 5 1198 -0.00086 0.976
code trials + E1 per unit Oz all 42 6 1198 -0.0144 0.619
code trials + E1 per unit Oz positive 13 5 497 -0.0224 0.619
code trials + E1 per unit Oz positive 13 6 497 -0.0414 0.358
code trials + E1 per unit Oz negative 3 5 84 0.109 0.323
code trials + E1 per unit Oz negative 3 6 84 0.0319 0.774
code trials + E1 per unit Ci all 63 5 2691 0.0134 0.486
code trials + E1 per unit Ci all 63 6 2691 -0.0192 0.319
code trials + E1 per unit Ci positive 17 5 743 -0.0195 0.595
code trials + E1 per unit Ci positive 17 6 743 0.0046 0.9
code trials + E1 per unit Ci negative 4 5 213 0.107 0.121
code trials + E1 per unit Ci negative 4 6 213 -0.167 0.0144
code trials + E1 code (within-session index) Oz all 42 5 1198 -0.0102 0.725
code trials + E1 code (within-session index) Oz all 42 6 1198 -0.0163 0.573
code trials + E1 code (within-session index) Oz positive 13 5 497 -0.0698 0.12
code trials + E1 code (within-session index) Oz positive 13 6 497 -0.0537 0.232
code trials + E1 code (within-session index) Oz negative 3 5 84 0.114 0.304
code trials + E1 code (within-session index) Oz negative 3 6 84 0.0581 0.6
code trials + E1 code (within-session index) Ci all 63 5 2691 0.0121 0.531
code trials + E1 code (within-session index) Ci all 63 6 2691 -0.0197 0.308
code trials + E1 code (within-session index) Ci positive 17 5 743 -0.0169 0.646
code trials + E1 code (within-session index) Ci positive 17 6 743 -0.00329 0.929
code trials + E1 code (within-session index) Ci negative 4 5 213 0.0986 0.151
code trials + E1 code (within-session index) Ci negative 4 6 213 -0.184 0.00715
Methods trials + code pupil per unit Oz all 42 5 1208 0.00551 0.848
Methods trials + code pupil per unit Oz all 42 6 1208 -0.0144 0.617
Methods trials + code pupil per unit Oz positive 12 5 458 -0.036 0.442
Methods trials + code pupil per unit Oz positive 12 6 458 -0.0361 0.441
Methods trials + code pupil per unit Oz negative 3 5 86 0.141 0.195
Methods trials + code pupil per unit Oz negative 3 6 86 0.0125 0.909
Methods trials + code pupil per unit Ci all 63 5 2697 0.0058 0.763
Methods trials + code pupil per unit Ci all 63 6 2697 -0.0191 0.32
Methods trials + code pupil per unit Ci positive 17 5 745 -0.061 0.096
Methods trials + code pupil per unit Ci positive 17 6 745 0.00595 0.871
Methods trials + code pupil per unit Ci negative 4 5 217 0.0442 0.517
Methods trials + code pupil per unit Ci negative 4 6 217 -0.17 0.0121
Methods trials + code pupil code (within-session index) Oz all 42 5 1208 -0.00862 0.765
Methods trials + code pupil code (within-session index) Oz all 42 6 1208 -0.0167 0.561
Methods trials + code pupil code (within-session index) Oz positive 12 5 458 -0.0876 0.0609
Methods trials + code pupil code (within-session index) Oz positive 12 6 458 -0.0557 0.234
Methods trials + code pupil code (within-session index) Oz negative 3 5 86 0.145 0.183
Methods trials + code pupil code (within-session index) Oz negative 3 6 86 0.0403 0.713
Methods trials + code pupil code (within-session index) Ci all 63 5 2697 0.0018 0.926
Methods trials + code pupil code (within-session index) Ci all 63 6 2697 -0.0197 0.307
Methods trials + code pupil code (within-session index) Ci positive 17 5 745 -0.0652 0.0753
Methods trials + code pupil code (within-session index) Ci positive 17 6 745 -0.00133 0.971
Methods trials + code pupil code (within-session index) Ci negative 4 5 217 0.0476 0.485
Methods trials + code pupil code (within-session index) Ci negative 4 6 217 -0.188 0.00546
M-E1, 200 ms after beep per unit Oz all 42 5 1123 -0.00103 0.972
M-E1, 200 ms after beep per unit Oz all 42 6 1123 -0.0142 0.635
M-E1, 200 ms after beep per unit Oz positive 13 5 447 -0.0324 0.495
M-E1, 200 ms after beep per unit Oz positive 13 6 447 -0.0327 0.49
M-E1, 200 ms after beep per unit Oz negative 3 5 80 0.101 0.374
M-E1, 200 ms after beep per unit Oz negative 3 6 80 -0.0322 0.777
M-E1, 200 ms after beep per unit Ci all 63 5 2584 0.0136 0.49
M-E1, 200 ms after beep per unit Ci all 63 6 2584 -0.0194 0.323
M-E1, 200 ms after beep per unit Ci positive 17 5 707 -0.0285 0.45
M-E1, 200 ms after beep per unit Ci positive 17 6 707 0.0124 0.741
M-E1, 200 ms after beep per unit Ci negative 4 5 205 0.106 0.131
M-E1, 200 ms after beep per unit Ci negative 4 6 205 -0.179 0.0101
M-E1, 200 ms after beep code (within-session index) Oz all 42 5 1123 -0.0133 0.656
M-E1, 200 ms after beep code (within-session index) Oz all 42 6 1123 -0.0194 0.515
M-E1, 200 ms after beep code (within-session index) Oz positive 13 5 447 -0.0928 0.05
M-E1, 200 ms after beep code (within-session index) Oz positive 13 6 447 -0.0468 0.323
M-E1, 200 ms after beep code (within-session index) Oz negative 3 5 80 0.103 0.361
M-E1, 200 ms after beep code (within-session index) Oz negative 3 6 80 -0.00366 0.974
M-E1, 200 ms after beep code (within-session index) Ci all 63 5 2584 0.0125 0.527
M-E1, 200 ms after beep code (within-session index) Ci all 63 6 2584 -0.0212 0.282
M-E1, 200 ms after beep code (within-session index) Ci positive 17 5 707 -0.0245 0.515
M-E1, 200 ms after beep code (within-session index) Ci positive 17 6 707 0.00189 0.96
M-E1, 200 ms after beep code (within-session index) Ci negative 4 5 205 0.0996 0.155
M-E1, 200 ms after beep code (within-session index) Ci negative 4 6 205 -0.197 0.00456
M-E2, 200 ms after beep per unit Oz all 42 5 1123 -0.00113 0.97
M-E2, 200 ms after beep per unit Oz all 42 6 1123 -0.0142 0.635
M-E2, 200 ms after beep per unit Oz positive 13 5 447 -0.0396 0.403
M-E2, 200 ms after beep per unit Oz positive 13 6 447 -0.0327 0.49
M-E2, 200 ms after beep per unit Oz negative 3 5 80 0.105 0.355
M-E2, 200 ms after beep per unit Oz negative 3 6 80 -0.0322 0.777
M-E2, 200 ms after beep per unit Ci all 63 5 2584 0.00474 0.81
M-E2, 200 ms after beep per unit Ci all 63 6 2584 -0.0194 0.323
M-E2, 200 ms after beep per unit Ci positive 17 5 707 -0.0426 0.258
M-E2, 200 ms after beep per unit Ci positive 17 6 707 0.0124 0.741
M-E2, 200 ms after beep per unit Ci negative 4 5 205 0.0517 0.461
M-E2, 200 ms after beep per unit Ci negative 4 6 205 -0.179 0.0101
M-E2, 200 ms after beep code (within-session index) Oz all 42 5 1123 -0.0181 0.544
M-E2, 200 ms after beep code (within-session index) Oz all 42 6 1123 -0.0194 0.515
M-E2, 200 ms after beep code (within-session index) Oz positive 13 5 447 -0.101 0.0334
M-E2, 200 ms after beep code (within-session index) Oz positive 13 6 447 -0.0468 0.323
M-E2, 200 ms after beep code (within-session index) Oz negative 3 5 80 0.106 0.349
M-E2, 200 ms after beep code (within-session index) Oz negative 3 6 80 -0.00366 0.974
M-E2, 200 ms after beep code (within-session index) Ci all 63 5 2584 0.000973 0.961
M-E2, 200 ms after beep code (within-session index) Ci all 63 6 2584 -0.0212 0.282
M-E2, 200 ms after beep code (within-session index) Ci positive 17 5 707 -0.0447 0.235
M-E2, 200 ms after beep code (within-session index) Ci positive 17 6 707 0.00189 0.96
M-E2, 200 ms after beep code (within-session index) Ci negative 4 5 205 0.0513 0.465
M-E2, 200 ms after beep code (within-session index) Ci negative 4 6 205 -0.197 0.00456
reading zscore group column sig_same_sign_both sig_in
M-E1 per unit all 5 False
M-E1 per unit all 6 False
M-E1 per unit positive 5 False
M-E1 per unit positive 6 False
M-E1 per unit negative 5 False
M-E1 per unit negative 6 False Ci
M-E1 code (within-session index) all 5 False
M-E1 code (within-session index) all 6 False
M-E1 code (within-session index) positive 5 False
M-E1 code (within-session index) positive 6 False
M-E1 code (within-session index) negative 5 False
M-E1 code (within-session index) negative 6 False Ci
M-E2 per unit all 5 False
M-E2 per unit all 6 False
M-E2 per unit positive 5 False
M-E2 per unit positive 6 False
M-E2 per unit negative 5 False
M-E2 per unit negative 6 False Ci
M-E2 code (within-session index) all 5 False
M-E2 code (within-session index) all 6 False
M-E2 code (within-session index) positive 5 False Oz
M-E2 code (within-session index) positive 6 False
M-E2 code (within-session index) negative 5 False
M-E2 code (within-session index) negative 6 False Ci
code per unit all 5 False
code per unit all 6 False
code per unit positive 5 False
code per unit positive 6 False
code per unit negative 5 False
code per unit negative 6 False Ci
code code (within-session index) all 5 False
code code (within-session index) all 6 False
code code (within-session index) positive 5 False
code code (within-session index) positive 6 False
code code (within-session index) negative 5 False
code code (within-session index) negative 6 False Ci
code trials + E1 per unit all 5 False
code trials + E1 per unit all 6 False
code trials + E1 per unit positive 5 False
code trials + E1 per unit positive 6 False
code trials + E1 per unit negative 5 False
code trials + E1 per unit negative 6 False Ci
code trials + E1 code (within-session index) all 5 False
code trials + E1 code (within-session index) all 6 False
code trials + E1 code (within-session index) positive 5 False
code trials + E1 code (within-session index) positive 6 False
code trials + E1 code (within-session index) negative 5 False
code trials + E1 code (within-session index) negative 6 False Ci
Methods trials + code pupil per unit all 5 False
Methods trials + code pupil per unit all 6 False
Methods trials + code pupil per unit positive 5 False
Methods trials + code pupil per unit positive 6 False
Methods trials + code pupil per unit negative 5 False
Methods trials + code pupil per unit negative 6 False Ci
Methods trials + code pupil code (within-session index) all 5 False
Methods trials + code pupil code (within-session index) all 6 False
Methods trials + code pupil code (within-session index) positive 5 False
Methods trials + code pupil code (within-session index) positive 6 False
Methods trials + code pupil code (within-session index) negative 5 False
Methods trials + code pupil code (within-session index) negative 6 False Ci
M-E1, 200 ms after beep per unit all 5 False
M-E1, 200 ms after beep per unit all 6 False
M-E1, 200 ms after beep per unit positive 5 False
M-E1, 200 ms after beep per unit positive 6 False
M-E1, 200 ms after beep per unit negative 5 False
M-E1, 200 ms after beep per unit negative 6 False Ci
M-E1, 200 ms after beep code (within-session index) all 5 False
M-E1, 200 ms after beep code (within-session index) all 6 False
M-E1, 200 ms after beep code (within-session index) positive 5 False Oz
M-E1, 200 ms after beep code (within-session index) positive 6 False
M-E1, 200 ms after beep code (within-session index) negative 5 False
M-E1, 200 ms after beep code (within-session index) negative 6 False Ci
M-E2, 200 ms after beep per unit all 5 False
M-E2, 200 ms after beep per unit all 6 False
M-E2, 200 ms after beep per unit positive 5 False
M-E2, 200 ms after beep per unit positive 6 False
M-E2, 200 ms after beep per unit negative 5 False
M-E2, 200 ms after beep per unit negative 6 False Ci
M-E2, 200 ms after beep code (within-session index) all 5 False
M-E2, 200 ms after beep code (within-session index) all 6 False
M-E2, 200 ms after beep code (within-session index) positive 5 False Oz
M-E2, 200 ms after beep code (within-session index) positive 6 False
M-E2, 200 ms after beep code (within-session index) negative 5 False
M-E2, 200 ms after beep code (within-session index) negative 6 False Ci
cells significant with one sign in both monkeys: 0 of 84
# The code's legacy rows 43 and 65, and whether either unit is in a row 1 group under each reading
for name in ("M-E1", "M-E2", "code"):
B, F, C = T[name]
k = L.unit_order(B)
r1 = C[C.row == 1].set_index("unit_key")
x = k[k.legacy_row.isin([43, 65])].copy()
x["r_row1"] = r1.loc[x.unit_key, "r"].values
x["p_row1"] = r1.loc[x.unit_key, "p"].values
x["group"] = np.where(x.p_row1 < 0.05, np.where(x.r_row1 > 0, "positive", "negative"), "none")
print(name)
print(x[["legacy_row", "monkey", "session", "unit", "r_row1", "p_row1", "group"]].to_string(index=False, float_format=lambda v: f"{v:.3g}"))
# Groups formed after the code's removal of the two units (as the code forms them)
G = []
for name in ("M-E1", "M-E2", "code"):
B, F, C = T[name]
x = L.fig3_pooled(B[~B.unit_key.isin(REMOVED)], F[~F.unit_key.isin(REMOVED)], C[~C.unit_key.isin(REMOVED)])
G.append(x[x.group != "all"].assign(reading=name + ", code's removal"))
G = pd.concat(G, ignore_index=True)
print(G[["reading", "monkey", "group", "n_units", "column", "n", "rho", "p"]].to_string(index=False, float_format=lambda v: f"{v:.3g}"))
# Variant: pupil z-scored again per session over all stored samples before the measures are pooled
ZP = {s["session"]: (np.nanmean(s["pupil"]), np.nanstd(s["pupil"])) for s in sessions}
Z2 = []
for name in ("M-E1", "M-E2"):
B, F, C = T[name]
B, F = B.copy(), F.copy()
for D in (B, F):
D["pb"] = (D.pb - D.session.map(lambda s: ZP[s][0])) / D.session.map(lambda s: ZP[s][1])
B["pe"] = B.pe / B.session.map(lambda s: ZP[s][1])
L.add_residuals(B, F)
Z2.append(L.fig3_pooled(B, F, C).assign(reading=name + ", pupil z-scored again"))
Z2 = pd.concat(Z2, ignore_index=True)
print(Z2[["reading", "monkey", "group", "column", "rho", "p"]].to_string(index=False, float_format=lambda v: f"{v:.3g}"))
for d, lab in ((G, "groups after the code's removal"), (Z2, "pupil z-scored again")):
d = d[d.column.isin([5, 6])]
nb_ = sum(bool((g.p < 0.05).all() and len(set(np.sign(g.rho))) == 1)
for _, g in d.groupby(["reading", "group", "column"]))
print(lab, "| cells significant with one sign in both monkeys:", nb_)
M-E1
legacy_row monkey session unit r_row1 p_row1 group
43 Cicero CiCM101019d 1 0.114 0.199 none
65 Cicero Ci_LC_d14_6mm_SC_123107 2 0.0723 0.398 none
M-E2
legacy_row monkey session unit r_row1 p_row1 group
43 Cicero CiCM101019d 1 0.114 0.199 none
65 Cicero Ci_LC_d14_6mm_SC_123107 2 0.0723 0.398 none
code
legacy_row monkey session unit r_row1 p_row1 group
43 Cicero CiCM101019d 1 0.128 0.149 none
65 Cicero Ci_LC_d14_6mm_SC_123107 2 0.0689 0.42 none
reading monkey group n_units column n rho p M-E1, code's removal Oz positive 12 5 458 -0.0236 0.614 M-E1, code's removal Oz positive 12 6 458 -0.0361 0.441 M-E1, code's removal Oz negative 3 5 86 0.148 0.175 M-E1, code's removal Oz negative 3 6 86 0.0125 0.909 M-E1, code's removal Ci positive 17 5 745 -0.0159 0.666 M-E1, code's removal Ci positive 17 6 745 0.00595 0.871 M-E1, code's removal Ci negative 4 5 217 0.12 0.0771 M-E1, code's removal Ci negative 4 6 217 -0.17 0.0121 M-E2, code's removal Oz positive 12 5 458 -0.0438 0.349 M-E2, code's removal Oz positive 12 6 458 -0.0361 0.441 M-E2, code's removal Oz negative 3 5 86 0.14 0.199 M-E2, code's removal Oz negative 3 6 86 0.0125 0.909 M-E2, code's removal Ci positive 17 5 745 -0.043 0.241 M-E2, code's removal Ci positive 17 6 745 0.00595 0.871 M-E2, code's removal Ci negative 4 5 217 0.0591 0.386 M-E2, code's removal Ci negative 4 6 217 -0.17 0.0121 code, code's removal Oz positive 13 5 501 -0.0328 0.464 code, code's removal Oz positive 13 6 501 -0.0468 0.296 code, code's removal Oz negative 3 5 86 0.109 0.316 code, code's removal Oz negative 3 6 86 0.00203 0.985 code, code's removal Ci positive 18 5 791 -0.0588 0.0984 code, code's removal Ci positive 18 6 791 0.000282 0.994 code, code's removal Ci negative 4 5 218 0.0259 0.704 code, code's removal Ci negative 4 6 218 -0.16 0.0179
reading monkey group column rho p M-E1, pupil z-scored again Oz all 1 0.0898 1.86e-14 M-E1, pupil z-scored again Oz all 2 0.136 2.03e-06 M-E1, pupil z-scored again Oz all 3 -0.384 1.48e-33 M-E1, pupil z-scored again Oz all 4 -0.222 5.67e-15 M-E1, pupil z-scored again Oz all 5 0.00755 0.793 M-E1, pupil z-scored again Oz all 6 -0.015 0.603 M-E1, pupil z-scored again Oz positive 5 -0.0278 0.552 M-E1, pupil z-scored again Oz positive 6 -0.0382 0.415 M-E1, pupil z-scored again Oz negative 5 0.153 0.159 M-E1, pupil z-scored again Oz negative 6 0.012 0.912 M-E1, pupil z-scored again Ci all 1 0.0634 1.57e-12 M-E1, pupil z-scored again Ci all 2 0.102 1.27e-07 M-E1, pupil z-scored again Ci all 3 -0.388 1.08e-78 M-E1, pupil z-scored again Ci all 4 -0.177 1.63e-20 M-E1, pupil z-scored again Ci all 5 0.0166 0.39 M-E1, pupil z-scored again Ci all 6 -0.0194 0.314 M-E1, pupil z-scored again Ci positive 5 -0.0142 0.698 M-E1, pupil z-scored again Ci positive 6 0.00508 0.89 M-E1, pupil z-scored again Ci negative 5 0.12 0.0783 M-E1, pupil z-scored again Ci negative 6 -0.169 0.0126 M-E2, pupil z-scored again Oz all 1 0.0898 1.86e-14 M-E2, pupil z-scored again Oz all 2 0.123 1.9e-05 M-E2, pupil z-scored again Oz all 3 -0.393 3.32e-35 M-E2, pupil z-scored again Oz all 4 -0.222 5.67e-15 M-E2, pupil z-scored again Oz all 5 0.00418 0.885 M-E2, pupil z-scored again Oz all 6 -0.015 0.603 M-E2, pupil z-scored again Oz positive 5 -0.0478 0.307 M-E2, pupil z-scored again Oz positive 6 -0.0382 0.415 M-E2, pupil z-scored again Oz negative 5 0.148 0.174 M-E2, pupil z-scored again Oz negative 6 0.012 0.912 M-E2, pupil z-scored again Ci all 1 0.0634 1.57e-12 M-E2, pupil z-scored again Ci all 2 0.0845 1.12e-05 M-E2, pupil z-scored again Ci all 3 -0.334 1.4e-57 M-E2, pupil z-scored again Ci all 4 -0.177 1.63e-20 M-E2, pupil z-scored again Ci all 5 0.00587 0.761 M-E2, pupil z-scored again Ci all 6 -0.0194 0.314 M-E2, pupil z-scored again Ci positive 5 -0.042 0.253 M-E2, pupil z-scored again Ci positive 6 0.00508 0.89 M-E2, pupil z-scored again Ci negative 5 0.0591 0.386 M-E2, pupil z-scored again Ci negative 6 -0.169 0.0126 groups after the code's removal | cells significant with one sign in both monkeys: 0 pupil z-scored again | cells significant with one sign in both monkeys: 0
Result: reproduced. No cross-epoch column, in all units or in either group, is significant with the same sign in both monkeys, under any reading. Ci's negative group (4 units) shows a significant negative relation of evoked LC with baseline pupil (rho about -0.17, p about 0.01), not found in Oz's 3 units.
Neither unit the code removes as rows 43 and 65 is in a row 1 group under any reading (their row 1 p is 0.15 to 0.42), so the groups are the same whether they are formed from all 63 Ci units or from the code's 61, and the group results above are unchanged. Z-scoring the stored pupil again per session (a variant) changes the pooled coefficients by at most about 0.01 and no conclusion.
Summary¶
| Claim | Outcome |
|---|---|
| include-list-link (link) | reproduced |
| data-units-sessions | reproduced |
| fig2-row1-baseline-lc-pupil | reproduced |
| fig2-row2-evoked-lc-pupil | reproduced |
| fig2-row3-pupil-evoked-vs-baseline | reproduced |
| fig2-row4-lc-evoked-vs-baseline | reproduced |
| fig2-row5-baseline-lc-vs-evoked-pupil | reproduced |
| fig2-row6-baseline-pupil-vs-evoked-lc | reproduced |
| cross-epoch-no-reliable-relation | reproduced |
| range-baseline-pupil-evoked-lc | reproduced |
| range-baseline-lc-evoked-pupil | not reproduced |
| figs1-raw-baselines-similar | partially reproduced |
| figs2-llr-pupil-baseline-evoked | reproduced |
| figs2-llr-lc-baseline-evoked | reproduced |
| figs2-llr-cross-epoch | not reproduced |
| fig3-pooled-within-epoch | reproduced |
| fig3-pooled-cross-epoch-null | reproduced |
A failure to reproduce here may be a failure of this attempt, not of the paper: see the reasoning and the differences from the paper's method.
How the analysis differs from the paper's. The deciding readings follow the Methods where they and the code differ (trial rule, the fixation-only window for the baseline rate, and the evoked pupil window), as the claims file directs; the code's pipeline is run as a variant and reproduces the code's printed output. The three claims that do not reproduce in full each pass only under the code's full reading, and no single difference explains all three. For the Oz range effect and the cross-epoch LLR counts, neither mixture of the two methods gives the paper's numbers: they need both the code's trial rule and its evoked pupil (0 to 800 ms after the beep, in place of the beep to 20 ms before the end of fixation). For the raw-baseline comparison, the cell that differs (row 6 in Ci, evoked LC against baseline pupil) does not use the evoked pupil; it passes only under the code's full reading, whose trial rule keeps 85 beep rows with the beep 7 to 69 ms before the end of the trial, where the 200 ms evoked rate is counted mostly past the end; without such trials the code reading fails it too.
Two assumptions underlie the outcomes. The trial start is taken as fixation onset for every window, as in the code; the files hold no fixation marker, and spikes are stored from before the start (data check), so what the start marks is not known. The stored pupil is taken as already preprocessed (z-scored per session), which the data check is consistent with; the Figure 3 claims pool pupil across sessions and so rest on it (pupil z-scored again changes them little). The paper's units and sessions cannot be told apart from the code's by the archive (63 and 51 for Ci in the paper, 61 and 50 in the code's output), and row 6 in Ci is fragile on this point.
What was found about the dataset. It holds exactly the paper's 83 sessions and 105 units, the
same as the code's include lists, with no duplicated recordings. The pupil trace appears to be
stored already preprocessed (z-scored, mean trace removed, smoothed) without saying so; its unit is
"a.u.". Spike times are stored against artificial trial anchors 100 s apart, with about 40% of them in the
few seconds before a trial's start and almost none after its end, and the real time of each
trial is only in trial_time_index, whose unit is not stated (milliseconds by its range). What event
the trial start marks is not stated, and beep times run from about 1 to 2.8 s after it, against
the Methods' 1 to 1.5 s of fixation; a few beeps fall before the trial start or after its end, and
some fixation-only trials last under 1 s against the Methods' 1 to 5 s. The session
Cicero_022714_d18_402_FixnStim is named for stimulation but has no stimulation marker. The
code's z-scoring for Figure 3 groups units by within-session index (its printed Figure 3 values
are matched this way), and it removes two units twice.