Reproducing Ray, Moaddab & McDannald (2022) from CRCNS nac-1¶
Paper. Ray MH, Moaddab M, McDannald MA (2022). Threat and bidirectional valence signaling in the nucleus accumbens core. J Neurosci 42(5):817-833. doi:10.1523/JNEUROSCI.1107-21.2021. The claims file was written from the version of record (Introduction, Methods, Results, legends and Discussion); the Extended Data figures were not available.
Data set. CRCNS nac-1, doi:10.6080/K0M906VB, read from the
public bucket at https://crcnsarchive.s3-us-west-2.amazonaws.com/nac-1/live/data.zip, streamed
with range requests. CRCNS data sets are not versioned, so the version is recorded as
unversioned, and the file read is pinned by its MD5 in the data set's checksums.md5:
data.zip ab13407080360d7d683ef818ae66f33a (33,243,283 bytes, last modified 2026-02-11). There is
no other version to choose from: the bucket holds only live/ for nac-1 (no old/), and the
data description is version 0.6 (Feb 9, 2022), its initial version.
What the data set holds. One MATLAB file per unit for the 368 units (spike times, mean
waveform, and the session's event channels: cues, shocks, pellets, nose pokes), a precomputed
cube.mat that the authors' script builds from those files, and the authors' MATLAB scripts
(cubeScriptPR25.m and NAccAnalysis/*.m). It holds no pre-surgery behavior sessions and no
population (cluster) labels.
The authors' scripts. The paper links no analysis code (its lab page returns 404). The scripts in the data set are the authors' code, and this notebook takes from them the details the Methods and the claims file leave open, citing them. They give the event channel map, which the data description lacks.
Every random draw uses a generator seeded for its own claim section.
| Claim | Data | Status |
|---|---|---|
| units-recorded | data set | tested |
| cue-responsive-193 | data set | tested |
| fig1c-acquisition | data set | blocked: the pre-surgery sessions are not in the data set |
| fig1g-discrimination, fig1h-poke-rate-unrelated, fig1h-discrimination-safety | data set | tested |
| fig2-five-clusters, populations-by-rat, most-units-threat | data set | tested |
| fig3ab-rate-cv-unimodal, fig3c-waveform-bimodal | data set | tested |
| fig4ab, fig4b, fig4cd, fig4ef, fig4f, fig5ab, fig5cd (cue firing by population) | data set | tested |
| fig6-similarity-anova, fig6d, fig6e, fig6f, fig6-thi-greatest-similarity | data set | tested |
| fig7-tuning-curves, fig8ab, fig8cd, fig8ef | data set | tested |
| fig9a, fig9bcd, fig9efg, fig9hij (reward) | data set | tested |
| fig10a, fig10bcd, fig10efg (nose poke cessation) | data set | tested |
import collections
import time
import warnings
import numpy as np
import pandas as pd
from scipy import stats
import nac
pd.set_option("display.width", 220)
pd.set_option("display.max_columns", 40)
pd.set_option("display.max_rows", 300)
warnings.filterwarnings("ignore", category=RuntimeWarning)
started = time.time()
U = nac.load_units()
CUBE = nac.load_cube()
print(f"loaded {len(U)} unit files from {nac.URL} in {time.time() - started:.0f} s")
loaded 368 unit files from https://crcnsarchive.s3-us-west-2.amazonaws.com/nac-1/live/data.zip in 56 s
Data check¶
The loader assigns the cue channels to danger, uncertainty and safety by the program letter in
the file name, as cubeScriptPR25.m does, and splits uncertainty trials into shock and omission
by a shock within 30 s of onset. The first check compares what the loader computes from the raw
files with the authors' cube.mat: trial onsets and types, the binned firing, and the
suppression ratios.
cube_names = ["".join(CUBE.name[0][j][i] for j in range(22)) for i in range(len(CUBE.name[0][0]))]
cube_index = {n: i for i, n in enumerate(cube_names)}
raw250 = CUBE.fire[0, 0].raw[0, 0].ms250[0, 0].interval
cer = CUBE.cer[0, 0].cue
n_tag = n_raw = n_sr = 0
for u in U:
i = cube_index[u["filename"] + u["neuron"]]
n_tag += np.allclose(CUBE.tag[:, 1, i], u["onsets"]) and np.array_equal(CUBE.tag[:, 0, i], nac.TRIAL_TYPES + 1)
n_raw += np.array_equal(np.floor(nac.binned_rates(u["spikes"], u["onsets"])), raw250[:, :, i].astype(float))
n_sr += np.allclose(nac.suppression(u, "one")[0], cer[:, 0, i])
print(f"units in cube.mat: {len(cube_names)}; matched by name: {sum(u['filename'] + u['neuron'] in cube_index for u in U)}")
print(f"trial onsets and types equal to cube.tag: {n_tag} of {len(U)}")
print(f"floored 250-ms rates equal to cube.fire.raw.ms250: {n_raw} of {len(U)}")
print(f"suppression ratios (0/0 set to 1, as the script does) equal to cube.cer.cue: {n_sr} of {len(U)}")
print()
print("trials per type (danger, unc shock, unc omission, safety):", collections.Counter(u["n_type"] for u in U))
print("event channels:", collections.Counter(tuple(u["channels"]) for u in U))
print("programs:", dict(collections.Counter(u["program"] for u in U)))
units in cube.mat: 368; matched by name: 368
trial onsets and types equal to cube.tag: 368 of 368
floored 250-ms rates equal to cube.fire.raw.ms250: 368 of 368
suppression ratios (0/0 set to 1, as the script does) equal to cube.cer.cue: 368 of 368
trials per type (danger, unc shock, unc omission, safety): Counter({(4, 2, 6, 4): 368})
event channels: Counter({('EVT01', 'EVT02', 'EVT08', 'EVT09', 'EVT10', 'EVT12', 'EVT13', 'EVT14'): 218, ('EVT01', 'EVT02', 'EVT08', 'EVT09', 'EVT11', 'EVT12', 'EVT13', 'EVT14'): 150})
programs: {'d': 143, 'a': 68, 'e': 75, 'b': 82}
units = pd.DataFrame([dict(rat=u["rat"], session=u["session"], program=u["program"], n_spikes=len(u["spikes"]),
duration=u["spikes"][-1] - u["spikes"][0], rate=len(u["spikes"]) / (u["spikes"][-1] - u["spikes"][0]),
first_onset=u["onsets"].min(), last_onset=u["onsets"].max(), n_poke=len(u["poke"]),
n_pellet=len(u["pellet"]), n_shock=len(u["shock"])) for u in U])
print("units, sessions (rat and date) and programs per rat:")
print(units.groupby("rat").agg(units=("session", "size"), sessions=("session", "nunique"),
programs=("program", lambda x: "".join(sorted(set(x))))))
print(f"total: {len(units)} units, {units.session.nunique()} sessions, {units.rat.nunique()} rats")
print()
print(units[["n_spikes", "duration", "rate", "n_poke", "n_pellet", "n_shock"]].describe().round(2))
iti = np.concatenate([np.diff(np.sort(u["onsets"])) for u in {u["session"]: u for u in U}.values()])
print(f"\ninter-trial onset intervals: median {np.median(iti):.0f} s, range {iti.min():.0f} to {iti.max():.0f} s (paper: mean ITI 3.5 min)")
sh = []
for u in {u["session"]: u for u in U}.values():
for t in u["onsets"][nac.TRIAL_TYPES <= 1]:
d = u["shock"][(u["shock"] > t)] - t
sh.append(d.min() if len(d) else np.nan)
sh = np.array(sh)
print(f"shock after onset on danger and uncertainty-shock trials: {np.nanmin(sh):.2f} to {np.nanmax(sh):.2f} s (paper: 2 s after the 10-s cue, so 12 s)")
print(f"shocks per session: {collections.Counter(len(u['shock']) for u in {u['session']: u for u in U}.values())} (design: 6; EVT01)")
pb = CUBE.poke[0, 0].base
m20 = m2 = 0
for u in U:
i = cube_index[u["filename"] + u["neuron"]]
m20 += np.array_equal(nac.count_in(u["poke"], u["onsets"] - 20, u["onsets"]) * 3, pb[:, 0, i].astype(int))
m2 += np.array_equal(nac.count_in(u["poke"], u["onsets"] - 2, u["onsets"]) * 30, pb[:, 0, i].astype(int))
print(f"cube.poke.base equals the 20-s pre-cue poke rate (pokes/min) in {m20} units, the 2-s rate in {m2} (description: '2 s prior')")
w = np.array([u["wave"] for u in U])
print(f"waveforms: {w.shape[1]} points (description: 32 points over 0.8 ms), values {w.min():.2e} to {w.max():.2e} (units not given)")
units, sessions (rat and date) and programs per rat:
units sessions programs
rat
ac01 143 17 d
ac03 45 17 a
ac04 23 10 a
ac05 75 17 e
ac06 58 16 b
ac07 10 7 b
ac08 14 6 b
total: 368 units, 90 sessions, 7 rats
n_spikes duration rate n_poke n_pellet n_shock
count 368.00 368.00 368.00 368.00 368.00 368.0
mean 9295.19 3550.12 2.62 159.81 12.92 6.0
std 8708.04 19.82 2.45 67.15 3.12 0.0
min 111.00 3507.56 0.03 12.00 4.00 6.0
25% 3000.75 3531.05 0.85 108.00 11.00 6.0
50% 6497.50 3550.89 1.83 161.00 13.00 6.0
75% 13363.50 3569.82 3.76 199.50 15.00 6.0
max 40667.00 3581.17 11.51 325.00 21.00 6.0
inter-trial onset intervals: median 233 s, range 203 to 265 s (paper: mean ITI 3.5 min)
shock after onset on danger and uncertainty-shock trials: 12.00 to 12.02 s (paper: 2 s after the 10-s cue, so 12 s)
shocks per session: Counter({6: 90}) (design: 6; EVT01)
cube.poke.base equals the 20-s pre-cue poke rate (pokes/min) in 368 units, the 2-s rate in 0 (description: '2 s prior')
waveforms: 32 points (description: 32 points over 0.8 ms), values -2.36e-01 to 3.42e-01 (units not given)
What the checks show. The loader reproduces the authors' cube exactly (trial onsets and types,
binned firing, suppression ratios) for all 368 units, so the event channel map taken from the
script is the one the authors used. Every session has 4, 2, 6 and 4 trials of the four types
and 6 shocks, 12 s after onset, as the Methods describe. Onsets are 203 to 265 s apart
(median 233 s), consistent with a mean ITI of 3.5 min plus the trial. The data description says
the cube's poke.base is the rate 2 s before the cue; the values are the 20-s rate (a
description error, recorded as a finding).
Coverage. The files hold spikes, pokes and pellets only from 20 s before each onset to about 33 s after it: the recording is paused between trials. The data description does not say so.
Duplicates and clocks. A recording deposited twice would show identical spike trains; units of one session must share one set of event times. The clock check uses contrasts that only hold if the event times and the spikes and pokes share a clock: the suppression of poking to danger against safety, and the fraction of units whose firing changes at cue onset, each at the true onsets and at onsets moved 10 s earlier. The shifted onsets must fall in recorded time: 10 s earlier is the only shift that keeps a 10-s baseline and a 10-s pseudo-cue inside the recorded segment and away from the cue.
sig = collections.defaultdict(list)
for u in U:
sig[(len(u["spikes"]), round(float(u["spikes"].sum()), 4))].append(u["file"])
print("units with identical spike trains:", [v for v in sig.values() if len(v) > 1])
by_session = collections.defaultdict(list)
for u in U:
by_session[u["session"]].append(u)
print("sessions whose units disagree on event times:",
[s for s, v in by_session.items() if len({(round(float(x["onsets"].sum()), 4), len(x["poke"]), len(x["pellet"])) for x in v}) > 1])
ev_sets = collections.defaultdict(set)
for s, v in by_session.items():
ev_sets[(round(float(v[0]["onsets"].sum()), 4), len(v[0]["poke"]))].add(s)
print("event sets shared by two sessions:", [x for x in ev_sets.values() if len(x) > 1])
same_name = collections.Counter((u["session"], u["neuron"]) for u in U)
print("session and unit name used twice:", [k for k, c in same_name.items() if c > 1])
cover = []
for u in U:
on = np.sort(u["onsets"])
for name in ("spikes", "poke", "pellet"):
x = u[name]
if len(x):
rel = x - on[np.clip(np.searchsorted(on, x + 20, side="right") - 1, 0, 15)]
cover.append((name, rel.min(), rel.max()))
cover = pd.DataFrame(cover, columns=["stream", "min_rel", "max_rel"]).groupby("stream").agg(["min", "max"])
print("time of every spike, poke and pellet relative to the trial onset before it (s):")
print(cover.round(2))
gaps = np.concatenate([np.diff(u["spikes"]) for u in U])
print(f"inter-spike intervals longer than 100 s: {np.sum(gaps > 100)} (the recording is paused between trials, EVT14)")
def shifted(u, dt):
v = dict(u)
v["onsets"] = u["onsets"] + dt
return v
sr = []
for v in by_session.values():
s, _ = nac.suppression(v[0], "drop")
sr.append([np.nanmean(s[nac.CUE_OF_TRIAL == 0]), np.nanmean(s[nac.CUE_OF_TRIAL == 2])])
sr = np.array(sr)
print(f"suppression ratio at the true onsets: danger {np.nanmean(sr[:, 0]):.3f}, safety {np.nanmean(sr[:, 1]):.3f}, "
f"sessions with danger above safety {np.mean(sr[:, 0] > sr[:, 1]):.3f}")
# a pseudo-trial must lie inside the recorded segment and away from the cue: onsets 10 s earlier
# give a 10-s baseline 20 to 10 s before and a 'cue' in the 10 s before the true onset
pk = []
for v in by_session.values():
u = v[0]
for dt in (0, -10):
on = u["onsets"] + dt
b = nac.count_in(u["poke"], on - 10, on) / 10
c = nac.count_in(u["poke"], on, on + 10) / 10
pk.append(dict(shift_s=dt, danger_cue_minus_base=np.mean((c - b)[nac.CUE_OF_TRIAL == 0]),
safety_cue_minus_base=np.mean((c - b)[nac.CUE_OF_TRIAL == 2])))
pk = pd.DataFrame(pk).groupby("shift_s").mean()
pk["units_with_cue_response"] = [np.mean([nac.screen(shifted(u, dt), "pooled")[0] for u in U]) for dt in pk.index]
print("poke rate (per s) in the 10-s cue minus the 10 s before, mean over sessions, and the share of units passing")
print("screen reading (a), at the true onsets and 10 s earlier:")
print(pk.round(3).to_string())
units with identical spike trains: []
sessions whose units disagree on event times: []
event sets shared by two sessions: []
session and unit name used twice: []
time of every spike, poke and pellet relative to the trial onset before it (s):
min_rel max_rel
min max min max
stream
pellet -19.98 -4.05 -1.74 33.51
poke -19.98 -17.75 30.12 33.54
spikes -20.00 -18.80 31.42 202.53
inter-spike intervals longer than 100 s: 5519 (the recording is paused between trials, EVT14)
suppression ratio at the true onsets: danger 0.952, safety 0.240, sessions with danger above safety 0.878
poke rate (per s) in the 10-s cue minus the 10 s before, mean over sessions, and the share of units passing
screen reading (a), at the true onsets and 10 s earlier:
danger_cue_minus_base safety_cue_minus_base units_with_cue_response
shift_s
-10 -0.004 -0.000 0.258
0 -0.212 -0.038 0.595
The lines of the authors' scripts this notebook relies on, printed from the data set: the ITI reward and cessation windows, the 0/0 suppression ratio handling, the event baselines (columns 1 to 4 of 16, 2 to 1 s before the event) and the bootstrap call.
z_scripts = nac.open_zip()
def show_lines(path, ranges):
lines = z_scripts.read(path).decode("latin-1").splitlines()
print(f"--- {path}")
for a, b in ranges:
for n in range(a, b + 1):
print(f"{n:5d} {lines[n - 1]}")
print(" ...")
# the ITI windows and cessation rule, the 0/0 handling, the event baselines, the screen and the bootstrap
show_lines("data/cubeScriptPR25.m", [(149, 161), (176, 188), (254, 254), (557, 560), (672, 675)])
show_lines("data/NAccAnalysis/mainAnalysis.m", [(393, 393), (2054, 2054), (3134, 3134)])
--- data/cubeScriptPR25.m
149
150 window.start = time.cue(iii,2) - 18;
151 window.stop = time.cue(iii,2) - 2;
152 window.start2 = time.cue(iii,2) + 14;
153 window.stop2 = time.cue(iii,2) + 28;
154
155 start = time.pellet(time.pellet>=window.start); %start iti window
156 stop = time.pellet(time.pellet<=window.stop); % stop iti window
157 aaa = intersect(start,stop); % all pokes in window
158 start2 = time.pellet(time.pellet>=window.start2); %start iti window
159 stop2 = time.pellet(time.pellet<=window.stop2); % stop iti window
160 aaa2 = intersect(start2,stop2); % all pokes in window
161 time.itiPellet = [time.itiPellet; aaa; aaa2];
...
176 for iii = 1:length(time.cue)
177
178 window.start = time.cue(iii,2) - 18;
179 window.stop = time.cue(iii,2) - 2;
180
181 start = time.poke(time.poke>=window.start); %start iti window
182 stop = time.poke(time.poke<=window.stop); % stop iti window
183 a = intersect(start,stop); % all pokes in window
184 b = a(1:end-1,1);
185 c = a(2:end,1);
186 d = c-b;
187 e = b(d>2);
188 time.itiPokeCess = [time.itiPokeCess; e];
...
254 cer.cue(isnan(cer.cue))=1; % replace NaN with 1
...
557 fire.diff.s1.pellet = bsxfun(@minus,fire.raw.s1.pellet,fire.raw.s1.pellet(:,1));
558 fire.diff.ms500.pellet = bsxfun(@minus,fire.raw.ms500.pellet,mean(fire.raw.ms500.pellet(:,1:2),2));
559 fire.diff.ms250.pellet = bsxfun(@minus,fire.raw.ms250.pellet,mean(fire.raw.ms250.pellet(:,1:4),2));
560 fire.diff.ms100.pellet = bsxfun(@minus,fire.raw.ms100.pellet,mean(fire.raw.ms100.pellet(:,1:10),2));
...
672 fire.diff.s1.itiPokeCess = bsxfun(@minus,fire.raw.s1.itiPokeCess,fire.raw.s1.itiPokeCess(:,1));
673 fire.diff.ms500.itiPokeCess = bsxfun(@minus,fire.raw.ms500.itiPokeCess,mean(fire.raw.ms500.itiPokeCess(:,1:2),2));
674 fire.diff.ms250.itiPokeCess = bsxfun(@minus,fire.raw.ms250.itiPokeCess,mean(fire.raw.ms250.itiPokeCess(:,1:4),2));
675 fire.diff.ms100.itiPokeCess = bsxfun(@minus,fire.raw.ms100.itiPokeCess,mean(fire.raw.ms100.itiPokeCess(:,1:10),2));
...
--- data/NAccAnalysis/mainAnalysis.m
393 cueR.cer.cue(isnan(cueR.cer.cue))=1;
...
2054 [cueR.cerIndcue100cuePRboot(2:3,1),bootstat] = bootci(1000,{@mean,a},'type','student');
...
3134 [cueR.k2.fire.z.ms250.onsetcue100cuePRboot(2:3,1),bootstat] = bootci(1000,{@mean,diff1},'type','student');
...
units-recorded¶
368 NAcc single units were recorded from seven rats over 95 fear discrimination sessions.
A session is a rat and a date (the file name acRRMMDDYY...); each date has one behavior
program per rat. The authors' mainAnalysis.m counts sessions as distinct rows of
suppression ratios, which is shown as a variant.
n_units = len(U)
n_sessions = len({u["session"] for u in U})
n_rats = len({u["rat"] for u in U})
n_files = len({u["filename"] for u in U})
sr_rows = len({tuple(np.round(nac.suppression(u, "one")[0], 8)) for u in U})
print(f"units {n_units} (paper 368), sessions {n_sessions} (paper 95), rats {n_rats} (paper 7)")
print(f"distinct rat, date and program: {n_files}; distinct rows of 16 suppression ratios (mainAnalysis.m's count): {sr_rows}")
print("sessions per rat:", dict(sorted(collections.Counter(s[:4] for s in {u["session"] for u in U}).items())))
units 368 (paper 368), sessions 90 (paper 95), rats 7 (paper 7)
distinct rat, date and program: 90; distinct rows of 16 suppression ratios (mainAnalysis.m's count): 84
sessions per rat: {'ac01': 17, 'ac03': 17, 'ac04': 10, 'ac05': 17, 'ac06': 16, 'ac07': 7, 'ac08': 6}
Result: not reproduced. The data set holds 368 units from 7 rats, as the paper says, but from 90 distinct sessions (rat and date), not 95; counting distinct rows of suppression ratios, as the authors' script does, gives 84. The criterion's tolerance is zero for each count and it names no partial outcome, so the session count decides it.
cue-responsive-193¶
The cue-responsive screen identified 193 units (about 53% of all units) from 82 sessions, with at least seven cue-responsive units in each rat.
Readings of the criterion: (a) the eight uncertainty trials tested as one cue; (b) shock and
omission trials as two cues. Rates in Hz over the 10-s baseline and the first 1 s and last 5 s
of each cue, paired two-tailed t-tests at p < 0.05. The authors' cubeScriptPR25.m floors each
rate to an integer before mainAnalysis.m runs the same paired tests (ttest, pooled
uncertainty rows 5 to 12); that is shown as a variant. A test with no variance in the
differences gives no p-value and does not count, as MATLAB's ttest returns NaN.
screens = {}
for label, unc, fl in (("(a) uncertainty pooled", "pooled", False), ("(b) shock and omission split", "split", False),
("script: pooled, floored rates", "pooled", True), ("script floor, split", "split", True)):
screens[label] = np.array([nac.screen(u, unc, fl)[0] for u in U])
rows = []
for label, r in screens.items():
per_rat = collections.Counter(u["rat"] for u, x in zip(U, r) if x)
rows.append(dict(reading=label, responsive=int(r.sum()), share=r.mean(), sessions=len({u["session"] for u, x in zip(U, r) if x}),
min_per_rat=min(per_rat.values()), per_rat=dict(sorted(per_rat.items())),
within_tolerance=abs(r.sum() - 193) <= 19.3 and abs(len({u["session"] for u, x in zip(U, r) if x}) - 82) <= 8.2 and min(per_rat.values()) >= 7))
print(pd.DataFrame(rows).round(3).to_string(index=False))
print("expected: 193 +- 19.3 units, 82 +- 8.2 sessions, at least 7 per rat")
print("null reference: onsets moved 10 s earlier, so that the baseline is 20 to 10 s and the 'cue' the 10 s")
print("before the real onset, all inside the recorded segment and before any cue:")
for label, unc, fl in (("(a) uncertainty pooled", "pooled", False), ("(b) shock and omission split", "split", False),
("script: pooled, floored rates", "pooled", True)):
fp = np.array([nac.screen(shifted(u, -10), unc, fl)[0] for u in U])
print(f" {label}: {fp.sum()} of {len(fp)} units pass ({fp.mean():.3f}); at the true onsets {screens[label].mean():.3f}")
reading responsive share sessions min_per_rat per_rat within_tolerance
(a) uncertainty pooled 219 0.595 82 6 {'ac01': 79, 'ac03': 35, 'ac04': 9, 'ac05': 47, 'ac06': 32, 'ac07': 6, 'ac08': 11} False
(b) shock and omission split 211 0.573 81 7 {'ac01': 83, 'ac03': 33, 'ac04': 10, 'ac05': 39, 'ac06': 30, 'ac07': 9, 'ac08': 7} True
script: pooled, floored rates 193 0.524 82 7 {'ac01': 61, 'ac03': 28, 'ac04': 8, 'ac05': 49, 'ac06': 30, 'ac07': 7, 'ac08': 10} True
script floor, split 176 0.478 81 7 {'ac01': 59, 'ac03': 26, 'ac04': 10, 'ac05': 40, 'ac06': 26, 'ac07': 8, 'ac08': 7} True
expected: 193 +- 19.3 units, 82 +- 8.2 sessions, at least 7 per rat
null reference: onsets moved 10 s earlier, so that the baseline is 20 to 10 s and the 'cue' the 10 s
before the real onset, all inside the recorded segment and before any cue:
(a) uncertainty pooled: 95 of 368 units pass (0.258); at the true onsets 0.595
(b) shock and omission split: 107 of 368 units pass (0.291); at the true onsets 0.573
script: pooled, floored rates: 79 of 368 units pass (0.215); at the true onsets 0.524
Result: reproduced. Under reading (b) the screen finds 211 units from 81 sessions, with at least 7 per rat, all within tolerance; under reading (a) it finds 219 units, above the tolerance of 193 +- 19.3, from 82 sessions. The authors' own procedure (floored rates, pooled uncertainty) finds exactly 193 units from 82 sessions, with at least 7 per rat.
With onsets moved 10 s earlier, inside the recorded segment and before any cue, 25.8% of units pass reading (a), 29.1% reading (b) and 21.5% the script's screen, against 59.5%, 57.3% and 52.4% at the true onsets; six uncorrected tests at 0.05 would pass about 26% of units by chance. The paper states no chance level.
The later claims need the paper's 193 units. They use the set of the authors' procedure
(mainAnalysis.m: rates floored to whole Hz as cubeScriptPR25.m stores them, uncertainty
pooled), which gives the paper's 193 units and 82 sessions exactly. This is an assumption: it
is neither reading of the claims file, and the Methods say "mean firing rate (Hz)" and do not
mention flooring. The units of reading (b) (211) give other populations (shown under
fig2-five-clusters for reading (a)).
responsive = screens["script: pooled, floored rates"]
R = [u for u, r in zip(U, responsive) if r]
print(f"cue-responsive units used below: {len(R)} from {len({u['session'] for u in R})} sessions")
cue-responsive units used below: 193 from 82 sessions
fig1c-acquisition¶
Over the eight pre-surgery sessions rats acquired discrimination ...
The data set's files are listed below: there is one file per recorded unit, from the
recording sessions only. The pre-surgery sessions are not in it. The authors'
preRecordingBehavior.m reads them from a folder (AC Group Data) that is not part of the
data set.
z = nac.open_zip()
folders = collections.Counter(n.rsplit("/", 1)[0] for n in z.namelist() if not n.endswith("/"))
print("files per folder in data.zip:", dict(folders))
print("non-unit files:", [n for n in z.namelist() if not n.startswith("data/matFiles/") and not n.endswith("/")])
dates = sorted({u["date"] for u in U})
print(f"session dates: {len(dates)} distinct, from {dates[0]} to {dates[-1]} (MMDDYY)")
files per folder in data.zip: {'data': 4, 'data/matFiles': 368, 'data/NAccAnalysis': 8, 'data/cubeFile': 1}
non-unit files: ['data/cue3.wav', 'data/cue2.wav', 'data/cue1.wav', 'data/NAccAnalysis/pokeCessation.m', 'data/NAccAnalysis/probability_1.m', 'data/NAccAnalysis/halfDuration.m', 'data/NAccAnalysis/preRecordingBehavior.m', 'data/NAccAnalysis/probability_2.m', 'data/NAccAnalysis/mainAnalysis.m', 'data/NAccAnalysis/cvBaseline.m', 'data/NAccAnalysis/suppressionRatio.m', 'data/cubeFile/cube.mat', 'data/cubeScriptPR25.m']
session dates: 18 distinct, from 070719 to 072419 (MMDDYY)
Result: blocked (data missing). No file holds the eight pre-surgery sessions.
Behavior per rat (fig1g, fig1h)¶
Per session, the mean suppression ratio of each cue over its trials (uncertainty pooled), and
the mean baseline poke rate (pokes per min, 20 s before onset). Per rat, the mean over the
chosen sessions (the authors' mainAnalysis.m averages the session rows of each rat). Session
readings of fig1g: (a) the 82 sessions with a cue-responsive unit; (b) all sessions (90 here);
(c) the sessions of the three main populations (computed after the clustering, below). Readings
of a 0/0 suppression ratio from the claims file: left out, or 0; the authors' scripts set it to
1 (variant).
def behavior(sessions, nan_reading):
per_rat = collections.defaultdict(list)
for s in sorted(sessions):
u = by_session[s][0]
sr, base = nac.suppression(u, nan_reading)
per_rat[u["rat"]].append([np.nanmean(sr[nac.CUE_OF_TRIAL == k]) for k in range(3)] + [base.mean()])
rats = sorted(per_rat)
return pd.DataFrame([np.mean(per_rat[r], 0) for r in rats], index=rats,
columns=["danger", "uncertainty", "safety", "baseline_pokes_per_min"])
def fig1g(beh, rng, mirrored=None):
F = nac.rm_anova1(beh[["danger", "uncertainty", "safety"]].to_numpy())
d = {"D-U": beh.danger - beh.uncertainty, "U-S": beh.uncertainty - beh.safety, "D-S": beh.danger - beh.safety}
out = dict(F=F[0], df=f"{F[1]},{F[2]}", p=F[3])
for k, x in d.items():
m, lo, hi = nac.boot_ci(x.to_numpy(), rng, mirrored=mirrored)
out[k] = m
out[k + " CI"] = f"[{lo:.2f}, {hi:.2f}]"
out[k + " excl0"] = lo > 0 or hi < 0
return out
def fig1g_seeds(beh, seeds=range(1001, 1051), mirrored=None):
"""Median CI bounds over 50 seeds: with seven rats a bound near zero moves with the seed."""
out = {}
d = {"D-U": beh.danger - beh.uncertainty, "U-S": beh.uncertainty - beh.safety, "D-S": beh.danger - beh.safety}
for k, x in d.items():
b = np.array([nac.boot_ci(x.to_numpy(), np.random.default_rng(s), mirrored=mirrored)[1:] for s in seeds])
lo, hi = np.median(b, 0)
out[k + " median CI"] = f"[{lo:.3f}, {hi:.3f}]"
out[k + " excl0 (median)"] = lo > 0 or hi < 0
out[k + " excl0 share"] = np.mean((b[:, 0] > 0) | (b[:, 1] < 0))
return out
session_sets = {"(a) 82 with a cue-responsive unit": {u["session"] for u in R}, "(b) all": set(by_session)}
nan_readings = {"drop": "drop", "0": "zero", "1 (script)": "one"}
fig1g-discrimination¶
During the recording sessions all rats discriminated the cues, with suppression ratios highest to danger, intermediate to uncertainty and lowest to safety; every cue pair differed.
rows = []
for sl, S in session_sets.items():
for nl, nr in nan_readings.items():
beh = behavior(S, nr)
o = fig1g(beh, np.random.default_rng(1001))
o.update(fig1g_seeds(beh))
rows.append(dict(sessions=sl, zero_over_zero=nl, n_sessions=len(S), **o))
fig1g_table = pd.DataFrame(rows)
print(fig1g_table[["sessions", "zero_over_zero", "n_sessions", "F", "df", "p", "D-U", "U-S", "D-S"]].round(3).to_string(index=False))
print()
print(fig1g_table[["sessions", "zero_over_zero"] + [c for c in fig1g_table if "median" in c or "share" in c]].round(2).to_string(index=False))
print("seed 1001, does each CI exclude zero (standard interval):")
print(fig1g_table[["sessions", "zero_over_zero", "D-U CI", "D-U excl0", "U-S CI", "U-S excl0", "D-S CI", "D-S excl0"]].to_string(index=False))
print()
rows = []
for sl, S in session_sets.items():
for nl, nr in nan_readings.items():
o = fig1g_seeds(behavior(S, nr), mirrored=True)
rows.append(dict(sessions=sl, zero_over_zero=nl, **o))
print("the same 50 seeds with the non-reflected interval (the form that matches the paper's printed CIs):")
print(pd.DataFrame(rows).round(2).to_string(index=False))
print()
print("expected means: D-U 0.21 +- 0.05, U-S 0.47 +- 0.12, D-S 0.69 +- 0.19; paper F(2,12) = 57.41, CIs [0.16, 0.29], [0.35, 1.03], [0.50, 1.25]")
print()
beh_82 = behavior(session_sets["(a) 82 with a cue-responsive unit"], "one")
print("per rat, 82 sessions, 0/0 = 1 (the script's handling):")
print(beh_82.round(3))
print()
print("the same per-rat differences with the bootstrap-t quantiles added without reflection (variant):")
for seed in (1, 2, 3):
o = fig1g(beh_82, np.random.default_rng(seed), mirrored=True)
print(f" seed {seed}: D-U {o['D-U CI']}, U-S {o['U-S CI']}, D-S {o['D-S CI']}")
print("and with the standard studentized interval, over seeds:")
for seed in (1, 2, 3):
o = fig1g(beh_82, np.random.default_rng(seed))
print(f" seed {seed}: D-U {o['D-U CI']}, U-S {o['U-S CI']}, D-S {o['D-S CI']}")
sessions zero_over_zero n_sessions F df p D-U U-S D-S
(a) 82 with a cue-responsive unit drop 82 56.327 2,12 0.0 0.216 0.471 0.688
(a) 82 with a cue-responsive unit 0 82 53.781 2,12 0.0 0.201 0.466 0.667
(a) 82 with a cue-responsive unit 1 (script) 82 57.405 2,12 0.0 0.214 0.472 0.686
(b) all drop 90 53.729 2,12 0.0 0.220 0.476 0.696
(b) all 0 90 52.556 2,12 0.0 0.206 0.466 0.672
(b) all 1 (script) 90 54.486 2,12 0.0 0.217 0.477 0.694
sessions zero_over_zero D-U median CI D-U excl0 (median) D-U excl0 share U-S median CI U-S excl0 (median) U-S excl0 share D-S median CI D-S excl0 (median) D-S excl0 share
(a) 82 with a cue-responsive unit drop [0.134, 0.273] True 1.0 [-0.169, 0.597] False 0.00 [0.119, 0.855] True 1.0
(a) 82 with a cue-responsive unit 0 [0.127, 0.253] True 1.0 [-0.046, 0.596] False 0.10 [0.191, 0.833] True 1.0
(a) 82 with a cue-responsive unit 1 (script) [0.138, 0.272] True 1.0 [-0.125, 0.595] False 0.00 [0.165, 0.851] True 1.0
(b) all drop [0.123, 0.292] True 1.0 [-0.124, 0.608] False 0.00 [0.195, 0.870] True 1.0
(b) all 0 [0.112, 0.265] True 1.0 [0.012, 0.599] True 0.68 [0.207, 0.836] True 1.0
(b) all 1 (script) [0.129, 0.292] True 1.0 [-0.084, 0.607] False 0.00 [0.221, 0.870] True 1.0
seed 1001, does each CI exclude zero (standard interval):
sessions zero_over_zero D-U CI D-U excl0 U-S CI U-S excl0 D-S CI D-S excl0
(a) 82 with a cue-responsive unit drop [0.14, 0.28] True [-0.14, 0.60] False [0.09, 0.84] True
(a) 82 with a cue-responsive unit 0 [0.13, 0.26] True [-0.02, 0.60] False [0.17, 0.82] True
(a) 82 with a cue-responsive unit 1 (script) [0.14, 0.27] True [-0.10, 0.59] False [0.14, 0.84] True
(b) all drop [0.12, 0.30] True [-0.12, 0.60] False [0.14, 0.86] True
(b) all 0 [0.12, 0.27] True [0.04, 0.59] True [0.19, 0.83] True
(b) all 1 (script) [0.13, 0.30] True [-0.06, 0.60] False [0.18, 0.86] True
the same 50 seeds with the non-reflected interval (the form that matches the paper's printed CIs):
sessions zero_over_zero D-U median CI D-U excl0 (median) D-U excl0 share U-S median CI U-S excl0 (median) U-S excl0 share D-S median CI D-S excl0 (median) D-S excl0 share
(a) 82 with a cue-responsive unit drop [0.160, 0.299] True 1.0 [0.346, 1.111] True 1.0 [0.520, 1.257] True 1.0
(a) 82 with a cue-responsive unit 0 [0.150, 0.276] True 1.0 [0.336, 0.979] True 1.0 [0.501, 1.143] True 1.0
(a) 82 with a cue-responsive unit 1 (script) [0.156, 0.290] True 1.0 [0.348, 1.069] True 1.0 [0.520, 1.206] True 1.0
(b) all drop [0.147, 0.317] True 1.0 [0.345, 1.077] True 1.0 [0.523, 1.198] True 1.0
(b) all 0 [0.148, 0.301] True 1.0 [0.332, 0.919] True 1.0 [0.508, 1.137] True 1.0
(b) all 1 (script) [0.142, 0.306] True 1.0 [0.347, 1.038] True 1.0 [0.519, 1.168] True 1.0
expected means: D-U 0.21 +- 0.05, U-S 0.47 +- 0.12, D-S 0.69 +- 0.19; paper F(2,12) = 57.41, CIs [0.16, 0.29], [0.35, 1.03], [0.50, 1.25]
per rat, 82 sessions, 0/0 = 1 (the script's handling):
danger uncertainty safety baseline_pokes_per_min
ac01 0.935 0.707 0.561 14.614
ac03 0.961 0.633 0.058 15.785
ac04 0.961 0.778 0.235 18.938
ac05 0.967 0.732 0.205 13.477
ac06 0.988 0.736 0.128 7.768
ac07 1.000 0.922 0.640 17.009
ac08 0.843 0.649 0.029 13.469
the same per-rat differences with the bootstrap-t quantiles added without reflection (variant):
seed 1: D-U [0.16, 0.28], U-S [0.36, 1.03], D-S [0.52, 1.18]
seed 2: D-U [0.16, 0.29], U-S [0.35, 1.07], D-S [0.52, 1.22]
seed 3: D-U [0.16, 0.28], U-S [0.34, 1.10], D-S [0.54, 1.19]
and with the standard studentized interval, over seeds:
seed 1: D-U [0.14, 0.27], U-S [-0.09, 0.59], D-S [0.19, 0.85]
seed 2: D-U [0.14, 0.27], U-S [-0.13, 0.59], D-S [0.15, 0.86]
seed 3: D-U [0.14, 0.27], U-S [-0.16, 0.60], D-S [0.18, 0.83]
Result: reproduced, under one reading (all sessions, 0/0 read as 0), with a CI bound near zero. The cue effect holds under every reading (F(2,12) from 52.6 to 57.4, p < 1e-5), and the three mean differences are within tolerance under every reading (0.20 to 0.22, 0.47 to 0.48, 0.67 to 0.70). The danger minus uncertainty and danger minus safety CIs exclude zero under every reading. With the standard interval the uncertainty minus safety CI excludes zero only with all sessions and 0/0 read as 0 (median bounds over 50 seeds [0.012, 0.599], excluding zero in 68% of seeds; [0.04, 0.59] with seed 1001); under the other readings its lower bound is below zero, because one rat (ac01) has a difference of 0.15. In the CI section that reading reproduces in 3 of 5 seeds with the analytic SE and 2 of 5 with the inner bootstrap SE. With the authors' handling of 0/0 (set to 1) and the 82 sessions, F(2,12) = 57.41 and the means 0.21, 0.47 and 0.69 equal the paper's values exactly. The paper's CIs are not standard studentized intervals of these data: they match, within resampling noise, the bootstrap-t quantiles added to the mean without reflection ([0.36, 1.03] against the paper's [0.35, 1.03] for uncertainty minus safety, [0.52, 1.18] against [0.50, 1.25] for danger minus safety). With that form every CI excludes zero under every reading and every seed (median uncertainty minus safety bounds 0.33 to 0.35 at the lower end), and the claim is reproduced under all six readings.
This outcome rests on an assumption. The criterion accepts the claim under one reading, and the reproducing reading (all sessions, 0/0 read as 0) is not the authors' handling. With their handling (0/0 set to 1), which fig1h-poke-rate-unrelated adopts because it gives the paper's F exactly, the uncertainty minus safety CI contains zero in every one of the 50 seeds with the standard interval, in both session sets (median lower bounds -0.125 and -0.084).
fig1h-poke-rate-unrelated and fig1h-discrimination-safety¶
Baseline nose poke rate was unrelated to suppression to any cue and to overall discrimination. Overall discrimination ... correlated negatively with the safety suppression ratio across rats.
Result (fig1h-poke-rate-unrelated): reproduced, resting on the 0/0 handling. With the authors' handling of 0/0 ratios (set to 1, which gives the paper's F exactly) or with them left out, no correlation of baseline poke rate has p < 0.05 in either session set (smallest p 0.26; largest |R| 0.49). With 0/0 read as 0, baseline poke rate correlates with danger suppression in the 82 sessions (R = 0.76, p = 0.048).
Result (fig1h-discrimination-safety): reproduced. R is -0.98 or -0.99 with p from 4.5e-5 to 1.4e-4 under every reading (the paper: R = -0.98, p = 1.41e-4).
fig2-five-clusters¶
K-means clustering of the 193 cue-responsive units on six firing epochs ... gave five functional populations; Threat Excited (5), Threat Inhibited (26), Danger Excited (55), Bidirectional Valence (91) and Non-Selective (16).
Matrix readings: mean normalized firing (onset, first 1 s; late, last 5 s; per cue), under the
four normalization readings of the claims file (N1 to N4), or mean firing in Hz. Start readings:
(i) the lowest summed distance over 100 k-means++ starts; (ii) the most frequent partition over
100 starts. Clusters are named by matching their centroids to the Results' patterns. The
authors' script clusters the normalization of cubeScriptPR25.m with one start after rng(1)
(mainAnalysis.m, "K means clustering"); that normalization is shown as a variant (the MATLAB
random stream cannot be repeated here).
norm = {}
for k, kw in nac.NORM_READINGS.items():
norm[k] = np.array([nac.norm_methods(u, **kw)[0] for u in R])
norm["script normalization"] = np.array([nac.norm_code(u)[0] for u in R])
mats = {k: np.array([nac.epochs(t) for t in v]) for k, v in norm.items()}
mats["Hz"] = np.array([np.concatenate([[nac.window_rate(u["spikes"], u["onsets"], a, b)[nac.CUE_OF_TRIAL == c].mean()
for c in range(3)] for a, b in ((0, 1), (5, 10))]) for u in R])
print({k: v.shape for k, v in mats.items()})
{'N1 4 types, unc = mean of 8 trials': (193, 6), 'N2 4 types, unc = mean of 2 type traces': (193, 6), 'N3 3 types, unc = mean of 8 trials': (193, 6), 'N4 3 types, unc = mean of 2 type traces': (193, 6), 'script normalization': (193, 6), 'Hz': (193, 6)}
partitions = {}
rows = []
for k, X in mats.items():
runs = nac.kmeans_runs(X, 5, 100, seed=2000)
best = min(runs, key=lambda r: r[1])[0]
freq_count = collections.Counter(nac.canonical(r[0]) for r in runs)
freq, n_freq = freq_count.most_common(1)[0]
for start, lab in (("(i) best of 100", np.asarray(best)), ("(ii) most frequent", np.asarray(freq))):
names, cos = nac.name_clusters(X, lab)
pops = np.array([names[l] for l in lab])
key = f"{k} | {start}"
partitions[key] = pops
cnt = collections.Counter(pops)
rows.append(dict(matrix=k, start=start, times_found=n_freq if start.startswith("(ii)") else
sum(nac.canonical(r[0]) == nac.canonical(best) for r in runs),
**{p: cnt[p] for p in nac.POPULATIONS}, min_cosine=min(cos.values()),
within_tolerance=all(abs(cnt[p] - e) <= e * 0.1 for p, e in zip(nac.POPULATIONS, (5, 26, 55, 91, 16)))))
fig2_table = pd.DataFrame(rows)
print(fig2_table.round(2).to_string(index=False))
print("paper: Threat Excited 5, Threat Inhibited 26, Danger Excited 55, Bidirectional Valence 91, Non-Selective 16 (10% tolerance)")
matrix start times_found Threat Excited Threat Inhibited Danger Excited Bidirectional Valence Non-Selective min_cosine within_tolerance
N1 4 types, unc = mean of 8 trials (i) best of 100 1 44 36 57 46 10 -0.21 False
N1 4 types, unc = mean of 8 trials (ii) most frequent 2 80 3 40 60 10 0.65 False
N2 4 types, unc = mean of 2 type traces (i) best of 100 1 48 35 53 46 11 -0.34 False
N2 4 types, unc = mean of 2 type traces (ii) most frequent 2 7 27 44 91 24 0.77 False
N3 3 types, unc = mean of 8 trials (i) best of 100 1 49 35 57 42 10 -0.28 False
N3 3 types, unc = mean of 8 trials (ii) most frequent 3 51 25 60 41 16 -0.58 False
N4 3 types, unc = mean of 2 type traces (i) best of 100 1 46 28 27 86 6 0.73 False
N4 3 types, unc = mean of 2 type traces (ii) most frequent 2 6 28 45 89 25 0.79 False
script normalization (i) best of 100 1 9 25 34 89 36 0.66 False
script normalization (ii) most frequent 3 9 73 22 50 39 0.30 False
Hz (i) best of 100 2 30 9 27 83 44 -0.81 False
Hz (ii) most frequent 19 32 9 27 80 45 -0.81 False
paper: Threat Excited 5, Threat Inhibited 26, Danger Excited 55, Bidirectional Valence 91, Non-Selective 16 (10% tolerance)
claims_rows = fig2_table[fig2_table.matrix.isin(list(nac.NORM_READINGS))]
best_row = claims_rows.loc[claims_rows.min_cosine.idxmax()]
PRIMARY = f"{best_row.matrix} | {best_row.start}"
PRIMARY_NORM = best_row.matrix
alt_row = claims_rows.drop(index=best_row.name).sort_values("min_cosine").iloc[-1]
ALT = f"{alt_row.matrix} | {alt_row.start}"
FITTING = [f"{r.matrix} | {r.start}" for r in fig2_table.itertuples() if r.min_cosine >= 0.7]
print(f"next best (alternative partition, shown with every population claim): {ALT}, min cosine {alt_row.min_cosine:.2f}")
print(f"partitions whose clusters fit their names (smallest cosine at least 0.7), used in the outcome tallies: {FITTING}")
def tally(t, label="outcomes"):
"""Outcome counts over the partitions whose clusters fit their names; partitions with a
smaller cosine have clusters that do not show the named patterns, and their outcomes mean
nothing. Also the outcomes on the primary and the alternative partition."""
if "partition" not in t:
print(f"\n{label}:", dict(collections.Counter(t.outcome)))
return
fit = t[t.partition.isin(FITTING)]
print(f"\n{label}, fitting partitions:", dict(collections.Counter(fit.outcome)),
"| primary:", dict(collections.Counter(t[t.partition == PRIMARY].outcome)),
"| alternative:", dict(collections.Counter(t[t.partition == ALT].outcome)))
print(f"primary partition (claims-file readings, highest smallest cosine to the five patterns): {PRIMARY}, min cosine {best_row.min_cosine:.2f}")
print("centroids (danger, uncertainty, safety onset; then late cue) of each partition:")
for key, pops in partitions.items():
X = mats[key.split(" | ")[0]]
print(key)
for p in nac.POPULATIONS:
sel = pops == p
print(f" {p:22s} n={sel.sum():3d} {np.round(X[sel].mean(0), 2)}")
next best (alternative partition, shown with every population claim): N2 4 types, unc = mean of 2 type traces | (ii) most frequent, min cosine 0.77 partitions whose clusters fit their names (smallest cosine at least 0.7), used in the outcome tallies: ['N2 4 types, unc = mean of 2 type traces | (ii) most frequent', 'N4 3 types, unc = mean of 2 type traces | (i) best of 100', 'N4 3 types, unc = mean of 2 type traces | (ii) most frequent'] primary partition (claims-file readings, highest smallest cosine to the five patterns): N4 3 types, unc = mean of 2 type traces | (ii) most frequent, min cosine 0.79 centroids (danger, uncertainty, safety onset; then late cue) of each partition: N1 4 types, unc = mean of 8 trials | (i) best of 100 Threat Excited n= 44 [1.33 1.03 0.52 0.38 0.19 0.02] Threat Inhibited n= 36 [-1.34 -1.12 -0.6 -0.61 -0.47 0.04] Danger Excited n= 57 [-0.03 -0.31 -0.4 0.01 -0.12 0.01] Bidirectional Valence n= 46 [-0.29 0.15 0.57 -0.4 -0.08 -0.04] Non-Selective n= 10 [3.22 3.02 2.11 1.11 0.53 0.11] N1 4 types, unc = mean of 8 trials | (ii) most frequent Threat Excited n= 80 [ 0.08 0.07 0.04 -0.07 -0.08 -0.02] Threat Inhibited n= 3 [-3.05 -2.72 -1.66 -0.66 -0.45 0.16] Danger Excited n= 40 [1.37 1.08 0.58 0.44 0.22 0.01] Bidirectional Valence n= 60 [-0.95 -0.76 -0.28 -0.56 -0.33 0.03] Non-Selective n= 10 [3.22 3.02 2.11 1.11 0.53 0.11] N2 4 types, unc = mean of 2 type traces | (i) best of 100 Threat Excited n= 48 [1.25 0.99 0.46 0.39 0.15 0.03] Threat Inhibited n= 35 [-1.36 -1.11 -0.6 -0.62 -0.42 0.05] Danger Excited n= 53 [-0.11 -0.36 -0.43 -0.01 -0.15 -0.01] Bidirectional Valence n= 46 [-0.31 0.11 0.56 -0.41 -0.08 -0.04] Non-Selective n= 11 [3.16 2.96 2.07 0.95 0.46 0.11] N2 4 types, unc = mean of 2 type traces | (ii) most frequent Threat Excited n= 7 [3.74 3.38 2.22 0.85 0.36 0.03] Threat Inhibited n= 27 [-1.42 -1.33 -0.71 -0.64 -0.49 0.07] Danger Excited n= 44 [0.97 0.6 0.02 0.32 0.07 0.02] Bidirectional Valence n= 91 [-0.4 -0.24 -0.04 -0.25 -0.14 -0.03] Non-Selective n= 24 [1.4 1.46 1.34 0.36 0.3 0.1 ] N3 3 types, unc = mean of 8 trials | (i) best of 100 Threat Excited n= 49 [1.43 1.15 0.56 0.42 0.23 0. ] Threat Inhibited n= 35 [-1.55 -1.31 -0.7 -0.68 -0.55 0.05] Danger Excited n= 57 [-0.08 -0.35 -0.47 -0. -0.15 0.01] Bidirectional Valence n= 42 [-0.41 0.11 0.72 -0.51 -0.09 -0.04] Non-Selective n= 10 [3.56 3.36 2.32 0.89 0.43 0.12] N3 3 types, unc = mean of 8 trials | (ii) most frequent Threat Excited n= 51 [1.25 0.88 0.38 0.43 0.17 0.01] Threat Inhibited n= 25 [-1.7 -1.59 -0.74 -0.77 -0.68 0.11] Danger Excited n= 60 [-0.35 -0.44 -0.54 -0.12 -0.16 -0.02] Bidirectional Valence n= 41 [-0.46 0.14 0.68 -0.53 -0.11 -0.03] Non-Selective n= 16 [3.07 2.77 2.05 0.65 0.37 0.09] N4 3 types, unc = mean of 2 type traces | (i) best of 100 Threat Excited n= 46 [0.83 0.71 0.23 0.06 0.03 0.07] Threat Inhibited n= 28 [-1.53 -1.5 -0.8 -0.71 -0.57 0.06] Danger Excited n= 27 [ 1.92 1.54 1.14 0.75 0.4 -0.01] Bidirectional Valence n= 86 [-0.49 -0.3 -0.07 -0.27 -0.16 -0.04] Non-Selective n= 6 [4.02 4.04 2.65 0.85 0.32 0.09] N4 3 types, unc = mean of 2 type traces | (ii) most frequent Threat Excited n= 6 [4.02 4.04 2.65 0.85 0.32 0.09] Threat Inhibited n= 28 [-1.53 -1.5 -0.8 -0.71 -0.57 0.06] Danger Excited n= 45 [1.08 0.68 0.02 0.34 0.08 0.02] Bidirectional Valence n= 89 [-0.47 -0.26 -0.03 -0.29 -0.15 -0.03] Non-Selective n= 25 [1.66 1.63 1.48 0.4 0.34 0.08] script normalization | (i) best of 100 Threat Excited n= 9 [2.01 2.06 1.46 0.71 0.31 0.12] Threat Inhibited n= 25 [-0.81 -0.82 -0.33 -0.32 -0.32 0.13] Danger Excited n= 34 [ 0.81 0.36 -0.06 0.38 0.06 -0.16] Bidirectional Valence n= 89 [-0.21 -0.11 -0.09 -0.14 -0.07 -0.05] Non-Selective n= 36 [ 0.34 0.4 0.57 -0.05 0.06 0.19] script normalization | (ii) most frequent Threat Excited n= 9 [2.01 2.06 1.46 0.71 0.31 0.12] Threat Inhibited n= 73 [-0.01 -0.06 -0.18 -0.01 -0.05 -0.1 ] Danger Excited n= 22 [ 0.96 0.54 -0.03 0.49 0.15 -0.18] Bidirectional Valence n= 50 [-0.66 -0.52 -0.11 -0.34 -0.22 0.08] Non-Selective n= 39 [ 0.34 0.38 0.55 -0.05 0.03 0.18] Hz | (i) best of 100 Threat Excited n= 30 [30.21 27.97 25.43 23.01 22.94 22.4 ] Threat Inhibited n= 9 [40.97 43.28 43.28 41.49 38.49 39.98] Danger Excited n= 27 [18.16 17.7 15.67 19.89 18.55 18.18] Bidirectional Valence n= 83 [3.41 3.51 3.76 3.38 3.77 4. ] Non-Selective n= 44 [11.45 11.95 11.94 10.31 9.77 10.31] Hz | (ii) most frequent Threat Excited n= 32 [29.71 27.71 24.84 23.05 23.12 22.41] Threat Inhibited n= 9 [40.97 43.28 43.28 41.49 38.49 39.98] Danger Excited n= 27 [17.72 17.02 15.68 19.3 17.59 17.28] Bidirectional Valence n= 80 [3.29 3.37 3.68 3.24 3.59 3.86] Non-Selective n= 45 [10.92 11.54 11.36 9.84 9.56 10.14]
X = mats[PRIMARY_NORM]
rng_k = 2100
print(f"cluster number rule (variant): mean squared distance to centroid, best of 100 starts, {PRIMARY_NORM}")
for k in range(1, 8):
runs = nac.kmeans_runs(X, k, 100, seed=rng_k)
print(f" k={k}: mean squared distance {min(r[1] for r in runs) / len(X):.3f}")
alt = np.array([nac.screen(u, "pooled")[0] for u in U])
X219 = np.array([nac.epochs(nac.norm_methods(u, **nac.NORM_READINGS[PRIMARY_NORM])[0]) for u, r in zip(U, alt) if r])
best = min(nac.kmeans_runs(X219, 5, 100, seed=2200), key=lambda r: r[1])[0]
names, _ = nac.name_clusters(X219, best)
print(f"counts on the 219 units of screen reading (a), {PRIMARY_NORM}, best of 100:", dict(collections.Counter(names[l] for l in best)))
cluster number rule (variant): mean squared distance to centroid, best of 100 starts, N4 3 types, unc = mean of 2 type traces k=1: mean squared distance 5.759 k=2: mean squared distance 3.344 k=3: mean squared distance 2.692
k=4: mean squared distance 2.304 k=5: mean squared distance 2.091 k=6: mean squared distance 1.893
k=7: mean squared distance 1.756
counts on the 219 units of screen reading (a), N4 3 types, unc = mean of 2 type traces, best of 100: {'Danger Excited': 80, 'Bidirectional Valence': 45, 'Threat Inhibited': 36, 'Threat Excited': 47, 'Non-Selective': 11}
Result: partially reproduced. No reading gives the paper's five counts within tolerance. The five named patterns appear in some normalized readings: with N4 and the most frequent of 100 starts the centroids match the five patterns (smallest cosine 0.79) with counts of 6 Threat Excited, 28 Threat Inhibited, 45 Danger Excited, 89 Bidirectional Valence and 25 Non-Selective; N2 gives 7, 27, 44, 91 and 24. N4 with the best of 100 starts also has a smallest cosine above 0.7 (0.73), with counts of 46, 28, 27, 86 and 6. N1 most frequent (0.65) and the script normalization's best partition (0.66) come close; the other readings give partitions whose centroids do not show the patterns (smallest cosine 0.30 or below). The normalized solutions are unstable: their best and most frequent partitions are each found in 1 to 3 of 100 starts. The most frequent partition of firing in Hz is found in 19. Clustering firing in Hz groups units by firing rate and shows none of the patterns. The mean distance falls steadily from k = 1 to 7, with no elbow at 5.
The later population claims use the partition, among the claims file's readings, whose
centroids best match the five patterns (N4, most frequent partition). This is an assumption: the
paper's own labels are not in the data set and its clustering cannot be repeated (the script
uses one MATLAB start after rng(1)). Each later claim also shows its result under every
partition.
def pop_units(pops, names):
return [i for i, p in enumerate(pops) if p in names]
prim = partitions[PRIMARY]
print("primary partition:", dict(collections.Counter(prim)))
primary partition: {np.str_('Bidirectional Valence'): 89, np.str_('Danger Excited'): 45, np.str_('Non-Selective'): 25, np.str_('Threat Inhibited'): 28, np.str_('Threat Excited'): 6}
populations-by-rat¶
Threat Excited units came from two of seven rats ..., Threat Inhibited from four rats, Danger Excited from six and Bidirectional Valence from all seven; the three main populations (172 units) came from 79 sessions.
rows = []
for key, pops in partitions.items():
row = dict(partition=key)
for p in ["Threat Excited", "Threat Inhibited", "Danger Excited", "Bidirectional Valence"]:
row[p + " rats"] = len({R[i]["rat"] for i in pop_units(pops, [p])})
main = pop_units(pops, nac.MAIN3)
row["main3 units"] = len(main)
row["main3 sessions"] = len({R[i]["session"] for i in main})
row["all match"] = (row["Threat Excited rats"], row["Threat Inhibited rats"], row["Danger Excited rats"],
row["Bidirectional Valence rats"]) == (2, 4, 6, 7) and abs(row["main3 sessions"] - 79) <= 7.9
rows.append(row)
print(pd.DataFrame(rows).to_string(index=False))
print("paper: 2, 4, 6 and 7 rats; 172 units from 79 sessions")
te = pop_units(prim, ["Threat Excited"])
print("primary partition, Threat Excited units per rat:", dict(collections.Counter(R[i]["rat"] for i in te)))
partition Threat Excited rats Threat Inhibited rats Danger Excited rats Bidirectional Valence rats main3 units main3 sessions all match
N1 4 types, unc = mean of 8 trials | (i) best of 100 5 5 7 7 139 73 False
N1 4 types, unc = mean of 8 trials | (ii) most frequent 7 1 5 7 103 56 False
N2 4 types, unc = mean of 2 type traces | (i) best of 100 5 5 7 7 134 71 False
N2 4 types, unc = mean of 2 type traces | (ii) most frequent 4 5 6 7 162 77 False
N3 3 types, unc = mean of 8 trials | (i) best of 100 5 5 7 7 134 70 False
N3 3 types, unc = mean of 8 trials | (ii) most frequent 6 4 7 7 126 67 False
N4 3 types, unc = mean of 2 type traces | (i) best of 100 6 5 5 7 141 69 False
N4 3 types, unc = mean of 2 type traces | (ii) most frequent 3 5 6 7 162 77 False
script normalization | (i) best of 100 4 4 6 7 148 71 False
script normalization | (ii) most frequent 4 7 6 7 145 72 False
Hz | (i) best of 100 7 2 5 7 119 64 False
Hz | (ii) most frequent 7 2 5 7 116 64 False
paper: 2, 4, 6 and 7 rats; 172 units from 79 sessions
primary partition, Threat Excited units per rat: {'ac03': 1, 'ac04': 4, 'ac06': 1}
Result: not reproduced, under the assumed partition. The primary partition's Threat Excited units come from 3 rats (4 of 6 from ac04), Threat Inhibited from 5, Danger Excited from 6 and Bidirectional Valence from 7; the three main populations (162 units) come from 77 sessions, within tolerance of 79. No partition gives all four rat counts.
most-units-threat¶
Most cue-responsive NAcc units showed their greatest firing change to the shock-associated cues, danger and uncertainty.
rows = []
for key, pops in partitions.items():
four = len(pop_units(pops, ["Threat Excited", "Threat Inhibited", "Danger Excited", "Bidirectional Valence"]))
rows.append(dict(partition=key, four_populations=four, share=four / len(pops)))
t = pd.DataFrame(rows)
print(t.round(3).to_string(index=False))
d_or_u = np.array([np.argmax(np.abs(x[[0, 1, 2]])) <= 1 for x in mats[PRIMARY_NORM]])
print(f"unit by unit ({PRIMARY_NORM}): largest absolute onset change to danger or uncertainty in {d_or_u.mean():.3f} of {len(d_or_u)} units (chance 2/3)")
partition four_populations share
N1 4 types, unc = mean of 8 trials | (i) best of 100 183 0.948
N1 4 types, unc = mean of 8 trials | (ii) most frequent 183 0.948
N2 4 types, unc = mean of 2 type traces | (i) best of 100 182 0.943
N2 4 types, unc = mean of 2 type traces | (ii) most frequent 169 0.876
N3 3 types, unc = mean of 8 trials | (i) best of 100 183 0.948
N3 3 types, unc = mean of 8 trials | (ii) most frequent 177 0.917
N4 3 types, unc = mean of 2 type traces | (i) best of 100 187 0.969
N4 3 types, unc = mean of 2 type traces | (ii) most frequent 168 0.870
script normalization | (i) best of 100 157 0.813
script normalization | (ii) most frequent 154 0.798
Hz | (i) best of 100 149 0.772
Hz | (ii) most frequent 148 0.767
unit by unit (N4 3 types, unc = mean of 2 type traces): largest absolute onset change to danger or uncertainty in 0.731 of 193 units (chance 2/3)
Result: reproduced. Under every partition the four populations with differential cue firing hold more than half of the cue-responsive units (77% to 97%; 87% under the primary partition).
Firing and waveform characteristics (fig3)¶
Baseline rate: mean firing over the 10 s before onset, all 16 trials. Coefficient of variance,
readings of the claims file: (a) inter-spike intervals within the 10-s baselines; (b) the whole
session, which in these files is the recorded part of each trial, 20 s before to 33 s after
onset (see the data check: nothing is recorded between trials), so intervals across the gaps
are left out. The authors' cubeScriptPR25.m pools the intervals within the 20 s before each onset
(variant). Peak-valley duration: valley to after-hyperpolarization peak of the mean waveform,
counted as mainAnalysis.m counts it ("Get firing characteristics"), in ms at 40 samples per
ms. The script then halves it ("HD"), which gives 0.075 to 0.3, half the 0.15 to 0.6 ms of
Figure 3C; the unhalved value spans the figure's range, and its boundary 0.3875 falls between
the modes only on that scale, so the unhalved value is used. Hartigan's dip with a p-value from 1000 uniform samples, as the authors'
HartigansDipSignifTest(x, 1000).
def isi_cv(u, a, b):
isis = []
for t in u["onsets"]:
s = u["spikes"][(u["spikes"] > t + a) & (u["spikes"] <= t + b)]
isis.append(np.diff(s))
isi = np.concatenate(isis)
return isi.std(ddof=1) / isi.mean() if len(isi) > 2 else np.nan
char = pd.DataFrame(dict(
rate=[nac.window_rate(u["spikes"], u["onsets"], -10, 0).mean() for u in R],
cv_a=[isi_cv(u, -10, 0) for u in R],
cv_b=[isi_cv(u, -20, 33) for u in R],
cv_script=[isi_cv(u, -20, 0) for u in R],
hd=[nac.peak_valley(u["wave"]) for u in R],
hd_script=[nac.peak_valley(u["wave"]) / 2 for u in R],
pv_ms=[nac.peak_valley_ms(u["wave"]) for u in R]))
cube_cv = CUBE.fire[0, 0].CV[:, 0]
cv_check = [abs(cube_cv[cube_index[u["filename"] + u["neuron"]]] - c) < 1e-6 for u, c in zip(R, char.cv_script)]
print(f"cv_script equal to cube.fire.CV: {sum(cv_check)} of {len(R)}")
print(char.describe().round(3))
cv_script equal to cube.fire.CV: 193 of 193
rate cv_a cv_b cv_script hd hd_script pv_ms
count 193.000 193.000 193.000 193.000 193.000 193.000 193.000
mean 11.916 1.234 1.333 1.250 0.373 0.187 0.348
std 10.001 0.364 0.438 0.386 0.153 0.077 0.153
min 0.513 0.223 0.227 0.222 0.150 0.075 0.125
25% 4.506 1.027 1.062 1.024 0.225 0.112 0.200
50% 8.200 1.227 1.295 1.246 0.350 0.175 0.325
75% 16.838 1.421 1.524 1.437 0.550 0.275 0.525
max 48.375 2.488 3.284 2.869 0.600 0.300 0.575
fig3ab-rate-cv-unimodal¶
Across the 172 units of the three main populations, baseline firing rate and coefficient of variance had unimodal distributions.
rng_3 = np.random.default_rng(3001)
rows = []
for key, pops in partitions.items():
main = pop_units(pops, nac.MAIN3)
row = dict(partition=key, n=len(main))
for col in ("rate", "cv_a", "cv_b", "cv_script"):
x = char[col].to_numpy()[main]
d, p = nac.dip_test(x[np.isfinite(x)], rng_3, 1000 if key == PRIMARY else 200)
row[col + " dip"] = d
row[col + " p"] = p
rows.append(row)
print(pd.DataFrame(rows).round(3).to_string(index=False))
print("paper: rate dip 0.013, p = 1.0; CV dip 0.016, p = 0.99 (n = 172). p from 1000 uniform samples for the primary partition, 200 for the others")
partition n rate dip rate p cv_a dip cv_a p cv_b dip cv_b p cv_script dip cv_script p
N1 4 types, unc = mean of 8 trials | (i) best of 100 139 0.016 1.000 0.023 0.925 0.024 0.885 0.017 1.000
N1 4 types, unc = mean of 8 trials | (ii) most frequent 103 0.022 0.995 0.030 0.775 0.041 0.245 0.033 0.680
N2 4 types, unc = mean of 2 type traces | (i) best of 100 134 0.018 0.985 0.023 0.910 0.025 0.860 0.020 0.985
N2 4 types, unc = mean of 2 type traces | (ii) most frequent 162 0.015 1.000 0.023 0.815 0.024 0.795 0.016 1.000
N3 3 types, unc = mean of 8 trials | (i) best of 100 134 0.018 1.000 0.023 0.935 0.025 0.860 0.016 1.000
N3 3 types, unc = mean of 8 trials | (ii) most frequent 126 0.017 1.000 0.021 0.985 0.025 0.915 0.019 1.000
N4 3 types, unc = mean of 2 type traces | (i) best of 100 141 0.019 0.995 0.021 0.970 0.024 0.830 0.028 0.610
N4 3 types, unc = mean of 2 type traces | (ii) most frequent 162 0.015 1.000 0.023 0.821 0.024 0.805 0.016 0.997
script normalization | (i) best of 100 148 0.017 1.000 0.019 0.985 0.023 0.880 0.017 1.000
script normalization | (ii) most frequent 145 0.018 1.000 0.022 0.945 0.025 0.780 0.018 0.995
Hz | (i) best of 100 119 0.018 1.000 0.020 1.000 0.027 0.825 0.026 0.890
Hz | (ii) most frequent 116 0.022 0.965 0.020 0.995 0.029 0.680 0.026 0.860
paper: rate dip 0.013, p = 1.0; CV dip 0.016, p = 0.99 (n = 172). p from 1000 uniform samples for the primary partition, 200 for the others
Result: reproduced. Under the primary partition (162 units) the dip test finds no departure from unimodality for baseline rate (dip 0.015, p = 1.0) or for the coefficient of variance under either reading (dip 0.023, p = 0.82; dip 0.024, p = 0.80), nor for the script's 20-s variant. No partition gives p < 0.05 for any of them.
fig3c-waveform-bimodal¶
Waveform peak-valley duration was bimodal across the 172 units; Threat Inhibited units were mostly wide (bimodal only at an uncorrected p), Danger Excited units unimodal and mostly narrow, and Bidirectional Valence units bimodal with about half narrow and half wide.
Boundary readings: (a) the dashed line of Figure 3C, which halfDuration.m sets at
(0.375 + 0.4) / 2 = 0.3875 and which sits at about 0.39 in the figure; (b) the lowest bin
between the two modes of the histogram of all main-population units (bins of 0.025).
hd_all = char.hd.to_numpy()
print("peak-valley values (Figure 3C scale):", dict(sorted(collections.Counter(np.round(hd_all, 4)).items())))
print(f"the same in ms at 40 kHz (valley to peak): {np.unique(char.pv_ms).round(3)}")
def trough(x):
edges = np.arange(0.0125, 0.8, 0.025) # bins centred on the 0.025-ms sample grid
h, _ = np.histogram(x, edges)
lo_mode = np.argmax(np.where(edges[:-1] < 0.35, h, -1))
hi_mode = np.argmax(np.where(edges[:-1] >= 0.35, h, -1))
j = lo_mode + np.argmin(h[lo_mode:hi_mode + 1])
return (edges[j] + edges[j + 1]) / 2
rows = []
for key, pops in partitions.items():
main = pop_units(pops, nac.MAIN3)
x = hd_all[main]
nsim = 1000 if key == PRIMARY else 200
d_all, p_all = nac.dip_test(x, rng_3, nsim)
row = dict(partition=key, all_dip=d_all, all_p=p_all, trough=trough(x))
for p, short in (("Threat Inhibited", "TI"), ("Danger Excited", "DE"), ("Bidirectional Valence", "BV")):
y = hd_all[pop_units(pops, [p])]
if len(y) < 5:
continue
d, pv = nac.dip_test(y, rng_3, nsim)
row[short + " n"] = len(y)
row[short + " dip"] = d
row[short + " p"] = pv
row[short + " narrow(a)"] = np.mean(y < nac.HD_BOUNDARY)
row[short + " narrow(b)"] = np.mean(y < row["trough"])
rows.append(row)
fig3c_table = pd.DataFrame(rows)
print(fig3c_table.round(3).to_string(index=False))
print("paper: all p = 0; TI dip 0.096 (+-0.0096), p = 0.035; DE dip 0.06 (+-0.006), p = 0.18; BV dip 0.11 (+-0.011), p = 0; BV 45-55% narrow")
peak-valley values (Figure 3C scale): {np.float64(0.15): 3, np.float64(0.175): 14, np.float64(0.2): 26, np.float64(0.225): 13, np.float64(0.25): 11, np.float64(0.275): 11, np.float64(0.3): 11, np.float64(0.325): 7, np.float64(0.35): 6, np.float64(0.375): 7, np.float64(0.4): 4, np.float64(0.425): 2, np.float64(0.45): 3, np.float64(0.475): 5, np.float64(0.5): 5, np.float64(0.525): 12, np.float64(0.55): 25, np.float64(0.575): 25, np.float64(0.6): 3}
the same in ms at 40 kHz (valley to peak): [0.125 0.15 0.175 0.2 0.225 0.25 0.275 0.3 0.325 0.35 0.375 0.4
0.425 0.45 0.475 0.5 0.525 0.55 0.575]
partition all_dip all_p trough TI n TI dip TI p TI narrow(a) TI narrow(b) DE n DE dip DE p DE narrow(a) DE narrow(b) BV n BV dip BV p BV narrow(a) BV narrow(b)
N1 4 types, unc = mean of 8 trials | (i) best of 100 0.099 0.0 0.325 36.0 0.097 0.010 0.417 0.333 57 0.098 0.000 0.544 0.456 46 0.115 0.0 0.609 0.543
N1 4 types, unc = mean of 8 trials | (ii) most frequent 0.103 0.0 0.400 NaN NaN NaN NaN NaN 40 0.100 0.000 0.700 0.700 60 0.092 0.0 0.433 0.433
N2 4 types, unc = mean of 2 type traces | (i) best of 100 0.100 0.0 0.325 35.0 0.100 0.000 0.429 0.343 53 0.093 0.000 0.528 0.434 46 0.125 0.0 0.609 0.543
N2 4 types, unc = mean of 2 type traces | (ii) most frequent 0.114 0.0 0.425 27.0 0.130 0.000 0.333 0.370 44 0.068 0.130 0.818 0.841 91 0.125 0.0 0.527 0.571
N3 3 types, unc = mean of 8 trials | (i) best of 100 0.101 0.0 0.325 35.0 0.100 0.000 0.400 0.314 57 0.098 0.000 0.526 0.439 42 0.123 0.0 0.619 0.571
N3 3 types, unc = mean of 8 trials | (ii) most frequent 0.096 0.0 0.325 25.0 0.100 0.035 0.360 0.240 60 0.105 0.000 0.517 0.433 41 0.135 0.0 0.585 0.537
N4 3 types, unc = mean of 2 type traces | (i) best of 100 0.093 0.0 0.425 28.0 0.125 0.000 0.357 0.393 27 0.111 0.010 0.630 0.630 86 0.113 0.0 0.523 0.570
N4 3 types, unc = mean of 2 type traces | (ii) most frequent 0.114 0.0 0.425 28.0 0.125 0.001 0.357 0.393 45 0.067 0.118 0.822 0.844 89 0.119 0.0 0.517 0.562
script normalization | (i) best of 100 0.108 0.0 0.425 25.0 0.100 0.015 0.360 0.400 34 0.076 0.140 0.735 0.735 89 0.120 0.0 0.539 0.584
script normalization | (ii) most frequent 0.106 0.0 0.425 73.0 0.088 0.000 0.589 0.644 22 0.098 0.060 0.727 0.727 50 0.110 0.0 0.420 0.440
Hz | (i) best of 100 0.075 0.0 0.425 9.0 0.167 0.015 0.667 0.667 27 0.093 0.035 0.667 0.704 83 0.078 0.0 0.434 0.482
Hz | (ii) most frequent 0.078 0.0 0.425 9.0 0.167 0.005 0.667 0.667 27 0.094 0.050 0.704 0.741 80 0.075 0.0 0.425 0.475
paper: all p = 0; TI dip 0.096 (+-0.0096), p = 0.035; DE dip 0.06 (+-0.006), p = 0.18; BV dip 0.11 (+-0.011), p = 0; BV 45-55% narrow
Result: reproduced under boundary reading (a), resting on the assumed partition. Under the primary partition the 162 units are bimodal (dip 0.114, p < 0.001). Threat Inhibited units are bimodal (dip 0.125, p = 0.001) and mostly wide (36% narrow at 0.3875). Danger Excited units are unimodal (dip 0.067, p = 0.12) and mostly narrow (82%). Bidirectional Valence units are bimodal (dip 0.119, p < 0.001) with 52% narrow. The dips are within tolerance for Bidirectional Valence (0.11 +- 0.011) and outside it for Threat Inhibited (0.096 +- 0.0096) and Danger Excited (0.06 +- 0.006). With the trough boundary (b, 0.425) the Bidirectional Valence split is 56% narrow, just outside 45 to 55%. The authors' script halves this measure, which would put every unit below the 0.3875 boundary; the data match Figure 3C's scale only unhalved.
Cue firing of the populations (fig4, fig5)¶
Normalized firing as in the opening comment of the claims file; the cue by interval ANOVA over
48 bins of 250 ms from 2 s before onset to offset, uncertainty collapsed; onset is the first 1 s
and late cue the last 5 s; studentized bootstrap CIs over units (1000 resamples). The
differences are those of the Methods (Population and single-unit firing analyses) and
mainAnalysis.m (diff1 = a - b, diff2 = (a + b)/2 - c, diff3 = b - c). "Danger and
uncertainty" readings: (a) the mean of the two values; (b) trials pooled, (4 danger + 8
uncertainty) / 12.
def cue_stats(tr, rng):
"""tr: units x 3 cues x 200 bins. ANOVA and window differences."""
A = nac.rm_anova2(tr[:, :, nac.ANOVA_BINS])
on = tr[:, :, nac.ONSET].mean(2)
late = tr[:, :, nac.LATE].mean(2)
out = dict(n=len(tr), F_cue=A["A"][0], df_cue=f"{A['A'][1]},{A['A'][2]}", p_cue=A["A"][3],
F_int=A["B"][0], p_int=A["B"][3], F_x=A["AxB"][0], df_x=f"{A['AxB'][1]},{A['AxB'][2]}", p_x=A["AxB"][3])
for w, v in (("onset", on), ("late", late)):
d, un, s = v[:, 0], v[:, 1], v[:, 2]
diffs = {"D-U": d - un, "U-S": un - s, "(D+U)/2-S": (d + un) / 2 - s, "(4D+8U)/12-S": (4 * d + 8 * un) / 12 - s,
"D-(U+S)/2": d - (un + s) / 2}
for k, x in diffs.items():
m, lo, hi = nac.boot_ci(x, rng)
out[f"{w} {k}"] = (round(m, 3), round(lo, 3), round(hi, 3))
return out
def excl(ci):
return ci[1] > 0 or ci[2] < 0
def pop_traces(pops, p, reading=PRIMARY_NORM):
return norm[reading][pop_units(pops, [p])]
def run_pop(p, judge, seed):
"""Run cue_stats for population p under every partition (primary normalization; for the
primary partition also every normalization reading). judge(stats) -> outcome string."""
rows = []
for key, pops in partitions.items():
readings = list(nac.NORM_READINGS) + ["script normalization"] if key == PRIMARY else [PRIMARY_NORM]
for nr in readings:
tr = pop_traces(pops, p, nr)
if len(tr) < 5:
rows.append(dict(partition=key, normalization=nr, n=len(tr), outcome="too few units"))
continue
st = cue_stats(tr, np.random.default_rng(seed))
rows.append(dict(partition=key, normalization=nr, **st, outcome=judge(st)))
return pd.DataFrame(rows)
def show(t, cols):
print(t[["partition", "normalization", "n"] + [c for c in cols if c in t] + ["outcome"]].to_string(index=False))
tally(t)
fig4ab-thi-threat-firing¶
Threat Inhibited units decreased firing more to danger and uncertainty than to safety, both at cue onset and during late cue.
def judge_4ab(st):
ok_cis = []
for key in ("(D+U)/2-S", "(4D+8U)/12-S"):
on, la = st["onset " + key], st["late " + key]
cis = excl(on) and excl(la) and on[0] < 0 and la[0] < 0
within = abs(on[0] + 0.47) <= 0.15 and abs(la[0] + 0.44) <= 0.16
ok_cis.append((cis, within))
anova = st["p_cue"] < 0.05 and st["p_x"] < 0.05
if any(c and w for c, w in ok_cis) and anova:
return "reproduced"
if any(c for c, w in ok_cis):
return "partially_reproduced"
return "not_reproduced"
t4ab = run_pop("Threat Inhibited", judge_4ab, 4001)
show(t4ab, ["F_cue", "df_cue", "p_cue", "F_x", "df_x", "p_x", "onset (D+U)/2-S", "late (D+U)/2-S", "onset (4D+8U)/12-S", "late (4D+8U)/12-S"])
print("paper: F(2,50) = 37.84, interaction F(94,2350) = 4.95; onset -0.47 [-0.63, -0.32], late -0.44 [-0.60, -0.20]")
partition normalization n F_cue df_cue p_cue F_x df_x p_x onset (D+U)/2-S late (D+U)/2-S onset (4D+8U)/12-S late (4D+8U)/12-S outcome
N1 4 types, unc = mean of 8 trials | (i) best of 100 N4 3 types, unc = mean of 2 type traces 36 42.451383 2,70 8.440348e-13 3.590723 94,3290 2.572026e-27 (-0.693, -0.933, -0.476) (-0.61, -0.871, -0.416) (-0.645, -0.926, -0.43) (-0.573, -0.839, -0.375) partially_reproduced
N1 4 types, unc = mean of 8 trials | (ii) most frequent N4 3 types, unc = mean of 2 type traces 3 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN too few units
N2 4 types, unc = mean of 2 type traces | (i) best of 100 N4 3 types, unc = mean of 2 type traces 35 43.694063 2,68 6.267537e-13 3.876738 94,3196 3.701631e-31 (-0.705, -0.951, -0.479) (-0.63, -0.875, -0.443) (-0.659, -0.947, -0.448) (-0.594, -0.851, -0.389) partially_reproduced
N2 4 types, unc = mean of 2 type traces | (ii) most frequent N4 3 types, unc = mean of 2 type traces 27 43.519697 2,52 7.843365e-12 3.910090 94,2444 5.877568e-31 (-0.748, -1.069, -0.472) (-0.708, -1.0, -0.456) (-0.732, -1.071, -0.426) (-0.682, -0.972, -0.455) partially_reproduced
N3 3 types, unc = mean of 8 trials | (i) best of 100 N4 3 types, unc = mean of 2 type traces 35 42.600647 2,68 1.014800e-12 3.551441 94,3196 9.755597e-27 (-0.693, -0.949, -0.448) (-0.622, -0.912, -0.418) (-0.649, -0.919, -0.423) (-0.589, -0.826, -0.377) partially_reproduced
N3 3 types, unc = mean of 8 trials | (ii) most frequent N4 3 types, unc = mean of 2 type traces 25 50.976713 2,48 1.339172e-12 4.184054 94,2256 2.283753e-34 (-0.864, -1.171, -0.591) (-0.802, -1.133, -0.545) (-0.841, -1.212, -0.531) (-0.779, -1.062, -0.518) partially_reproduced
N4 3 types, unc = mean of 2 type traces | (i) best of 100 N4 3 types, unc = mean of 2 type traces 28 41.763596 2,54 1.091792e-11 3.832310 94,2538 5.103208e-30 (-0.716, -1.043, -0.424) (-0.704, -0.983, -0.477) (-0.711, -1.028, -0.407) (-0.682, -1.0, -0.445) partially_reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent N1 4 types, unc = mean of 8 trials 28 44.352727 2,54 4.024724e-12 4.179220 94,2538 1.089573e-34 (-0.644, -0.933, -0.386) (-0.652, -0.911, -0.449) (-0.641, -0.914, -0.379) (-0.637, -0.935, -0.438) partially_reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent N2 4 types, unc = mean of 2 type traces 28 40.649904 2,54 1.696710e-11 3.841019 94,2538 3.904516e-30 (-0.638, -0.93, -0.377) (-0.632, -0.893, -0.424) (-0.633, -0.914, -0.36) (-0.61, -0.917, -0.391) partially_reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent N3 3 types, unc = mean of 8 trials 28 46.291436 2,54 1.951571e-12 4.167413 94,2538 1.575461e-34 (-0.739, -1.072, -0.442) (-0.742, -1.012, -0.521) (-0.736, -1.051, -0.442) (-0.727, -1.036, -0.511) partially_reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent N4 3 types, unc = mean of 2 type traces 28 41.763596 2,54 1.091792e-11 3.832310 94,2538 5.103208e-30 (-0.716, -1.043, -0.424) (-0.704, -0.983, -0.477) (-0.711, -1.028, -0.407) (-0.682, -1.0, -0.445) partially_reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent script normalization 28 26.717476 2,54 8.584214e-09 4.321894 94,2538 1.248129e-36 (-0.374, -0.532, -0.204) (-0.377, -0.578, -0.226) (-0.386, -0.542, -0.216) (-0.382, -0.626, -0.242) reproduced
script normalization | (i) best of 100 N4 3 types, unc = mean of 2 type traces 25 39.621138 2,48 6.896605e-11 4.509226 94,2256 9.902589e-39 (-0.85, -1.193, -0.555) (-0.768, -1.089, -0.523) (-0.823, -1.16, -0.498) (-0.74, -1.033, -0.451) partially_reproduced
script normalization | (ii) most frequent N4 3 types, unc = mean of 2 type traces 73 2.431987 2,144 9.146345e-02 1.223533 94,6768 7.123422e-02 (0.138, -0.021, 0.288) (-0.036, -0.157, 0.086) (0.122, -0.026, 0.273) (-0.042, -0.158, 0.073) not_reproduced
Hz | (i) best of 100 N4 3 types, unc = mean of 2 type traces 9 0.322377 2,16 7.290224e-01 1.855737 94,752 6.420801e-06 (-0.014, -0.682, 0.799) (-0.016, -0.508, 2.854) (0.057, -0.564, 0.783) (-0.055, -0.453, 2.797) not_reproduced
Hz | (ii) most frequent N4 3 types, unc = mean of 2 type traces 9 0.322377 2,16 7.290224e-01 1.855737 94,752 6.420801e-06 (-0.014, -0.682, 0.799) (-0.016, -0.508, 2.854) (0.057, -0.564, 0.783) (-0.055, -0.453, 2.797) not_reproduced
outcomes, fitting partitions: {'partially_reproduced': 6, 'reproduced': 1} | primary: {'partially_reproduced': 4, 'reproduced': 1} | alternative: {'partially_reproduced': 1}
paper: F(2,50) = 37.84, interaction F(94,2350) = 4.95; onset -0.47 [-0.63, -0.32], late -0.44 [-0.60, -0.20]
Result: partially reproduced, resting on the assumed partition. Under the primary partition (28 Threat Inhibited units) the cue effect (F(2,54) = 41.8) and the interaction (F(94,2538) = 3.83) have p < 1e-10, and threat minus safety is below zero at onset (-0.72 [-1.04, -0.42] with N4) and in the late cue (-0.70 [-0.98, -0.48]) under every normalization reading, but the means are larger than the paper's (-0.47 +- 0.15, -0.44 +- 0.16) under every claims-file reading. With the authors' script normalization (variant) they are -0.37 and -0.38, within tolerance.
fig4b-thi-danger-equals-uncertainty¶
Threat Inhibited firing decreases to danger and uncertainty did not differ, at onset or during late cue.
def judge_4b(st):
return "reproduced" if not excl(st["onset D-U"]) and not excl(st["late D-U"]) else "not_reproduced"
t4b = run_pop("Threat Inhibited", judge_4b, 4101)
show(t4b, ["onset D-U", "late D-U"])
print("paper: onset -0.01 [-0.11, 0.12], late -0.02 [-0.14, 0.12]")
partition normalization n onset D-U late D-U outcome
N1 4 types, unc = mean of 8 trials | (i) best of 100 N4 3 types, unc = mean of 2 type traces 36 (-0.29, -0.527, -0.095) (-0.227, -0.473, -0.037) not_reproduced
N1 4 types, unc = mean of 8 trials | (ii) most frequent N4 3 types, unc = mean of 2 type traces 3 NaN NaN too few units
N2 4 types, unc = mean of 2 type traces | (i) best of 100 N4 3 types, unc = mean of 2 type traces 35 (-0.278, -0.52, -0.063) (-0.219, -0.458, -0.017) not_reproduced
N2 4 types, unc = mean of 2 type traces | (ii) most frequent N4 3 types, unc = mean of 2 type traces 27 (-0.098, -0.312, 0.09) (-0.156, -0.38, 0.059) reproduced
N3 3 types, unc = mean of 8 trials | (i) best of 100 N4 3 types, unc = mean of 2 type traces 35 (-0.267, -0.491, -0.059) (-0.197, -0.422, 0.001) not_reproduced
N3 3 types, unc = mean of 8 trials | (ii) most frequent N4 3 types, unc = mean of 2 type traces 25 (-0.142, -0.365, 0.059) (-0.141, -0.359, 0.094) reproduced
N4 3 types, unc = mean of 2 type traces | (i) best of 100 N4 3 types, unc = mean of 2 type traces 28 (-0.03, -0.257, 0.222) (-0.134, -0.354, 0.074) reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent N1 4 types, unc = mean of 8 trials 28 (-0.02, -0.21, 0.182) (-0.088, -0.242, 0.098) reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent N2 4 types, unc = mean of 2 type traces 28 (-0.031, -0.237, 0.194) (-0.128, -0.324, 0.057) reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent N3 3 types, unc = mean of 8 trials 28 (-0.019, -0.233, 0.216) (-0.088, -0.267, 0.123) reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent N4 3 types, unc = mean of 2 type traces 28 (-0.03, -0.257, 0.222) (-0.134, -0.354, 0.074) reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent script normalization 28 (0.07, -0.035, 0.188) (0.032, -0.079, 0.134) reproduced
script normalization | (i) best of 100 N4 3 types, unc = mean of 2 type traces 25 (-0.163, -0.49, 0.067) (-0.169, -0.428, 0.068) reproduced
script normalization | (ii) most frequent N4 3 types, unc = mean of 2 type traces 73 (0.101, -0.085, 0.283) (0.036, -0.097, 0.165) reproduced
Hz | (i) best of 100 N4 3 types, unc = mean of 2 type traces 9 (-0.427, -0.888, 0.346) (0.23, -0.254, 0.711) reproduced
Hz | (ii) most frequent N4 3 types, unc = mean of 2 type traces 9 (-0.427, -0.888, 0.346) (0.23, -0.254, 0.711) reproduced
outcomes, fitting partitions: {'reproduced': 7} | primary: {'reproduced': 5} | alternative: {'reproduced': 1}
paper: onset -0.01 [-0.11, 0.12], late -0.02 [-0.14, 0.12]
Result: reproduced, resting on the assumed partition. Danger minus uncertainty CIs contain zero at onset (-0.03 [-0.26, 0.22]) and in the late cue (-0.13 [-0.35, 0.07]) under the primary partition, under every normalization reading. Under three partitions found with N1 to N3 and the best of 100 starts, danger decreases exceed uncertainty decreases.
fig4cd-de-danger-firing¶
Danger Excited units fired most to danger and discriminated all three cues at onset, and during late cue their firing was selective for danger over uncertainty and safety.
def judge_4cd(st):
cis = [st["onset D-U"], st["onset U-S"], st["late D-(U+S)/2"]]
exp = [(0.22, 0.11), (0.21, 0.12), (0.17, 0.10)]
allx = all(excl(c) and c[0] > 0 for c in cis)
within = all(abs(c[0] - e) <= t for c, (e, t) in zip(cis, exp))
if allx and within and st["p_cue"] < 0.05 and st["p_x"] < 0.05:
return "reproduced"
return "partially_reproduced" if allx else "not_reproduced"
t4cd = run_pop("Danger Excited", judge_4cd, 4201)
show(t4cd, ["F_cue", "df_cue", "p_cue", "F_x", "p_x", "onset D-U", "onset U-S", "late D-(U+S)/2"])
print("paper: F(2,106) = 13.05, interaction F(94,4982) = 2.23; onset D-U 0.22 [0.11, 0.33], U-S 0.21 [0.07, 0.33]; late D-(U+S)/2 0.17 [0.07, 0.27]")
partition normalization n F_cue df_cue p_cue F_x p_x onset D-U onset U-S late D-(U+S)/2 outcome
N1 4 types, unc = mean of 8 trials | (i) best of 100 N4 3 types, unc = mean of 2 type traces 57 1.189136 2,112 3.082985e-01 1.493703 1.542180e-03 (0.328, 0.125, 0.533) (0.089, -0.078, 0.29) (0.084, -0.04, 0.222) not_reproduced
N1 4 types, unc = mean of 8 trials | (ii) most frequent N4 3 types, unc = mean of 2 type traces 40 16.310636 2,78 1.207765e-06 1.973256 1.045029e-07 (0.252, -0.014, 0.525) (0.632, 0.321, 0.91) (0.379, 0.157, 0.625) not_reproduced
N2 4 types, unc = mean of 2 type traces | (i) best of 100 N4 3 types, unc = mean of 2 type traces 53 1.197782 2,104 3.059924e-01 1.376023 9.908815e-03 (0.278, 0.081, 0.49) (0.084, -0.116, 0.302) (0.066, -0.065, 0.231) not_reproduced
N2 4 types, unc = mean of 2 type traces | (ii) most frequent N4 3 types, unc = mean of 2 type traces 44 12.342315 2,86 1.939450e-05 2.010229 4.191346e-08 (0.424, 0.133, 0.651) (0.649, 0.403, 0.91) (0.306, 0.117, 0.517) partially_reproduced
N3 3 types, unc = mean of 8 trials | (i) best of 100 N4 3 types, unc = mean of 2 type traces 57 1.347929 2,112 2.639587e-01 1.455057 2.917605e-03 (0.282, 0.086, 0.48) (0.102, -0.061, 0.307) (0.084, -0.039, 0.228) not_reproduced
N3 3 types, unc = mean of 8 trials | (ii) most frequent N4 3 types, unc = mean of 2 type traces 60 2.683660 2,118 7.248211e-02 1.320065 2.158703e-02 (0.096, -0.093, 0.29) (0.082, -0.084, 0.266) (-0.02, -0.163, 0.123) not_reproduced
N4 3 types, unc = mean of 2 type traces | (i) best of 100 N4 3 types, unc = mean of 2 type traces 27 19.798004 2,52 4.048525e-07 1.608227 2.418588e-04 (0.385, -0.021, 0.771) (0.394, 0.025, 0.751) (0.549, 0.248, 0.85) not_reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent N1 4 types, unc = mean of 8 trials 45 12.832423 2,88 1.287320e-05 2.187188 5.598378e-10 (0.395, 0.158, 0.594) (0.542, 0.298, 0.809) (0.271, 0.123, 0.448) partially_reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent N2 4 types, unc = mean of 2 type traces 45 12.831753 2,88 1.287987e-05 2.079964 7.853913e-09 (0.35, 0.118, 0.564) (0.587, 0.361, 0.827) (0.27, 0.11, 0.45) partially_reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent N3 3 types, unc = mean of 8 trials 45 12.639726 2,88 1.494814e-05 2.128344 2.414890e-09 (0.46, 0.165, 0.701) (0.629, 0.341, 0.933) (0.307, 0.136, 0.502) partially_reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent N4 3 types, unc = mean of 2 type traces 45 12.703572 2,88 1.422523e-05 2.035060 2.302468e-08 (0.395, 0.119, 0.638) (0.662, 0.406, 0.932) (0.299, 0.12, 0.502) partially_reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent script normalization 45 8.247764 2,88 5.211210e-04 2.196606 4.418704e-10 (0.24, 0.103, 0.364) (0.249, 0.102, 0.411) (0.161, 0.056, 0.272) reproduced
script normalization | (i) best of 100 N4 3 types, unc = mean of 2 type traces 34 18.991140 2,66 3.056975e-07 3.653274 4.696193e-28 (0.729, 0.441, 1.019) (0.65, 0.263, 0.946) (0.591, 0.379, 0.803) partially_reproduced
script normalization | (ii) most frequent N4 3 types, unc = mean of 2 type traces 22 31.147801 2,42 5.065813e-09 3.893732 4.141647e-30 (0.745, 0.337, 1.123) (0.942, 0.591, 1.262) (0.802, 0.486, 1.089) partially_reproduced
Hz | (i) best of 100 N4 3 types, unc = mean of 2 type traces 27 2.777209 2,52 7.145645e-02 1.077633 2.896557e-01 (0.248, -0.01, 0.605) (0.103, -0.232, 0.468) (0.28, 0.004, 0.612) not_reproduced
Hz | (ii) most frequent N4 3 types, unc = mean of 2 type traces 27 3.016293 2,52 5.762581e-02 1.105768 2.319539e-01 (0.268, -0.003, 0.601) (0.041, -0.327, 0.422) (0.333, 0.035, 0.642) not_reproduced
outcomes, fitting partitions: {'partially_reproduced': 5, 'not_reproduced': 1, 'reproduced': 1} | primary: {'partially_reproduced': 4, 'reproduced': 1} | alternative: {'partially_reproduced': 1}
paper: F(2,106) = 13.05, interaction F(94,4982) = 2.23; onset D-U 0.22 [0.11, 0.33], U-S 0.21 [0.07, 0.33]; late D-(U+S)/2 0.17 [0.07, 0.27]
Result: partially reproduced, resting on the assumed partition. Under the primary partition (45 Danger Excited units) the cue effect (F(2,88) = 12.7, p = 1.4e-5) and the interaction (p = 2.3e-8) hold, and all three CIs exclude zero (onset danger minus uncertainty 0.40 [0.12, 0.64], uncertainty minus safety 0.66 [0.41, 0.93], late danger minus the others 0.30 [0.12, 0.50] with N4), but every mean is above its tolerance under the claims-file readings. With the script normalization (variant) all three are within tolerance (0.24, 0.25, 0.16).
fig4ef-bv-danger-decrease¶
Bidirectional Valence units, the most abundant population (about 47% of cue-responsive units), decreased firing to danger more than to uncertainty and safety, at onset and during late cue.
def judge_4ef(st, share):
on, la = st["onset D-(U+S)/2"], st["late D-(U+S)/2"]
allx = excl(on) and excl(la) and on[0] < 0 and la[0] < 0
within = abs(on[0] + 0.13) <= 0.09 and abs(la[0] + 0.09) <= 0.07 and abs(share - 47) <= 4.7
if allx and within and st["p_cue"] < 0.05 and st["p_x"] < 0.05:
return "reproduced"
return "partially_reproduced" if allx else "not_reproduced"
rows = []
for key, pops in partitions.items():
share = 100 * np.mean(pops == "Bidirectional Valence")
readings = list(nac.NORM_READINGS) + ["script normalization"] if key == PRIMARY else [PRIMARY_NORM]
for nr in readings:
st = cue_stats(pop_traces(pops, "Bidirectional Valence", nr), np.random.default_rng(4301))
rows.append(dict(partition=key, normalization=nr, share=share, **st, outcome=judge_4ef(st, share)))
t4ef = pd.DataFrame(rows)
show(t4ef.round(3), ["share", "F_cue", "df_cue", "p_cue", "F_x", "p_x", "onset D-(U+S)/2", "late D-(U+S)/2"])
print("paper: 47% of cue-responsive units; F(2,178) = 8.90, interaction F(94,8366) = 1.45; onset -0.13 [-0.22, -0.03], late -0.09 [-0.16, -0.02]")
partition normalization n share F_cue df_cue p_cue F_x p_x onset D-(U+S)/2 late D-(U+S)/2 outcome
N1 4 types, unc = mean of 8 trials | (i) best of 100 N4 3 types, unc = mean of 2 type traces 46 23.834 20.401 2,90 0.000 1.718 0.000 (-0.725, -0.941, -0.538) (-0.378, -0.547, -0.197) partially_reproduced
N1 4 types, unc = mean of 8 trials | (ii) most frequent N4 3 types, unc = mean of 2 type traces 60 31.088 48.891 2,118 0.000 3.593 0.000 (-0.498, -0.677, -0.338) (-0.465, -0.62, -0.331) partially_reproduced
N2 4 types, unc = mean of 2 type traces | (i) best of 100 N4 3 types, unc = mean of 2 type traces 46 23.834 21.295 2,90 0.000 1.654 0.000 (-0.731, -0.947, -0.543) (-0.39, -0.561, -0.206) partially_reproduced
N2 4 types, unc = mean of 2 type traces | (ii) most frequent N4 3 types, unc = mean of 2 type traces 91 47.150 17.729 2,180 0.000 1.509 0.001 (-0.305, -0.466, -0.145) (-0.19, -0.314, -0.059) partially_reproduced
N3 3 types, unc = mean of 8 trials | (i) best of 100 N4 3 types, unc = mean of 2 type traces 42 21.762 22.770 2,82 0.000 1.832 0.000 (-0.785, -1.01, -0.583) (-0.423, -0.614, -0.23) partially_reproduced
N3 3 types, unc = mean of 8 trials | (ii) most frequent N4 3 types, unc = mean of 2 type traces 41 21.244 24.794 2,80 0.000 1.885 0.000 (-0.826, -1.038, -0.646) (-0.442, -0.622, -0.246) partially_reproduced
N4 3 types, unc = mean of 2 type traces | (i) best of 100 N4 3 types, unc = mean of 2 type traces 86 44.560 14.495 2,170 0.000 1.514 0.001 (-0.303, -0.472, -0.136) (-0.168, -0.297, -0.038) partially_reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent N1 4 types, unc = mean of 8 trials 89 46.114 18.685 2,176 0.000 1.574 0.000 (-0.304, -0.443, -0.162) (-0.179, -0.291, -0.06) partially_reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent N2 4 types, unc = mean of 2 type traces 89 46.114 17.858 2,176 0.000 1.556 0.000 (-0.286, -0.423, -0.137) (-0.172, -0.287, -0.051) partially_reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent N3 3 types, unc = mean of 8 trials 89 46.114 19.509 2,176 0.000 1.552 0.001 (-0.357, -0.518, -0.195) (-0.21, -0.338, -0.074) partially_reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent N4 3 types, unc = mean of 2 type traces 89 46.114 18.421 2,176 0.000 1.539 0.001 (-0.325, -0.479, -0.161) (-0.195, -0.321, -0.063) partially_reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent script normalization 89 46.114 6.225 2,176 0.002 1.555 0.001 (-0.145, -0.235, -0.06) (-0.078, -0.153, 0.002) not_reproduced
script normalization | (i) best of 100 N4 3 types, unc = mean of 2 type traces 89 46.114 13.689 2,176 0.000 1.414 0.005 (-0.209, -0.365, -0.045) (-0.157, -0.282, -0.03) reproduced
script normalization | (ii) most frequent N4 3 types, unc = mean of 2 type traces 50 25.907 52.652 2,98 0.000 4.839 0.000 (-0.677, -0.863, -0.518) (-0.505, -0.677, -0.34) partially_reproduced
Hz | (i) best of 100 N4 3 types, unc = mean of 2 type traces 83 43.005 14.725 2,164 0.000 2.039 0.000 (-0.17, -0.365, 0.021) (-0.248, -0.377, -0.113) not_reproduced
Hz | (ii) most frequent N4 3 types, unc = mean of 2 type traces 80 41.451 15.002 2,158 0.000 2.078 0.000 (-0.17, -0.352, 0.026) (-0.236, -0.36, -0.103) not_reproduced
outcomes, fitting partitions: {'partially_reproduced': 6, 'not_reproduced': 1} | primary: {'partially_reproduced': 4, 'not_reproduced': 1} | alternative: {'partially_reproduced': 1}
paper: 47% of cue-responsive units; F(2,178) = 8.90, interaction F(94,8366) = 1.45; onset -0.13 [-0.22, -0.03], late -0.09 [-0.16, -0.02]
Result: partially reproduced, resting on the assumed partition. Bidirectional Valence units are 46.1% of cue-responsive units (within 47 +- 4.7); the cue effect (F(2,176) = 18.4) and the interaction (p = 0.001) hold; danger minus uncertainty and safety is below zero at onset (-0.33 [-0.48, -0.16]) and in the late cue (-0.20 [-0.32, -0.06]) under every normalization reading, with means beyond the tolerance (-0.13 +- 0.09, -0.09 +- 0.07). With the script normalization the onset mean is -0.15 and the late CI reaches zero ([-0.15, 0.00]).
fig4f-bv-safety-variability¶
Bidirectional Valence units varied more in their safety onset firing than in their danger or uncertainty onset firing.
Pitman-Morgan test of paired variances, as the authors' PitmanMorganTest in mainAnalysis.m.
rows = []
for key, pops in partitions.items():
readings = list(nac.NORM_READINGS) + ["script normalization"] if key == PRIMARY else [PRIMARY_NORM]
for nr in readings:
on = pop_traces(pops, "Bidirectional Valence", nr)[:, :, nac.ONSET].mean(2)
r1 = nac.pitman_morgan(on[:, 2], on[:, 0])
r2 = nac.pitman_morgan(on[:, 2], on[:, 1])
ok = r1[2] < 0.05 and r2[2] < 0.05 and r1[0] > 1 and r2[0] > 1
rows.append(dict(partition=key, normalization=nr, n=len(on), var_ratio_S_D=r1[0], p_S_D=r1[2],
var_ratio_S_U=r2[0], p_S_U=r2[2], outcome="reproduced" if ok else "not_reproduced"))
t4f = pd.DataFrame(rows)
show(t4f.round(4), ["var_ratio_S_D", "p_S_D", "var_ratio_S_U", "p_S_U"])
print("paper: p = 0.0087 (safety against danger), 0.0046 (safety against uncertainty), n = 91")
partition normalization n var_ratio_S_D p_S_D var_ratio_S_U p_S_U outcome
N1 4 types, unc = mean of 8 trials | (i) best of 100 N4 3 types, unc = mean of 2 type traces 46 0.9062 0.7447 0.9626 0.8964 not_reproduced
N1 4 types, unc = mean of 8 trials | (ii) most frequent N4 3 types, unc = mean of 2 type traces 60 2.2694 0.0021 1.4273 0.1765 not_reproduced
N2 4 types, unc = mean of 2 type traces | (i) best of 100 N4 3 types, unc = mean of 2 type traces 46 1.0062 0.9836 1.0034 0.9908 not_reproduced
N2 4 types, unc = mean of 2 type traces | (ii) most frequent N4 3 types, unc = mean of 2 type traces 91 1.7003 0.0113 1.5466 0.0404 reproduced
N3 3 types, unc = mean of 8 trials | (i) best of 100 N4 3 types, unc = mean of 2 type traces 42 0.9740 0.9340 1.1285 0.7017 not_reproduced
N3 3 types, unc = mean of 8 trials | (ii) most frequent N4 3 types, unc = mean of 2 type traces 41 1.2050 0.5621 1.1247 0.7114 not_reproduced
N4 3 types, unc = mean of 2 type traces | (i) best of 100 N4 3 types, unc = mean of 2 type traces 86 1.7691 0.0074 1.9852 0.0019 reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent N1 4 types, unc = mean of 8 trials 89 1.6788 0.0147 1.8214 0.0055 reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent N2 4 types, unc = mean of 2 type traces 89 1.6788 0.0147 1.8350 0.0050 reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent N3 3 types, unc = mean of 8 trials 89 1.7299 0.0100 1.6878 0.0150 reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent N4 3 types, unc = mean of 2 type traces 89 1.7029 0.0123 1.7053 0.0134 reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent script normalization 89 1.2465 0.2872 1.8689 0.0039 not_reproduced
script normalization | (i) best of 100 N4 3 types, unc = mean of 2 type traces 89 1.4517 0.0788 1.4433 0.0876 not_reproduced
script normalization | (ii) most frequent N4 3 types, unc = mean of 2 type traces 50 1.5745 0.0881 1.1101 0.6880 not_reproduced
Hz | (i) best of 100 N4 3 types, unc = mean of 2 type traces 83 0.5986 0.0187 0.7399 0.1454 not_reproduced
Hz | (ii) most frequent N4 3 types, unc = mean of 2 type traces 80 0.6242 0.0351 0.7399 0.1547 not_reproduced
outcomes, fitting partitions: {'reproduced': 6, 'not_reproduced': 1} | primary: {'reproduced': 4, 'not_reproduced': 1} | alternative: {'reproduced': 1}
paper: p = 0.0087 (safety against danger), 0.0046 (safety against uncertainty), n = 91
Result: reproduced, resting on the assumed partition. Under the primary partition and every normalization reading of the claims file, safety onset firing varies more than danger onset firing (variance ratio 1.68 to 1.73, p 0.010 to 0.015) and more than uncertainty onset firing (ratio 1.69 to 1.84, p 0.005 to 0.015). With the script normalization (variant) the safety against danger test is not significant (ratio 1.25, p = 0.29).
fig5ab-the-onset¶
Threat Excited units increased firing more to danger and uncertainty than to safety at onset, but not during late cue.
def judge_5ab(st):
res = []
for key in ("(D+U)/2-S", "(4D+8U)/12-S"):
on, la = st["onset " + key], st["late " + key]
res.append(st["p_x"] < 0.05 and excl(on) and on[0] > 0 and abs(on[0] - 0.9) <= 0.6 and not excl(la))
return "reproduced" if any(res) else "not_reproduced"
t5ab = run_pop("Threat Excited", judge_5ab, 5001)
show(t5ab, ["F_int", "F_x", "df_x", "p_x", "onset (D+U)/2-S", "late (D+U)/2-S", "onset (4D+8U)/12-S", "late (4D+8U)/12-S"])
print("paper: n = 5; interval F(47,188) = 19.75, interaction F(94,376) = 1.46, p = 0.008; onset 0.9 [0.30, 12.58]; late [-1.08, 1.11]")
partition normalization n F_int F_x df_x p_x onset (D+U)/2-S late (D+U)/2-S onset (4D+8U)/12-S late (4D+8U)/12-S outcome
N1 4 types, unc = mean of 8 trials | (i) best of 100 N4 3 types, unc = mean of 2 type traces 44 13.526352 1.922126 94,4042 3.189451e-07 (0.787, 0.496, 1.077) (0.28, 0.085, 0.501) (0.745, 0.464, 1.052) (0.242, 0.059, 0.428) not_reproduced
N1 4 types, unc = mean of 8 trials | (ii) most frequent N4 3 types, unc = mean of 2 type traces 80 2.031281 0.903560 94,7426 7.361518e-01 (0.021, -0.165, 0.196) (-0.069, -0.181, 0.048) (0.015, -0.148, 0.174) (-0.071, -0.179, 0.034) not_reproduced
N2 4 types, unc = mean of 2 type traces | (i) best of 100 N4 3 types, unc = mean of 2 type traces 48 12.823551 1.851377 94,4418 1.481686e-06 (0.755, 0.488, 1.044) (0.264, 0.081, 0.46) (0.706, 0.44, 0.975) (0.22, 0.034, 0.394) not_reproduced
N2 4 types, unc = mean of 2 type traces | (ii) most frequent N4 3 types, unc = mean of 2 type traces 7 15.796050 1.393096 94,564 1.310691e-02 (1.423, 0.438, 2.131) (0.607, -0.072, 1.285) (1.366, 0.755, 2.439) (0.522, -0.248, 1.137) reproduced
N3 3 types, unc = mean of 8 trials | (i) best of 100 N4 3 types, unc = mean of 2 type traces 49 13.682387 1.825913 94,4512 2.557350e-06 (0.74, 0.475, 1.031) (0.307, 0.144, 0.49) (0.705, 0.454, 0.978) (0.272, 0.105, 0.436) not_reproduced
N3 3 types, unc = mean of 8 trials | (ii) most frequent N4 3 types, unc = mean of 2 type traces 51 9.891567 1.824935 94,4700 2.576763e-06 (0.695, 0.435, 0.973) (0.285, 0.118, 0.46) (0.647, 0.385, 0.901) (0.24, 0.064, 0.41) not_reproduced
N4 3 types, unc = mean of 2 type traces | (i) best of 100 N4 3 types, unc = mean of 2 type traces 46 5.345801 1.524695 94,4230 9.358505e-04 (0.545, 0.308, 0.769) (-0.021, -0.156, 0.128) (0.524, 0.296, 0.757) (-0.026, -0.161, 0.132) reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent N1 4 types, unc = mean of 8 trials 6 16.536541 1.201562 94,470 1.137663e-01 (1.299, 0.249, 2.127) (0.466, -0.181, 1.399) (1.295, 0.48, 2.282) (0.381, -0.284, 1.105) not_reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent N2 4 types, unc = mean of 2 type traces 6 15.524554 1.217517 94,470 9.806167e-02 (1.299, 0.257, 2.259) (0.473, -0.256, 1.264) (1.296, 0.501, 2.316) (0.389, -0.417, 1.038) not_reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent N3 3 types, unc = mean of 8 trials 6 16.529021 1.222740 94,470 9.331462e-02 (1.407, 0.283, 2.222) (0.499, -0.219, 1.434) (1.411, 0.582, 2.637) (0.409, -0.324, 1.157) not_reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent N4 3 types, unc = mean of 2 type traces 6 15.541824 1.236821 94,470 8.143690e-02 (1.383, 0.326, 2.362) (0.499, -0.309, 1.305) (1.386, 0.605, 2.649) (0.412, -0.438, 1.091) not_reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent script normalization 6 16.330938 1.239793 94,470 7.909470e-02 (0.833, 0.174, 1.346) (0.298, -0.266, 1.55) (0.851, 0.2, 1.483) (0.255, -0.257, 1.208) not_reproduced
script normalization | (i) best of 100 N4 3 types, unc = mean of 2 type traces 9 17.084544 1.429702 94,752 6.994564e-03 (1.019, 0.408, 1.833) (0.678, 0.015, 1.113) (1.037, 0.469, 2.159) (0.575, -0.117, 0.999) reproduced
script normalization | (ii) most frequent N4 3 types, unc = mean of 2 type traces 9 17.084544 1.429702 94,752 6.994564e-03 (1.019, 0.408, 1.833) (0.678, 0.015, 1.113) (1.037, 0.469, 2.159) (0.575, -0.117, 0.999) reproduced
Hz | (i) best of 100 N4 3 types, unc = mean of 2 type traces 30 6.043352 1.192945 94,2726 1.024115e-01 (0.503, 0.169, 0.918) (0.037, -0.206, 0.288) (0.469, 0.076, 0.831) (0.046, -0.209, 0.297) not_reproduced
Hz | (ii) most frequent N4 3 types, unc = mean of 2 type traces 32 5.386772 1.255090 94,2914 5.107382e-02 (0.501, 0.166, 0.856) (0.023, -0.226, 0.262) (0.466, 0.152, 0.844) (0.03, -0.197, 0.25) not_reproduced
outcomes, fitting partitions: {'reproduced': 2, 'not_reproduced': 5} | primary: {'not_reproduced': 5} | alternative: {'reproduced': 1}
paper: n = 5; interval F(47,188) = 19.75, interaction F(94,376) = 1.46, p = 0.008; onset 0.9 [0.30, 12.58]; late [-1.08, 1.11]
Result: not reproduced, under the assumed partition. The primary partition has 6 Threat Excited units. Threat minus safety firing is above zero at onset (1.38 [0.33, 2.36] with N4) and its late CI contains zero, but the cue by interval interaction is not significant under any normalization reading (p 0.08 to 0.11). The outcome depends on the partition: on the alternative partition (N2, most frequent, smallest cosine 0.77; 7 Threat Excited units) the interaction has p = 0.013, the onset CI is above zero (1.42 [0.44, 2.13]) and the late CI contains zero, so the claim is reproduced there. The CI form, SE and seed do not change the outcome on the primary partition (CI section).
fig5cd-ns-nonselective¶
Non-Selective units showed no main effect of cue and no cue by interval interaction, and their threat and safety firing did not differ at onset or late cue.
def judge_5cd(st):
# a claim of absence, judged on the paper's tests; reading (a) of "danger and uncertainty"
ok = st["p_cue"] >= 0.05 and st["p_x"] >= 0.05 and not excl(st["onset (D+U)/2-S"]) and not excl(st["late (D+U)/2-S"])
return "reproduced" if ok else "not_reproduced"
t5cd = run_pop("Non-Selective", judge_5cd, 5101)
show(t5cd, ["F_cue", "df_cue", "p_cue", "F_x", "p_x", "onset (D+U)/2-S", "late (D+U)/2-S"])
print("paper: n = 16; F(2,30) = 3.04, p = 0.063; interaction F(94,1410) = 1.19, p = 0.11; onset [-0.22, 0.36], late [-0.09, 0.46]")
partition normalization n F_cue df_cue p_cue F_x p_x onset (D+U)/2-S late (D+U)/2-S outcome
N1 4 types, unc = mean of 8 trials | (i) best of 100 N4 3 types, unc = mean of 2 type traces 10 14.174491 2,18 0.000201 1.492762 0.002659 (1.083, 0.551, 1.77) (0.736, 0.024, 1.144) not_reproduced
N1 4 types, unc = mean of 8 trials | (ii) most frequent N4 3 types, unc = mean of 2 type traces 10 14.174491 2,18 0.000201 1.492762 0.002659 (1.083, 0.551, 1.77) (0.736, 0.024, 1.144) not_reproduced
N2 4 types, unc = mean of 2 type traces | (i) best of 100 N4 3 types, unc = mean of 2 type traces 11 10.857561 2,20 0.000642 1.444367 0.005132 (1.059, 0.531, 1.681) (0.614, -0.039, 1.067) not_reproduced
N2 4 types, unc = mean of 2 type traces | (ii) most frequent N4 3 types, unc = mean of 2 type traces 24 3.793049 2,46 0.029870 1.245768 0.058184 (0.107, -0.255, 0.478) (0.245, -0.018, 0.536) not_reproduced
N3 3 types, unc = mean of 8 trials | (i) best of 100 N4 3 types, unc = mean of 2 type traces 10 8.433970 2,18 0.002604 1.382270 0.012631 (1.139, 0.607, 1.764) (0.55, -0.074, 1.086) not_reproduced
N3 3 types, unc = mean of 8 trials | (ii) most frequent N4 3 types, unc = mean of 2 type traces 16 7.657078 2,30 0.002057 1.307080 0.029275 (0.87, 0.436, 1.385) (0.416, 0.034, 0.824) not_reproduced
N4 3 types, unc = mean of 2 type traces | (i) best of 100 N4 3 types, unc = mean of 2 type traces 6 4.330984 2,10 0.044179 1.236821 0.081437 (1.383, 0.222, 2.213) (0.499, -0.309, 1.306) not_reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent N1 4 types, unc = mean of 8 trials 25 5.233619 2,48 0.008788 1.252121 0.053870 (0.077, -0.261, 0.467) (0.275, 0.034, 0.54) not_reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent N2 4 types, unc = mean of 2 type traces 25 5.131031 2,48 0.009562 1.280283 0.038443 (0.149, -0.185, 0.539) (0.272, 0.032, 0.533) not_reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent N3 3 types, unc = mean of 8 trials 25 4.906889 2,48 0.011509 1.232605 0.067370 (0.09, -0.306, 0.54) (0.292, 0.012, 0.578) not_reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent N4 3 types, unc = mean of 2 type traces 25 4.905470 2,48 0.011523 1.265139 0.046189 (0.169, -0.202, 0.603) (0.285, 0.015, 0.565) not_reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent script normalization 25 3.236663 2,48 0.048015 1.272863 0.042087 (0.025, -0.167, 0.269) (0.143, -0.046, 0.313) not_reproduced
script normalization | (i) best of 100 N4 3 types, unc = mean of 2 type traces 36 1.216806 2,70 0.302361 1.275601 0.039532 (-0.086, -0.386, 0.196) (-0.123, -0.255, 0.039) not_reproduced
script normalization | (ii) most frequent N4 3 types, unc = mean of 2 type traces 39 0.500135 2,76 0.608431 1.414363 0.005763 (-0.086, -0.389, 0.219) (-0.155, -0.29, 0.001) not_reproduced
Hz | (i) best of 100 N4 3 types, unc = mean of 2 type traces 44 0.099084 2,86 0.905770 1.018966 0.430696 (0.033, -0.239, 0.312) (-0.013, -0.235, 0.178) reproduced
Hz | (ii) most frequent N4 3 types, unc = mean of 2 type traces 45 0.434378 2,88 0.649048 0.951384 0.613310 (0.05, -0.187, 0.334) (-0.053, -0.255, 0.135) reproduced
outcomes, fitting partitions: {'not_reproduced': 7} | primary: {'not_reproduced': 5} | alternative: {'not_reproduced': 1}
paper: n = 16; F(2,30) = 3.04, p = 0.063; interaction F(94,1410) = 1.19, p = 0.11; onset [-0.22, 0.36], late [-0.09, 0.46]
Result: not reproduced, under the assumed partition. The 25 Non-Selective units of the primary partition show a main effect of cue (F(2,48) = 4.9 to 5.2, p 0.009 to 0.012), and their late threat minus safety CI excludes zero (0.27 to 0.29, lower bounds 0.01 to 0.03); the onset CI contains zero. The interaction is at p 0.04 to 0.07.
Firing similarity (fig6)¶
Per unit, mean normalized firing to each cue in 12 bins of 1 s from 2 s before onset to offset;
Pearson R between the traces of each cue pair. Readings: (a) the mean of four 250-ms normalized
bins; (b) 1-s bins normalized in the same way. The authors' mainAnalysis.m correlates the 1-s
bins of the script normalization (columns 19 to 30 of fire.z.s1), shown as a variant. Units
with a constant trace (no R) are left out and counted. Readings (a) and (b) give the same R for
every unit: the two traces differ by an affine map that is the same for the three cues of a
unit (the 1-s rate is the mean of four 250-ms rates, and the z-score only shifts and scales), and
Pearson R is unchanged by it. They are one reading, computed twice as a check (largest
difference printed below).
def similarity(pops, reading, nr=PRIMARY_NORM):
idx = pop_units(pops, nac.MAIN3)
out = []
for i in idx:
u = R[i]
if reading == "a":
tr = norm[nr][i][:, nac.ONSET_BIN - 8: nac.ONSET_BIN + 40].reshape(3, 12, 4).mean(2)
elif reading == "b":
kw = nac.NORM_READINGS[nr] if nr in nac.NORM_READINGS else {}
tr = nac.norm_methods(u, bin_s=1.0, **kw)[0][:, 18:30]
else:
z = nac.trial_code(u, 1.0)
tr = np.array([z[nac.CUE_OF_TRIAL == c].mean(0) for c in range(3)])[:, 18:30]
rr = [stats.pearsonr(tr[0], tr[1]).statistic if tr[0].std() > 0 and tr[1].std() > 0 else np.nan,
stats.pearsonr(tr[1], tr[2]).statistic if tr[1].std() > 0 and tr[2].std() > 0 else np.nan,
stats.pearsonr(tr[0], tr[2]).statistic if tr[0].std() > 0 and tr[2].std() > 0 else np.nan]
out.append(dict(pop=pops[i], DU=rr[0], US=rr[1], DS=rr[2]))
return pd.DataFrame(out)
sim = {}
for key, pops in partitions.items():
for rd in ("a", "b", "script"):
if key != PRIMARY and rd == "script":
continue
sim[(key, rd)] = similarity(pops, rd)
fig6-similarity-anova¶
Temporal firing similarity between cue pairs depended on population and comparison, with a population by comparison interaction.
rows = []
for (key, rd), s in sim.items():
s = s.dropna()
groups = [s[s["pop"] == p][["DU", "US", "DS"]].to_numpy() for p in nac.MAIN3]
A = nac.mixed_anova(groups)
allp = all(A[k][3] < 0.05 for k in A)
out = "reproduced" if allp else ("partially_reproduced" if A["group x level"][3] < 0.05 else "not_reproduced")
rows.append(dict(partition=key, reading=rd, n=len(s), dropped=len(sim[(key, rd)]) - len(s),
F_pop=A["group"][0], df_pop=f"{A['group'][1]},{A['group'][2]}", p_pop=A["group"][3],
F_comp=A["level"][0], p_comp=A["level"][3], F_x=A["group x level"][0],
df_x=f"{A['group x level'][1]},{A['group x level'][2]}", p_x=A["group x level"][3], outcome=out))
t6 = pd.DataFrame(rows)
print(t6.round(4).to_string(index=False))
print("paper: population F(2,169) = 3.34, p = 0.038; comparison F(2,338) = 26.26; interaction F(4,338) = 3.86, p = 0.004")
tally(t6)
d_ab = max(np.nanmax(np.abs(sim[(k, "a")][["DU", "US", "DS"]].to_numpy() - sim[(k, "b")][["DU", "US", "DS"]].to_numpy()))
for k in partitions)
print(f"largest difference in R between readings (a) and (b), any unit and partition: {d_ab:.1e}")
partition reading n dropped F_pop df_pop p_pop F_comp p_comp F_x df_x p_x outcome
N1 4 types, unc = mean of 8 trials | (i) best of 100 a 139 0 4.5717 2,136 0.0120 6.6320 0.0015 1.6136 4,272 0.1710 not_reproduced
N1 4 types, unc = mean of 8 trials | (i) best of 100 b 139 0 4.5717 2,136 0.0120 6.6320 0.0015 1.6136 4,272 0.1710 not_reproduced
N1 4 types, unc = mean of 8 trials | (ii) most frequent a 103 0 8.3897 2,100 0.0004 19.0314 0.0000 0.2452 4,200 0.9123 not_reproduced
N1 4 types, unc = mean of 8 trials | (ii) most frequent b 103 0 8.3897 2,100 0.0004 19.0314 0.0000 0.2452 4,200 0.9123 not_reproduced
N2 4 types, unc = mean of 2 type traces | (i) best of 100 a 134 0 5.5562 2,131 0.0048 7.0704 0.0010 1.7534 4,262 0.1387 not_reproduced
N2 4 types, unc = mean of 2 type traces | (i) best of 100 b 134 0 5.5562 2,131 0.0048 7.0704 0.0010 1.7534 4,262 0.1387 not_reproduced
N2 4 types, unc = mean of 2 type traces | (ii) most frequent a 162 0 5.9387 2,159 0.0033 12.0584 0.0000 2.9943 4,318 0.0190 reproduced
N2 4 types, unc = mean of 2 type traces | (ii) most frequent b 162 0 5.9387 2,159 0.0033 12.0584 0.0000 2.9943 4,318 0.0190 reproduced
N3 3 types, unc = mean of 8 trials | (i) best of 100 a 134 0 5.1135 2,131 0.0073 6.6824 0.0015 2.0982 4,262 0.0814 not_reproduced
N3 3 types, unc = mean of 8 trials | (i) best of 100 b 134 0 5.1135 2,131 0.0073 6.6824 0.0015 2.0982 4,262 0.0814 not_reproduced
N3 3 types, unc = mean of 8 trials | (ii) most frequent a 126 0 2.9101 2,123 0.0582 8.4993 0.0003 3.9013 4,246 0.0043 partially_reproduced
N3 3 types, unc = mean of 8 trials | (ii) most frequent b 126 0 2.9101 2,123 0.0582 8.4993 0.0003 3.9013 4,246 0.0043 partially_reproduced
N4 3 types, unc = mean of 2 type traces | (i) best of 100 a 141 0 9.6447 2,138 0.0001 14.3977 0.0000 3.0098 4,276 0.0187 reproduced
N4 3 types, unc = mean of 2 type traces | (i) best of 100 b 141 0 9.6447 2,138 0.0001 14.3977 0.0000 3.0098 4,276 0.0187 reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent a 162 0 5.6589 2,159 0.0042 11.9790 0.0000 2.4511 4,318 0.0461 reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent b 162 0 5.6589 2,159 0.0042 11.9790 0.0000 2.4511 4,318 0.0461 reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent script 162 0 6.2295 2,159 0.0025 17.1052 0.0000 2.9045 4,318 0.0220 reproduced
script normalization | (i) best of 100 a 148 0 3.7645 2,145 0.0255 16.1767 0.0000 4.5118 4,290 0.0015 reproduced
script normalization | (i) best of 100 b 148 0 3.7645 2,145 0.0255 16.1767 0.0000 4.5118 4,290 0.0015 reproduced
script normalization | (ii) most frequent a 145 0 1.5302 2,142 0.2200 16.6270 0.0000 5.5067 4,284 0.0003 partially_reproduced
script normalization | (ii) most frequent b 145 0 1.5302 2,142 0.2200 16.6270 0.0000 5.5067 4,284 0.0003 partially_reproduced
Hz | (i) best of 100 a 119 0 0.2271 2,116 0.7972 14.0309 0.0000 0.7237 4,232 0.5765 not_reproduced
Hz | (i) best of 100 b 119 0 0.2271 2,116 0.7972 14.0309 0.0000 0.7237 4,232 0.5765 not_reproduced
Hz | (ii) most frequent a 116 0 0.2053 2,113 0.8147 15.4072 0.0000 0.7483 4,226 0.5600 not_reproduced
Hz | (ii) most frequent b 116 0 0.2053 2,113 0.8147 15.4072 0.0000 0.7483 4,226 0.5600 not_reproduced
paper: population F(2,169) = 3.34, p = 0.038; comparison F(2,338) = 26.26; interaction F(4,338) = 3.86, p = 0.004
outcomes, fitting partitions: {'reproduced': 7} | primary: {'reproduced': 3} | alternative: {'reproduced': 2}
largest difference in R between readings (a) and (b), any unit and partition: 5.6e-16
Result: reproduced, resting on the assumed partition. Under the primary partition (162 units, none dropped) population (F(2,159) = 5.66, p = 0.004), comparison (F(2,318) = 12.0, p < 1e-4) and their interaction (F(4,318) = 2.45, p = 0.046) are significant. Readings (a) and (b) give identical R values: the 1-s normalization differs from the averaged 250-ms one by a scale and an offset per unit, which leave Pearson's R unchanged.
fig6d-thi-similarity, fig6e-de-similarity, fig6f-bv-no-similarity-difference¶
Paired t tests between comparisons within each population, at the Bonferroni level 0.05 / 9.
rows = []
for (key, rd), s in sim.items():
s = s.dropna()
row = dict(partition=key, reading=rd)
for p, short in (("Threat Inhibited", "TI"), ("Danger Excited", "DE"), ("Bidirectional Valence", "BV")):
x = s[s["pop"] == p]
for a, b in (("DU", "US"), ("DU", "DS"), ("US", "DS")):
t = stats.ttest_rel(x[a], x[b])
row[f"{short} {a}-{b}"] = (round(t.statistic, 2), float(f"{t.pvalue:.2g}"))
row[short + " n"] = len(x)
row["fig6d"] = "reproduced" if all(row[f"TI DU-{c}"][0] > 0 and row[f"TI DU-{c}"][1] < 0.05 / 9 for c in ("US", "DS")) else "not_reproduced"
row["fig6e"] = "reproduced" if all(row[f"DE DU-{c}"][0] > 0 and row[f"DE DU-{c}"][1] < 0.05 / 9 for c in ("US", "DS")) else "not_reproduced"
row["fig6f"] = "reproduced" if all(row[f"BV {c}"][1] >= 0.05 / 9 for c in ("DU-US", "DU-DS", "US-DS")) else "not_reproduced"
rows.append(row)
t6t = pd.DataFrame(rows)
print(t6t.to_string(index=False))
print("paper: TI t(25) = 3.31 and 4.11; DE t(54) = 3.24 and 4.21; BV all t < 2.1, p > 0.0056")
for c in ("fig6d", "fig6e", "fig6f"):
print(c, dict(collections.Counter(t6t[c])))
partition reading TI DU-US TI DU-DS TI US-DS TI n DE DU-US DE DU-DS DE US-DS DE n BV DU-US BV DU-DS BV US-DS BV n fig6d fig6e fig6f
N1 4 types, unc = mean of 8 trials | (i) best of 100 a (2.49, 0.018) (3.12, 0.0036) (1.19, 0.24) 36 (1.65, 0.1) (1.71, 0.093) (0.19, 0.85) 57 (0.07, 0.95) (0.87, 0.39) (0.9, 0.38) 46 not_reproduced not_reproduced reproduced
N1 4 types, unc = mean of 8 trials | (i) best of 100 b (2.49, 0.018) (3.12, 0.0036) (1.19, 0.24) 36 (1.65, 0.1) (1.71, 0.093) (0.19, 0.85) 57 (0.07, 0.95) (0.87, 0.39) (0.9, 0.38) 46 not_reproduced not_reproduced reproduced
N1 4 types, unc = mean of 8 trials | (ii) most frequent a (0.68, 0.57) (1.33, 0.31) (0.6, 0.61) 3 (3.25, 0.0024) (4.66, 0.000036) (1.72, 0.093) 40 (2.99, 0.0041) (3.33, 0.0015) (0.72, 0.47) 60 not_reproduced reproduced not_reproduced
N1 4 types, unc = mean of 8 trials | (ii) most frequent b (0.68, 0.57) (1.33, 0.31) (0.6, 0.61) 3 (3.25, 0.0024) (4.66, 0.000036) (1.72, 0.093) 40 (2.99, 0.0041) (3.33, 0.0015) (0.72, 0.47) 60 not_reproduced reproduced not_reproduced
N2 4 types, unc = mean of 2 type traces | (i) best of 100 a (2.78, 0.0089) (3.13, 0.0036) (0.92, 0.37) 35 (1.28, 0.21) (2.05, 0.046) (0.94, 0.35) 53 (0.09, 0.93) (0.75, 0.45) (0.73, 0.47) 46 not_reproduced not_reproduced reproduced
N2 4 types, unc = mean of 2 type traces | (i) best of 100 b (2.78, 0.0089) (3.13, 0.0036) (0.92, 0.37) 35 (1.28, 0.21) (2.05, 0.046) (0.94, 0.35) 53 (0.09, 0.93) (0.75, 0.45) (0.73, 0.47) 46 not_reproduced not_reproduced reproduced
N2 4 types, unc = mean of 2 type traces | (ii) most frequent a (3.33, 0.0026) (3.43, 0.002) (0.77, 0.45) 27 (2.5, 0.016) (2.98, 0.0047) (0.58, 0.57) 44 (0.92, 0.36) (1.65, 0.1) (0.95, 0.34) 91 reproduced not_reproduced reproduced
N2 4 types, unc = mean of 2 type traces | (ii) most frequent b (3.33, 0.0026) (3.43, 0.002) (0.77, 0.45) 27 (2.5, 0.016) (2.98, 0.0047) (0.58, 0.57) 44 (0.92, 0.36) (1.65, 0.1) (0.95, 0.34) 91 reproduced not_reproduced reproduced
N3 3 types, unc = mean of 8 trials | (i) best of 100 a (2.46, 0.019) (3.59, 0.001) (1.94, 0.06) 35 (1.66, 0.1) (1.66, 0.1) (0.14, 0.89) 57 (0.05, 0.96) (0.5, 0.62) (0.55, 0.58) 42 not_reproduced not_reproduced reproduced
N3 3 types, unc = mean of 8 trials | (i) best of 100 b (2.46, 0.019) (3.59, 0.001) (1.94, 0.06) 35 (1.66, 0.1) (1.66, 0.1) (0.14, 0.89) 57 (0.05, 0.96) (0.5, 0.62) (0.55, 0.58) 42 not_reproduced not_reproduced reproduced
N3 3 types, unc = mean of 8 trials | (ii) most frequent a (3.72, 0.0011) (3.89, 0.00069) (0.81, 0.42) 25 (1.24, 0.22) (2.24, 0.029) (1.23, 0.22) 60 (0.17, 0.87) (0.52, 0.61) (0.44, 0.66) 41 reproduced not_reproduced reproduced
N3 3 types, unc = mean of 8 trials | (ii) most frequent b (3.72, 0.0011) (3.89, 0.00069) (0.81, 0.42) 25 (1.24, 0.22) (2.24, 0.029) (1.23, 0.22) 60 (0.17, 0.87) (0.52, 0.61) (0.44, 0.66) 41 reproduced not_reproduced reproduced
N4 3 types, unc = mean of 2 type traces | (i) best of 100 a (3.08, 0.0047) (3.49, 0.0017) (1.1, 0.28) 28 (2.81, 0.0094) (3.78, 0.00083) (1.46, 0.16) 27 (1.23, 0.22) (1.95, 0.055) (0.89, 0.38) 86 reproduced not_reproduced reproduced
N4 3 types, unc = mean of 2 type traces | (i) best of 100 b (3.08, 0.0047) (3.49, 0.0017) (1.1, 0.28) 28 (2.81, 0.0094) (3.78, 0.00083) (1.46, 0.16) 27 (1.23, 0.22) (1.95, 0.055) (0.89, 0.38) 86 reproduced not_reproduced reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent a (3.08, 0.0047) (3.49, 0.0017) (1.1, 0.28) 28 (2.36, 0.023) (2.64, 0.011) (0.43, 0.67) 45 (1.1, 0.28) (1.81, 0.074) (0.93, 0.36) 89 reproduced not_reproduced reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent b (3.08, 0.0047) (3.49, 0.0017) (1.1, 0.28) 28 (2.36, 0.023) (2.64, 0.011) (0.43, 0.67) 45 (1.1, 0.28) (1.81, 0.074) (0.93, 0.36) 89 reproduced not_reproduced reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent script (3.27, 0.0029) (3.85, 0.00066) (1.59, 0.12) 28 (3.04, 0.004) (3.42, 0.0014) (0.56, 0.58) 45 (1.53, 0.13) (2.24, 0.028) (0.7, 0.49) 89 reproduced reproduced reproduced
script normalization | (i) best of 100 a (3.01, 0.006) (3.69, 0.0011) (1.3, 0.21) 25 (2.51, 0.017) (4.75, 0.000038) (2.13, 0.041) 34 (1.78, 0.079) (1.46, 0.15) (-0.27, 0.79) 89 not_reproduced not_reproduced reproduced
script normalization | (i) best of 100 b (3.01, 0.006) (3.69, 0.0011) (1.3, 0.21) 25 (2.51, 0.017) (4.75, 0.000038) (2.13, 0.041) 34 (1.78, 0.079) (1.46, 0.15) (-0.27, 0.79) 89 not_reproduced not_reproduced reproduced
script normalization | (ii) most frequent a (0.47, 0.64) (0.94, 0.35) (0.53, 0.6) 73 (3.36, 0.003) (5.15, 0.000042) (1.56, 0.13) 22 (4.08, 0.00017) (4.34, 0.000071) (0.67, 0.51) 50 not_reproduced reproduced not_reproduced
script normalization | (ii) most frequent b (0.47, 0.64) (0.94, 0.35) (0.53, 0.6) 73 (3.36, 0.003) (5.15, 0.000042) (1.56, 0.13) 22 (4.08, 0.00017) (4.34, 0.000071) (0.67, 0.51) 50 not_reproduced reproduced not_reproduced
Hz | (i) best of 100 a (1.18, 0.27) (1.7, 0.13) (0.6, 0.57) 9 (0.14, 0.89) (1.71, 0.099) (1.53, 0.14) 27 (3.3, 0.0014) (4.14, 0.000083) (1.63, 0.11) 83 not_reproduced not_reproduced not_reproduced
Hz | (i) best of 100 b (1.18, 0.27) (1.7, 0.13) (0.6, 0.57) 9 (0.14, 0.89) (1.71, 0.099) (1.53, 0.14) 27 (3.3, 0.0014) (4.14, 0.000083) (1.63, 0.11) 83 not_reproduced not_reproduced not_reproduced
Hz | (ii) most frequent a (1.18, 0.27) (1.7, 0.13) (0.6, 0.57) 9 (0.26, 0.79) (1.93, 0.065) (1.65, 0.11) 27 (3.52, 0.00071) (4.23, 0.000062) (1.6, 0.11) 80 not_reproduced not_reproduced not_reproduced
Hz | (ii) most frequent b (1.18, 0.27) (1.7, 0.13) (0.6, 0.57) 9 (0.26, 0.79) (1.93, 0.065) (1.65, 0.11) 27 (3.52, 0.00071) (4.23, 0.000062) (1.6, 0.11) 80 not_reproduced not_reproduced not_reproduced
paper: TI t(25) = 3.31 and 4.11; DE t(54) = 3.24 and 4.21; BV all t < 2.1, p > 0.0056
fig6d {'not_reproduced': 16, 'reproduced': 9}
fig6e {'not_reproduced': 20, 'reproduced': 5}
fig6f {'reproduced': 17, 'not_reproduced': 8}
Result (fig6d-thi-similarity): reproduced, resting on the assumed partition. Threat Inhibited danger/uncertainty R exceeds uncertainty/safety (t(27) = 3.08, p = 0.0047) and danger/safety (t(27) = 3.49, p = 0.0017), both below 0.0056.
Result (fig6e-de-similarity): not reproduced, under the assumed partition. Danger Excited danger/uncertainty R is higher than both other pairs (t(44) = 2.36, p = 0.023; t(44) = 2.64, p = 0.011) but neither passes 0.0056. With the script normalization (variant) both pass (p = 0.004 and 0.0014).
Result (fig6f-bv-no-similarity-difference): reproduced, resting on the assumed partition. No Bidirectional Valence comparison reaches 0.0056 (largest t 1.81, p = 0.074).
fig6-thi-greatest-similarity¶
Danger/uncertainty firing similarity in Threat Inhibited units exceeded that of Danger Excited and Bidirectional Valence units, and was the greatest of all populations and cue pairs.
rows = []
for (key, rd), s in sim.items():
s = s.dropna()
means = s.groupby("pop")[["DU", "US", "DS"]].mean()
ti = s[s["pop"] == "Threat Inhibited"].DU
t1 = stats.ttest_ind(ti, s[s["pop"] == "Danger Excited"].DU)
t2 = stats.ttest_ind(ti, s[s["pop"] == "Bidirectional Valence"].DU)
greatest = means.stack().idxmax() == ("Threat Inhibited", "DU")
ok = [t1.statistic > 0 and t2.statistic > 0 and t1.pvalue < lvl and t2.pvalue < lvl and greatest for lvl in (0.05, 0.05 / 9)]
rows.append(dict(partition=key, reading=rd, TI_DU=means.loc["Threat Inhibited", "DU"], max_cell=str(means.stack().idxmax()),
t_vs_DE=t1.statistic, p_vs_DE=t1.pvalue, t_vs_BV=t2.statistic, p_vs_BV=t2.pvalue,
outcome="reproduced" if any(ok) else "not_reproduced"))
t6g = pd.DataFrame(rows)
print(t6g.round(4).to_string(index=False))
tally(t6g)
partition reading TI_DU max_cell t_vs_DE p_vs_DE t_vs_BV p_vs_BV outcome
N1 4 types, unc = mean of 8 trials | (i) best of 100 a 0.4473 (np.str_('Threat Inhibited'), 'DU') 3.1486 0.0022 3.3960 0.0011 reproduced
N1 4 types, unc = mean of 8 trials | (i) best of 100 b 0.4473 (np.str_('Threat Inhibited'), 'DU') 3.1486 0.0022 3.3960 0.0011 reproduced
N1 4 types, unc = mean of 8 trials | (ii) most frequent a 0.8657 (np.str_('Threat Inhibited'), 'DU') 2.7333 0.0092 2.3316 0.0230 reproduced
N1 4 types, unc = mean of 8 trials | (ii) most frequent b 0.8657 (np.str_('Threat Inhibited'), 'DU') 2.7333 0.0092 2.3316 0.0230 reproduced
N2 4 types, unc = mean of 2 type traces | (i) best of 100 a 0.4673 (np.str_('Threat Inhibited'), 'DU') 3.4132 0.0010 3.7770 0.0003 reproduced
N2 4 types, unc = mean of 2 type traces | (i) best of 100 b 0.4673 (np.str_('Threat Inhibited'), 'DU') 3.4132 0.0010 3.7770 0.0003 reproduced
N2 4 types, unc = mean of 2 type traces | (ii) most frequent a 0.5355 (np.str_('Threat Inhibited'), 'DU') 3.6514 0.0005 4.4557 0.0000 reproduced
N2 4 types, unc = mean of 2 type traces | (ii) most frequent b 0.5355 (np.str_('Threat Inhibited'), 'DU') 3.6514 0.0005 4.4557 0.0000 reproduced
N3 3 types, unc = mean of 8 trials | (i) best of 100 a 0.4688 (np.str_('Threat Inhibited'), 'DU') 3.4695 0.0008 3.7305 0.0004 reproduced
N3 3 types, unc = mean of 8 trials | (i) best of 100 b 0.4688 (np.str_('Threat Inhibited'), 'DU') 3.4695 0.0008 3.7305 0.0004 reproduced
N3 3 types, unc = mean of 8 trials | (ii) most frequent a 0.5544 (np.str_('Threat Inhibited'), 'DU') 3.8158 0.0003 4.7344 0.0000 reproduced
N3 3 types, unc = mean of 8 trials | (ii) most frequent b 0.5544 (np.str_('Threat Inhibited'), 'DU') 3.8158 0.0003 4.7344 0.0000 reproduced
N4 3 types, unc = mean of 2 type traces | (i) best of 100 a 0.5191 (np.str_('Danger Excited'), 'DU') -0.3842 0.7024 4.2060 0.0001 not_reproduced
N4 3 types, unc = mean of 2 type traces | (i) best of 100 b 0.5191 (np.str_('Danger Excited'), 'DU') -0.3842 0.7024 4.2060 0.0001 not_reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent a 0.5191 (np.str_('Threat Inhibited'), 'DU') 3.5883 0.0006 4.2006 0.0001 reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent b 0.5191 (np.str_('Threat Inhibited'), 'DU') 3.5883 0.0006 4.2006 0.0001 reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent script 0.5505 (np.str_('Threat Inhibited'), 'DU') 3.8224 0.0003 4.7870 0.0000 reproduced
script normalization | (i) best of 100 a 0.5133 (np.str_('Threat Inhibited'), 'DU') 2.5773 0.0126 3.6216 0.0004 reproduced
script normalization | (i) best of 100 b 0.5133 (np.str_('Threat Inhibited'), 'DU') 2.5773 0.0126 3.6216 0.0004 reproduced
script normalization | (ii) most frequent a 0.1860 (np.str_('Bidirectional Valence'), 'DU') -1.7020 0.0921 -2.8263 0.0055 not_reproduced
script normalization | (ii) most frequent b 0.1860 (np.str_('Bidirectional Valence'), 'DU') -1.7020 0.0921 -2.8263 0.0055 not_reproduced
Hz | (i) best of 100 a 0.3182 (np.str_('Bidirectional Valence'), 'DU') 0.2150 0.8311 -0.1502 0.8809 not_reproduced
Hz | (i) best of 100 b 0.3182 (np.str_('Bidirectional Valence'), 'DU') 0.2150 0.8311 -0.1502 0.8809 not_reproduced
Hz | (ii) most frequent a 0.3182 (np.str_('Bidirectional Valence'), 'DU') 0.1473 0.8838 -0.2294 0.8191 not_reproduced
Hz | (ii) most frequent b 0.3182 (np.str_('Bidirectional Valence'), 'DU') 0.1473 0.8838 -0.2294 0.8191 not_reproduced
outcomes, fitting partitions: {'reproduced': 5, 'not_reproduced': 2} | primary: {'reproduced': 3} | alternative: {'reproduced': 2}
Result: reproduced, resting on the assumed partition. Threat Inhibited danger/uncertainty R (mean 0.52) is the highest of the nine population and pair means, and exceeds Danger Excited (t = 3.59, p = 0.0006) and Bidirectional Valence (t = 4.20, p = 0.0001), at either level.
fig7-tuning-curves¶
The extreme of the Threat Inhibited tuning curve was at an uncertainty assignment of 0.75, and those of Danger Excited and Bidirectional Valence units at 0.50 ...
Per unit, the 16 trials of its session; the cue regressor 1 for danger, 0 for safety and u for
the eight uncertainty trials; linear regression with a constant (Methods, Tuning curve). Per-trial
normalization readings (a), (b), (c) of the claims file, in 1-s bins. The regression readings (a)
one regression on each trial's 10-s cue mean and (b) the mean of the ten 1-s betas give the same
beta, since the beta is linear in the response; both are computed and compared. The authors'
cubeScriptPR25.m and mainAnalysis.m regress the script's per-trial normalization on the cue
regressor and the trial's suppression ratio together, and probability_1.m averages the betas
over the cue's 1-s bins (columns 3 to 12); that is shown as a variant. Per-trial readings (a) and (b) also give the same betas: they differ by a
per-trial offset (the trial's 10-s baseline minus its trial type's mean baseline) whose mean is
zero within each trial type, and the regressors (the constant and the cue pattern) are constant
within a trial type, so the offset is orthogonal to them. They are one reading; the largest
difference is printed.
U_LEVELS = (0.0, 0.25, 0.5, 0.75, 1.0)
CUE_1S = slice(20, 30)
def tuning(pops, p, reading, nr=PRIMARY_NORM, with_sr=False):
betas_a, betas_b = [], []
kw = nac.NORM_READINGS.get(nr, {})
for i in pop_units(pops, [p]):
u = R[i]
if reading == "script":
y = nac.trial_code(u, 1.0)
else:
_, sd, _ = nac.norm_methods(u, **kw)
y, _ = nac.trial_norm(u, reading, sd)
sr, _ = nac.suppression(u, "one")
ba, bb = [], []
for lv in U_LEVELS:
X = np.column_stack([nac.pattern(lv), sr]) if with_sr else nac.pattern(lv)[:, None]
ba.append(nac.ols_betas(y[:, CUE_1S].mean(1), X)[0])
bb.append(np.mean(nac.ols_betas(y[:, CUE_1S], X)[0]))
betas_a.append(ba)
betas_b.append(bb)
return np.array(betas_a), np.array(betas_b)
expected_ext = {"Threat Inhibited": 0.75, "Danger Excited": 0.5, "Bidirectional Valence": 0.5}
rows = []
extremes = {}
for key, pops in partitions.items():
for rd in ("a", "b", "c", "script"):
if rd == "script" and key != PRIMARY:
continue
row = dict(partition=key, normalization=rd)
hits = 0
for p in nac.MAIN3:
ba, bb = tuning(pops, p, rd, with_sr=(rd == "script"))
mb = np.nanmean(ba, 0)
ext = U_LEVELS[int(np.nanargmax(np.abs(mb)))]
row[p + " betas"] = np.round(mb, 3).tolist()
row[p + " extreme"] = ext
row[p + " max |a-b|"] = float(np.nanmax(np.abs(ba - bb)))
hits += ext == expected_ext[p]
extremes[(key, rd, p)] = ext
row["matches"] = hits
row["outcome"] = "reproduced" if hits == 3 else ("partially_reproduced" if hits == 2 else "not_reproduced")
rows.append(row)
t7 = pd.DataFrame(rows)
print(t7.drop(columns=[c for c in t7 if c.endswith("|a-b|")]).to_string(index=False))
print(f"largest difference between regression readings (a) and (b): {t7[[c for c in t7 if c.endswith('|a-b|')]].to_numpy().max():.2e}")
d_rd = max(np.nanmax(np.abs(np.array(t7[(t7.partition == k) & (t7.normalization == "a")][p + " betas"].iloc[0])
- np.array(t7[(t7.partition == k) & (t7.normalization == "b")][p + " betas"].iloc[0])))
for k in partitions for p in nac.MAIN3)
print(f"largest difference in mean beta between per-trial readings (a) and (b): {d_rd:.1e} (betas rounded to 0.001)")
print("paper: Threat Inhibited 0.75, Danger Excited 0.50, Bidirectional Valence 0.50")
tally(t7)
partition normalization Threat Inhibited betas Threat Inhibited extreme Danger Excited betas Danger Excited extreme Bidirectional Valence betas Bidirectional Valence extreme matches outcome
N1 4 types, unc = mean of 8 trials | (i) best of 100 a [-0.534, -0.78, -0.955, -0.918, -0.74] 0.50 [0.021, -0.003, -0.039, -0.066, -0.073] 1.00 [-0.375, -0.449, -0.448, -0.348, -0.223] 0.25 0 not_reproduced
N1 4 types, unc = mean of 8 trials | (i) best of 100 b [-0.534, -0.78, -0.955, -0.918, -0.74] 0.50 [0.021, -0.003, -0.039, -0.066, -0.073] 1.00 [-0.375, -0.449, -0.448, -0.348, -0.223] 0.25 0 not_reproduced
N1 4 types, unc = mean of 8 trials | (i) best of 100 c [-0.471, -0.64, -0.734, -0.665, -0.508] 0.50 [0.073, 0.067, 0.041, 0.006, -0.019] 0.00 [-0.215, -0.255, -0.251, -0.192, -0.12] 0.25 0 not_reproduced
N1 4 types, unc = mean of 8 trials | (ii) most frequent a [-0.828, -1.152, -1.351, -1.249, -0.973] 0.50 [0.391, 0.509, 0.558, 0.483, 0.353] 0.50 [-0.504, -0.689, -0.794, -0.723, -0.555] 0.50 2 partially_reproduced
N1 4 types, unc = mean of 8 trials | (ii) most frequent b [-0.828, -1.152, -1.351, -1.249, -0.973] 0.50 [0.391, 0.509, 0.558, 0.483, 0.353] 0.50 [-0.504, -0.689, -0.794, -0.723, -0.555] 0.50 2 partially_reproduced
N1 4 types, unc = mean of 8 trials | (ii) most frequent c [-0.594, -0.811, -0.934, -0.85, -0.652] 0.50 [0.261, 0.351, 0.399, 0.358, 0.271] 0.50 [-0.405, -0.528, -0.58, -0.503, -0.368] 0.50 2 partially_reproduced
N2 4 types, unc = mean of 2 type traces | (i) best of 100 a [-0.548, -0.801, -0.982, -0.944, -0.761] 0.50 [-0.016, -0.041, -0.068, -0.08, -0.075] 0.75 [-0.385, -0.458, -0.453, -0.347, -0.219] 0.25 0 not_reproduced
N2 4 types, unc = mean of 2 type traces | (i) best of 100 b [-0.548, -0.801, -0.982, -0.944, -0.761] 0.50 [-0.016, -0.041, -0.068, -0.08, -0.075] 0.75 [-0.385, -0.458, -0.453, -0.347, -0.219] 0.25 0 not_reproduced
N2 4 types, unc = mean of 2 type traces | (i) best of 100 c [-0.484, -0.661, -0.762, -0.693, -0.532] 0.50 [0.048, 0.037, 0.012, -0.016, -0.032] 0.00 [-0.224, -0.262, -0.255, -0.19, -0.116] 0.25 0 not_reproduced
N2 4 types, unc = mean of 2 type traces | (ii) most frequent a [-0.526, -0.817, -1.05, -1.049, -0.873] 0.50 [0.344, 0.43, 0.451, 0.372, 0.258] 0.50 [-0.248, -0.312, -0.33, -0.274, -0.191] 0.50 2 partially_reproduced
N2 4 types, unc = mean of 2 type traces | (ii) most frequent b [-0.526, -0.817, -1.05, -1.049, -0.873] 0.50 [0.344, 0.43, 0.451, 0.372, 0.258] 0.50 [-0.248, -0.312, -0.33, -0.274, -0.191] 0.50 2 partially_reproduced
N2 4 types, unc = mean of 2 type traces | (ii) most frequent c [-0.497, -0.704, -0.838, -0.785, -0.62] 0.50 [0.245, 0.313, 0.335, 0.283, 0.202] 0.50 [-0.138, -0.174, -0.184, -0.153, -0.107] 0.50 2 partially_reproduced
N3 3 types, unc = mean of 8 trials | (i) best of 100 a [-0.51, -0.762, -0.95, -0.926, -0.756] 0.50 [0.011, -0.015, -0.051, -0.075, -0.079] 1.00 [-0.408, -0.495, -0.502, -0.397, -0.261] 0.50 1 not_reproduced
N3 3 types, unc = mean of 8 trials | (i) best of 100 b [-0.51, -0.762, -0.95, -0.926, -0.756] 0.50 [0.011, -0.015, -0.051, -0.075, -0.079] 1.00 [-0.408, -0.495, -0.502, -0.397, -0.261] 0.50 1 not_reproduced
N3 3 types, unc = mean of 8 trials | (i) best of 100 c [-0.467, -0.64, -0.738, -0.673, -0.517] 0.50 [0.074, 0.067, 0.04, 0.004, -0.021] 0.00 [-0.232, -0.281, -0.284, -0.224, -0.147] 0.50 1 not_reproduced
N3 3 types, unc = mean of 8 trials | (ii) most frequent a [-0.557, -0.877, -1.139, -1.148, -0.963] 0.75 [-0.093, -0.129, -0.151, -0.139, -0.108] 0.50 [-0.423, -0.515, -0.525, -0.418, -0.277] 0.50 3 reproduced
N3 3 types, unc = mean of 8 trials | (ii) most frequent b [-0.557, -0.877, -1.139, -1.148, -0.963] 0.75 [-0.093, -0.129, -0.151, -0.139, -0.108] 0.50 [-0.423, -0.515, -0.525, -0.418, -0.277] 0.50 3 reproduced
N3 3 types, unc = mean of 8 trials | (ii) most frequent c [-0.5, -0.711, -0.851, -0.802, -0.635] 0.50 [-0.045, -0.07, -0.089, -0.088, -0.073] 0.50 [-0.241, -0.292, -0.297, -0.235, -0.155] 0.50 2 partially_reproduced
N4 3 types, unc = mean of 2 type traces | (i) best of 100 a [-0.497, -0.782, -1.013, -1.02, -0.854] 0.75 [0.487, 0.66, 0.754, 0.681, 0.519] 0.50 [-0.24, -0.302, -0.319, -0.265, -0.185] 0.50 3 reproduced
N4 3 types, unc = mean of 2 type traces | (i) best of 100 b [-0.497, -0.782, -1.013, -1.02, -0.854] 0.75 [0.487, 0.66, 0.754, 0.681, 0.519] 0.50 [-0.24, -0.302, -0.319, -0.265, -0.185] 0.50 3 reproduced
N4 3 types, unc = mean of 2 type traces | (i) best of 100 c [-0.471, -0.668, -0.797, -0.749, -0.593] 0.50 [0.411, 0.559, 0.64, 0.58, 0.443] 0.50 [-0.136, -0.178, -0.197, -0.172, -0.127] 0.50 2 partially_reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent a [-0.497, -0.782, -1.013, -1.02, -0.854] 0.75 [0.339, 0.425, 0.448, 0.371, 0.258] 0.50 [-0.259, -0.324, -0.34, -0.281, -0.195] 0.50 3 reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent b [-0.497, -0.782, -1.013, -1.02, -0.854] 0.75 [0.339, 0.425, 0.448, 0.371, 0.258] 0.50 [-0.259, -0.324, -0.34, -0.281, -0.195] 0.50 3 reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent c [-0.471, -0.668, -0.797, -0.749, -0.593] 0.50 [0.248, 0.316, 0.339, 0.287, 0.205] 0.50 [-0.148, -0.186, -0.197, -0.164, -0.115] 0.50 2 partially_reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent script [-0.039, -0.191, -0.415, -0.582, -0.545] 0.75 [0.23, 0.279, 0.284, 0.212, 0.111] 0.50 [-0.131, -0.176, -0.208, -0.181, -0.091] 0.50 3 reproduced
script normalization | (i) best of 100 a [-0.575, -0.89, -1.139, -1.135, -0.944] 0.50 [0.586, 0.733, 0.769, 0.635, 0.439] 0.50 [-0.216, -0.274, -0.293, -0.247, -0.175] 0.50 2 partially_reproduced
script normalization | (i) best of 100 b [-0.575, -0.89, -1.139, -1.135, -0.944] 0.50 [0.586, 0.733, 0.769, 0.635, 0.439] 0.50 [-0.216, -0.274, -0.293, -0.247, -0.175] 0.50 2 partially_reproduced
script normalization | (i) best of 100 c [-0.53, -0.745, -0.882, -0.823, -0.647] 0.50 [0.428, 0.539, 0.571, 0.476, 0.333] 0.50 [-0.112, -0.15, -0.17, -0.152, -0.114] 0.50 2 partially_reproduced
script normalization | (ii) most frequent a [-0.044, -0.066, -0.081, -0.078, -0.064] 0.50 [0.791, 1.023, 1.115, 0.959, 0.695] 0.50 [-0.578, -0.802, -0.938, -0.865, -0.672] 0.50 2 partially_reproduced
script normalization | (ii) most frequent b [-0.044, -0.066, -0.081, -0.078, -0.064] 0.50 [0.791, 1.023, 1.115, 0.959, 0.695] 0.50 [-0.578, -0.802, -0.938, -0.865, -0.672] 0.50 2 partially_reproduced
script normalization | (ii) most frequent c [0.029, 0.019, 0.001, -0.018, -0.028] 0.00 [0.561, 0.717, 0.772, 0.656, 0.469] 0.50 [-0.472, -0.623, -0.693, -0.609, -0.452] 0.50 2 partially_reproduced
Hz | (i) best of 100 a [0.202, 0.26, 0.282, 0.241, 0.173] 0.50 [0.212, 0.217, 0.169, 0.083, 0.013] 0.25 [-0.247, -0.345, -0.407, -0.378, -0.296] 0.50 1 not_reproduced
Hz | (i) best of 100 b [0.202, 0.26, 0.282, 0.241, 0.173] 0.50 [0.212, 0.217, 0.169, 0.083, 0.013] 0.25 [-0.247, -0.345, -0.407, -0.378, -0.296] 0.50 1 not_reproduced
Hz | (i) best of 100 c [0.238, 0.266, 0.241, 0.163, 0.083] 0.25 [0.151, 0.197, 0.217, 0.188, 0.138] 0.50 [-0.179, -0.238, -0.267, -0.236, -0.177] 0.50 2 partially_reproduced
Hz | (ii) most frequent a [0.202, 0.26, 0.282, 0.241, 0.173] 0.50 [0.241, 0.261, 0.224, 0.138, 0.058] 0.25 [-0.248, -0.347, -0.409, -0.38, -0.298] 0.50 1 not_reproduced
Hz | (ii) most frequent b [0.202, 0.26, 0.282, 0.241, 0.173] 0.50 [0.241, 0.261, 0.224, 0.138, 0.058] 0.25 [-0.248, -0.347, -0.409, -0.38, -0.298] 0.50 1 not_reproduced
Hz | (ii) most frequent c [0.238, 0.266, 0.241, 0.163, 0.083] 0.25 [0.191, 0.239, 0.25, 0.206, 0.142] 0.50 [-0.182, -0.246, -0.279, -0.25, -0.189] 0.50 2 partially_reproduced
largest difference between regression readings (a) and (b): 9.09e-16
largest difference in mean beta between per-trial readings (a) and (b): 0.0e+00 (betas rounded to 0.001)
paper: Threat Inhibited 0.75, Danger Excited 0.50, Bidirectional Valence 0.50
outcomes, fitting partitions: {'partially_reproduced': 5, 'reproduced': 5} | primary: {'reproduced': 3, 'partially_reproduced': 1} | alternative: {'partially_reproduced': 3}
Result: reproduced, resting on the assumed partition. Under per-trial normalization reading (a), and the identical reading (b), the extremes are 0.75 for Threat Inhibited, and 0.50 for Danger Excited and Bidirectional Valence, as the paper reports; the two regression readings give the same betas (largest difference 9.1e-16), and so do per-trial readings (a) and (b) (difference 0 at three decimals). The Threat Inhibited extreme is narrow: its mean betas at 0.50 and 0.75 are -1.013 and -1.020. Under reading (c) the Threat Inhibited extreme is 0.50, and on the alternative partition (N2, most frequent) it is 0.50 under all three readings (-1.050 against -1.049 under reading (a)), which gives partially reproduced there. The script's procedure (variant) gives 0.75, 0.50 and 0.50.
Fear output and exaggerated threat (fig8)¶
Per unit and 1-s bin (2 s before onset to offset, 12 bins), per-trial normalized firing over the 16 trials regressed on the trial's suppression ratio (fear output) and the cue pattern with the population's uncertainty value (0.75, 0.50, 0.50, as the criterion gives), with a constant. Readings: (a) one model with both regressors; (b) a separate model for each. Per-trial normalization readings (a), (b), (c); 0/0 suppression ratios left out (trial dropped) or set to 0, and set to 1 as the scripts do (variant). Early cue is the first 5 s, late cue the last 5 s. Units whose suppression ratio does not vary are left out. Repeated-measures ANOVA on beta, regressor by bin.
BINS12 = slice(18, 30)
def fig8(pops, p, uval, norm_reading, model, nan_reading, nr=PRIMARY_NORM):
kw = nac.NORM_READINGS.get(nr, {})
B = []
dropped = 0
for i in pop_units(pops, [p]):
u = R[i]
if norm_reading == "script":
y = nac.trial_code(u, 1.0)
else:
_, sd, _ = nac.norm_methods(u, **kw)
y, _ = nac.trial_norm(u, norm_reading, sd)
y = y[:, BINS12]
sr, _ = nac.suppression(u, nan_reading)
keep = np.isfinite(sr)
if keep.sum() < 4 or np.nanstd(sr[keep]) == 0 or not np.all(np.isfinite(y)):
dropped += 1
continue
pat = nac.pattern(uval)
if model == "joint":
b = nac.ols_betas(y[keep], np.column_stack([sr[keep], pat[keep]]))
fo, et = b[0], b[1]
else:
fo = nac.ols_betas(y[keep], sr[keep][:, None])[0]
et = nac.ols_betas(y[keep], pat[keep][:, None])[0]
if not (np.all(np.isfinite(fo)) and np.all(np.isfinite(et))):
dropped += 1
continue
B.append(np.stack([fo, et]))
return np.array(B), dropped
def fig8_stats(B, rng):
A = nac.rm_anova2(B)
early, late = slice(2, 7), slice(7, 12)
out = dict(n=len(B), F_reg=A["A"][0], df_reg=f"{A['A'][1]},{A['A'][2]}", p_reg=A["A"][3],
F_x=A["AxB"][0], df_x=f"{A['AxB'][1]},{A['AxB'][2]}", p_x=A["AxB"][3])
for w, sl in (("early", early), ("late", late)):
fo, et = B[:, 0, sl].mean(1), B[:, 1, sl].mean(1)
for k, x in (("ET", et), ("FO", fo), ("ET-FO", et - fo)):
m, lo, hi = nac.boot_ci(x, rng)
out[f"{w} {k}"] = (round(m, 3), round(lo, 3), round(hi, 3))
return out
def run_fig8(p, uval, judge, seed):
rows = []
for key, pops in partitions.items():
for nrd in ("a", "b", "c", "script"):
for model in ("joint", "separate"):
for nan_r in ("drop", "zero", "one"):
if key != PRIMARY and not (nrd == "a" and model == "joint" and nan_r == "drop"):
continue
if nrd == "script" and not (model == "joint" and nan_r == "one"):
continue
B, dropped = fig8(pops, p, uval, nrd, model, nan_r)
if len(B) < 3:
rows.append(dict(partition=key, norm=nrd, model=model, zero_over_zero=nan_r, n=len(B), outcome="too few units"))
continue
st = fig8_stats(B, np.random.default_rng(seed))
rows.append(dict(partition=key, norm=nrd, model=model, zero_over_zero=nan_r, dropped=dropped, **st, outcome=judge(st)))
t = pd.DataFrame(rows)
return t
def show8(t, cols):
print(t[["partition", "norm", "model", "zero_over_zero", "n", "dropped"] + cols + ["outcome"]].to_string(index=False))
claims_readings = t[t.norm != "script"]
tally(claims_readings, "claims-file readings")
fig8ab-thi-exaggerated-threat¶
Threat Inhibited firing signaled exaggerated threat and not fear output; exaggerated threat betas were below zero at early and late cue, and differed from fear output betas at early but not late cue.
def judge_8ab(st):
e, l, fe, fl, de, dl = (st[k] for k in ("early ET", "late ET", "early FO", "late FO", "early ET-FO", "late ET-FO"))
core = excl(e) and excl(l) and e[0] < 0 and l[0] < 0 and not excl(fe) and not excl(fl)
full = (core and st["p_x"] < 0.05 and excl(de) and not excl(dl) and abs(e[0] + 0.97) <= 0.41
and abs(l[0] + 0.47) <= 0.39 and abs(de[0] + 0.92) <= 0.6)
return "reproduced" if full else ("partially_reproduced" if core else "not_reproduced")
t8ab = run_fig8("Threat Inhibited", 0.75, judge_8ab, 8001)
show8(t8ab, ["F_x", "df_x", "p_x", "early ET", "late ET", "early FO", "late FO", "early ET-FO", "late ET-FO"])
print("paper: interaction F(11,264) = 2.32, p = 0.01; ET early -0.97 [-1.42, -0.56], late -0.47 [-0.86, -0.05]; ET-FO early -0.92 [-1.58, -0.32], late [-1.06, 0.43]")
partition norm model zero_over_zero n dropped F_x df_x p_x early ET late ET early FO late FO early ET-FO late ET-FO outcome
N1 4 types, unc = mean of 8 trials | (i) best of 100 a joint drop 35 1 1.721828 11,374 0.066756 (-1.051, -1.414, -0.712) (-0.509, -0.89, -0.184) (-0.27, -0.567, -0.011) (-0.248, -0.55, 0.1) (-0.781, -1.415, -0.238) (-0.261, -0.891, 0.318) not_reproduced
N1 4 types, unc = mean of 8 trials | (ii) most frequent a joint drop 3 0 4.039560 11,22 0.002589 (-2.197, -3.398, -1.844) (-0.66, -1.031, -0.124) (0.71, -604579485684748.0, 0.96) (-0.246, -875295600650112.25, 0.032) (-2.907, -3.925, 1108135461564957.5) (-0.414, -0.716, 1.014) partially_reproduced
N2 4 types, unc = mean of 2 type traces | (i) best of 100 a joint drop 34 1 1.919901 11,363 0.035724 (-1.078, -1.432, -0.743) (-0.515, -0.918, -0.207) (-0.221, -0.481, 0.051) (-0.224, -0.527, 0.124) (-0.857, -1.505, -0.337) (-0.291, -0.932, 0.313) reproduced
N2 4 types, unc = mean of 2 type traces | (ii) most frequent a joint drop 26 1 1.984373 11,275 0.029965 (-1.195, -1.645, -0.761) (-0.577, -1.043, -0.145) (-0.192, -0.512, 0.121) (-0.145, -0.519, 0.289) (-1.003, -1.776, -0.344) (-0.432, -1.211, 0.373) reproduced
N3 3 types, unc = mean of 8 trials | (i) best of 100 a joint drop 34 1 1.678600 11,363 0.076351 (-1.06, -1.436, -0.736) (-0.514, -0.921, -0.201) (-0.275, -0.556, -0.004) (-0.253, -0.586, 0.087) (-0.785, -1.431, -0.235) (-0.261, -0.884, 0.304) not_reproduced
N3 3 types, unc = mean of 8 trials | (ii) most frequent a joint drop 24 1 2.015583 11,253 0.027428 (-1.319, -1.751, -0.897) (-0.725, -1.237, -0.326) (-0.178, -0.499, 0.173) (-0.079, -0.436, 0.413) (-1.141, -1.827, -0.362) (-0.647, -1.5, 0.099) reproduced
N4 3 types, unc = mean of 2 type traces | (i) best of 100 a joint drop 27 1 1.884495 11,286 0.041084 (-1.146, -1.627, -0.769) (-0.573, -1.041, -0.166) (-0.171, -0.476, 0.122) (-0.124, -0.527, 0.319) (-0.975, -1.7, -0.288) (-0.449, -1.232, 0.327) reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent a joint drop 27 1 1.884495 11,286 0.041084 (-1.146, -1.627, -0.769) (-0.573, -1.041, -0.166) (-0.171, -0.476, 0.122) (-0.124, -0.527, 0.319) (-0.975, -1.7, -0.288) (-0.449, -1.232, 0.327) reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent a joint zero 28 0 2.078053 11,297 0.021784 (-1.134, -1.558, -0.738) (-0.548, -1.016, -0.179) (-0.156, -0.456, 0.118) (-0.363, -0.696, -0.088) (-0.978, -1.637, -0.371) (-0.185, -0.835, 0.455) not_reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent a joint one 27 1 1.881800 11,286 0.041437 (-1.127, -1.614, -0.737) (-0.547, -1.018, -0.153) (-0.156, -0.458, 0.14) (-0.121, -0.527, 0.313) (-0.971, -1.706, -0.273) (-0.426, -1.168, 0.353) reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent a separate drop 27 1 2.164465 11,286 0.016422 (-1.267, -1.58, -0.949) (-0.838, -1.163, -0.586) (-0.794, -1.087, -0.534) (-0.447, -0.69, -0.153) (-0.473, -0.774, -0.094) (-0.392, -0.663, -0.131) not_reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent a separate zero 28 0 2.405604 11,297 0.007121 (-1.223, -1.524, -0.913) (-0.817, -1.148, -0.572) (-0.692, -0.913, -0.454) (-0.563, -0.765, -0.32) (-0.532, -0.778, -0.269) (-0.253, -0.458, -0.025) not_reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent a separate one 27 1 2.177257 11,286 0.015730 (-1.242, -1.549, -0.928) (-0.812, -1.168, -0.562) (-0.758, -1.02, -0.505) (-0.412, -0.676, -0.081) (-0.484, -0.771, -0.116) (-0.401, -0.661, -0.132) not_reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent b joint drop 27 1 1.884495 11,286 0.041084 (-1.104, -1.536, -0.767) (-0.531, -0.974, -0.158) (-0.272, -0.586, -0.006) (-0.225, -0.588, 0.162) (-0.832, -1.536, -0.265) (-0.306, -1.031, 0.415) not_reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent b joint zero 28 0 2.078053 11,297 0.021784 (-1.097, -1.497, -0.742) (-0.511, -0.944, -0.167) (-0.172, -0.385, 0.092) (-0.379, -0.684, -0.099) (-0.925, -1.505, -0.438) (-0.132, -0.799, 0.478) not_reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent b joint one 27 1 1.881800 11,286 0.041437 (-1.072, -1.511, -0.724) (-0.492, -0.955, -0.126) (-0.268, -0.578, -0.003) (-0.233, -0.594, 0.146) (-0.803, -1.517, -0.225) (-0.259, -0.972, 0.452) not_reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent b separate drop 27 1 2.164465 11,286 0.016422 (-1.278, -1.576, -0.968) (-0.849, -1.174, -0.602) (-0.857, -1.182, -0.597) (-0.509, -0.735, -0.24) (-0.421, -0.71, 0.024) (-0.34, -0.592, -0.083) not_reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent b separate zero 28 0 2.405604 11,297 0.007121 (-1.223, -1.524, -0.913) (-0.817, -1.148, -0.572) (-0.688, -0.893, -0.451) (-0.56, -0.769, -0.328) (-0.535, -0.732, -0.327) (-0.257, -0.466, -0.04) not_reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent b separate one 27 1 2.177257 11,286 0.015730 (-1.242, -1.549, -0.928) (-0.812, -1.168, -0.562) (-0.838, -1.131, -0.594) (-0.492, -0.728, -0.217) (-0.403, -0.687, 0.025) (-0.32, -0.554, -0.069) not_reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent c joint drop 27 1 1.887654 11,286 0.040673 (-0.812, -1.164, -0.519) (-0.315, -0.631, -0.024) (-0.261, -0.497, -0.064) (-0.215, -0.485, 0.099) (-0.551, -1.077, -0.091) (-0.1, -0.634, 0.436) not_reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent c joint zero 28 0 2.028818 11,297 0.025633 (-0.797, -1.142, -0.498) (-0.291, -0.616, -0.022) (-0.185, -0.364, -0.004) (-0.339, -0.556, -0.13) (-0.612, -1.085, -0.199) (0.048, -0.452, 0.468) not_reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent c joint one 27 1 1.885800 11,286 0.040914 (-0.79, -1.147, -0.483) (-0.288, -0.6, 0.005) (-0.255, -0.478, -0.064) (-0.218, -0.486, 0.096) (-0.535, -1.072, -0.087) (-0.07, -0.601, 0.46) not_reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent c separate drop 27 1 2.253658 11,286 0.012139 (-0.988, -1.281, -0.722) (-0.599, -0.854, -0.403) (-0.693, -0.882, -0.52) (-0.386, -0.591, -0.126) (-0.295, -0.506, -0.037) (-0.213, -0.403, -0.021) not_reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent c separate zero 28 0 2.466943 11,297 0.005742 (-0.934, -1.224, -0.643) (-0.564, -0.835, -0.368) (-0.606, -0.792, -0.415) (-0.471, -0.641, -0.316) (-0.328, -0.499, -0.143) (-0.093, -0.253, 0.08) not_reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent c separate one 27 1 2.263884 11,286 0.011722 (-0.964, -1.264, -0.684) (-0.573, -0.842, -0.374) (-0.678, -0.856, -0.52) (-0.372, -0.582, -0.065) (-0.286, -0.504, -0.038) (-0.201, -0.398, -0.018) not_reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent script joint one 27 1 2.044474 11,286 0.024482 (-0.818, -1.209, -0.471) (-0.347, -0.797, 0.042) (-0.1, -0.359, 0.151) (-0.104, -0.497, 0.534) (-0.718, -1.379, -0.101) (-0.243, -1.053, 0.492) not_reproduced
script normalization | (i) best of 100 a joint drop 24 1 1.950078 11,253 0.033871 (-1.355, -1.771, -0.894) (-0.661, -1.154, -0.239) (-0.165, -0.523, 0.161) (-0.168, -0.548, 0.383) (-1.19, -1.899, -0.458) (-0.493, -1.385, 0.293) reproduced
script normalization | (ii) most frequent a joint drop 67 6 1.772685 11,726 0.054912 (-0.173, -0.353, -0.002) (-0.008, -0.188, 0.198) (0.107, -0.073, 0.303) (-0.053, -0.233, 0.123) (-0.28, -0.606, 0.046) (0.045, -0.288, 0.377) not_reproduced
Hz | (i) best of 100 a joint drop 8 1 1.580870 11,77 0.121328 (0.426, -0.211, 1.352) (-0.061, -0.741, 1.493) (0.034, -3.501, 0.718) (-0.077, -1.444, 0.752) (0.392, -0.6, 1.836) (0.016, -1.088, 1.106) not_reproduced
Hz | (ii) most frequent a joint drop 8 1 1.580870 11,77 0.121328 (0.426, -0.211, 1.352) (-0.061, -0.741, 1.493) (0.034, -3.501, 0.718) (-0.077, -1.444, 0.752) (0.392, -0.6, 1.836) (0.016, -1.088, 1.106) not_reproduced
claims-file readings, fitting partitions: {'reproduced': 4, 'not_reproduced': 16} | primary: {'reproduced': 2, 'not_reproduced': 16} | alternative: {'reproduced': 1}
paper: interaction F(11,264) = 2.32, p = 0.01; ET early -0.97 [-1.42, -0.56], late -0.47 [-0.86, -0.05]; ET-FO early -0.92 [-1.58, -0.32], late [-1.06, 0.43]
Result: reproduced, under one reading and the assumed partition. With per-trial reading (a), one model and 0/0 trials left out (27 units, 1 dropped for a constant suppression ratio), the interaction is F(11,286) = 1.88, p = 0.041; exaggerated threat betas are -1.15 [-1.63, -0.77] early and -0.57 [-1.04, -0.17] late; fear output CIs contain zero; the early difference is -0.98 [-1.70, -0.29] and the late difference CI contains zero, all within tolerance. The same holds with 0/0 set to 1. With separate models, fear output betas are themselves below zero, and the claim fails; under readings (b) and (c) the early fear output CI excludes zero. In the CI section the readings that reproduce (per-trial (a), 0/0 left out or set to 1) do so in every seed, interval form and SE; per-trial reading (b), not reproduced with this claim's seed, is reproduced in 2 to 5 of 5 seeds with 0/0 left out or set to 1, depending on the form and SE.
fig8cd-de-exaggerated-threat¶
Danger Excited firing signaled exaggerated threat and not fear output; exaggerated threat betas exceeded zero at early and late cue, and exceeded fear output betas at early but not late cue.
def judge_8cd(st):
e, l, fe, fl, de, dl = (st[k] for k in ("early ET", "late ET", "early FO", "late FO", "early ET-FO", "late ET-FO"))
core = excl(e) and excl(l) and e[0] > 0 and l[0] > 0 and not excl(fe) and not excl(fl)
full = (core and st["p_reg"] < 0.05 and excl(de) and de[0] > 0 and not excl(dl) and abs(e[0] - 0.43) <= 0.18
and abs(l[0] - 0.3) <= 0.21 and abs(de[0] - 0.39) <= 0.29)
return "reproduced" if full else ("partially_reproduced" if core else "not_reproduced")
t8cd = run_fig8("Danger Excited", 0.5, judge_8cd, 8101)
show8(t8cd, ["F_reg", "df_reg", "p_reg", "early ET", "late ET", "early FO", "late FO", "early ET-FO", "late ET-FO"])
print("paper: regressor F(1,53) = 6.64, p = 0.01; ET early 0.43 [0.22, 0.61], late 0.30 [0.06, 0.51]; ET-FO early 0.39 [0.10, 0.69], late [-0.05, 0.58]")
partition norm model zero_over_zero n dropped F_reg df_reg p_reg early ET late ET early FO late FO early ET-FO late ET-FO outcome
N1 4 types, unc = mean of 8 trials | (i) best of 100 a joint drop 53 4 0.013358 1,52 0.908432 (-0.109, -0.299, 0.093) (0.047, -0.156, 0.269) (0.057, -0.108, 0.229) (-0.049, -0.213, 0.117) (-0.166, -0.47, 0.123) (0.096, -0.231, 0.392) not_reproduced
N1 4 types, unc = mean of 8 trials | (ii) most frequent a joint drop 37 3 6.351002 1,36 0.016307 (0.606, 0.298, 0.913) (0.481, 0.194, 0.794) (0.125, -0.031, 0.312) (0.146, -0.063, 0.359) (0.481, 0.109, 0.847) (0.334, -0.061, 0.765) reproduced
N2 4 types, unc = mean of 2 type traces | (i) best of 100 a joint drop 49 4 0.020590 1,48 0.886502 (-0.153, -0.357, 0.059) (0.042, -0.16, 0.269) (0.011, -0.18, 0.184) (-0.076, -0.235, 0.1) (-0.164, -0.477, 0.157) (0.118, -0.207, 0.427) not_reproduced
N2 4 types, unc = mean of 2 type traces | (ii) most frequent a joint drop 44 0 2.705926 1,43 0.107268 (0.486, 0.179, 0.772) (0.288, 0.016, 0.588) (0.125, -0.037, 0.305) (0.094, -0.089, 0.266) (0.361, -0.06, 0.702) (0.194, -0.182, 0.549) partially_reproduced
N3 3 types, unc = mean of 8 trials | (i) best of 100 a joint drop 53 4 0.112074 1,52 0.739142 (-0.122, -0.312, 0.093) (0.044, -0.145, 0.269) (0.076, -0.09, 0.243) (-0.046, -0.204, 0.129) (-0.198, -0.526, 0.102) (0.09, -0.224, 0.413) not_reproduced
N3 3 types, unc = mean of 8 trials | (ii) most frequent a joint drop 56 4 0.123803 1,55 0.726290 (-0.25, -0.469, -0.048) (-0.009, -0.196, 0.199) (-0.025, -0.204, 0.143) (-0.147, -0.327, 0.011) (-0.224, -0.558, 0.065) (0.138, -0.191, 0.434) not_reproduced
N4 3 types, unc = mean of 2 type traces | (i) best of 100 a joint drop 26 1 5.069863 1,25 0.033379 (0.623, 0.226, 0.944) (0.62, 0.261, 1.008) (0.159, -0.046, 0.398) (0.184, -0.036, 0.431) (0.464, -0.01, 0.866) (0.436, -0.049, 0.955) partially_reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent a joint drop 45 0 2.443452 1,44 0.125181 (0.468, 0.159, 0.725) (0.28, 0.03, 0.55) (0.141, -0.026, 0.311) (0.097, -0.065, 0.272) (0.326, -0.115, 0.644) (0.183, -0.172, 0.551) partially_reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent a joint zero 45 0 3.910210 1,44 0.054279 (0.448, 0.157, 0.701) (0.307, 0.066, 0.569) (0.133, -0.066, 0.31) (0.047, -0.139, 0.253) (0.315, -0.076, 0.686) (0.261, -0.086, 0.621) partially_reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent a joint one 45 0 2.639640 1,44 0.111370 (0.444, 0.141, 0.7) (0.292, 0.037, 0.559) (0.144, -0.025, 0.313) (0.087, -0.074, 0.262) (0.299, -0.128, 0.622) (0.205, -0.148, 0.569) partially_reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent a separate drop 45 0 8.424849 1,44 0.005764 (0.587, 0.344, 0.811) (0.315, 0.104, 0.568) (0.317, 0.141, 0.481) (0.198, 0.05, 0.375) (0.27, 0.1, 0.438) (0.117, -0.031, 0.282) not_reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent a separate zero 45 0 6.746241 1,44 0.012729 (0.566, 0.317, 0.793) (0.329, 0.115, 0.583) (0.257, 0.039, 0.422) (0.147, -0.044, 0.331) (0.309, 0.107, 0.606) (0.182, 0.017, 0.428) not_reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent a separate one 45 0 8.542530 1,44 0.005461 (0.566, 0.317, 0.793) (0.329, 0.115, 0.583) (0.321, 0.131, 0.517) (0.206, 0.058, 0.377) (0.245, 0.071, 0.411) (0.123, -0.023, 0.285) not_reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent b joint drop 45 0 0.373313 1,44 0.544348 (0.395, 0.029, 0.667) (0.207, -0.067, 0.465) (0.18, 0.023, 0.379) (0.135, -0.022, 0.296) (0.215, -0.258, 0.54) (0.072, -0.269, 0.422) not_reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent b joint zero 45 0 4.749543 1,44 0.034703 (0.451, 0.157, 0.698) (0.31, 0.08, 0.56) (0.129, -0.02, 0.288) (0.044, -0.12, 0.206) (0.322, -0.069, 0.659) (0.267, -0.058, 0.588) partially_reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent b joint one 45 0 1.093775 1,44 0.301348 (0.409, 0.084, 0.668) (0.257, 0.008, 0.511) (0.177, 0.01, 0.381) (0.119, -0.036, 0.282) (0.232, -0.178, 0.549) (0.138, -0.189, 0.472) not_reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent b separate drop 45 0 3.495001 1,44 0.068218 (0.557, 0.304, 0.792) (0.285, 0.078, 0.538) (0.326, 0.149, 0.564) (0.208, 0.053, 0.385) (0.23, 0.04, 0.418) (0.078, -0.061, 0.24) not_reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent b separate zero 45 0 8.574185 1,44 0.005382 (0.566, 0.317, 0.793) (0.329, 0.115, 0.583) (0.248, 0.068, 0.392) (0.138, -0.04, 0.309) (0.318, 0.116, 0.582) (0.191, 0.043, 0.407) not_reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent b separate one 45 0 4.642310 1,44 0.036707 (0.566, 0.317, 0.793) (0.329, 0.115, 0.583) (0.328, 0.132, 0.604) (0.213, 0.052, 0.408) (0.238, 0.031, 0.433) (0.117, -0.041, 0.281) not_reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent c joint drop 45 0 0.522629 1,44 0.473548 (0.322, 0.075, 0.528) (0.175, -0.029, 0.37) (0.149, 0.04, 0.288) (0.104, -0.02, 0.233) (0.173, -0.149, 0.425) (0.071, -0.181, 0.359) not_reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent c joint zero 45 0 4.287390 1,44 0.044295 (0.358, 0.143, 0.565) (0.245, 0.05, 0.442) (0.101, 0.001, 0.221) (0.026, -0.107, 0.16) (0.257, -0.021, 0.534) (0.219, -0.03, 0.502) not_reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent c joint one 45 0 1.370464 1,44 0.248034 (0.336, 0.126, 0.549) (0.215, 0.017, 0.417) (0.144, 0.031, 0.303) (0.09, -0.034, 0.227) (0.192, -0.1, 0.445) (0.125, -0.135, 0.397) not_reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent c separate drop 45 0 1.836029 1,44 0.182333 (0.425, 0.218, 0.608) (0.212, 0.052, 0.391) (0.276, 0.146, 0.461) (0.173, 0.058, 0.3) (0.149, 0.001, 0.294) (0.039, -0.076, 0.172) not_reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent c separate zero 45 0 6.904761 1,44 0.011790 (0.433, 0.229, 0.617) (0.245, 0.084, 0.423) (0.197, 0.062, 0.304) (0.104, -0.037, 0.218) (0.236, 0.089, 0.453) (0.142, 0.016, 0.313) not_reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent c separate one 45 0 2.754027 1,44 0.104122 (0.433, 0.229, 0.617) (0.245, 0.084, 0.423) (0.276, 0.132, 0.503) (0.176, 0.062, 0.322) (0.157, -0.02, 0.307) (0.069, -0.058, 0.202) not_reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent script joint one 45 0 1.866881 1,44 0.178775 (0.339, 0.072, 0.591) (0.229, 0.018, 0.467) (0.088, -0.074, 0.243) (0.037, -0.121, 0.201) (0.251, -0.13, 0.592) (0.192, -0.118, 0.563) partially_reproduced
script normalization | (i) best of 100 a joint drop 33 1 9.615227 1,32 0.004009 (0.729, 0.418, 1.045) (0.627, 0.314, 0.955) (0.115, -0.202, 0.311) (0.017, -0.29, 0.281) (0.613, 0.225, 1.006) (0.611, 0.21, 1.01) partially_reproduced
script normalization | (ii) most frequent a joint drop 21 1 27.504803 1,20 0.000039 (1.162, 0.796, 1.473) (0.918, 0.525, 1.329) (0.052, -0.438, 0.329) (0.108, -0.413, 0.432) (1.109, 0.77, 1.496) (0.81, 0.316, 1.353) partially_reproduced
Hz | (i) best of 100 a joint drop 25 2 0.001537 1,24 0.969054 (0.041, -0.515, 0.536) (0.174, -0.209, 0.644) (0.131, -0.255, 0.401) (0.294, -0.011, 0.608) (-0.09, -0.866, 0.656) (-0.12, -0.671, 0.46) not_reproduced
Hz | (ii) most frequent a joint drop 26 1 0.060034 1,25 0.808442 (0.096, -0.492, 0.581) (0.25, -0.116, 0.654) (0.101, -0.27, 0.377) (0.292, 0.004, 0.596) (-0.004, -0.731, 0.654) (-0.041, -0.599, 0.503) not_reproduced
claims-file readings, fitting partitions: {'partially_reproduced': 6, 'not_reproduced': 14} | primary: {'partially_reproduced': 4, 'not_reproduced': 14} | alternative: {'partially_reproduced': 1}
paper: regressor F(1,53) = 6.64, p = 0.01; ET early 0.43 [0.22, 0.61], late 0.30 [0.06, 0.51]; ET-FO early 0.39 [0.10, 0.69], late [-0.05, 0.58]
Result: partially reproduced, resting on the assumed partition. With one model (45 units), exaggerated threat betas are above zero early (0.47 [0.16, 0.73]) and late (0.28 [0.03, 0.55]) and fear output CIs contain zero, but the early difference CI contains zero (0.33 [-0.12, 0.64]) under every one-model reading, and the main effect of regressor (p = 0.13 here) is significant in only two of them. With separate models the fear output betas exceed zero. In the CI section, with per-trial reading (a) and 0/0 left out, the non-reflected interval or the inner bootstrap SE gives not reproduced in 2 or 3 of 5 seeds (one of the CI conditions of the partial outcome fails); with 0/0 read as 0 or set to 1 it stays partially reproduced in every seed and form.
fig8ef-bv-exaggerated-threat¶
Bidirectional Valence firing signaled exaggerated threat and not fear output; early exaggerated threat betas were below zero while fear output betas were not, and the two differed at early but not late cue.
def judge_8ef(st):
e, fe, de, dl = (st[k] for k in ("early ET", "early FO", "early ET-FO", "late ET-FO"))
full = (st["p_reg"] < 0.05 and st["p_x"] < 0.05 and excl(e) and e[0] < 0 and excl(de) and de[0] < 0
and abs(e[0] + 0.31) <= 0.14 and abs(de[0] + 0.39) <= 0.23 and not excl(fe) and not excl(dl))
core = excl(e) and e[0] < 0 and not excl(fe)
return "reproduced" if full else ("partially_reproduced" if core else "not_reproduced")
t8ef = run_fig8("Bidirectional Valence", 0.5, judge_8ef, 8201)
show8(t8ef, ["F_reg", "p_reg", "F_x", "df_x", "p_x", "early ET", "early FO", "early ET-FO", "late ET-FO"])
print("paper: regressor F(1,85) = 6.22, p = 0.015; interaction F(11,935) = 2.56, p = 0.003; ET early -0.31 [-0.45, -0.16]; FO early [-0.05, 0.20]; ET-FO early -0.39 [-0.62, -0.12], late [-0.40, 0.08]")
partition norm model zero_over_zero n dropped F_reg p_reg F_x df_x p_x early ET early FO early ET-FO late ET-FO outcome
N1 4 types, unc = mean of 8 trials | (i) best of 100 a joint drop 41 5 10.188526 0.002751 1.166507 11,440 0.308166 (-0.566, -0.805, -0.302) (0.09, -0.184, 0.347) (-0.656, -1.1, -0.241) (-0.456, -0.801, -0.073) partially_reproduced
N1 4 types, unc = mean of 8 trials | (ii) most frequent a joint drop 57 3 10.560734 0.001956 2.183900 11,616 0.013886 (-0.857, -1.078, -0.645) (-0.266, -0.428, -0.105) (-0.592, -0.894, -0.241) (-0.256, -0.548, 0.093) not_reproduced
N2 4 types, unc = mean of 2 type traces | (i) best of 100 a joint drop 41 5 11.338156 0.001688 1.245803 11,440 0.254024 (-0.569, -0.808, -0.309) (0.092, -0.172, 0.346) (-0.661, -1.115, -0.231) (-0.502, -0.849, -0.144) partially_reproduced
N2 4 types, unc = mean of 2 type traces | (ii) most frequent a joint drop 82 9 5.743523 0.018853 1.999092 11,891 0.025704 (-0.455, -0.63, -0.287) (0.006, -0.152, 0.171) (-0.46, -0.752, -0.177) (-0.132, -0.358, 0.11) partially_reproduced
N3 3 types, unc = mean of 8 trials | (i) best of 100 a joint drop 37 5 8.296557 0.006651 1.093214 11,396 0.365126 (-0.545, -0.778, -0.269) (-0.034, -0.322, 0.201) (-0.512, -0.874, -0.049) (-0.522, -0.87, -0.131) partially_reproduced
N3 3 types, unc = mean of 8 trials | (ii) most frequent a joint drop 36 5 12.393375 0.001218 1.504788 11,385 0.127090 (-0.612, -0.819, -0.351) (0.056, -0.257, 0.317) (-0.667, -1.039, -0.233) (-0.599, -0.951, -0.247) partially_reproduced
N4 3 types, unc = mean of 2 type traces | (i) best of 100 a joint drop 79 7 5.233852 0.024861 1.946080 11,858 0.030826 (-0.447, -0.612, -0.263) (0.028, -0.13, 0.184) (-0.475, -0.751, -0.196) (-0.094, -0.344, 0.15) reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent a joint drop 80 9 5.217402 0.025047 1.809014 11,869 0.048505 (-0.466, -0.64, -0.29) (-0.009, -0.182, 0.157) (-0.456, -0.744, -0.167) (-0.122, -0.367, 0.116) partially_reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent a joint zero 85 4 4.664017 0.033652 1.304646 11,924 0.216313 (-0.434, -0.593, -0.266) (-0.065, -0.226, 0.085) (-0.369, -0.645, -0.107) (-0.108, -0.335, 0.125) partially_reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent a joint one 80 9 4.674571 0.033639 2.050427 11,869 0.021576 (-0.458, -0.633, -0.288) (0.007, -0.16, 0.168) (-0.465, -0.755, -0.171) (-0.097, -0.343, 0.144) partially_reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent a separate drop 80 9 6.199045 0.014882 2.085997 11,869 0.019072 (-0.462, -0.6, -0.31) (-0.212, -0.369, -0.073) (-0.249, -0.407, -0.091) (-0.081, -0.212, 0.054) not_reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent a separate zero 85 4 5.154846 0.025741 1.722947 11,924 0.063807 (-0.436, -0.564, -0.306) (-0.23, -0.37, -0.101) (-0.207, -0.351, -0.054) (-0.061, -0.19, 0.066) not_reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent a separate one 80 9 5.012800 0.027974 2.284591 11,869 0.009423 (-0.449, -0.59, -0.306) (-0.209, -0.36, -0.074) (-0.24, -0.388, -0.078) (-0.062, -0.196, 0.073) not_reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent b joint drop 80 9 2.013761 0.159812 1.809014 11,869 0.048505 (-0.442, -0.629, -0.268) (-0.068, -0.214, 0.07) (-0.374, -0.667, -0.132) (-0.04, -0.287, 0.193) partially_reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent b joint zero 85 4 3.430945 0.067498 1.304646 11,924 0.216313 (-0.429, -0.582, -0.275) (-0.084, -0.218, 0.04) (-0.344, -0.599, -0.112) (-0.083, -0.347, 0.154) partially_reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent b joint one 80 9 1.566095 0.214468 2.050427 11,869 0.021576 (-0.435, -0.622, -0.269) (-0.057, -0.203, 0.085) (-0.378, -0.66, -0.132) (-0.01, -0.255, 0.228) partially_reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent b separate drop 80 9 2.432774 0.122820 2.085997 11,869 0.019072 (-0.455, -0.593, -0.307) (-0.263, -0.384, -0.143) (-0.192, -0.335, -0.062) (-0.024, -0.155, 0.112) not_reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent b separate zero 85 4 3.979380 0.049303 1.722947 11,924 0.063807 (-0.436, -0.564, -0.306) (-0.249, -0.369, -0.136) (-0.187, -0.312, -0.056) (-0.042, -0.176, 0.084) not_reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent b separate one 80 9 1.744912 0.190331 2.284591 11,869 0.009423 (-0.449, -0.59, -0.306) (-0.262, -0.382, -0.145) (-0.187, -0.327, -0.05) (-0.009, -0.142, 0.133) not_reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent c joint drop 80 9 0.065215 0.799099 1.917046 11,869 0.033964 (-0.271, -0.408, -0.133) (-0.065, -0.164, 0.036) (-0.206, -0.404, -0.028) (0.071, -0.102, 0.254) partially_reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent c joint zero 85 4 0.860901 0.356145 1.341728 11,924 0.195992 (-0.265, -0.392, -0.147) (-0.065, -0.15, 0.027) (-0.2, -0.381, -0.026) (0.011, -0.176, 0.19) partially_reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent c joint one 80 9 0.013559 0.907597 2.150383 11,869 0.015220 (-0.265, -0.404, -0.133) (-0.056, -0.154, 0.047) (-0.209, -0.413, -0.028) (0.092, -0.088, 0.283) partially_reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent c separate drop 80 9 0.246352 0.621034 2.274908 11,869 0.009759 (-0.289, -0.415, -0.155) (-0.175, -0.265, -0.084) (-0.114, -0.227, -0.014) (0.031, -0.072, 0.134) not_reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent c separate zero 85 4 0.850380 0.359086 1.835732 11,924 0.044355 (-0.273, -0.38, -0.161) (-0.161, -0.244, -0.075) (-0.111, -0.208, -0.011) (0.009, -0.099, 0.104) not_reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent c separate one 80 9 0.097364 0.755839 2.509968 11,869 0.004110 (-0.284, -0.408, -0.157) (-0.174, -0.264, -0.082) (-0.11, -0.226, -0.001) (0.041, -0.067, 0.147) not_reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent script joint one 80 9 4.554530 0.035933 2.215390 11,869 0.012084 (-0.303, -0.465, -0.143) (0.086, -0.053, 0.237) (-0.389, -0.68, -0.124) (-0.119, -0.361, 0.116) reproduced
script normalization | (i) best of 100 a joint drop 81 8 3.664014 0.059175 1.866980 11,880 0.040095 (-0.368, -0.524, -0.203) (-0.003, -0.153, 0.158) (-0.365, -0.62, -0.091) (-0.124, -0.379, 0.173) partially_reproduced
script normalization | (ii) most frequent a joint drop 47 3 21.727069 0.000027 3.802545 11,506 0.000029 (-1.099, -1.355, -0.864) (-0.22, -0.402, -0.031) (-0.879, -1.268, -0.49) (-0.437, -0.752, -0.071) not_reproduced
Hz | (i) best of 100 a joint drop 75 8 1.418265 0.237495 1.433548 11,814 0.152468 (-0.434, -0.684, -0.208) (-0.11, -0.267, 0.039) (-0.324, -0.635, -0.034) (0.056, -0.21, 0.335) partially_reproduced
Hz | (ii) most frequent a joint drop 72 8 1.275027 0.262627 1.563252 11,781 0.104753 (-0.441, -0.66, -0.231) (-0.115, -0.261, 0.048) (-0.327, -0.626, -0.02) (0.061, -0.204, 0.356) partially_reproduced
claims-file readings, fitting partitions: {'partially_reproduced': 10, 'reproduced': 1, 'not_reproduced': 9} | primary: {'partially_reproduced': 9, 'not_reproduced': 9} | alternative: {'partially_reproduced': 1}
paper: regressor F(1,85) = 6.22, p = 0.015; interaction F(11,935) = 2.56, p = 0.003; ET early -0.31 [-0.45, -0.16]; FO early [-0.05, 0.20]; ET-FO early -0.39 [-0.62, -0.12], late [-0.40, 0.08]
Result: partially reproduced, resting on the assumed partition. With reading (a), one model and 0/0 trials left out (80 units, 9 dropped), the regressor effect (p = 0.025) and the interaction (p = 0.049) hold, early exaggerated threat betas are below zero (-0.47 [-0.64, -0.29]) while fear output betas are not, and the early difference (-0.46 [-0.74, -0.17]) holds with the late one containing zero; only the early exaggerated threat mean is outside its tolerance (-0.31 +- 0.14). The script's procedure (variant) meets every part (-0.30 [-0.47, -0.14]).
Reward and nose poke cessation firing (fig9, fig10)¶
Pellet feeder advances (EVT02) and nose pokes followed by at least 2 s without a poke, in the
ITI. ITI readings of the claims file: (a) the event's 4-s window outside 20 s before onset to 20 s
after offset; (b) the window overlapping no cue and no shock. Normalization readings: (i) the
event-averaged trace minus its 1-s pre-event mean, divided by the unit's SD from the cue
normalization (the primary normalization, N4); (ii) the same trace z-scored over its 16 bins. The authors' script
(cubeScriptPR25.m) takes events 18 to 2 s before onset or 14 to 28 s after it (pellets), and
18 to 2 s before onset (cessation), and z-scores per event; shown as a variant, alone and with the two normalizations of the claims file. Units with no
event are left out. Pre is the 250-ms bin before the event, post the first bin after it. The
claims-file readings subtract the mean of the 1 s before the event (bins 5 to 8 of 16), as the
Methods say ("mean of 1 s before reward delivery"); the script subtracts its bins 1 to 4, 2 to 1
s before the event (cubeScriptPR25.m lines 559 and 674, printed in the data check), and the
script variant keeps that.
The files hold nothing from about 31 to 33.5 s after one onset to 20 s before the next (data check). An event counts only when its 4-s window lies inside a recorded segment, (onset - 20, onset + 30] s, and a cessation only when its 2 s without a poke lie inside the segment; otherwise a poke just before a pause in the recording would count as a cessation, and a window would run into time with no recording. ITI reading (a) asks for a window outside (onset - 20, onset + 30], so it can hold no recorded event: it cannot be tested. The counts dropped by this rule are printed. The ITI window and the event normalization are details the Methods leave open and the authors' script settles, so the script's reading is run as a reading taken from the paper's code (author, step 1.6). The cue firing used in the correlations is the claims file's normalization.
sd_primary = np.array([nac.norm_methods(u, **nac.NORM_READINGS[PRIMARY_NORM])[1] for u in R])
# ITI reading (a, b, or the script's windows) and normalization (sd, z16, or the script's per-event z-score)
EVENT_READINGS = [("a", "sd"), ("a", "z16"), ("b", "sd"), ("b", "z16"), ("script", "sd"), ("script", "z16"), ("script", "code")]
ALT_READING = ("b", "sd") # the reading shown for partitions other than the primary one
def event_traces(kind):
out = {}
for itr, nm in EVENT_READINGS:
tr, n_ev = [], []
for i, u in enumerate(R):
if kind == "pellet":
ev = nac.iti_events_code(u["pellet"], u) if itr == "script" else nac.iti_events(u["pellet"], u, itr)
else:
ev = nac.cessations(u, "code" if itr == "script" else itr)
n_ev.append(len(ev))
tr.append(nac.event_trace(u, ev, nm, sd_primary[i]))
out[(itr, nm)] = (np.array(tr), np.array(n_ev))
return out
reward = event_traces("pellet")
cess = event_traces("cessation")
for name, d in (("reward", reward), ("cessation", cess)):
for k, (tr, n_ev) in d.items():
print(f"{name} {k}: units with events {np.sum(np.isfinite(tr[:, 0]))} of {len(tr)}, events per unit median {np.median(n_ev):.0f} (range {n_ev.min()} to {n_ev.max()})")
print("events whose window runs past a recorded segment (or cessations whose 2 s do), dropped:")
for rd in ("a", "b"):
n_all = sum(len(nac.iti_events(u["pellet"], u, rd, require_recorded=False)) for u in R)
n_rec = sum(len(nac.iti_events(u["pellet"], u, rd)) for u in R)
c_all = sum(len(nac.cessations(u, rd, require_recorded=False)) for u in R)
c_rec = sum(len(nac.cessations(u, rd)) for u in R)
print(f" ITI reading ({rd}): rewards {n_all - n_rec} of {n_all} dropped, cessations {c_all - c_rec} of {c_all} dropped")
print("the script's windows (18 to 2 s before onset, 14 to 28 s after) lie inside the segments: nothing dropped")
def has_events(tr):
return bool(np.isfinite(tr).any())
def event_anova(tr, pops):
groups = []
for p in nac.MAIN3:
x = tr[pop_units(pops, [p])]
groups.append(x[np.all(np.isfinite(x), 1)])
A = nac.mixed_anova(groups)
per = {p: nac.rm_anova1(g) for p, g in zip(nac.MAIN3, groups)}
return A, per, groups
reward ('a', 'sd'): units with events 0 of 193, events per unit median 0 (range 0 to 0)
reward ('a', 'z16'): units with events 0 of 193, events per unit median 0 (range 0 to 0)
reward ('b', 'sd'): units with events 193 of 193, events per unit median 9 (range 3 to 20)
reward ('b', 'z16'): units with events 193 of 193, events per unit median 9 (range 3 to 20)
reward ('script', 'sd'): units with events 193 of 193, events per unit median 9 (range 3 to 20)
reward ('script', 'z16'): units with events 193 of 193, events per unit median 9 (range 3 to 20)
reward ('script', 'code'): units with events 193 of 193, events per unit median 9 (range 3 to 20)
cessation ('a', 'sd'): units with events 0 of 193, events per unit median 0 (range 0 to 0)
cessation ('a', 'z16'): units with events 0 of 193, events per unit median 0 (range 0 to 0)
cessation ('b', 'sd'): units with events 193 of 193, events per unit median 67 (range 8 to 117)
cessation ('b', 'z16'): units with events 193 of 193, events per unit median 67 (range 8 to 117)
cessation ('script', 'sd'): units with events 193 of 193, events per unit median 20 (range 1 to 46)
cessation ('script', 'z16'): units with events 193 of 193, events per unit median 20 (range 1 to 46)
cessation ('script', 'code'): units with events 193 of 193, events per unit median 20 (range 1 to 46)
events whose window runs past a recorded segment (or cessations whose 2 s do), dropped:
ITI reading (a): rewards 33 of 33 dropped, cessations 306 of 306 dropped
ITI reading (b): rewards 301 of 2159 dropped, cessations 2737 of 15363 dropped the script's windows (18 to 2 s before onset, 14 to 28 s after) lie inside the segments: nothing dropped
fig9a-reward-firing¶
Around pellet feeder advance in the ITI, Bidirectional Valence units selectively increased firing after reward, while Threat Inhibited and Danger Excited units did not change firing.
rows = []
for key, pops in partitions.items():
for k, (tr, _) in reward.items():
if key != PRIMARY and k != ALT_READING:
continue
if not has_events(tr):
rows.append(dict(partition=key, reading=k, n=0, outcome="no events"))
continue
A, per, groups = event_anova(tr, pops)
ok = (A["group x level"][3] < 0.05 and per["Bidirectional Valence"][3] < 0.05
and per["Threat Inhibited"][3] >= 0.05 and per["Danger Excited"][3] >= 0.05)
rows.append(dict(partition=key, reading=k, n=sum(len(g) for g in groups),
F_bin=A["level"][0], df_bin=f"{A['level'][1]},{A['level'][2]}", p_bin=A["level"][3],
F_x=A["group x level"][0], p_x=A["group x level"][3],
**{f"{p[:2]} F,p": (round(per[p][0], 2), float(f"{per[p][3]:.2g}")) for p in nac.MAIN3},
outcome="reproduced" if ok else "not_reproduced"))
t9a = pd.DataFrame(rows)
print(t9a.round(4).to_string(index=False))
print("paper: interval F(15,2430) = 3.83; interaction F(30,2430) = 1.72, p = 0.009; BV F(15,1290) = 8.78; TI and DE F < 1.1, p > 0.4")
tally(t9a)
partition reading n F_bin df_bin p_bin F_x p_x Th F,p Da F,p Bi F,p outcome
N1 4 types, unc = mean of 8 trials | (i) best of 100 (b, sd) 139 12.2145 15,2040 0.0 2.5947 0.0000 (2.02, 0.013) (4.05, 0.0) (8.27, 0.0) not_reproduced
N1 4 types, unc = mean of 8 trials | (ii) most frequent (b, sd) 103 5.2653 15,1500 0.0 2.5421 0.0000 (1.34, 0.24) (1.25, 0.23) (7.46, 0.0) reproduced
N2 4 types, unc = mean of 2 type traces | (i) best of 100 (b, sd) 134 11.7768 15,1965 0.0 2.4390 0.0000 (1.81, 0.031) (4.22, 0.0) (7.89, 0.0) not_reproduced
N2 4 types, unc = mean of 2 type traces | (ii) most frequent (b, sd) 162 10.1016 15,2385 0.0 2.1465 0.0003 (2.69, 0.00064) (0.88, 0.59) (9.59, 0.0) not_reproduced
N3 3 types, unc = mean of 8 trials | (i) best of 100 (b, sd) 134 11.1385 15,1965 0.0 2.6001 0.0000 (2.19, 0.006) (3.81, 0.000001) (7.34, 0.0) not_reproduced
N3 3 types, unc = mean of 8 trials | (ii) most frequent (b, sd) 126 11.0385 15,1845 0.0 2.5847 0.0000 (1.46, 0.12) (4.78, 0.0) (7.17, 0.0) not_reproduced
N4 3 types, unc = mean of 2 type traces | (i) best of 100 (b, sd) 141 9.1993 15,2070 0.0 2.7663 0.0000 (3.05, 0.00011) (1.24, 0.24) (9.87, 0.0) not_reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent (a, sd) 0 NaN NaN NaN NaN NaN NaN NaN NaN no events
N4 3 types, unc = mean of 2 type traces | (ii) most frequent (a, z16) 0 NaN NaN NaN NaN NaN NaN NaN NaN no events
N4 3 types, unc = mean of 2 type traces | (ii) most frequent (b, sd) 162 10.1207 15,2385 0.0 2.3008 0.0001 (3.05, 0.00011) (0.92, 0.54) (9.51, 0.0) not_reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent (b, z16) 162 5.3617 15,2385 0.0 1.8456 0.0035 (3.33, 0.000026) (0.93, 0.53) (4.93, 0.0) not_reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent (script, sd) 162 10.0203 15,2385 0.0 2.3659 0.0000 (2.8, 0.00038) (0.9, 0.57) (9.66, 0.0) not_reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent (script, z16) 162 4.9773 15,2385 0.0 1.9006 0.0023 (2.98, 0.00015) (0.89, 0.58) (5.02, 0.0) not_reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent (script, code) 162 7.8513 15,2385 0.0 2.0491 0.0007 (2.51, 0.0014) (0.88, 0.59) (8.37, 0.0) not_reproduced
script normalization | (i) best of 100 (b, sd) 148 8.4058 15,2175 0.0 3.3717 0.0000 (1.07, 0.38) (0.59, 0.88) (11.0, 0.0) reproduced
script normalization | (ii) most frequent (b, sd) 145 8.1976 15,2130 0.0 2.9703 0.0000 (5.79, 0.0) (1.75, 0.041) (5.78, 0.0) not_reproduced
Hz | (i) best of 100 (b, sd) 119 7.4216 15,1740 0.0 2.8323 0.0000 (1.48, 0.12) (1.48, 0.11) (9.8, 0.0) reproduced
Hz | (ii) most frequent (b, sd) 116 6.9380 15,1695 0.0 3.1774 0.0000 (1.48, 0.12) (1.26, 0.22) (10.18, 0.0) reproduced
paper: interval F(15,2430) = 3.83; interaction F(30,2430) = 1.72, p = 0.009; BV F(15,1290) = 8.78; TI and DE F < 1.1, p > 0.4
outcomes, fitting partitions: {'not_reproduced': 7, 'no events': 2} | primary: {'no events': 2, 'not_reproduced': 5} | alternative: {'not_reproduced': 1}
Result: not reproduced, under the assumed partition. ITI reading (a) holds no event once an event's window must lie inside a recorded segment (33 of 33 rewards dropped), so it cannot be tested. Under ITI reading (b) with either normalization, Bidirectional Valence units change firing around reward (F(15,1320) = 9.51 with (i), 4.93 with (ii), p < 1e-4) and the population by bin interaction is significant (p = 0.0001 and 0.0035), but Threat Inhibited units also change (F = 3.05, p = 0.0001; F = 3.33, p = 3e-5); Danger Excited units do not (p 0.53 and 0.54). The same holds with the script's ITI windows, with any of the three normalizations (Threat Inhibited p 0.0014 or less).
fig9bcd-reward-pre-post¶
Bidirectional Valence firing around zero before reward rose after reward, with post exceeding pre; Threat Inhibited and Danger Excited pre and post reward firing differed neither from zero nor from each other.
def pre_post(tr, pops, rng):
out = {}
for p in nac.MAIN3:
x = tr[pop_units(pops, [p])]
x = x[np.all(np.isfinite(x), 1)]
if len(x) < 3:
for k in ("pre", "post", "post-pre"):
out[f"{p[:2]} {k}"] = (np.nan, np.nan, np.nan)
continue
for k, v in (("pre", x[:, 7]), ("post", x[:, 8]), ("post-pre", x[:, 8] - x[:, 7])):
m, lo, hi = nac.boot_ci(v, rng)
out[f"{p[:2]} {k}"] = (round(m, 3), round(lo, 3), round(hi, 3))
return out
def judge_9b(o):
bv = (not excl(o["Bi pre"]) and excl(o["Bi post"]) and o["Bi post"][0] > 0 and excl(o["Bi post-pre"])
and o["Bi post-pre"][0] > 0 and abs(o["Bi post"][0] - 0.47) <= 0.15 and abs(o["Bi post-pre"][0] - 0.42) <= 0.16)
others = not any(excl(o[f"{p} {w}"]) for p in ("Th", "Da") for w in ("pre", "post", "post-pre"))
return "reproduced" if bv and others else ("partially_reproduced" if bv else "not_reproduced")
rows = []
for key, pops in partitions.items():
for k, (tr, _) in reward.items():
if key != PRIMARY and k != ALT_READING:
continue
if not has_events(tr):
rows.append(dict(partition=key, reading=k, n=0, outcome="no events"))
continue
o = pre_post(tr, pops, np.random.default_rng(9101))
if any(np.isnan(v[0]) for v in o.values()):
rows.append(dict(partition=key, reading=k, **o, outcome="too few units"))
continue
rows.append(dict(partition=key, reading=k, **o, outcome=judge_9b(o)))
t9b = pd.DataFrame(rows)
print(t9b.to_string(index=False))
print("paper: BV pre [-0.07, 0.13], post 0.47 [0.28, 0.62], post-pre 0.42 [0.21, 0.58]; TI and DE all CIs contain zero")
tally(t9b)
partition reading Th pre Th post Th post-pre Da pre Da post Da post-pre Bi pre Bi post Bi post-pre outcome n
N1 4 types, unc = mean of 8 trials | (i) best of 100 (b, sd) (-0.058, -0.217, 0.121) (0.493, 0.01, 1.019) (0.551, 0.114, 1.068) (0.219, 0.054, 0.422) (0.827, 0.405, 1.437) (0.609, 0.195, 1.159) (0.196, -0.023, 0.449) (2.068, 1.131, 3.91) (1.872, 0.928, 3.781) not_reproduced NaN
N1 4 types, unc = mean of 8 trials | (ii) most frequent (b, sd) (-0.261, -684085494456699.875, -0.072) (0.122, -1.441, 0.678) (0.383, -1269680287995426.0, 0.751) (-0.248, -0.454, -0.039) (0.068, -0.397, 0.919) (0.317, -0.125, 1.303) (0.061, -0.098, 0.279) (1.698, 0.916, 2.945) (1.637, 0.911, 2.939) not_reproduced NaN
N2 4 types, unc = mean of 2 type traces | (i) best of 100 (b, sd) (-0.098, -0.246, 0.065) (0.495, 0.017, 1.046) (0.593, 0.184, 1.069) (0.257, 0.088, 0.458) (0.836, 0.397, 1.498) (0.58, 0.133, 1.201) (0.224, 0.008, 0.481) (2.037, 1.104, 3.876) (1.813, 0.897, 3.822) not_reproduced NaN
N2 4 types, unc = mean of 2 type traces | (ii) most frequent (b, sd) (-0.07, -0.229, 0.114) (0.615, -0.008, 1.367) (0.684, 0.119, 1.309) (0.009, -0.239, 0.252) (0.323, -0.084, 0.8) (0.315, -0.04, 0.894) (0.178, 0.017, 0.349) (1.417, 0.872, 2.273) (1.239, 0.669, 2.075) not_reproduced NaN
N3 3 types, unc = mean of 8 trials | (i) best of 100 (b, sd) (-0.043, -0.212, 0.138) (0.506, 0.065, 1.067) (0.549, 0.114, 1.085) (0.22, 0.059, 0.418) (0.819, 0.4, 1.461) (0.599, 0.175, 1.12) (0.149, -0.07, 0.439) (2.122, 1.075, 3.815) (1.973, 0.954, 4.119) not_reproduced NaN
N3 3 types, unc = mean of 8 trials | (ii) most frequent (b, sd) (-0.156, -0.311, 0.057) (0.324, -0.216, 0.972) (0.48, -0.027, 1.042) (0.235, 0.076, 0.429) (0.869, 0.446, 1.485) (0.634, 0.216, 1.165) (0.15, -0.08, 0.429) (2.184, 1.154, 3.973) (2.034, 0.934, 3.797) not_reproduced NaN
N4 3 types, unc = mean of 2 type traces | (i) best of 100 (b, sd) (-0.037, -0.204, 0.16) (0.668, 0.116, 1.347) (0.705, 0.151, 1.368) (-0.286, -0.501, -0.066) (0.023, -0.452, 1.374) (0.309, -0.165, 1.664) (0.209, 0.042, 0.373) (1.484, 0.908, 2.358) (1.275, 0.681, 2.189) not_reproduced NaN
N4 3 types, unc = mean of 2 type traces | (ii) most frequent (a, sd) NaN NaN NaN NaN NaN NaN NaN NaN NaN no events 0.0
N4 3 types, unc = mean of 2 type traces | (ii) most frequent (a, z16) NaN NaN NaN NaN NaN NaN NaN NaN NaN no events 0.0
N4 3 types, unc = mean of 2 type traces | (ii) most frequent (b, sd) (-0.037, -0.204, 0.16) (0.668, 0.116, 1.347) (0.705, 0.151, 1.368) (-0.005, -0.26, 0.227) (0.301, -0.081, 0.757) (0.306, -0.068, 0.827) (0.179, 0.021, 0.343) (1.433, 0.879, 2.479) (1.254, 0.666, 2.16) not_reproduced NaN
N4 3 types, unc = mean of 2 type traces | (ii) most frequent (b, z16) (-0.315, -0.601, 0.086) (0.581, 0.035, 1.098) (0.896, 0.322, 1.452) (-0.087, -0.393, 0.258) (0.185, -0.207, 0.617) (0.272, -0.136, 0.735) (0.122, -0.075, 0.339) (0.778, 0.47, 1.096) (0.656, 0.319, 0.993) not_reproduced NaN
N4 3 types, unc = mean of 2 type traces | (ii) most frequent (script, sd) (-0.044, -0.197, 0.154) (0.671, 0.118, 1.35) (0.715, 0.166, 1.394) (0.006, -0.254, 0.234) (0.282, -0.111, 0.729) (0.276, -0.087, 0.765) (0.176, 0.011, 0.351) (1.427, 0.879, 2.436) (1.251, 0.657, 2.148) not_reproduced NaN
N4 3 types, unc = mean of 2 type traces | (ii) most frequent (script, z16) (-0.315, -0.606, 0.101) (0.569, 0.023, 1.071) (0.883, 0.292, 1.461) (-0.073, -0.393, 0.273) (0.118, -0.263, 0.526) (0.19, -0.222, 0.618) (0.13, -0.063, 0.349) (0.783, 0.474, 1.109) (0.653, 0.315, 1.0) not_reproduced NaN
N4 3 types, unc = mean of 2 type traces | (ii) most frequent (script, code) (-0.077, -0.19, 0.109) (0.239, 0.033, 0.493) (0.316, 0.038, 0.59) (-0.032, -0.173, 0.103) (0.074, -0.083, 0.264) (0.106, -0.05, 0.303) (0.072, -0.013, 0.173) (0.463, 0.307, 0.676) (0.391, 0.196, 0.614) partially_reproduced NaN
script normalization | (i) best of 100 (b, sd) (-0.14, -0.321, 0.085) (0.136, -0.391, 0.607) (0.276, -0.222, 0.744) (-0.029, -0.242, 0.176) (-0.046, -0.427, 0.335) (-0.017, -0.326, 0.395) (0.194, 0.034, 0.358) (1.548, 1.032, 2.432) (1.354, 0.82, 2.202) not_reproduced NaN
script normalization | (ii) most frequent (b, sd) (0.242, 0.081, 0.414) (0.817, 0.464, 1.298) (0.574, 0.23, 0.992) (-0.216, -0.515, 0.037) (-0.312, -0.753, 0.173) (-0.096, -0.425, 0.405) (-0.018, -0.199, 0.235) (1.664, 0.822, 3.391) (1.681, 0.782, 3.443) not_reproduced NaN
Hz | (i) best of 100 (b, sd) (-0.016, -0.359, 0.369) (-0.122, -1.04, 0.412) (-0.106, -0.701, 0.476) (-0.215, -0.429, 0.012) (-0.025, -0.562, 0.501) (0.19, -0.196, 0.608) (0.101, -0.059, 0.267) (1.264, 0.85, 1.775) (1.164, 0.747, 1.709) not_reproduced NaN
Hz | (ii) most frequent (b, sd) (-0.016, -0.359, 0.369) (-0.122, -1.04, 0.412) (-0.106, -0.701, 0.476) (-0.269, -0.495, -0.035) (-0.202, -0.668, 0.352) (0.067, -0.258, 0.456) (0.126, -0.021, 0.309) (1.273, 0.863, 1.843) (1.147, 0.76, 1.637) not_reproduced NaN
paper: BV pre [-0.07, 0.13], post 0.47 [0.28, 0.62], post-pre 0.42 [0.21, 0.58]; TI and DE all CIs contain zero
outcomes, fitting partitions: {'not_reproduced': 6, 'no events': 2, 'partially_reproduced': 1} | primary: {'no events': 2, 'not_reproduced': 4, 'partially_reproduced': 1} | alternative: {'not_reproduced': 1}
Result: not reproduced, under the assumed partition. Under ITI reading (b), the only one with events, the Bidirectional Valence part fails with both normalizations: with (i) its pre-reward firing is above zero (0.18 [0.02, 0.34]) and its post-reward mean (1.43) is outside 0.47 +- 0.15; with (ii) the post-reward mean (0.78) and the rise (0.66) are outside their tolerances. Threat Inhibited post-reward firing and its rise exclude zero under both (post 0.67 [0.12, 1.35] and 0.58 [0.04, 1.10]; rise 0.71 [0.15, 1.37] and 0.90 [0.32, 1.45]). The script's ITI windows with the claims file's normalizations give the same pattern (Bidirectional Valence post 1.43 and 0.78). Only the script's full procedure (its windows, a baseline of 2 to 1 s before the event and a per-event z-score, which the Methods do not describe) meets the Bidirectional Valence part (pre 0.07 [-0.01, 0.17], post 0.46 [0.31, 0.68], post minus pre 0.39 [0.20, 0.61]), with Threat Inhibited post-reward CIs excluding zero (0.24 [0.03, 0.49]); that variant would be partially reproduced. The CI form, SE and seed do not change these outcomes (CI section).
fig9efg-reward-cue-correlations¶
Bidirectional Valence reward onset firing correlated positively with safety onset firing and negatively with danger firing, and the two correlations differed; ...
Reward onset firing is the post bin of the reward trace; safety onset is the first 1 s and
danger the whole 10-s cue of the normalized cue traces (the primary normalization N4; the authors' cue0onset and
cue100entire). Comparison readings: (a) Fisher r-to-z for independent correlations; (b)
Steiger's test for dependent correlations sharing a variable.
cue_on_s = norm[PRIMARY_NORM][:, 2, nac.ONSET].mean(1)
cue_whole_d = norm[PRIMARY_NORM][:, 0, nac.WHOLE_CUE].mean(1)
def reward_corr(tr, pops):
out = {}
for p in nac.MAIN3:
idx = np.array(pop_units(pops, [p]))
ok = np.isfinite(tr[idx, 8])
rw, s, d = tr[idx, 8][ok], cue_on_s[idx][ok], cue_whole_d[idx][ok]
n = len(rw)
if n < 4:
out[p] = dict(n=n, r_safety=np.nan, R2_safety=np.nan, p_safety=np.nan, r_danger=np.nan, R2_danger=np.nan,
p_danger=np.nan, fisher_p=np.nan, steiger_p=np.nan)
continue
rs, rd, rsd = stats.pearsonr(rw, s), stats.pearsonr(rw, d), stats.pearsonr(s, d).statistic
out[p] = dict(n=n, r_safety=rs.statistic, R2_safety=rs.statistic**2, p_safety=rs.pvalue, r_danger=rd.statistic,
R2_danger=rd.statistic**2, p_danger=rd.pvalue,
fisher_p=nac.fisher_independent(rs.statistic, n, rd.statistic, n)[1],
steiger_p=nac.steiger_dependent(rs.statistic, rd.statistic, rsd, n)[1])
return out
rows = []
for key, pops in partitions.items():
for k, (tr, _) in reward.items():
if key != PRIMARY and k != ALT_READING:
continue
if not has_events(tr):
rows.append(dict(partition=key, reading=k, n=0, outcome="no events"))
continue
o = reward_corr(tr, pops)
if any(o[p]["n"] < 4 for p in nac.MAIN3):
for p in nac.MAIN3:
rows.append(dict(partition=key, reading=k, pop=p, **o[p], outcome="too few units"))
continue
res = []
for cmp in ("fisher_p", "steiger_p"):
b, ti, de = o["Bidirectional Valence"], o["Threat Inhibited"], o["Danger Excited"]
bv = b["r_safety"] > 0 and b["p_safety"] < 0.05 and b["r_danger"] < 0 and b["p_danger"] < 0.05 and b[cmp] < 0.05
ti_ok = ti[cmp] >= 0.05
rest = ti["p_safety"] >= 0.05 and de["p_safety"] >= 0.05 and de["p_danger"] >= 0.05 and de[cmp] < 0.05
res.append("reproduced" if bv and ti_ok and rest else ("partially_reproduced" if bv and ti_ok or bv else "not_reproduced"))
best = "reproduced" if "reproduced" in res else ("partially_reproduced" if "partially_reproduced" in res else "not_reproduced")
for p in nac.MAIN3:
rows.append(dict(partition=key, reading=k, pop=p, **o[p], outcome=best))
t9e = pd.DataFrame(rows)
print(t9e.round(4).to_string(index=False))
print("paper: BV R2 0.08 (p = 0.006) safety, 0.12 (p = 8.4e-4) danger, Z = -3.96; TI 0.07 (p = 0.18), 0.15 (p = 0.05), Z = -0.50; DE 0.06 (p = 0.07), 0.06 (p = 0.07), Z = -2.10")
partition reading pop n r_safety R2_safety p_safety r_danger R2_danger p_danger fisher_p steiger_p outcome
N1 4 types, unc = mean of 8 trials | (i) best of 100 (b, sd) Threat Inhibited 36 -0.1940 0.0376 0.2569 -0.3453 0.1192 0.0391 0.5063 0.4698 not_reproduced
N1 4 types, unc = mean of 8 trials | (i) best of 100 (b, sd) Danger Excited 57 -0.0366 0.0013 0.7869 -0.1942 0.0377 0.1478 0.4056 0.3774 not_reproduced
N1 4 types, unc = mean of 8 trials | (i) best of 100 (b, sd) Bidirectional Valence 46 0.0717 0.0051 0.6356 -0.5471 0.2993 0.0001 0.0015 0.0014 not_reproduced
N1 4 types, unc = mean of 8 trials | (ii) most frequent (b, sd) Threat Inhibited 3 NaN NaN NaN NaN NaN NaN NaN NaN too few units
N1 4 types, unc = mean of 8 trials | (ii) most frequent (b, sd) Danger Excited 40 0.0601 0.0036 0.7124 -0.1516 0.0230 0.3503 0.3595 0.4344 too few units
N1 4 types, unc = mean of 8 trials | (ii) most frequent (b, sd) Bidirectional Valence 60 0.3288 0.1081 0.0103 -0.2100 0.0441 0.1073 0.0031 0.0046 too few units
N2 4 types, unc = mean of 2 type traces | (i) best of 100 (b, sd) Threat Inhibited 35 -0.1940 0.0376 0.2642 -0.3480 0.1211 0.0405 0.5050 0.4694 not_reproduced
N2 4 types, unc = mean of 2 type traces | (i) best of 100 (b, sd) Danger Excited 53 -0.0345 0.0012 0.8065 -0.1756 0.0308 0.2085 0.4747 0.4649 not_reproduced
N2 4 types, unc = mean of 2 type traces | (i) best of 100 (b, sd) Bidirectional Valence 46 0.0799 0.0064 0.5978 -0.5455 0.2976 0.0001 0.0013 0.0013 not_reproduced
N2 4 types, unc = mean of 2 type traces | (ii) most frequent (b, sd) Threat Inhibited 27 -0.1749 0.0306 0.3830 -0.4310 0.1858 0.0248 0.3244 0.3037 partially_reproduced
N2 4 types, unc = mean of 2 type traces | (ii) most frequent (b, sd) Danger Excited 44 0.2194 0.0482 0.1524 -0.3758 0.1412 0.0119 0.0051 0.0156 partially_reproduced
N2 4 types, unc = mean of 2 type traces | (ii) most frequent (b, sd) Bidirectional Valence 91 0.2310 0.0534 0.0276 -0.3544 0.1256 0.0006 0.0001 0.0001 partially_reproduced
N3 3 types, unc = mean of 8 trials | (i) best of 100 (b, sd) Threat Inhibited 35 -0.1886 0.0356 0.2779 -0.3603 0.1298 0.0335 0.4560 0.4075 not_reproduced
N3 3 types, unc = mean of 8 trials | (i) best of 100 (b, sd) Danger Excited 57 -0.0408 0.0017 0.7630 -0.2024 0.0410 0.1311 0.3931 0.3671 not_reproduced
N3 3 types, unc = mean of 8 trials | (i) best of 100 (b, sd) Bidirectional Valence 42 0.0634 0.0040 0.6899 -0.4987 0.2487 0.0008 0.0070 0.0039 not_reproduced
N3 3 types, unc = mean of 8 trials | (ii) most frequent (b, sd) Threat Inhibited 25 -0.1447 0.0209 0.4900 -0.6194 0.3836 0.0010 0.0551 0.0429 not_reproduced
N3 3 types, unc = mean of 8 trials | (ii) most frequent (b, sd) Danger Excited 60 -0.1021 0.0104 0.4374 -0.1765 0.0312 0.1773 0.6854 0.6769 not_reproduced
N3 3 types, unc = mean of 8 trials | (ii) most frequent (b, sd) Bidirectional Valence 41 0.0789 0.0062 0.6239 -0.4951 0.2451 0.0010 0.0067 0.0046 not_reproduced
N4 3 types, unc = mean of 2 type traces | (i) best of 100 (b, sd) Threat Inhibited 28 -0.1776 0.0315 0.3659 -0.3175 0.1008 0.0997 0.5975 0.5835 partially_reproduced
N4 3 types, unc = mean of 2 type traces | (i) best of 100 (b, sd) Danger Excited 27 0.0876 0.0077 0.6640 -0.1928 0.0372 0.3353 0.3269 0.3954 partially_reproduced
N4 3 types, unc = mean of 2 type traces | (i) best of 100 (b, sd) Bidirectional Valence 86 0.2634 0.0694 0.0143 -0.3541 0.1254 0.0008 0.0000 0.0001 partially_reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent (a, sd) NaN 0 NaN NaN NaN NaN NaN NaN NaN NaN no events
N4 3 types, unc = mean of 2 type traces | (ii) most frequent (a, z16) NaN 0 NaN NaN NaN NaN NaN NaN NaN NaN no events
N4 3 types, unc = mean of 2 type traces | (ii) most frequent (b, sd) Threat Inhibited 28 -0.1776 0.0315 0.3659 -0.3175 0.1008 0.0997 0.5975 0.5835 partially_reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent (b, sd) Danger Excited 45 0.2282 0.0521 0.1316 -0.3701 0.1369 0.0123 0.0044 0.0138 partially_reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent (b, sd) Bidirectional Valence 89 0.2336 0.0546 0.0276 -0.3512 0.1233 0.0007 0.0001 0.0002 partially_reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent (b, z16) Threat Inhibited 28 -0.2720 0.0740 0.1615 -0.4502 0.2027 0.0162 0.4664 0.4577 partially_reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent (b, z16) Danger Excited 45 0.2209 0.0488 0.1447 -0.3447 0.1188 0.0204 0.0074 0.0205 partially_reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent (b, z16) Bidirectional Valence 89 0.2296 0.0527 0.0304 -0.2489 0.0620 0.0187 0.0014 0.0023 partially_reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent (script, sd) Threat Inhibited 28 -0.2081 0.0433 0.2880 -0.3242 0.1051 0.0923 0.6580 0.6466 partially_reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent (script, sd) Danger Excited 45 0.2379 0.0566 0.1155 -0.3633 0.1320 0.0142 0.0043 0.0134 partially_reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent (script, sd) Bidirectional Valence 89 0.2398 0.0575 0.0236 -0.3526 0.1243 0.0007 0.0001 0.0001 partially_reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent (script, z16) Threat Inhibited 28 -0.3218 0.1036 0.0949 -0.4958 0.2458 0.0073 0.4578 0.4532 partially_reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent (script, z16) Danger Excited 45 0.2534 0.0642 0.0931 -0.3518 0.1238 0.0178 0.0041 0.0129 partially_reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent (script, z16) Bidirectional Valence 89 0.2324 0.0540 0.0284 -0.2464 0.0607 0.0199 0.0014 0.0022 partially_reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent (script, code) Threat Inhibited 28 -0.2270 0.0515 0.2454 -0.4028 0.1623 0.0336 0.4883 0.4762 partially_reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent (script, code) Danger Excited 45 0.2579 0.0665 0.0872 -0.3438 0.1182 0.0208 0.0044 0.0135 partially_reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent (script, code) Bidirectional Valence 89 0.2968 0.0881 0.0047 -0.3299 0.1088 0.0016 0.0000 0.0000 partially_reproduced
script normalization | (i) best of 100 (b, sd) Threat Inhibited 25 -0.2306 0.0532 0.2674 -0.5136 0.2638 0.0086 0.2698 0.2190 partially_reproduced
script normalization | (i) best of 100 (b, sd) Danger Excited 34 -0.1899 0.0361 0.2821 -0.2408 0.0580 0.1701 0.8335 0.8287 partially_reproduced
script normalization | (i) best of 100 (b, sd) Bidirectional Valence 89 0.2312 0.0534 0.0293 -0.3882 0.1507 0.0002 0.0000 0.0001 partially_reproduced
script normalization | (ii) most frequent (b, sd) Threat Inhibited 73 -0.1446 0.0209 0.2221 -0.2510 0.0630 0.0322 0.5119 0.4858 not_reproduced
script normalization | (ii) most frequent (b, sd) Danger Excited 22 -0.2493 0.0622 0.2631 -0.1444 0.0209 0.5214 0.7362 0.7328 not_reproduced
script normalization | (ii) most frequent (b, sd) Bidirectional Valence 50 0.3821 0.1460 0.0062 -0.1674 0.0280 0.2452 0.0056 0.0023 not_reproduced
Hz | (i) best of 100 (b, sd) Threat Inhibited 9 0.4866 0.2368 0.1841 0.0087 0.0001 0.9823 0.3651 0.3165 not_reproduced
Hz | (i) best of 100 (b, sd) Danger Excited 27 -0.0971 0.0094 0.6298 -0.2852 0.0813 0.1493 0.4974 0.2725 not_reproduced
Hz | (i) best of 100 (b, sd) Bidirectional Valence 83 0.1139 0.0130 0.3052 -0.1535 0.0236 0.1659 0.0887 0.0586 not_reproduced
Hz | (ii) most frequent (b, sd) Threat Inhibited 9 0.4866 0.2368 0.1841 0.0087 0.0001 0.9823 0.3651 0.3165 not_reproduced
Hz | (ii) most frequent (b, sd) Danger Excited 27 -0.0284 0.0008 0.8883 -0.2583 0.0667 0.1932 0.4137 0.1898 not_reproduced
Hz | (ii) most frequent (b, sd) Bidirectional Valence 80 0.0862 0.0074 0.4469 -0.1723 0.0297 0.1265 0.1061 0.0775 not_reproduced
paper: BV R2 0.08 (p = 0.006) safety, 0.12 (p = 8.4e-4) danger, Z = -3.96; TI 0.07 (p = 0.18), 0.15 (p = 0.05), Z = -0.50; DE 0.06 (p = 0.07), 0.06 (p = 0.07), Z = -2.10
Result: partially reproduced, resting on the assumed partition. Under ITI reading (b) with either normalization, Bidirectional Valence reward onset firing correlates positively with safety onset firing (R2 = 0.055, p = 0.028 with (i); 0.053, p = 0.030 with (ii)) and negatively with danger firing (R2 = 0.123, p = 0.0007; 0.062, p = 0.019), the two correlations differ (Fisher and Steiger p of 0.0023 or less), and Threat Inhibited shows no difference between its correlations (p 0.46 to 0.60). The Danger Excited pattern does not hold: its danger correlation is significant (p 0.012 and 0.020). The script's windows, alone or with its normalization, give the same outcome; with the script's full procedure the R2 values (0.088 and 0.109) are close to the paper's 0.08 and 0.12, and under reading (b) with (i) they are 0.055 and 0.123.
Note on the criterion's partial outcome: the claims file's text reads "partially reproduced when the Bidirectional Valence part holds and the Threat Inhibited or Danger Excited pattern of the statement does not". The table's outcome column gives "reproduced" only when the Bidirectional Valence part, the Threat Inhibited test of no difference, and the rest of the pattern all hold.
fig9hij-danger-safety-correlations¶
Danger firing correlated negatively with safety onset firing in Danger Excited and Bidirectional Valence units but not in Threat Inhibited units.
rows = []
for key, pops in partitions.items():
for nr in (list(nac.NORM_READINGS) + ["script normalization"] if key == PRIMARY else [PRIMARY_NORM]):
s_on = norm[nr][:, 2, nac.ONSET].mean(1)
d_wh = norm[nr][:, 0, nac.WHOLE_CUE].mean(1)
row = dict(partition=key, normalization=nr)
for p in nac.MAIN3:
idx = pop_units(pops, [p])
r = stats.pearsonr(d_wh[idx], s_on[idx])
row[f"{p[:2]} n"] = len(idx)
row[f"{p[:2]} r"] = r.statistic
row[f"{p[:2]} R2"] = r.statistic ** 2
row[f"{p[:2]} p"] = r.pvalue
ok = row["Da r"] < 0 and row["Da p"] < 0.05 and row["Bi r"] < 0 and row["Bi p"] < 0.05 and row["Th p"] >= 0.05
row["outcome"] = "reproduced" if ok else "not_reproduced"
rows.append(row)
t9h = pd.DataFrame(rows)
print(t9h.round(4).to_string(index=False))
print("paper: TI R2 0.06, p = 0.24; DE R2 0.25 (+-0.025), p = 1.2e-4; BV R2 0.06 (+-0.006), p = 0.015")
tally(t9h)
partition normalization Th n Th r Th R2 Th p Da n Da r Da R2 Da p Bi n Bi r Bi R2 Bi p outcome
N1 4 types, unc = mean of 8 trials | (i) best of 100 N4 3 types, unc = mean of 2 type traces 36 0.1902 0.0362 0.2665 57 0.1188 0.0141 0.3787 46 0.0312 0.0010 0.8368 not_reproduced
N1 4 types, unc = mean of 8 trials | (ii) most frequent N4 3 types, unc = mean of 2 type traces 3 0.9548 0.9117 0.1920 40 -0.3733 0.1394 0.0177 60 -0.0897 0.0081 0.4954 not_reproduced
N2 4 types, unc = mean of 2 type traces | (i) best of 100 N4 3 types, unc = mean of 2 type traces 35 0.1871 0.0350 0.2819 53 0.0486 0.0024 0.7295 46 0.0369 0.0014 0.8078 not_reproduced
N2 4 types, unc = mean of 2 type traces | (ii) most frequent N4 3 types, unc = mean of 2 type traces 27 0.1278 0.0163 0.5253 44 -0.3384 0.1145 0.0247 91 -0.1116 0.0124 0.2924 not_reproduced
N3 3 types, unc = mean of 8 trials | (i) best of 100 N4 3 types, unc = mean of 2 type traces 35 0.2268 0.0515 0.1901 57 0.1108 0.0123 0.4120 42 0.1489 0.0222 0.3465 not_reproduced
N3 3 types, unc = mean of 8 trials | (ii) most frequent N4 3 types, unc = mean of 2 type traces 25 0.1756 0.0308 0.4010 60 0.0641 0.0041 0.6265 41 0.1071 0.0115 0.5049 not_reproduced
N4 3 types, unc = mean of 2 type traces | (i) best of 100 N4 3 types, unc = mean of 2 type traces 28 0.1034 0.0107 0.6005 27 -0.3294 0.1085 0.0933 86 -0.1339 0.0179 0.2190 not_reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent N1 4 types, unc = mean of 8 trials 28 0.1894 0.0359 0.3344 45 -0.3327 0.1107 0.0255 89 -0.1052 0.0111 0.3266 not_reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent N2 4 types, unc = mean of 2 type traces 28 0.1894 0.0359 0.3344 45 -0.3327 0.1107 0.0255 89 -0.1052 0.0111 0.3266 not_reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent N3 3 types, unc = mean of 8 trials 28 0.0928 0.0086 0.6387 45 -0.3705 0.1373 0.0122 89 -0.0911 0.0083 0.3961 not_reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent N4 3 types, unc = mean of 2 type traces 28 0.1034 0.0107 0.6005 45 -0.3326 0.1106 0.0256 89 -0.0976 0.0095 0.3626 not_reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent script normalization 28 0.1527 0.0233 0.4380 45 -0.4609 0.2124 0.0014 89 -0.2484 0.0617 0.0189 reproduced
script normalization | (i) best of 100 N4 3 types, unc = mean of 2 type traces 25 0.2616 0.0684 0.2066 34 0.0787 0.0062 0.6580 89 -0.1295 0.0168 0.2264 not_reproduced
script normalization | (ii) most frequent N4 3 types, unc = mean of 2 type traces 73 0.1339 0.0179 0.2586 22 0.0458 0.0021 0.8395 50 0.1805 0.0326 0.2097 not_reproduced
Hz | (i) best of 100 N4 3 types, unc = mean of 2 type traces 9 0.2122 0.0450 0.5836 27 0.6289 0.3955 0.0004 83 0.1903 0.0362 0.0849 not_reproduced
Hz | (ii) most frequent N4 3 types, unc = mean of 2 type traces 9 0.2122 0.0450 0.5836 27 0.6177 0.3816 0.0006 80 0.1628 0.0265 0.1491 not_reproduced
paper: TI R2 0.06, p = 0.24; DE R2 0.25 (+-0.025), p = 1.2e-4; BV R2 0.06 (+-0.006), p = 0.015
outcomes, fitting partitions: {'not_reproduced': 6, 'reproduced': 1} | primary: {'not_reproduced': 4, 'reproduced': 1} | alternative: {'not_reproduced': 1}
Result: not reproduced, resting on the assumed partition. With the claims file's normalization, Danger Excited danger firing correlates negatively with safety onset firing (R2 0.11 to 0.14, p 0.01 to 0.03, below the paper's 0.25), but Bidirectional Valence firing does not (R2 0.008 to 0.011, p 0.33 to 0.40); Threat Inhibited shows no correlation (p 0.33 to 0.64). With the script normalization (variant) the pattern holds (DE R2 0.21, p = 0.001; BV R2 0.062, p = 0.019; TI p = 0.44).
fig10a-poke-cessation-anova¶
The three populations showed minimal firing changes around nose poke cessation in the ITI; there was no main effect of interval, and a population by interval interaction driven by modest Bidirectional Valence increases.
rows = []
for key, pops in partitions.items():
for k, (tr, _) in cess.items():
if key != PRIMARY and k != ALT_READING:
continue
if not has_events(tr):
rows.append(dict(partition=key, reading=k, n=0, outcome="no events"))
continue
A, per, groups = event_anova(tr, pops)
ok = A["level"][3] >= 0.05 and A["group x level"][3] < 0.05
rows.append(dict(partition=key, reading=k, n=sum(len(g) for g in groups),
F_bin=A["level"][0], df_bin=f"{A['level'][1]},{A['level'][2]}", p_bin=A["level"][3],
F_x=A["group x level"][0], df_x=f"{A['group x level'][1]},{A['group x level'][2]}", p_x=A["group x level"][3],
outcome="reproduced" if ok else "not_reproduced"))
t10a = pd.DataFrame(rows)
print(t10a.round(4).to_string(index=False))
print("paper: interval F(15,2535) = 1.58, p = 0.071; interaction F(30,2535) = 2.18, p = 2.35e-4")
tally(t10a)
partition reading n F_bin df_bin p_bin F_x df_x p_x outcome
N1 4 types, unc = mean of 8 trials | (i) best of 100 (b, sd) 139 2.5251 15,2040 0.0010 1.3307 30,2040 0.1087 not_reproduced
N1 4 types, unc = mean of 8 trials | (ii) most frequent (b, sd) 103 1.7401 15,1500 0.0381 3.3935 30,1500 0.0000 not_reproduced
N2 4 types, unc = mean of 2 type traces | (i) best of 100 (b, sd) 134 2.5481 15,1965 0.0009 1.5862 30,1965 0.0230 not_reproduced
N2 4 types, unc = mean of 2 type traces | (ii) most frequent (b, sd) 162 1.2056 15,2385 0.2593 3.0381 30,2385 0.0000 reproduced
N3 3 types, unc = mean of 8 trials | (i) best of 100 (b, sd) 134 2.2516 15,1965 0.0039 1.3330 30,1965 0.1074 not_reproduced
N3 3 types, unc = mean of 8 trials | (ii) most frequent (b, sd) 126 2.4729 15,1845 0.0013 2.8814 30,1845 0.0000 not_reproduced
N4 3 types, unc = mean of 2 type traces | (i) best of 100 (b, sd) 141 1.3702 15,2070 0.1530 4.5032 30,2070 0.0000 reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent (a, sd) 0 NaN NaN NaN NaN NaN NaN no events
N4 3 types, unc = mean of 2 type traces | (ii) most frequent (a, z16) 0 NaN NaN NaN NaN NaN NaN no events
N4 3 types, unc = mean of 2 type traces | (ii) most frequent (b, sd) 162 1.2061 15,2385 0.2589 3.0708 30,2385 0.0000 reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent (b, z16) 162 1.4321 15,2385 0.1232 2.4674 30,2385 0.0000 reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent (script, sd) 162 1.0498 15,2385 0.3996 1.7496 30,2385 0.0072 reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent (script, z16) 162 1.2096 15,2385 0.2562 1.8284 30,2385 0.0040 reproduced
N4 3 types, unc = mean of 2 type traces | (ii) most frequent (script, code) 162 0.9649 15,2385 0.4903 1.7008 30,2385 0.0103 reproduced
script normalization | (i) best of 100 (b, sd) 148 1.1304 15,2175 0.3225 4.2371 30,2175 0.0000 reproduced
script normalization | (ii) most frequent (b, sd) 145 1.0973 15,2130 0.3530 3.4697 30,2130 0.0000 reproduced
Hz | (i) best of 100 (b, sd) 119 1.2814 15,1740 0.2054 2.3627 30,1740 0.0000 reproduced
Hz | (ii) most frequent (b, sd) 116 1.1978 15,1695 0.2658 3.0867 30,1695 0.0000 reproduced
paper: interval F(15,2535) = 1.58, p = 0.071; interaction F(30,2535) = 2.18, p = 2.35e-4
outcomes, fitting partitions: {'reproduced': 7, 'no events': 2} | primary: {'no events': 2, 'reproduced': 5} | alternative: {'reproduced': 1}
Result: reproduced, resting on the assumed partition. ITI reading (a) holds no cessation inside a recorded segment (306 of 306 dropped) and cannot be tested. Under ITI reading (b) there is no effect of interval (F(15,2385) = 1.21, p = 0.26 with (i); 1.43, p = 0.12 with (ii)) and a population by interval interaction (F(30,2385) = 3.07 and 2.47, p < 1e-4). The script's windows give the same with each normalization (interval p 0.26 to 0.49, interaction p 0.004 to 0.010). Under reading (b), 2737 of 15363 candidate cessations were dropped because their 2 s without a poke ran into a pause in the recording.
fig10bcd-poke-cessation-pre-post¶
Pre and post nose poke cessation firing differed neither from zero nor from each other in Threat Inhibited and Danger Excited units; in Bidirectional Valence units both exceeded zero but did not differ.
def judge_10b(o):
others = not any(excl(o[f"{p} {w}"]) for p in ("Th", "Da") for w in ("pre", "post", "post-pre"))
bv = excl(o["Bi pre"]) and o["Bi pre"][0] > 0 and excl(o["Bi post"]) and o["Bi post"][0] > 0 and not excl(o["Bi post-pre"])
return "reproduced" if others and bv else "not_reproduced"
rows = []
for key, pops in partitions.items():
for k, (tr, _) in cess.items():
if key != PRIMARY and k != ALT_READING:
continue
if not has_events(tr):
rows.append(dict(partition=key, reading=k, n=0, outcome="no events"))
continue
o = pre_post(tr, pops, np.random.default_rng(10101))
if any(np.isnan(v[0]) for v in o.values()):
rows.append(dict(partition=key, reading=k, **o, outcome="too few units"))
continue
rows.append(dict(partition=key, reading=k, **o, outcome=judge_10b(o)))
t10b = pd.DataFrame(rows)
print(t10b.to_string(index=False))
tally(t10b)
partition reading Th pre Th post Th post-pre Da pre Da post Da post-pre Bi pre Bi post Bi post-pre outcome n
N1 4 types, unc = mean of 8 trials | (i) best of 100 (b, sd) (0.008, -0.116, 0.122) (0.01, -0.212, 0.181) (0.002, -0.217, 0.152) (0.138, 0.037, 0.264) (0.156, -0.007, 0.342) (0.018, -0.119, 0.178) (0.018, -0.088, 0.165) (0.203, -0.013, 0.422) (0.185, -0.092, 0.399) not_reproduced NaN
N1 4 types, unc = mean of 8 trials | (ii) most frequent (b, sd) (-0.056, -2829031432842913.5, 0.046) (0.306, 0.217, 396793466610806.5625) (0.362, 0.176, 1615499741404472.75) (-0.178, -0.298, -0.061) (-0.134, -0.363, 0.052) (0.044, -0.133, 0.234) (0.045, -0.065, 0.165) (0.123, -0.07, 0.285) (0.077, -0.176, 0.242) not_reproduced NaN
N2 4 types, unc = mean of 2 type traces | (i) best of 100 (b, sd) (-0.016, -0.138, 0.095) (0.007, -0.226, 0.185) (0.023, -0.188, 0.171) (0.159, 0.044, 0.299) (0.15, -0.022, 0.351) (-0.009, -0.157, 0.159) (0.03, -0.075, 0.161) (0.187, -0.022, 0.409) (0.158, -0.152, 0.371) not_reproduced NaN
N2 4 types, unc = mean of 2 type traces | (ii) most frequent (b, sd) (-0.008, -0.109, 0.095) (0.06, -0.199, 0.25) (0.067, -0.272, 0.25) (-0.071, -0.21, 0.066) (-0.054, -0.273, 0.169) (0.017, -0.186, 0.213) (0.086, -0.006, 0.196) (0.175, 0.038, 0.315) (0.089, -0.072, 0.223) not_reproduced NaN
N3 3 types, unc = mean of 8 trials | (i) best of 100 (b, sd) (0.014, -0.109, 0.125) (0.022, -0.215, 0.185) (0.008, -0.215, 0.158) (0.14, 0.036, 0.267) (0.163, 0.005, 0.362) (0.023, -0.134, 0.184) (0.002, -0.115, 0.143) (0.184, -0.058, 0.413) (0.182, -0.154, 0.414) not_reproduced NaN
N3 3 types, unc = mean of 8 trials | (ii) most frequent (b, sd) (-0.08, -0.193, 0.015) (-0.059, -0.449, 0.135) (0.021, -0.318, 0.208) (0.172, 0.069, 0.296) (0.184, 0.03, 0.356) (0.012, -0.132, 0.165) (-0.003, -0.119, 0.163) (0.23, 0.007, 0.464) (0.232, -0.085, 0.449) not_reproduced NaN
N4 3 types, unc = mean of 2 type traces | (i) best of 100 (b, sd) (0.006, -0.093, 0.109) (0.062, -0.217, 0.242) (0.055, -0.239, 0.224) (-0.133, -0.254, 0.005) (-0.095, -0.283, 0.167) (0.038, -0.115, 0.267) (0.1, -0.0, 0.208) (0.188, 0.035, 0.335) (0.087, -0.078, 0.23) not_reproduced NaN
N4 3 types, unc = mean of 2 type traces | (ii) most frequent (a, sd) NaN NaN NaN NaN NaN NaN NaN NaN NaN no events 0.0
N4 3 types, unc = mean of 2 type traces | (ii) most frequent (a, z16) NaN NaN NaN NaN NaN NaN NaN NaN NaN no events 0.0
N4 3 types, unc = mean of 2 type traces | (ii) most frequent (b, sd) (0.006, -0.093, 0.109) (0.062, -0.217, 0.242) (0.055, -0.239, 0.224) (-0.073, -0.216, 0.062) (-0.06, -0.265, 0.168) (0.014, -0.184, 0.22) (0.085, -0.009, 0.207) (0.181, 0.042, 0.331) (0.096, -0.067, 0.231) not_reproduced NaN
N4 3 types, unc = mean of 2 type traces | (ii) most frequent (b, z16) (-0.228, -0.652, 0.224) (0.05, -0.466, 0.559) (0.279, -0.247, 0.804) (-0.258, -0.671, 0.202) (-0.255, -0.6, 0.19) (0.002, -0.477, 0.484) (0.218, -0.038, 0.485) (0.439, 0.102, 0.756) (0.221, -0.096, 0.514) not_reproduced NaN
N4 3 types, unc = mean of 2 type traces | (ii) most frequent (script, sd) (0.082, -0.07, 0.247) (0.039, -0.371, 0.325) (-0.043, -0.468, 0.302) (-0.16, -0.31, 0.048) (-0.074, -0.344, 0.204) (0.086, -0.161, 0.305) (0.088, -0.026, 0.232) (0.148, -0.019, 0.317) (0.06, -0.129, 0.23) not_reproduced NaN
N4 3 types, unc = mean of 2 type traces | (ii) most frequent (script, z16) (0.122, -0.32, 0.589) (0.108, -0.319, 0.62) (-0.014, -0.584, 0.597) (-0.451, -0.748, -0.11) (-0.195, -0.518, 0.151) (0.256, -0.148, 0.642) (0.169, -0.059, 0.436) (0.315, 0.045, 0.574) (0.146, -0.128, 0.442) not_reproduced NaN
N4 3 types, unc = mean of 2 type traces | (ii) most frequent (script, code) (0.056, -0.092, 0.24) (0.013, -0.13, 0.167) (-0.043, -0.353, 0.135) (-0.119, -0.213, -0.018) (-0.077, -0.185, 0.035) (0.042, -0.075, 0.149) (0.062, -0.007, 0.153) (0.086, 0.007, 0.168) (0.025, -0.056, 0.101) not_reproduced NaN
script normalization | (i) best of 100 (b, sd) (-0.091, -0.232, 0.004) (-0.078, -0.41, 0.099) (0.013, -0.31, 0.209) (-0.111, -0.252, 0.057) (-0.141, -0.361, 0.046) (-0.03, -0.225, 0.167) (0.123, 0.032, 0.232) (0.194, 0.051, 0.339) (0.071, -0.097, 0.211) reproduced NaN
script normalization | (ii) most frequent (b, sd) (0.115, 0.02, 0.225) (0.141, 0.002, 0.309) (0.025, -0.097, 0.168) (-0.193, -0.361, -0.006) (-0.316, -0.648, -0.119) (-0.123, -0.348, 0.115) (0.009, -0.1, 0.125) (0.099, -0.134, 0.287) (0.09, -0.218, 0.279) not_reproduced NaN
Hz | (i) best of 100 (b, sd) (0.084, -0.239, 0.388) (-0.034, -1.256, 0.387) (-0.118, -0.775, 0.266) (-0.13, -0.265, 0.025) (-0.021, -0.222, 0.213) (0.109, -0.043, 0.29) (0.044, -0.04, 0.146) (0.165, 0.012, 0.291) (0.121, -0.012, 0.243) not_reproduced NaN
Hz | (ii) most frequent (b, sd) (0.084, -0.239, 0.388) (-0.034, -1.256, 0.387) (-0.118, -0.775, 0.266) (-0.177, -0.309, -0.026) (-0.123, -0.311, 0.091) (0.054, -0.096, 0.21) (0.059, -0.028, 0.165) (0.174, 0.031, 0.313) (0.115, -0.014, 0.241) not_reproduced NaN
outcomes, fitting partitions: {'not_reproduced': 7, 'no events': 2} | primary: {'no events': 2, 'not_reproduced': 5} | alternative: {'not_reproduced': 1}
Result: not reproduced, under the assumed partition. Threat Inhibited and Danger Excited pre, post and difference CIs contain zero under ITI reading (b) with either normalization, and the Bidirectional Valence post CI excludes zero above it (0.18 [0.04, 0.33] with (i); 0.44 [0.10, 0.76] with (ii)), but the Bidirectional Valence pre CI contains zero (0.085 [-0.009, 0.207]; 0.218 [-0.038, 0.485]). With the script's windows the Bidirectional Valence pre CI also contains zero under every normalization. The CI form, SE and seed do not change it (CI section).
fig10efg-poke-cessation-cue-unrelated¶
Nose poke cessation firing was unrelated to safety onset and danger cue firing in all three populations ...
Result: not reproduced, resting on the assumed partition. Under ITI reading (b) Danger Excited cessation firing correlates with danger cue firing (R2 = 0.10, p = 0.034 with (i); 0.22, p = 0.0012 with (ii)); the other correlations have p of 0.16 or more. The script's windows give the same with every normalization (Danger Excited danger p 0.001 to 0.034). Reading (a) holds no event inside a recorded segment and cannot be tested.
tables = {"fig4ab-thi-threat-firing": t4ab, "fig4b-thi-danger-equals-uncertainty": t4b, "fig4cd-de-danger-firing": t4cd,
"fig4ef-bv-danger-decrease": t4ef, "fig5ab-the-onset": t5ab, "fig5cd-ns-nonselective": t5cd,
"fig6-similarity-anova": t6, "fig6-thi-greatest-similarity": t6g, "fig7-tuning-curves": t7,
"fig8ab-thi-exaggerated-threat": t8ab[t8ab.norm != "script"], "fig8cd-de-exaggerated-threat": t8cd[t8cd.norm != "script"],
"fig8ef-bv-exaggerated-threat": t8ef[t8ef.norm != "script"],
"fig9a-reward-firing": t9a, "fig9bcd-reward-pre-post": t9b,
"fig9efg-reward-cue-correlations": t9e.drop_duplicates(["partition", "reading"]), "fig9hij-danger-safety-correlations": t9h,
"fig10a-poke-cessation-anova": t10a, "fig10bcd-poke-cessation-pre-post": t10b,
"fig10efg-poke-cessation-cue-unrelated": t10e.drop_duplicates(["partition", "reading"])}
rows = []
for claim, t in tables.items():
def outs(key, t=t):
s = t[t.partition == key]
if "normalization" in s and key == PRIMARY:
s = s[s.normalization != "script normalization"]
return dict(sorted(collections.Counter(s.outcome).items()))
rows.append(dict(claim=claim, primary=outs(PRIMARY), alternative=outs(ALT)))
with pd.option_context("display.max_colwidth", 90):
print(pd.DataFrame(rows).to_string(index=False))
claim primary alternative
fig4ab-thi-threat-firing {'partially_reproduced': 4} {'partially_reproduced': 1}
fig4b-thi-danger-equals-uncertainty {'reproduced': 4} {'reproduced': 1}
fig4cd-de-danger-firing {'partially_reproduced': 4} {'partially_reproduced': 1}
fig4ef-bv-danger-decrease {'partially_reproduced': 4} {'partially_reproduced': 1}
fig5ab-the-onset {'not_reproduced': 4} {'reproduced': 1}
fig5cd-ns-nonselective {'not_reproduced': 4} {'not_reproduced': 1}
fig6-similarity-anova {'reproduced': 3} {'reproduced': 2}
fig6-thi-greatest-similarity {'reproduced': 3} {'reproduced': 2}
fig7-tuning-curves {'partially_reproduced': 1, 'reproduced': 3} {'partially_reproduced': 3}
fig8ab-thi-exaggerated-threat {'not_reproduced': 16, 'reproduced': 2} {'reproduced': 1}
fig8cd-de-exaggerated-threat {'not_reproduced': 14, 'partially_reproduced': 4} {'partially_reproduced': 1}
fig8ef-bv-exaggerated-threat {'not_reproduced': 9, 'partially_reproduced': 9} {'partially_reproduced': 1}
fig9a-reward-firing {'no events': 2, 'not_reproduced': 5} {'not_reproduced': 1}
fig9bcd-reward-pre-post {'no events': 2, 'not_reproduced': 4, 'partially_reproduced': 1} {'not_reproduced': 1}
fig9efg-reward-cue-correlations {'no events': 2, 'partially_reproduced': 5} {'partially_reproduced': 1}
fig9hij-danger-safety-correlations {'not_reproduced': 4} {'not_reproduced': 1}
fig10a-poke-cessation-anova {'no events': 2, 'reproduced': 5} {'reproduced': 1}
fig10bcd-poke-cessation-pre-post {'no events': 2, 'not_reproduced': 5} {'not_reproduced': 1}
fig10efg-poke-cessation-cue-unrelated {'no events': 2, 'not_reproduced': 5} {'not_reproduced': 1}
Primary and alternative partition¶
The primary partition is the claims-file partition whose centroids best match the five patterns (smallest cosine 0.79, N4 most frequent); the next best (0.77, N2 most frequent) is nearly as good. The outcomes of every population claim on the two, read from the tables above (for each, the rows of that partition: under every normalization for the primary partition, under the primary normalization for the alternative).
CI_CONFIGS = [(False, "analytic"), (True, "analytic"), (False, "boot"), (True, "boot")]
CI_SEEDS = range(5)
def ci_robustness(claim, reading, run):
"""run(rng) -> outcome, repeated under each interval form, SE and seed."""
rows = []
for mir, se in CI_CONFIGS:
nac.CI_MIRRORED, nac.CI_SE = mir, se
try:
outs = [run(np.random.default_rng(70000 + s)) for s in CI_SEEDS]
finally:
nac.CI_MIRRORED, nac.CI_SE = False, "analytic"
rows.append(dict(claim=claim, reading=reading, interval="non-reflected" if mir else "reflected", se=se,
outcomes=dict(sorted(collections.Counter(outs).items()))))
return rows
def judge_1g(o):
cis = o["D-U excl0"] and o["U-S excl0"] and o["D-S excl0"]
within = abs(o["D-U"] - 0.21) <= 0.05 and abs(o["U-S"] - 0.47) <= 0.12 and abs(o["D-S"] - 0.69) <= 0.19
if o["p"] < 0.05 and cis:
return "reproduced" if within else "partially_reproduced"
return "not_reproduced"
t_start = time.time()
ci_rows = []
for sl, S in session_sets.items():
for nl, nrd in nan_readings.items():
beh = behavior(S, nrd)
ci_rows += ci_robustness("fig1g-discrimination", f"{sl[:3]} sessions, 0/0 {nl}", lambda rng: judge_1g(fig1g(beh, rng)))
for claim, p, judge in (("fig4ab-thi-threat-firing", "Threat Inhibited", judge_4ab),
("fig4b-thi-danger-equals-uncertainty", "Threat Inhibited", judge_4b),
("fig4cd-de-danger-firing", "Danger Excited", judge_4cd),
("fig4ef-bv-danger-decrease", "Bidirectional Valence",
lambda st: judge_4ef(st, 100 * np.mean(prim == "Bidirectional Valence"))),
("fig5ab-the-onset", "Threat Excited", judge_5ab),
("fig5cd-ns-nonselective", "Non-Selective", judge_5cd)):
for nr in nac.NORM_READINGS:
tr = pop_traces(prim, p, nr)
ci_rows += ci_robustness(claim, nr[:2], lambda rng: judge(cue_stats(tr, rng)))
for claim, p, uval, judge in (("fig8ab-thi-exaggerated-threat", "Threat Inhibited", 0.75, judge_8ab),
("fig8cd-de-exaggerated-threat", "Danger Excited", 0.5, judge_8cd),
("fig8ef-bv-exaggerated-threat", "Bidirectional Valence", 0.5, judge_8ef)):
for nrd in ("a", "b", "c"):
for nan_r in ("drop", "zero", "one"):
B, _ = fig8(prim, p, uval, nrd, "joint", nan_r)
ci_rows += ci_robustness(claim, f"per-trial ({nrd}), joint, 0/0 {nan_r}", lambda rng: judge(fig8_stats(B, rng)))
for claim, d, judge in (("fig9bcd-reward-pre-post", reward, judge_9b), ("fig10bcd-poke-cessation-pre-post", cess, judge_10b)):
for k in (("b", "sd"), ("b", "z16"), ("script", "code")):
tr = d[k][0]
ci_rows += ci_robustness(claim, str(k), lambda rng: judge(pre_post(tr, prim, rng)))
t_ci = pd.DataFrame(ci_rows)
t_ci["config"] = t_ci.interval + ", " + t_ci.se
wide = t_ci.pivot_table(index=["claim", "reading"], columns="config", values="outcomes", aggfunc="first", sort=False)
with pd.option_context("display.max_colwidth", 60):
print(wide.to_string())
print(f"({time.time() - t_start:.0f} s)")
config reflected, analytic non-reflected, analytic reflected, boot non-reflected, boot
claim reading
fig1g-discrimination (a) sessions, 0/0 drop {'not_reproduced': 5} {'reproduced': 5} {'not_reproduced': 5} {'reproduced': 5}
(a) sessions, 0/0 0 {'not_reproduced': 5} {'reproduced': 5} {'not_reproduced': 5} {'reproduced': 5}
(a) sessions, 0/0 1 (script) {'not_reproduced': 5} {'reproduced': 5} {'not_reproduced': 5} {'reproduced': 5}
(b) sessions, 0/0 drop {'not_reproduced': 5} {'reproduced': 5} {'not_reproduced': 5} {'reproduced': 5}
(b) sessions, 0/0 0 {'not_reproduced': 2, 'reproduced': 3} {'reproduced': 5} {'not_reproduced': 3, 'reproduced': 2} {'reproduced': 5}
(b) sessions, 0/0 1 (script) {'not_reproduced': 5} {'reproduced': 5} {'not_reproduced': 5} {'reproduced': 5}
fig4ab-thi-threat-firing N1 {'partially_reproduced': 5} {'partially_reproduced': 5} {'partially_reproduced': 5} {'partially_reproduced': 5}
N2 {'partially_reproduced': 5} {'partially_reproduced': 5} {'partially_reproduced': 5} {'partially_reproduced': 5}
N3 {'partially_reproduced': 5} {'partially_reproduced': 5} {'partially_reproduced': 5} {'partially_reproduced': 5}
N4 {'partially_reproduced': 5} {'partially_reproduced': 5} {'partially_reproduced': 5} {'partially_reproduced': 5}
fig4b-thi-danger-equals-uncertainty N1 {'reproduced': 5} {'reproduced': 5} {'reproduced': 5} {'reproduced': 5}
N2 {'reproduced': 5} {'reproduced': 5} {'reproduced': 5} {'reproduced': 5}
N3 {'reproduced': 5} {'reproduced': 5} {'reproduced': 5} {'reproduced': 5}
N4 {'reproduced': 5} {'reproduced': 5} {'reproduced': 5} {'reproduced': 5}
fig4cd-de-danger-firing N1 {'partially_reproduced': 5} {'partially_reproduced': 5} {'partially_reproduced': 5} {'partially_reproduced': 5}
N2 {'partially_reproduced': 5} {'partially_reproduced': 5} {'partially_reproduced': 5} {'partially_reproduced': 5}
N3 {'partially_reproduced': 5} {'partially_reproduced': 5} {'partially_reproduced': 5} {'partially_reproduced': 5}
N4 {'partially_reproduced': 5} {'partially_reproduced': 5} {'partially_reproduced': 5} {'partially_reproduced': 5}
fig4ef-bv-danger-decrease N1 {'partially_reproduced': 5} {'partially_reproduced': 5} {'partially_reproduced': 5} {'partially_reproduced': 5}
N2 {'partially_reproduced': 5} {'partially_reproduced': 5} {'partially_reproduced': 5} {'partially_reproduced': 5}
N3 {'partially_reproduced': 5} {'partially_reproduced': 5} {'partially_reproduced': 5} {'partially_reproduced': 5}
N4 {'partially_reproduced': 5} {'partially_reproduced': 5} {'partially_reproduced': 5} {'partially_reproduced': 5}
fig5ab-the-onset N1 {'not_reproduced': 5} {'not_reproduced': 5} {'not_reproduced': 5} {'not_reproduced': 5}
N2 {'not_reproduced': 5} {'not_reproduced': 5} {'not_reproduced': 5} {'not_reproduced': 5}
N3 {'not_reproduced': 5} {'not_reproduced': 5} {'not_reproduced': 5} {'not_reproduced': 5}
N4 {'not_reproduced': 5} {'not_reproduced': 5} {'not_reproduced': 5} {'not_reproduced': 5}
fig5cd-ns-nonselective N1 {'not_reproduced': 5} {'not_reproduced': 5} {'not_reproduced': 5} {'not_reproduced': 5}
N2 {'not_reproduced': 5} {'not_reproduced': 5} {'not_reproduced': 5} {'not_reproduced': 5}
N3 {'not_reproduced': 5} {'not_reproduced': 5} {'not_reproduced': 5} {'not_reproduced': 5}
N4 {'not_reproduced': 5} {'not_reproduced': 5} {'not_reproduced': 5} {'not_reproduced': 5}
fig8ab-thi-exaggerated-threat per-trial (a), joint, 0/0 drop {'reproduced': 5} {'reproduced': 5} {'reproduced': 5} {'reproduced': 5}
per-trial (a), joint, 0/0 zero {'not_reproduced': 5} {'not_reproduced': 5} {'not_reproduced': 5} {'not_reproduced': 5}
per-trial (a), joint, 0/0 one {'reproduced': 5} {'reproduced': 5} {'reproduced': 5} {'reproduced': 5}
per-trial (b), joint, 0/0 drop {'not_reproduced': 1, 'reproduced': 4} {'reproduced': 5} {'not_reproduced': 1, 'reproduced': 4} {'not_reproduced': 1, 'reproduced': 4}
per-trial (b), joint, 0/0 zero {'not_reproduced': 5} {'not_reproduced': 5} {'not_reproduced': 5} {'not_reproduced': 5}
per-trial (b), joint, 0/0 one {'not_reproduced': 1, 'reproduced': 4} {'reproduced': 5} {'not_reproduced': 1, 'reproduced': 4} {'not_reproduced': 3, 'reproduced': 2}
per-trial (c), joint, 0/0 drop {'not_reproduced': 5} {'not_reproduced': 5} {'not_reproduced': 5} {'not_reproduced': 4, 'reproduced': 1}
per-trial (c), joint, 0/0 zero {'not_reproduced': 5} {'not_reproduced': 5} {'not_reproduced': 5} {'not_reproduced': 5}
per-trial (c), joint, 0/0 one {'not_reproduced': 5} {'not_reproduced': 5} {'not_reproduced': 5} {'not_reproduced': 5}
fig8cd-de-exaggerated-threat per-trial (a), joint, 0/0 drop {'partially_reproduced': 5} {'not_reproduced': 2, 'partially_reproduced': 3} {'not_reproduced': 2, 'partially_reproduced': 3} {'not_reproduced': 3, 'partially_reproduced': 2}
per-trial (a), joint, 0/0 zero {'partially_reproduced': 5} {'partially_reproduced': 5} {'partially_reproduced': 5} {'partially_reproduced': 5}
per-trial (a), joint, 0/0 one {'partially_reproduced': 5} {'partially_reproduced': 5} {'partially_reproduced': 5} {'partially_reproduced': 5}
per-trial (b), joint, 0/0 drop {'not_reproduced': 5} {'not_reproduced': 5} {'not_reproduced': 5} {'not_reproduced': 5}
per-trial (b), joint, 0/0 zero {'partially_reproduced': 5} {'partially_reproduced': 3, 'reproduced': 2} {'partially_reproduced': 5} {'not_reproduced': 1, 'partially_reproduced': 3, 'reproduced': 1}
per-trial (b), joint, 0/0 one {'not_reproduced': 5} {'not_reproduced': 4, 'partially_reproduced': 1} {'not_reproduced': 3, 'partially_reproduced': 2} {'not_reproduced': 3, 'partially_reproduced': 2}
per-trial (c), joint, 0/0 drop {'not_reproduced': 5} {'not_reproduced': 5} {'not_reproduced': 5} {'not_reproduced': 5}
per-trial (c), joint, 0/0 zero {'partially_reproduced': 4, 'reproduced': 1} {'partially_reproduced': 4, 'reproduced': 1} {'not_reproduced': 1, 'partially_reproduced': 3, 'reproduced': 1} {'not_reproduced': 1, 'partially_reproduced': 2, 'reproduced': 2}
per-trial (c), joint, 0/0 one {'not_reproduced': 5} {'partially_reproduced': 5} {'not_reproduced': 5} {'not_reproduced': 1, 'partially_reproduced': 4}
fig8ef-bv-exaggerated-threat per-trial (a), joint, 0/0 drop {'partially_reproduced': 5} {'partially_reproduced': 5} {'partially_reproduced': 5} {'partially_reproduced': 5}
per-trial (a), joint, 0/0 zero {'partially_reproduced': 5} {'partially_reproduced': 5} {'partially_reproduced': 5} {'partially_reproduced': 5}
per-trial (a), joint, 0/0 one {'partially_reproduced': 5} {'partially_reproduced': 5} {'partially_reproduced': 5} {'partially_reproduced': 5}
per-trial (b), joint, 0/0 drop {'partially_reproduced': 5} {'partially_reproduced': 5} {'partially_reproduced': 5} {'partially_reproduced': 5}
per-trial (b), joint, 0/0 zero {'partially_reproduced': 5} {'partially_reproduced': 5} {'partially_reproduced': 5} {'partially_reproduced': 5}
per-trial (b), joint, 0/0 one {'partially_reproduced': 5} {'partially_reproduced': 5} {'partially_reproduced': 5} {'partially_reproduced': 5}
per-trial (c), joint, 0/0 drop {'partially_reproduced': 5} {'partially_reproduced': 5} {'partially_reproduced': 5} {'partially_reproduced': 5}
per-trial (c), joint, 0/0 zero {'partially_reproduced': 5} {'partially_reproduced': 5} {'partially_reproduced': 5} {'partially_reproduced': 5}
per-trial (c), joint, 0/0 one {'partially_reproduced': 5} {'partially_reproduced': 5} {'partially_reproduced': 5} {'partially_reproduced': 5}
fig9bcd-reward-pre-post ('b', 'sd') {'not_reproduced': 5} {'not_reproduced': 5} {'not_reproduced': 5} {'not_reproduced': 5}
('b', 'z16') {'not_reproduced': 5} {'not_reproduced': 5} {'not_reproduced': 5} {'not_reproduced': 5}
('script', 'code') {'partially_reproduced': 5} {'partially_reproduced': 5} {'partially_reproduced': 5} {'partially_reproduced': 5}
fig10bcd-poke-cessation-pre-post ('b', 'sd') {'not_reproduced': 5} {'not_reproduced': 5} {'not_reproduced': 5} {'not_reproduced': 5}
('b', 'z16') {'not_reproduced': 5} {'not_reproduced': 5} {'not_reproduced': 5} {'not_reproduced': 5}
('script', 'code') {'not_reproduced': 5} {'not_reproduced': 5} {'not_reproduced': 5} {'not_reproduced': 5}
(143 s)
CI form, standard error and seed¶
Every CI-based judgement above uses the standard (reflected) studentized interval with the
analytic standard error in each resample and one seed per claim. The authors call
bootci(1000, {@mean, x}, 'type', 'student') (printed in the data check), which estimates the
standard error by an inner bootstrap, and the paper's printed Figure 1G intervals match the
bootstrap-t quantiles added without reflection (fig1g-discrimination). Here each CI-based claim
is judged again on the primary partition under the two interval forms, the two standard errors
(analytic, and an inner bootstrap of 100 resamples as bootci uses) and five seeds, under the
readings its outcome rests on. The counts are the outcomes over the five seeds.
Summary¶
A failure to reproduce here may be a failure of this attempt, not of the paper: see the reasoning and the differences from the paper's method.
| Claim | Outcome |
|---|---|
| units-recorded | not reproduced: 368 units and 7 rats, but 90 sessions, not 95 |
| cue-responsive-193 | reproduced (211 units under reading b; the script's procedure gives 193 exactly) |
| fig1c-acquisition | blocked: data missing |
| fig1g-discrimination | reproduced under one reading (assumed; not with the authors' 0/0 handling), with a CI bound near zero (under all six with the paper's interval form) |
| fig1h-poke-rate-unrelated | reproduced (assumed 0/0 handling) |
| fig1h-discrimination-safety | reproduced |
| fig2-five-clusters | partially reproduced: the patterns, not the counts |
| populations-by-rat | not reproduced (assumed partition) |
| most-units-threat | reproduced |
| fig3ab-rate-cv-unimodal | reproduced |
| fig3c-waveform-bimodal | reproduced (assumed partition) |
| fig4ab-thi-threat-firing | partially reproduced (assumed partition) |
| fig4b-thi-danger-equals-uncertainty | reproduced (assumed partition) |
| fig4cd-de-danger-firing | partially reproduced (assumed partition) |
| fig4ef-bv-danger-decrease | partially reproduced (assumed partition) |
| fig4f-bv-safety-variability | reproduced (assumed partition) |
| fig5ab-the-onset | not reproduced (assumed partition; reproduced on the alternative partition) |
| fig5cd-ns-nonselective | not reproduced (assumed partition) |
| fig6-similarity-anova | reproduced (assumed partition) |
| fig6d-thi-similarity | reproduced (assumed partition) |
| fig6e-de-similarity | not reproduced (assumed partition) |
| fig6f-bv-no-similarity-difference | reproduced (assumed partition) |
| fig6-thi-greatest-similarity | reproduced (assumed partition) |
| fig7-tuning-curves | reproduced (assumed partition; partially on the alternative partition) |
| fig8ab-thi-exaggerated-threat | reproduced under one reading (assumed partition) |
| fig8cd-de-exaggerated-threat | partially reproduced (assumed partition) |
| fig8ef-bv-exaggerated-threat | partially reproduced (assumed partition) |
| fig9a-reward-firing | not reproduced (assumed partition) |
| fig9bcd-reward-pre-post | not reproduced (assumed partition) |
| fig9efg-reward-cue-correlations | partially reproduced (assumed partition) |
| fig9hij-danger-safety-correlations | not reproduced (assumed partition) |
| fig10a-poke-cessation-anova | reproduced (assumed partition) |
| fig10bcd-poke-cessation-pre-post | not reproduced (assumed partition) |
| fig10efg-poke-cessation-cue-unrelated | not reproduced (assumed partition) |
How the analysis differs from the paper's. The populations are not the paper's: its labels
are not deposited, and its k-means cannot be repeated (one MATLAB start after rng(1)), so the
population claims rest on a reproduced partition chosen among the claims file's readings. The
cue firing normalization follows the Methods; the authors' script normalizes differently (per
trial, minus a floored 2-s baseline, z-scored over all trials), and that variant brings several
effect sizes to the paper's values (fig4ab, fig4cd, fig8ef, and the Bidirectional Valence R2 of
fig9hij; its Danger Excited R2, 0.212, stays outside 0.25 +- 0.025). The cue-responsive set is
the script's (floored rates), the only procedure that gives 193 units. The primary partition is the
one of the claims file's readings whose centroids best match the five described patterns; the
next best (N2, most frequent) is nearly as good, and the two give different outcomes for
fig5ab-the-onset and for the Threat Inhibited extreme of fig7-tuning-curves (section "Primary and
alternative partition"). ITI events count only when their 4-s window lies inside a recorded
segment, and a cessation only when its 2 s without a poke do; this leaves ITI reading (a) with no
event, so the reward and cessation claims rest on reading (b), with the script's windows as a
variant. Their baseline is the 1 s before the event, as the Methods say; the script uses 2 to 1 s
before. The bootstrap intervals are standard studentized intervals; the paper's printed
intervals match a form that does not reflect the bootstrap-t quantiles. Judged again under both
forms, the bootstrap SE of bootci and five seeds (section "CI form"), fig1g-discrimination is
reproduced under every reading without reflection and under one reading, in some seeds, with it.
For fig8ab and fig8cd some readings move between outcomes across seeds and forms; the readings
fig8ab's outcome rests on hold in every case, and fig8cd stays partially reproduced under two of
the three 0/0 readings of per-trial reading (a). The other CI-based claims keep their outcomes in
every seed, form and SE.
What was found about the data set. It holds all 368 units and 7 rats, from 90 sessions
where the paper reports 95. The pre-surgery sessions and the paper's population labels are not
in it. The data description does not say which event channel is which (the script does), nor
that the recording is paused between trials, so that the files hold only 20 s before to about
33 s after each onset; it describes poke.base as a 2-s rate where the values are 20-s rates.
The script's waveform measure is half the scale of Figure 3C.