Reproducing Johnson et al. (2018) from CRCNS fcx-2¶
Paper. Johnson EL, Adams JN, Solbakk A-K, Endestad T, Larsson PG, Ivanovic J, Meling TR, Lin JJ, Knight RT (2018). Dynamic frontotemporal systems process space and time in working memory. PLoS Biology 16, e2004274. doi:10.1371/journal.pbio.2004274. The claims file was written from the version of record (PMC5895055, full text with Methods and figure legends; the supplementary tables were not supplied).
Data set. CRCNS fcx-2,
doi:10.6080/K0VX0DQD, read from the public bucket
crcnsarchive under fcx-2/live/. CRCNS data sets are not versioned, so the version is recorded
as unversioned. The paper cites the data set by its DOI and no version. The bucket holds the live
files and, under fcx-2/orig/ver_0_6/, only the documents and scripts of version 0.6; the data
files exist once, under live/, which is the published version 0.61 (descriptor of April 4, 2018,
whose change from 0.6 is an updated psianalysis.m). This is the only version of the data, so it is
pinned. MD5 sums of the files read, from the data set's checksums.md5:
| file | md5 |
|---|---|
| data_indiv/s1.tar.gz | 0bbbcce3cc2738bc7ce5545b27843d4c |
| data_indiv/s2.tar.gz | 5ead31d89d1ae4a50adae20054bb6572 |
| data_indiv/s3.tar.gz | 740991d34257dabc1fdd8a467f1e80a2 |
| data_indiv/s4.tar.gz | 306d554f9e9ec77a35b68879f301f6b1 |
| data_indiv/s5.tar.gz | 66673b1504648aff5ea1f2e0bea6fcdd |
| data_indiv/s6.tar.gz | 68608a2237469bc285b928298b1e8f3f |
| data_indiv/s7.tar.gz | 639d8e97e026f9b8dea08610c51af00e |
| data_indiv/s8.tar.gz | 6aa467667c0fec9566f49fd19c8461e8 |
| data_indiv/s9.tar.gz | bfd6d72c7663db18db4f0fe90cea63c7 |
| data_indiv/s10.tar.gz | 5eb078815470c8d1b70b06d8f2be5300 |
| docs/summary_channel_analysis.csv | 79adb25db44e195ad952359ed43d9a3a |
| docs/summary_file.csv | 6d214de444bf222cee1c3291b6191a6f |
| analysis_scripts.tar.gz | 8b5b07094a3a31e8bb4828afcdffd2f2 (read for the methods, not run) |
What the data set holds. For each of the 10 subjects, the preprocessed bipolar data
(data_derived.mat: segments pre, encmain and proc, each 4.5 s long with a time axis from -1.5
to 3 s, and a trial table per segment), the filtered monopolar data, a per-trial table and electrode
coordinates; the analysed channels per region and hemisphere (summary_channel_analysis.csv); a
behaviour table per subject; and the MATLAB analysis scripts. The tar files are streamed and read
in memory; only the derived data of the 254 analysed channels are kept.
Methods. Everything not in the claims file is taken from the paper's Methods or from the
analysis code deposited with the data, as the helper module fcx2.py says parameter by parameter.
Every window is placed by the trial table and the descriptor (the main reading), 1.5 s earlier on the derived time axes than the deposited code places it; the data check below shows why. ERPs, power, PLV and both PSI measures are also run with the code's windows. If the deposited scripts produced the paper's figures, the paper's numbers come from the code's windows: the table's placement tests the claims against the events the Methods describe, and does not recompute what the paper did.
| claim | tested | rests on an assumption |
|---|---|---|
| behavior-proficient | yes | |
| behavior-no-difficulty-difference | yes | numeric coding of condition; response time from summary_file.csv; accuracy model on subject-level logits |
| electrode-counts | yes | |
| correct-trial-counts | yes | |
| erp-no-condition-difference | yes | baseline as erp_compute.m subtracts it (trial mean) |
| power-theta-sustained | yes | |
| power-condition-exclusions | yes | |
| plv-theta-peak | yes | |
| psi-theta-shift | yes | window placement of the trial table |
| crossspectral-shift | yes | |
| phase-directing-counts | yes | |
| crossspectral-equal-strength | blocked (methods_underspecified) | |
| theta-peak-bands | yes | |
| pac-* (8 claims) | blocked (methods_underspecified) |
import time
import warnings
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import statsmodels.formula.api as smf
from scipy import stats
import fcx2
warnings.filterwarnings("ignore")
pd.set_option("display.width", 220)
pd.set_option("display.max_columns", 60)
pd.set_option("display.max_rows", 400)
started = time.time()
chtab = fcx2.read_channel_table()
summary = fcx2.read_summary_file()
R = {}
# one subject at a time: stream, check, run every per-subject measure, keep only the results
for sid in ['s1', 's2', 's3', 's4']:
R[sid] = fcx2.process_subject(sid, chtab)
print(f"{len(R)} subjects done after {(time.time() - started) / 60:.1f} min")
s1: analysed in 138 s; erp 8, power 41, power_test 44, edge 55, plv 64, psi 84, plv_alt 94, psi_alt 114, pac 138
s2: analysed in 268 s; erp 13, power 52, power_test 57, edge 77, plv 94, psi 134, plv_alt 151, psi_alt 190, pac 268
s3: analysed in 52 s; erp 4, power 13, power_test 15, edge 20, plv 23, psi 32, plv_alt 35, psi_alt 43, pac 52
s4: analysed in 205 s; erp 10, power 40, power_test 44, edge 59, plv 72, psi 104, plv_alt 117, psi_alt 148, pac 205 4 subjects done after 13.3 min
# one subject at a time: stream, check, run every per-subject measure, keep only the results
for sid in ['s5', 's6']:
R[sid] = fcx2.process_subject(sid, chtab)
print(f"{len(R)} subjects done after {(time.time() - started) / 60:.1f} min")
s5: analysed in 330 s; erp 14, power 53, power_test 58, edge 78, plv 94, psi 137, plv_alt 153, psi_alt 192, pac 330
s6: analysed in 417 s; erp 24, power 96, power_test 104, edge 141, plv 167, psi 244, plv_alt 270, psi_alt 344, pac 417 6 subjects done after 28.1 min
# one subject at a time: stream, check, run every per-subject measure, keep only the results
for sid in ['s7', 's8', 's9']:
R[sid] = fcx2.process_subject(sid, chtab)
print(f"{len(R)} subjects done after {(time.time() - started) / 60:.1f} min")
s7: analysed in 267 s; erp 13, power 49, power_test 53, edge 72, plv 85, psi 122, plv_alt 135, psi_alt 171, pac 267
s8: analysed in 29 s; erp 3, power 10, power_test 12, edge 14, plv 16, psi 21, plv_alt 22, psi_alt 27, pac 29
s9: analysed in 128 s; erp 7, power 25, power_test 30, edge 40, plv 48, psi 73, plv_alt 82, psi_alt 103, pac 128 9 subjects done after 36.8 min
# one subject at a time: stream, check, run every per-subject measure, keep only the results
for sid in ['s10']:
R[sid] = fcx2.process_subject(sid, chtab)
print(f"{len(R)} subjects done after {(time.time() - started) / 60:.1f} min")
s10: analysed in 895 s; erp 28, power 113, power_test 122, edge 166, plv 212, psi 324, plv_alt 372, psi_alt 468, pac 895 10 subjects done after 52.7 min
Data check¶
rows = []
for sid, r in R.items():
s = r["sanity"]
ti = r["trialinfo"]
rows.append({
"subject": sid, "fs": s["fs"], "hdr_fs": sorted(set(s["hdr_fs"].values())),
"derived_labels": s["n_labels"], "analysed": len(r["chans"]),
"trials_table": len(s["trials"]), "trials_derived": s["n_trials_derived"],
"correct_derived": int((ti[:, 1] == 1).sum()),
"samples_pre": s["n_samples"]["pre"], "samples_enc": s["n_samples"]["encmain"],
"samples_proc": s["n_samples"]["proc"],
"time_enc": s["time_range"]["encmain"][:2], "same_start": all(s["same_start"].values()),
"x_min_uV": round(s["x_range"][0], 1), "x_max_uV": round(s["x_range"][1], 1),
"load_s": round(s["load_s"]),
})
info = pd.DataFrame(rows)
print(info.to_string(index=False))
print("\nmembers of each tar file:")
for sid, r in R.items():
print(sid, {k.split('/')[-1]: v for k, v in r["sanity"]["members"].items()})
print("\nAll analysed channels of docs/summary_channel_analysis.csv found among the derived labels: yes "
"(load_subject raises otherwise)")
print("Channels per region in the channel table:", chtab.region.value_counts().to_dict(), "total", len(chtab))
subject fs hdr_fs derived_labels analysed trials_table trials_derived correct_derived samples_pre samples_enc samples_proc time_enc same_start x_min_uV x_max_uV load_s
s1 1000.0 [1000.0] 33 15 120 111 102 (4501, 4501) (4501, 4502) (4501, 4501) (-1.5, 3.0) True -155.9 163.9 30
s2 1000.0 [1000.0] 31 25 120 113 109 (4501, 4501) (4502, 4503) (4501, 4501) (-1.5, 3.001) True -116.7 181.2 24
s3 1000.0 [1000.0] 14 7 120 115 96 (4501, 4501) (4498, 4499) (4501, 4501) (-1.5, 2.997) True -208.6 191.9 23
s4 1000.0 [1000.0] 34 19 120 118 110 (4501, 4501) (4502, 4504) (4501, 4501) (-1.5, 3.001) True -763.3 642.5 23
s5 1000.0 [1000.0] 118 28 120 120 95 (4501, 4501) (4496, 4498) (4501, 4501) (-1.5, 2.995) True -840.7 733.7 74
s6 1000.0 [1000.0] 74 48 120 108 103 (4501, 4501) (4505, 4506) (4501, 4501) (-1.5, 3.004) True -621.2 1053.4 38
s7 1000.0 [1000.0] 57 24 120 100 100 (4501, 4501) (4498, 4499) (4501, 4501) (-1.5, 2.997) True -557.6 399.6 31
s8 512.0 [512.0] 43 9 120 90 86 (2305, 2305) (2304, 2304) (2305, 2305) (-1.5, 2.998047) True -109.7 117.6 14
s9 512.0 [512.0] 57 27 120 120 101 (2305, 2305) (2304, 2304) (2305, 2305) (-1.5, 2.998047) True -944.9 1446.8 33
s10 1000.0 [1000.0] 57 52 120 116 107 (4501, 4501) (4505, 4506) (4501, 4501) (-1.5, 3.004) True -681.6 597.1 37
members of each tar file:
s1 {'s1_MNI_grid.csv': 41355, 'data_primary.mat': 749624672, 'data_derived.mat': 388011682, 'summary_file_trial.csv': 4776}
s2 {'data_primary.mat': 490708543, 'data_derived.mat': 371704202, 'summary_file_trial.csv': 4777, 's2_MNI_grid.csv': 37858}
s3 {'data_primary.mat': 830254334, 's3_MNI_grid.csv': 29044, 'data_derived.mat': 175410863, 'summary_file_trial.csv': 4882}
s4 {'s4_MNI_grid.csv': 48306, 'data_primary.mat': 523312496, 'data_derived.mat': 424683631, 'summary_file_trial.csv': 4787}
s5 {'data_primary.mat': 1344466768, 's5_MNI_grid.csv': 80260, 'data_derived.mat': 1480159055, 'summary_file_trial.csv': 4821}
s6 {'data_primary.mat': 590509681, 's6_MNI_grid.csv': 54916, 'data_derived.mat': 836696067, 'summary_file_trial.csv': 4776}
s7 {'data_primary.mat': 647441439, 's7_MNI_grid.csv': 53143, 'data_derived.mat': 601042976, 'summary_file_trial.csv': 4716}
s8 {'s8_MNI_grid.csv': 49364, 'data_primary.mat': 347028413, 'data_derived.mat': 210369492, 'summary_file_trial.csv': 4730}
s9 {'s9_MNI_grid.csv': 82240, 'data_primary.mat': 716071886, 'data_derived.mat': 369821472, 'summary_file_trial.csv': 4751}
s10 {'data_primary.mat': 702006362, 's10_MNI_grid.csv': 55217, 'data_derived.mat': 695045000, 'summary_file_trial.csv': 6532}
All analysed channels of docs/summary_channel_analysis.csv found among the derived labels: yes (load_subject raises otherwise)
Channels per region in the channel table: {'PFC': 116, 'OFC': 102, 'MTL': 36} total 254
The descriptor says the derived structures have fsample: 1000; s8 and s9 are at 512 Hz, as its
note on the trial table says and as the paper says for the Oslo subjects. Trials differ in length by at
most a sample or two within a segment; the analysis keeps the samples all trials share, from the
common first time (-1.5 s).
rows = []
for sid, r in R.items():
s = r["sanity"]
rows.append({"subject": sid, **{k: np.round(v, 2).tolist()[:4] + (["..."] if len(v) > 4 else []) for k, v in s["offsets"].items()},
"overlap_maxdiff": s["overlap_maxdiff"], "overlap_samples": s["overlap_samples"],
"trialinfo_same_in_segments": s["trialinfo_same_segments"],
"trialinfo_equals_trial_table": s["trialinfo_matches_table"]})
print(pd.DataFrame(rows).to_string(index=False))
subject pre - pre_start encmain - enc_start proc - post_start overlap_maxdiff overlap_samples trialinfo_same_in_segments trialinfo_equals_trial_table
s1 [101.0, 102.0] [0.0] [-300.0] {'pre/encmain': 0.0, 'encmain/proc': 0.0} {'pre/encmain': (2699, 2700), 'encmain/proc': (2246, 2498)} True True
s2 [101.0, 102.0] [0.0] [-300.0] {'pre/encmain': 0.0, 'encmain/proc': 0.0} {'pre/encmain': (2699, 2700), 'encmain/proc': (2247, 2499)} True True
s3 [104.0, 105.0] [0.0] [-300.0] {'pre/encmain': 0.0, 'encmain/proc': 0.0} {'pre/encmain': (2699, 2700), 'encmain/proc': (2246, 2498)} True True
s4 [100.0, 101.0] [0.0] [-300.0] {'pre/encmain': 0.0, 'encmain/proc': 0.0} {'pre/encmain': (2699, 2700), 'encmain/proc': (2246, 2498)} True True
s5 [105.0, 106.0, 107.0, 108.0] [0.0] [-300.0] {'pre/encmain': 0.0, 'encmain/proc': 0.0} {'pre/encmain': (2698, 2701), 'encmain/proc': (2245, 2498)} True True
s6 [98.0, 99.0] [0.0] [-300.0] {'pre/encmain': 0.0, 'encmain/proc': 0.0} {'pre/encmain': (2699, 2700), 'encmain/proc': (2247, 2499)} True True
s7 [104.0, 105.0, 106.0] [0.0] [-300.0] {'pre/encmain': 0.0, 'encmain/proc': 0.0} {'pre/encmain': (2699, 2700), 'encmain/proc': (2247, 2499)} True True
s8 [51.0] [0.0] [-154.0] {'pre/encmain': 0.0, 'encmain/proc': 0.0} {'pre/encmain': (1373, 1399), 'encmain/proc': (1153, 1281)} True True
s9 [51.0] [0.0] [-154.0] {'pre/encmain': 0.0, 'encmain/proc': 0.0} {'pre/encmain': (1373, 1398), 'encmain/proc': (1153, 1281)} True True
s10 [97.07, 97.09, 97.14, 97.15, ...] [-0.49, -0.48, -0.48, -0.47, ...] [-300.5, -300.47, -300.46, -300.46, ...] {'pre/encmain': 0.0, 'encmain/proc': 0.0} {'pre/encmain': (2699, 2700), 'encmain/proc': (2246, 2498)} True False
The three derived segments of a trial are cut from one continuous recording: placed by their
sampleinfo, their overlapping samples are identical (largest difference 0) in every subject. In
nine subjects the first sample of encmain is the trial table's column H ("encoding and pre-cue
delay epoch start"), the first sample of proc is 0.3 s before column I ("post-cue delay epoch
start") and the first sample of pre is about 0.1 s after column G ("pretrial epoch start, 1000 ms
before trial start"; 98 to 108 samples at 1 kHz, 51 at 512 Hz). In s10 the offsets are not whole samples and vary over trials (the table's columns
for s10 are not on the derived data's sample grid; for two trials pre is 114 samples after G), so
for s10 the table does not place the derived segments exactly. In every subject trialinfo is the
same in the three segments and equals the trial table's columns, except s10, where the
trial-table check fails as printed above.
This bears on where time 0 is. Each derived segment runs from -1.5 s to 3.0 s, and its first sample
(-1.5 s) is the table's epoch start. The analysis code takes encoding as [0, 1.5] s of encmain, the
postcue delay as [0.3, 1.2] s of proc and the baseline as [0.65, 0.85] s of pre ("-250 to 50 ms
pretrial"), which places stimulus onset at 0 s, 1.5 s after the table's column H. The descriptor
places stimulus onset at column H itself, 1.5 s earlier, and the table's columns agree with the
task's timing (H minus G is 1.9 s, the 1 s fixation, 800 ms start screen and 100 ms fixation; I
minus H is 600 ms plus the delay plus the 800 ms test cue). While preparing the first run, a
derived trial of s8 was compared with the monopolar data in data_primary.mat (not run here, as it
streams the primary files): the bipolar CL_02 and BR_03 traces equal the difference of
adjacent contacts from sample H on, so sampleinfo indexes the primary data as the table does.
The check below decides between the two placements from the data.
edges = R["s1"]["sanity"]["evoked_edges"]
centres = edges[:-1] + 0.025
for seg in ("pre", "encmain", "proc"):
hg9 = np.nanmean([r["sanity"]["hg"][(seg, 900)] for r in R.values()], axis=0)
hg11 = np.nanmean([r["sanity"]["hg"][(seg, 1150)] for r in R.values()], axis=0)
ev = np.nanmean([r["sanity"]["evoked_rms"][seg] / np.nanmean(r["sanity"]["evoked_rms"][seg]) for r in R.values()], axis=0)
print(f"{seg}: high-gamma amplitude relative to its mean, 900 ms delay trials, 100 ms steps from -1.5 s:")
print(" ", " ".join(f"{v:.2f}" for v in hg9[::2]))
print(" 1150 ms delay trials:")
print(" ", " ".join(f"{v:.2f}" for v in hg11[::2]))
print(" evoked RMS over channels relative to its mean:")
print(" ", " ".join(f"{v:.2f}" for v in ev[::2]))
print(f" range of the high-gamma curves {np.nanmin([hg9, hg11]):.3f} to {np.nanmax([hg9, hg11]):.3f}; "
f"largest 900 vs 1150 difference {np.nanmax(np.abs(hg9 - hg11)):.3f} at {centres[np.nanargmax(np.abs(hg9 - hg11))]:.2f} s")
WINS = np.arange(-1.5, 3.0, 0.25)
# per electrode: t of the 900 against the 1150 ms trials in 50 ms bins (fcx2.sanity_subject),
# pooled over subjects: the fraction of electrode bins with |t| > 1.96 per 250 ms window, and its p
# against 200 permutations of the jitter labels (the same permutation index summed over subjects)
print("\nPer electrode, 900 against 1150 ms delay trials, in 250 ms windows from -1.5 s")
FIRST = {"pre": ("test cue onset", 1.8, None), "encmain": ("test cue onset", 0.0, 1.5),
"proc": ("response screen", -0.3, 1.2)}
for seg in ("pre", "encmain", "proc"):
ev, t_tab, t_code = FIRST[seg]
print(f"{seg}: first event that depends on the delay, {ev}: {t_tab:+.2f} s by the trial table, "
+ (f"{t_code:+.2f} s by the code's windows" if t_code is not None else "after the segment's end by the code's windows"))
for name in ("hg", "erp"):
obs = sum((np.abs(r["sanity"]["jitter_t"][(seg, name)]) > 1.96).sum(axis=0) for r in R.values())
null = sum(r["sanity"]["jitter_t"][(seg, name, "null")].astype(int) for r in R.values())
nel = sum(r["sanity"]["jitter_t"][(seg, name)].shape[0] for r in R.values())
frac, pv = [], []
for w0 in WINS:
m = (centres >= w0) & (centres < w0 + 0.25)
frac.append(obs[m].sum() / (nel * m.sum()))
pv.append((np.sum(null[:, m].sum(axis=1) >= obs[m].sum()) + 1) / (null.shape[0] + 1))
print(f" {name:4s} frac " + " ".join(f"{v:.2f}" for v in frac))
print(f" {'':4s} p " + " ".join(f"{v:.2f}" for v in pv))
print(" windows " + " ".join(f"{w:+.2f}" for w in WINS))
# the electrode with the largest high-gamma modulation in encmain, per subject
rows = []
for sid, r in R.items():
hm = r["sanity"]["jitter_t"][("encmain", "hg_mean")][:, 1:] # first bin is the segment edge
rng_ = hm.max(axis=1) - hm.min(axis=1)
e = int(np.argmax(rng_))
rows.append({"subject": sid, "electrode": r["chans"].label[e], "region": r["chans"].region[e],
"log_amp_range": round(float(rng_[e]), 3), "peak_at_s": round(float(centres[1:][np.argmax(hm[e])]), 2),
"trough_at_s": round(float(centres[1:][np.argmin(hm[e])]), 2),
"curve_100ms": np.round(hm[e][::2], 2).tolist()})
print(pd.DataFrame(rows).to_string(index=False))
pre: high-gamma amplitude relative to its mean, 900 ms delay trials, 100 ms steps from -1.5 s:
1.29 0.99 1.00 1.00 1.01 1.00 1.00 1.01 1.00 1.00 1.00 1.00 0.99 0.99 0.99 0.99 0.99 0.99 0.99 1.00 0.99 0.98 0.98 0.98 0.98 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 1.00 1.00 1.00 1.00 0.99 0.99 1.00 1.00 1.00 1.00 1.01 1.00
1150 ms delay trials:
1.30 0.99 1.00 1.00 0.99 1.00 1.00 1.00 0.99 1.00 0.99 0.99 0.99 0.99 1.00 0.99 0.99 0.99 0.99 1.00 1.00 0.99 0.98 0.99 0.99 0.99 1.00 1.00 0.98 0.99 0.99 0.99 1.00 0.99 0.99 0.99 0.99 0.99 0.98 0.99 0.99 0.99 0.99 0.99 0.99
evoked RMS over channels relative to its mean:
0.90 0.90 1.01 0.82 0.99 1.15 1.15 0.94 0.89 0.92 1.01 1.02 1.10 1.07 1.03 0.97 0.92 1.05 0.92 0.98 1.10 1.21 1.13 1.13 1.02 1.04 1.09 1.04 1.08 1.10 1.18 0.94 1.01 0.97 0.98 0.86 0.86 1.03 0.99 0.94 0.95 0.89 1.00 0.87 0.86
range of the high-gamma curves 0.980 to 1.304; largest 900 vs 1150 difference 0.023 at 2.48 s
encmain: high-gamma amplitude relative to its mean, 900 ms delay trials, 100 ms steps from -1.5 s:
1.28 1.00 1.00 0.99 0.99 0.98 0.99 0.99 1.00 0.99 0.99 1.00 0.99 0.99 1.00 1.00 1.00 1.00 1.00 1.00 0.99 1.00 1.01 1.00 1.01 1.01 1.00 1.00 1.00 0.99 1.00 1.00 0.99 0.99 0.99 0.98 0.98 0.98 0.98 0.99 0.99 0.99 0.99 0.99 1.01
1150 ms delay trials:
1.28 1.00 1.00 0.99 0.99 0.99 0.99 0.99 1.00 1.00 0.99 0.99 0.99 0.99 1.00 1.00 1.00 1.00 0.99 0.99 0.99 0.99 0.99 0.99 0.99 1.00 0.99 0.99 0.99 1.00 0.99 0.99 0.99 0.99 0.99 0.99 0.98 0.99 1.00 0.99 0.99 0.99 0.99 0.99 0.99
evoked RMS over channels relative to its mean:
0.94 0.92 1.04 1.19 1.16 1.25 1.10 1.05 1.01 1.02 1.07 1.10 1.18 0.91 1.03 0.99 0.97 0.84 0.87 1.04 0.97 1.01 0.98 0.90 1.00 0.93 0.87 1.01 0.97 0.91 0.99 0.85 0.92 0.92 1.03 0.90 0.89 1.02 1.04 1.13 1.02 1.06 0.99 1.01 1.04
range of the high-gamma curves 0.978 to 1.284; largest 900 vs 1150 difference 0.022 at 0.68 s
proc: high-gamma amplitude relative to its mean, 900 ms delay trials, 100 ms steps from -1.5 s:
1.30 1.00 1.00 1.00 1.01 1.01 1.00 1.00 1.00 0.99 1.00 1.00 0.99 0.99 0.99 0.98 0.98 0.98 0.98 0.98 0.99 0.99 0.99 0.99 1.01 0.99 1.00 1.00 1.00 1.00 1.00 1.00 1.01 1.00 1.00 1.00 0.99 0.99 0.99 0.99 0.99 0.98 0.99 0.99 0.99
1150 ms delay trials:
1.29 0.99 0.99 0.99 1.00 0.99 0.99 0.99 0.99 0.99 0.98 0.98 0.99 0.98 0.99 1.00 1.00 0.99 0.98 0.98 0.98 0.99 0.99 0.99 0.99 1.00 1.00 1.00 0.99 0.99 1.00 0.99 1.00 1.00 0.99 0.99 0.99 1.00 1.00 1.00 1.00 1.00 0.99 1.00 1.00
evoked RMS over channels relative to its mean:
1.07 1.00 0.96 0.87 0.97 1.11 1.11 1.05 0.93 0.96 1.05 1.01 1.00 1.07 1.00 0.99 0.96 1.20 1.03 1.13 1.00 1.14 1.02 1.10 1.09 1.11 1.04 0.90 1.06 1.02 0.90 0.94 0.92 0.97 0.90 0.89 0.95 0.90 1.00 1.00 0.93 0.88 0.96 1.01 0.89
range of the high-gamma curves 0.976 to 1.302; largest 900 vs 1150 difference 0.022 at 0.13 s
Per electrode, 900 against 1150 ms delay trials, in 250 ms windows from -1.5 s
pre: first event that depends on the delay, test cue onset: +1.80 s by the trial table, after the segment's end by the code's windows
hg frac 0.04 0.05 0.06 0.05 0.05 0.07 0.05 0.06 0.04 0.07 0.05 0.05 0.06 0.06 0.05 0.07 0.05 0.06
p 0.97 0.71 0.26 0.51 0.41 0.03 0.69 0.40 0.84 0.05 0.34 0.49 0.14 0.37 0.59 0.02 0.45 0.16
erp frac 0.07 0.05 0.05 0.05 0.06 0.04 0.04 0.06 0.06 0.04 0.05 0.07 0.04 0.05 0.07 0.08 0.07 0.06
p 0.07 0.47 0.44 0.61 0.43 0.93 0.83 0.32 0.23 0.79 0.61 0.05 0.95 0.62 0.11 0.01 0.03 0.16
encmain: first event that depends on the delay, test cue onset: +0.00 s by the trial table, +1.50 s by the code's windows
hg frac 0.06 0.06 0.06 0.06 0.05 0.06 0.06 0.05 0.07 0.05 0.06 0.05 0.05 0.08 0.09 0.08 0.09 0.08
p 0.21 0.39 0.20 0.17 0.59 0.18 0.29 0.55 0.03 0.64 0.23 0.69 0.64 0.00 0.00 0.00 0.00 0.00
erp frac 0.05 0.05 0.04 0.05 0.06 0.03 0.05 0.08 0.08 0.07 0.07 0.05 0.05 0.08 0.08 0.08 0.11 0.07
p 0.62 0.54 0.75 0.42 0.24 1.00 0.44 0.01 0.01 0.07 0.01 0.38 0.40 0.01 0.03 0.02 0.00 0.05
proc: first event that depends on the delay, response screen: -0.30 s by the trial table, +1.20 s by the code's windows
hg frac 0.05 0.06 0.04 0.05 0.05 0.07 0.08 0.07 0.06 0.06 0.06 0.05 0.05 0.06 0.05 0.06 0.05 0.05
p 0.62 0.10 0.99 0.76 0.45 0.01 0.01 0.05 0.15 0.23 0.11 0.54 0.71 0.25 0.55 0.23 0.48 0.65
erp frac 0.05 0.05 0.06 0.05 0.05 0.07 0.11 0.12 0.08 0.08 0.05 0.06 0.04 0.05 0.05 0.05 0.06 0.05
p 0.56 0.56 0.28 0.44 0.40 0.05 0.00 0.00 0.02 0.02 0.57 0.29 0.94 0.69 0.35 0.44 0.20 0.39
windows -1.50 -1.25 -1.00 -0.75 -0.50 -0.25 +0.00 +0.25 +0.50 +0.75 +1.00 +1.25 +1.50 +1.75 +2.00 +2.25 +2.50 +2.75
subject electrode region log_amp_range peak_at_s trough_at_s curve_100ms
s1 RCD10 PFC 0.293 2.98 1.18 [-0.04, -0.01, -0.05, -0.03, 0.01, -0.01, 0.05, -0.04, 0.0, -0.01, -0.06, 0.01, -0.02, -0.0, 0.05, -0.02, 0.02, 0.02, 0.04, 0.02, -0.02, 0.01, -0.05, 0.05, 0.01, 0.03, -0.08, 0.02, -0.0, -0.03, -0.03, -0.01, 0.0, -0.04, -0.06, 0.01, -0.0, 0.05, 0.06, -0.04, 0.05, 0.01, 0.01, -0.01, 0.21]
s2 ROF12 PFC 0.261 2.98 1.43 [-0.02, 0.03, 0.01, 0.01, 0.03, 0.04, -0.05, -0.06, -0.02, -0.02, -0.04, 0.04, -0.03, 0.03, 0.01, -0.04, 0.03, -0.01, 0.0, 0.03, -0.04, 0.01, 0.02, -0.08, -0.01, 0.06, 0.0, -0.01, -0.03, 0.0, 0.03, -0.04, 0.02, -0.03, 0.02, -0.0, -0.05, 0.01, -0.02, -0.01, 0.02, -0.03, -0.01, -0.0, 0.16]
s3 ROF7 PFC 0.179 2.98 -1.32 [-0.01, -0.08, -0.02, -0.0, -0.04, -0.02, 0.03, 0.01, 0.02, -0.03, 0.05, -0.02, 0.0, 0.01, -0.0, -0.04, -0.02, -0.05, 0.05, 0.03, -0.06, -0.05, 0.04, 0.06, -0.0, 0.0, 0.03, -0.0, 0.04, -0.01, 0.02, 0.0, -0.03, -0.0, -0.02, -0.05, -0.04, 0.01, -0.01, 0.02, 0.02, -0.03, -0.03, 0.03, 0.1]
s4 LCI6 PFC 0.538 2.98 2.68 [-0.06, -0.01, 0.0, -0.03, 0.01, 0.05, -0.06, -0.02, 0.04, 0.03, 0.0, -0.07, 0.02, -0.01, 0.01, -0.05, -0.02, -0.03, 0.0, -0.01, 0.01, -0.03, -0.05, 0.02, -0.04, -0.02, -0.01, 0.02, 0.04, -0.05, 0.04, 0.02, 0.0, -0.01, -0.04, -0.01, -0.02, -0.0, -0.05, -0.0, -0.01, -0.09, -0.02, 0.01, 0.45]
s5 OFG14 OFC 0.371 2.98 2.63 [0.09, 0.06, 0.05, 0.08, 0.01, -0.01, -0.0, -0.03, -0.01, -0.01, 0.03, -0.04, 0.0, 0.0, 0.02, 0.06, 0.01, -0.0, 0.01, -0.01, -0.06, -0.01, -0.03, -0.04, 0.01, -0.04, -0.02, -0.02, -0.07, 0.02, -0.07, 0.0, -0.01, -0.1, -0.06, -0.02, -0.02, -0.01, -0.01, 0.01, -0.09, -0.1, -0.04, -0.06, 0.27]
s6 FG27 PFC 0.398 2.98 2.58 [-0.02, -0.03, 0.02, -0.01, -0.06, 0.06, 0.02, 0.04, -0.04, 0.01, -0.03, -0.03, -0.0, 0.02, -0.06, -0.04, -0.01, -0.04, -0.01, 0.02, 0.0, 0.03, 0.0, 0.06, -0.01, 0.01, -0.04, -0.02, -0.01, 0.0, -0.04, -0.03, 0.03, -0.02, -0.03, 0.02, 0.01, 0.05, 0.01, -0.02, -0.09, -0.0, -0.07, -0.02, 0.3]
s7 LAM5 MTL 0.396 -0.67 1.48 [-0.02, 0.01, 0.04, 0.01, -0.05, 0.04, 0.03, 0.11, 0.17, 0.15, 0.1, 0.03, -0.03, -0.04, -0.03, -0.04, -0.0, -0.07, -0.02, -0.03, -0.08, -0.02, -0.03, -0.03, -0.0, -0.01, -0.01, -0.05, -0.04, -0.11, 0.02, -0.08, -0.07, -0.01, -0.09, -0.01, -0.02, -0.05, -0.05, 0.04, 0.0, 0.07, 0.07, 0.05, 0.24]
s8 FOAL_04 PFC 0.353 2.98 -0.32 [-0.04, 0.01, -0.05, -0.05, -0.02, -0.01, -0.04, -0.01, 0.06, 0.06, -0.02, -0.11, -0.08, -0.09, -0.0, 0.01, -0.07, -0.05, 0.07, 0.05, -0.05, 0.03, 0.13, 0.11, 0.01, 0.05, 0.01, 0.03, 0.03, 0.04, -0.02, -0.0, 0.01, 0.02, -0.06, -0.03, -0.07, 0.0, -0.04, -0.04, -0.05, 0.02, -0.08, 0.04, 0.24]
s9 FAR_03 PFC 0.249 2.98 1.18 [-0.02, 0.03, 0.04, 0.02, 0.02, -0.01, 0.0, 0.0, -0.0, -0.01, 0.01, -0.03, 0.01, -0.04, -0.03, -0.04, 0.03, 0.06, -0.01, 0.02, -0.0, 0.04, -0.0, -0.03, 0.03, -0.03, -0.1, -0.03, -0.01, -0.01, 0.06, -0.03, 0.01, -0.03, -0.0, -0.05, 0.01, -0.02, 0.01, -0.04, -0.05, 0.0, -0.05, -0.01, 0.15]
s10 MVF1 OFC 0.547 2.98 1.68 [-0.04, -0.08, -0.02, -0.02, -0.06, -0.04, -0.01, 0.22, -0.09, -0.02, -0.07, -0.01, -0.07, -0.03, -0.09, -0.06, -0.03, -0.08, -0.0, -0.06, -0.02, -0.02, -0.03, 0.01, -0.01, 0.05, -0.06, -0.02, -0.05, -0.02, -0.06, -0.11, -0.07, -0.01, 0.17, 0.05, -0.01, 0.05, 0.09, 0.18, 0.12, 0.06, 0.01, 0.07, 0.44]
Pooled over all channels, the high-gamma amplitude (70 to 150 Hz) and the evoked response show no
task-locked modulation large enough to place the events (the curves stay within a few percent of
their mean apart from the first bin, the edge of the segment). The per-electrode test of the 900
against the 1150 ms delay trials does place them. The two groups can only differ from the first
event whose time depends on the delay. In proc the ERPs part from -0.25 s to 0.75 s (fraction of
electrode bins with |t| > 1.96 of 0.07 to 0.12, p from 0.05 down to 0.005, the smallest 200
permutations can give),
which is where the trial table puts the response screen (-0.3 s), and not at 1.2 s, where the
code's windows put it (p 0.29 to 0.94 in the windows from 1.0 to 2.0 s); high gamma parts at -0.25 to 0.25 s (p
0.01 to 0.05). In encmain the ERPs part from 0.25 s (p 0.01 at 0.25, 0.5 and 1.0 s), after the
test cue at 0 s by the table and before 1.5 s, where the code puts it. In pre they part at 2.25
to 2.5 s (p 0.01 and 0.03), after the test cue at 1.8 s by the table; by the code's windows pre
holds no event that depends on the delay. So the data are consistent with the trial table's
placement and not with the code's, and every window below is placed by the table: encoding
[-1.5, 0] s and the precue delay [-0.9, 0] s of encmain, the postcue delay [-1.2, -0.3] s of
proc and the baseline [-0.85, -0.65] s of pre. The baseline then starts 0.65 s, the encoding
window 0 s and the postcue delay 0.3 s after the first sample of their segment, inside the reach
of the low filters; the edge check after power-theta-sustained measures what this does to power. ERPs, power, PLV
and both PSI measures are also computed with the code's windows. The electrode with the largest
high-gamma range per subject is printed for reference; in 9 of 10 subjects its peak is the last bin
(2.98 s), the segment's edge.
# the deposited analysis scripts, read to quote the lines the windows, the ERP baseline and the
# PSI are taken from (not run)
SCRIPTS = fcx2.read_scripts()
def quote(name, first, last):
lines = SCRIPTS[name].splitlines()
print(f"--- {name}, lines {first}-{last}")
for k in range(first - 1, last):
print(f"{k + 1:4d} {lines[k]}")
print("files:", sorted(SCRIPTS))
quote("erp_compute.m", 44, 47) # baseline window
quote("erp_compute.m", 74, 97) # baseline correction and segment latencies
for name in ("power_compute.m", "psi_compute.m", "cspsi_compute.m", "plv_compute.m", "pac_compute.m", "dirpac_compute.m"):
for k, line in enumerate(SCRIPTS[name].splitlines()):
if "latency" in line:
print(f"{name}:{k + 1} {line.strip()}")
quote("psi_compute.m", 29, 36) # spectral step
quote("psianalysis.m", 26, 30) # cross-spectral density, no conjugate
quote("psianalysis.m", 46, 72) # per-trial PSI, trial mean, frequency-shuffled null
files: ['circ_corrcl.m', 'cspsi_compute.m', 'dirpac_compute.m', 'erp_compute.m', 'hilbertanalysis.m', 'pac_compute.m', 'pacanalysis.m', 'plv_compute.m', 'plvanalysis.m', 'power_compute.m', 'psi_compute.m', 'psianalysis.m', 'psianalysis_ver0_6.m', 'resamplemtx.m', 'subtracterp.m', 'zbaseline.m'] --- erp_compute.m, lines 44-47 44 % set up baseline correction 45 cfgb = []; 46 cfgb.latency = [0.65 0.85]; % -250 to 50 ms pretrial 47 cfgb.avgovertime = 'yes'; --- erp_compute.m, lines 74-97 74 % compute pretrial baseline temporal mean 75 pretrial = ft_timelockanalysis(cfgf, pretrial); % ERP 76 pretrial = ft_selectdata(cfgb, pretrial); % average over time 77 78 % compute ERPs 79 encmain = ft_selectdata(cfgc, encmain); % select trials 80 encmain = ft_timelockanalysis(cfgf, encmain); % ERP 81 proc = ft_selectdata(cfgc, proc); 82 proc = ft_timelockanalysis(cfgf, proc); 83 84 % absolute baseline correction 85 encmain.trial = encmain.trial - ... 86 repmat(nanmean(pretrial.trial), [size(encmain.trial,1) 1 size(encmain.trial,3)]); 87 proc.trial = proc.trial - ... 88 repmat(nanmean(pretrial.trial), [size(proc.trial,1) 1 size(proc.trial,3)]); 89 90 clear pretrial 91 92 % cut epochs of interest (and adjust to zero) 93 cfgt.latency = [0 1.5]; 94 encmain = ft_selectdata(cfgt, encmain); 95 96 cfgt.latency = [0.3 1.2]; 97 proc = ft_selectdata(cfgt, proc); power_compute.m:60 cfgt.latency = [0.65 0.85]; power_compute.m:63 cfgt.latency = [0 1.5]; power_compute.m:66 cfgt.latency = [0.3 1.2]; psi_compute.m:52 cfgt.latency = [0.6 1.5]; psi_compute.m:58 cfgt.latency = [0.3 1.2]; cspsi_compute.m:68 cfgt.latency = [0.6 1.5]; cspsi_compute.m:90 cfgt.latency = [0.3 1.2]; plv_compute.m:44 cfgt.latency = [0.6 1.5]; plv_compute.m:49 cfgt.latency = [0.3 1.2]; pac_compute.m:53 cfgt.latency = [0.3 1.2]; dirpac_compute.m:48 cfgt.latency = [0.3 1.2]; --- psi_compute.m, lines 29-36 29 cfg = []; 30 cfg.method = 'mtmfft'; 31 cfg.taper = 'hanning'; 32 cfg.foi = 3:1:7; % 3-7 Hz 33 cfg.tapsmofrq = 1; % 1-Hz half-band 34 cfg.pad = 4; % pad to 4 s 35 cfg.t_ftimwin = 3./cfg.foi; % frequency-dependent time window 36 cfg.output = 'fourier'; --- psianalysis.m, lines 26-30 26 % compute cross-spectral density 27 csd = zeros(ntrials, nchan, nchan, nfidx); 28 for e = 1:nchan 29 csd(:,e,:,:) = repmat(data.fourierspctrm(:,e,:), [1 nchan 1]).*data2.fourierspctrm; 30 end --- psianalysis.m, lines 46-72 46 end 47 48 % average phase slope for each frequency band 49 psisub = zeros(size(ppsub)); 50 psisub(:,:,freqbini) = sum(imag(conj(ppsub(:,:,1:end-1)).*ppsub(:,:,2:end)),3); 51 52 pp(r,:,:,:) = ppsub; 53 psisub2(r,:,:) = psisub(:,:,freqbini); 54 clear cs ppsub psisub 55 end 56 57 pp = squeeze(mean(pp)); % trial mean 58 psisub2 = squeeze(mean(psisub2)); 59 60 % z-score using frequency-shuffled data 61 nulldist = zeros(nchan,nchan,n_permutes); 62 for permi = 1:n_permutes 63 nulldist(:,:,permi) = sum(imag(conj(pp(:,:,randperm(nfidx))).*... 64 pp(:,:,randperm(nfidx))),3); 65 end 66 67 psimtx(:,:,freqbini) = (psisub2-mean(nulldist,3))./std(nulldist,[],3); 68 69 end 70 71 psi = []; 72 psi.dimord = 'chan_chan_freq';
erp_compute.m (lines 84 to 88) subtracts nanmean(pretrial.trial), the mean over trials of each
trial's baseline mean, so one value per electrode is subtracted from every trial; the ERP section
follows it, and subtracting each trial's own baseline mean is run as a variant. Every script cuts
the same latencies from the derived segments ([0 1.5] of encmain, [0.6 1.5] for the precue
delay, [0.3 1.2] of proc, [0.65 0.85] of pre, commented "-250 to 50 ms pretrial"). The PSI
script uses FieldTrip mtmfft with a Hanning taper and t_ftimwin set, which mtmfft ignores, so
the spectrum comes from one window over the 900 ms segment. psianalysis.m multiplies the Fourier
coefficients without a conjugate, takes the trial mean of per-trial PSI as the observed value, and
z-scores it against PSI computed from the trial-mean normalised cross-spectrum with its frequencies
shuffled.
# behaviour tables: the trial table against docs/summary_file.csv
rows = []
for sid, r in R.items():
t = r["sanity"]["trials"]
row = {"subject": sid, "n_trials": len(t), "per_condition": t.condition.value_counts().sort_index().tolist(),
"jitters": sorted(t.jitter.unique().tolist())}
srow = summary.set_index("subject").loc[sid]
for c, name in ((1, "identity"), (2, "spatial"), (3, "temporal")):
tc = t[t.condition == c]
row[f"acc_{name}"] = round(tc.accuracy.mean(), 3)
row[f"acc_{name}_doc"] = srow[f"acc_{name}"]
row[f"rt_{name}"] = round(tc[tc.accuracy == 1].rt.mean(), 1)
row[f"rt_{name}_doc"] = round(srow[f"rt_{name}"], 1)
rows.append(row)
beh = pd.DataFrame(rows)
print(beh.to_string(index=False))
acc_ok = all(np.isclose(beh[f"acc_{n}"], beh[f"acc_{n}_doc"], atol=1e-3).all() for n in ("identity", "spatial", "temporal"))
rt_ok = all(np.isclose(beh[f"rt_{n}"], beh[f"rt_{n}_doc"], atol=0.5).all() for n in ("identity", "spatial", "temporal"))
print("\naccuracy in summary_file.csv equals the trial tables (all 120 trials):", acc_ok)
print("response time in summary_file.csv equals the mean over correct trials of the trial tables:", rt_ok)
print("subjects' age and sex:", summary[["subject", "age", "sex"]].values.tolist())
print(f"age mean {summary.age.mean():.1f} SD {summary.age.std():.1f} range {summary.age.min()}-{summary.age.max()}; males {(summary.sex == 'M').sum()}")
# recordings deposited more than once
sig = {sid: (tuple(r["sanity"]["trials"].rt.tolist()), tuple(np.round(r["erp_mean"]["enc"][0, :50], 4))) for sid, r in R.items()}
dups = [(a, b) for i, a in enumerate(sig) for b in list(sig)[i + 1:] if sig[a][0] == sig[b][0] or sig[a][1] == sig[b][1]]
print("subjects with identical response-time sequences or identical evoked traces:", dups or "none")
# where do the response times of summary_file.csv come from? Candidate summaries of the trial
# tables, per subject and condition, against the file (a match is within 0.05 ms)
cands = {}
for sid, r in R.items():
t = r["sanity"]["trials"]
ti = r["trialinfo"]
k = pd.DataFrame({"accuracy": ti[:, 1], "condition": ti[:, 3], "rt": ti[:, 5], "trial": ti[:, 0]})
for c in (1, 2, 3):
tc, kc = t[t.condition == c], k[k.condition == c]
cr = tc[tc.accuracy == 1]
cands[(sid, c)] = {"mean correct": cr.rt.mean(), "median correct": cr.rt.median(), "mean all": tc.rt.mean(),
"median all": tc.rt.median(), "mean incorrect": tc[tc.accuracy == 0].rt.mean(),
"mean kept correct": kc[kc.accuracy == 1].rt.mean(), "mean kept all": kc.rt.mean(),
"median kept correct": kc[kc.accuracy == 1].rt.median(),
"geometric mean correct": np.exp(np.log(cr.rt).mean()),
"mean correct, by trial type": t[(t.accuracy == 1) & (t.trial_type == (1 if c == 1 else 2))].rt.mean()}
cr = t[t.accuracy == 1]
for b in range(3):
cands[(sid, f"block{b + 1}")] = {"mean correct, trials of block": cr[(cr.trial > 40 * b) & (cr.trial <= 40 * (b + 1))].rt.mean()}
doc = summary.set_index("subject")
rows = []
for sid in R:
for c, name in ((1, "identity"), (2, "spatial"), (3, "temporal")):
v = doc.loc[sid, f"rt_{name}"]
hits = [f"{s2}/{c2}: {k}" for (s2, c2), d in cands.items() for k, x in d.items() if abs(x - v) < 0.05]
rows.append({"subject": sid, "condition": name, "summary_file": round(v, 1),
"mean_correct": round(cands[(sid, c)]["mean correct"], 1),
"median_correct": round(cands[(sid, c)]["median correct"], 1),
"mean_all": round(cands[(sid, c)]["mean all"], 1), "matches": hits or "none"})
prov = pd.DataFrame(rows)
print("\nsummary_file.csv response times against summaries of the trial tables (any subject, condition or block):")
print(prov.to_string(index=False))
print("subject-condition values matched by some summary:", int((prov.matches != "none").sum()), "of", len(prov),
"; subjects with all three matched:", sorted(prov.groupby("subject").matches.apply(lambda s: (s != "none").all()).loc[lambda s: s].index.tolist()))
subject n_trials per_condition jitters acc_identity acc_identity_doc rt_identity rt_identity_doc acc_spatial acc_spatial_doc rt_spatial rt_spatial_doc acc_temporal acc_temporal_doc rt_temporal rt_temporal_doc
s1 120 [40, 40, 40] [900, 1150] 0.900 0.900 2348.3 1948.0 0.950 0.950 1060.6 1844.5 0.850 0.850 1575.1 1556.9
s2 120 [40, 40, 40] [900, 1150] 0.950 0.950 1324.4 1155.1 0.975 0.975 1095.1 1092.2 0.975 0.975 940.9 1169.4
s3 120 [40, 40, 40] [900, 1150] 0.925 0.925 2100.4 2248.9 0.775 0.775 1285.1 1432.2 0.750 0.750 1303.3 1481.5
s4 120 [40, 40, 40] [900, 1150] 0.925 0.925 2108.0 1562.4 0.925 0.925 1304.4 1740.3 0.950 0.950 1271.4 2069.6
s5 120 [40, 40, 40] [900, 1150] 0.825 0.825 2743.9 3174.5 0.800 0.800 2997.7 2535.3 0.750 0.750 2712.3 3142.2
s6 120 [40, 40, 40] [900, 1150] 0.925 0.925 1685.7 1685.7 1.000 1.000 962.9 962.9 0.925 0.925 1088.4 1088.4
s7 120 [40, 40, 40] [900, 1150] 0.900 0.900 1010.0 779.4 1.000 1.000 549.0 740.1 0.975 0.975 541.3 647.6
s8 120 [40, 40, 40] [900, 1150] 0.900 0.900 1469.2 1469.2 0.975 0.975 1037.1 1037.1 0.975 0.975 989.3 989.3
s9 120 [40, 40, 40] [900, 1150] 0.875 0.875 1700.1 1700.1 0.825 0.825 1308.8 1308.8 0.825 0.825 1797.5 1797.5
s10 120 [40, 40, 40] [900, 1150] 0.875 0.875 951.6 869.8 0.975 0.975 773.9 661.3 0.925 0.925 702.7 811.4
accuracy in summary_file.csv equals the trial tables (all 120 trials): True
response time in summary_file.csv equals the mean over correct trials of the trial tables: False
subjects' age and sex: [['s1', 33, 'F'], ['s2', 50, 'M'], ['s3', 69, 'F'], ['s4', 31, 'M'], ['s5', 22, 'M'], ['s6', 31, 'M'], ['s7', 34, 'M'], ['s8', 27, 'M'], ['s9', 34, 'F'], ['s10', 42, 'M']]
age mean 37.3 SD 13.5 range 22-69; males 7
subjects with identical response-time sequences or identical evoked traces: none
summary_file.csv response times against summaries of the trial tables (any subject, condition or block):
subject condition summary_file mean_correct median_correct mean_all matches
s1 identity 1948.0 2348.3 1681.0 2483.5 none
s1 spatial 1844.5 1060.6 820.5 1217.4 none
s1 temporal 1556.9 1575.1 661.0 1638.3 none
s2 identity 1155.1 1324.4 1290.5 1360.7 none
s2 spatial 1092.2 1095.1 1008.0 1106.3 none
s2 temporal 1169.4 940.9 950.0 942.5 none
s3 identity 2248.9 2100.4 1826.0 2277.8 none
s3 spatial 1432.2 1285.1 799.0 1928.4 none
s3 temporal 1481.5 1303.3 816.0 1506.9 none
s4 identity 1562.4 2108.0 1668.0 2606.0 none
s4 spatial 1740.3 1304.4 1079.0 1384.0 none
s4 temporal 2069.6 1271.4 1047.5 1424.0 none
s5 identity 3174.5 2743.9 1994.0 2965.7 none
s5 spatial 2535.3 2997.7 1062.0 3035.9 none
s5 temporal 3142.2 2712.3 1138.5 2774.5 none
s6 identity 1685.7 1685.7 1515.0 1783.4 [s6/1: mean correct, s6/1: mean correct, by trial type]
s6 spatial 962.9 962.9 815.0 962.9 [s6/2: mean correct, s6/2: mean all]
s6 temporal 1088.4 1088.4 908.0 1133.4 [s6/3: mean correct]
s7 identity 779.4 1010.0 885.0 1078.6 none
s7 spatial 740.1 549.0 489.0 549.0 none
s7 temporal 647.6 541.3 468.0 542.9 none
s8 identity 1469.2 1469.2 1299.0 1578.1 [s8/1: mean correct, s8/1: mean correct, by trial type]
s8 spatial 1037.1 1037.1 764.0 1074.1 [s8/2: mean correct]
s8 temporal 989.3 989.3 789.0 1021.4 [s8/3: mean correct]
s9 identity 1700.1 1700.1 1406.0 1858.8 [s9/1: mean correct, s9/1: mean kept correct, s9/1: mean correct, by trial type]
s9 spatial 1308.8 1308.8 895.0 1606.2 [s9/2: mean correct, s9/2: mean kept correct]
s9 temporal 1797.5 1797.5 1224.0 1947.3 [s9/3: mean correct, s9/3: mean kept correct]
s10 identity 869.8 951.6 863.0 962.2 none
s10 spatial 661.3 773.9 675.0 754.5 none
s10 temporal 811.4 702.7 661.0 673.7 none
subject-condition values matched by some summary: 9 of 30 ; subjects with all three matched: ['s6', 's8', 's9']
The accuracies of docs/summary_file.csv equal those of the per-trial tables over all 120 trials,
as its descriptor says. Its response times do not equal the mean over correct trials of the
per-trial tables in 7 of 10 subjects (they do in s6, s8 and s9; for s1, identity, 1948 against 2348
ms), although the descriptor says they are "calculated on all correct trials"; the paper's
condition means (1659, 1335, 1475 ms) are those of summary_file.csv. No other summary of the
trial tables tried here gives them either (medians, all trials, kept trials, other subjects'
rows, blocks of 40 trials, trial type): 9 of 30 values are matched, all by the mean over correct
trials of s6, s8 and s9. Age and sex match the paper's description (37 ± 13 years, 22 to 69, 7
males). No subject's data appear twice.
behavior-proficient¶
All ten subjects performed the task well above chance, with accuracy from 0.79 to 0.97 (chance 0.5).
acc_all = {sid: r["sanity"]["trials"].accuracy.mean() for sid, r in R.items()}
acc_kept = {sid: (r["trialinfo"][:, 1] == 1).mean() for sid, r in R.items()}
tab = pd.DataFrame({"all_120_trials": acc_all, "kept_trials": acc_kept}).round(3)
print(tab.to_string())
for col in tab:
v = tab[col]
print(f"{col}: min {v.min():.3f} (expected 0.79 +- 0.079), max {v.max():.3f} (expected 0.97 +- 0.097), "
f"all in [0.711, 1.0]: {bool(((v >= 0.711) & (v <= 1.0)).all())}; "
f"min ok {abs(v.min() - 0.79) <= 0.079}, max ok {abs(v.max() - 0.97) <= 0.097}")
all_120_trials kept_trials s1 0.900 0.919 s2 0.967 0.965 s3 0.817 0.835 s4 0.933 0.932 s5 0.792 0.792 s6 0.950 0.954 s7 0.958 1.000 s8 0.950 0.956 s9 0.842 0.842 s10 0.925 0.922 all_120_trials: min 0.792 (expected 0.79 +- 0.079), max 0.967 (expected 0.97 +- 0.097), all in [0.711, 1.0]: True; min ok True, max ok True kept_trials: min 0.792 (expected 0.79 +- 0.079), max 1.000 (expected 0.97 +- 0.097), all in [0.711, 1.0]: True; min ok True, max ok True
Result: reproduced. Over all 120 trials (reading a) accuracy runs from 0.792 to 0.967, every subject inside 0.711 to 1.0, both bounds within tolerance of 0.79 and 0.97. Over kept trials (reading b) it runs from 0.792 to 1.000, also within tolerance.
behavior-no-difficulty-difference¶
Accuracy and correct-trial response time did not differ between the identity, spatial and temporal conditions (mean accuracy 0.90, 0.92, 0.89; mean response time 1659, 1335, 1475 ms).
The models are fitted on one value per subject and condition (30 rows), as the criterion says; accuracy enters as the empirical logit, log((k + 0.5) / (n - k + 0.5)), as some subjects are at 100% in a condition (an assumption: the paper's "logit mixed-effects model" is not specified further). The criterion judges reading (c), condition as one numeric term coded identity 1, spatial 2, temporal 3 (the coding is an assumption the criterion states), which leaves F(1,28) on 30 rows. Its F is the squared t of the slope, with p from F(1,28), the residual degrees of freedom MATLAB's mixed-model F test uses by default (criterion). Reported, not judged: (a) each relation condition against identity and (b) one 3-level condition term (Wald test), and a trial-level variant of response time (all correct trials, subject random intercept).
Response time has two sources that disagree in 7 of 10 subjects: the mean over correct trials of
each trial table, and the per-subject values of docs/summary_file.csv, whose condition means are
the paper's. Both are tested; the outcome is judged on summary_file.csv as the values the paper's
statistics were computed from (an assumption). Accuracy is the same in both sources and is taken
under the two readings of behavior-proficient, (a) all 40 trials per condition and (b) the trials
kept in the derived data.
def behaviour_rows(kept):
rows = []
for sid, r in R.items():
if kept:
ti = r["trialinfo"]
t = pd.DataFrame({"accuracy": ti[:, 1], "condition": ti[:, 3], "rt": ti[:, 5]})
else:
t = r["sanity"]["trials"]
for c in (1, 2, 3):
tc = t[t.condition == c]
k, n = tc.accuracy.sum(), len(tc)
rows.append({"subject": sid, "cond": c, "acc": k / n, "k": k, "n": n,
"elogit": np.log((k + 0.5) / (n - k + 0.5)), "rt": tc[tc.accuracy == 1].rt.mean()})
return pd.DataFrame(rows)
def lmm_tests(d, y):
out = {}
m = smf.mixedlm(f"{y} ~ C(cond)", d, groups=d["subject"]).fit(reml=True)
out["spatial_vs_identity_p"] = m.pvalues["C(cond)[T.2]"]
out["temporal_vs_identity_p"] = m.pvalues["C(cond)[T.3]"]
w = m.wald_test("C(cond)[T.2] = 0, C(cond)[T.3] = 0", scalar=True)
out["three_level_chi2"], out["three_level_p"] = float(w.statistic), float(w.pvalue)
mn = smf.mixedlm(f"{y} ~ cond", d, groups=d["subject"]).fit(reml=True)
out["numeric_slope"], out["numeric_z"], out["numeric_p"] = mn.params["cond"], mn.tvalues["cond"], mn.pvalues["cond"]
# reading (c), judged: F(1,28) = t^2 of the slope, p from F(1,28) (criterion)
out["numeric_F"] = mn.tvalues["cond"] ** 2
out["numeric_p_F128"] = stats.f.sf(out["numeric_F"], 1, 28)
return out
for kept in (False, True):
d = behaviour_rows(kept)
label = "kept trials (b)" if kept else "all 120 trials (a)"
means = d.groupby("cond")[["acc", "rt"]].agg(["mean", "std"]).round(3)
print(f"--- {label}: mean and SD over subjects\n{means.to_string()}")
for y in ("elogit", "rt"):
print(f" {y}:", {k: round(v, 4) for k, v in lmm_tests(d, y).items()})
rows = []
for sid, r in R.items():
t = r["sanity"]["trials"]
t = t[t.accuracy == 1]
rows += [{"subject": sid, "cond": c, "rt": v} for c, v in zip(t.condition, t.rt)]
dt = pd.DataFrame(rows)
mt = smf.mixedlm("rt ~ C(cond)", dt, groups=dt["subject"]).fit()
w = mt.wald_test("C(cond)[T.2] = 0, C(cond)[T.3] = 0", scalar=True)
print("trial-level response time variant: p spatial", round(mt.pvalues["C(cond)[T.2]"], 4), "p temporal",
round(mt.pvalues["C(cond)[T.3]"], 4), "3-level p", round(float(w.pvalue), 4))
# the per-subject response times of docs/summary_file.csv, whose means are the paper's
sf = summary.melt(id_vars="subject", value_vars=["rt_identity", "rt_spatial", "rt_temporal"], var_name="c", value_name="rt")
sf["cond"] = sf.c.map({"rt_identity": 1, "rt_spatial": 2, "rt_temporal": 3})
print("summary_file.csv response time, mean and SD over subjects:", sf.groupby("cond").rt.agg(["mean", "std"]).round(1).to_dict("index"))
print(" rt (summary_file.csv):", {k: round(v, 4) for k, v in lmm_tests(sf, "rt").items()})
d = behaviour_rows(False)
exp = {1: (0.90, 0.04, 1659, 701), 2: (0.92, 0.09, 1335, 574), 3: (0.89, 0.09, 1475, 734)}
for c, (a, ta, rt, trt) in exp.items():
ma, mr = d[d.cond == c].acc.mean(), d[d.cond == c].rt.mean()
print(f"condition {c}: accuracy {ma:.3f} vs {a} +- {ta}: {abs(ma - a) <= ta}; rt {mr:.0f} vs {rt} +- {trt}: {abs(mr - rt) <= trt}")
# the judged reading (c): condition as one numeric term, p from F(1,28), effect at p < 0.05
judged = []
for kept in (False, True):
d = behaviour_rows(kept)
for y, source in (("elogit", "trial tables"), ("rt", "trial tables")):
judged.append((y, "kept" if kept else "all", source, lmm_tests(d, y)))
judged.append(("rt", "-", "summary_file.csv", lmm_tests(sf, "rt")))
print("reading (c), condition as one numeric term (paper: accuracy F(1,28) < 0.10, p > 0.75; rt F(1,28) < 2.55, p > 0.12)")
for y, trials, source, o in judged:
print(f" {y:7s} trials {trials:4s} {source:17s} slope {o['numeric_slope']:9.3f} F(1,28) {o['numeric_F']:6.2f} "
f"p {o['numeric_p_F128']:.4f} effect {o['numeric_p_F128'] < 0.05}")
--- all 120 trials (a): mean and SD over subjects
acc rt
mean std mean std
cond
1 0.90 0.035 1744.146 581.949
2 0.92 0.086 1237.449 663.860
3 0.89 0.090 1292.217 625.457
elogit: {'spatial_vs_identity_p': np.float64(0.0228), 'temporal_vs_identity_p': np.float64(0.6603), 'three_level_chi2': 5.8321, 'three_level_p': 0.0541, 'numeric_slope': np.float64(0.0617), 'numeric_z': np.float64(0.394), 'numeric_p': np.float64(0.6936), 'numeric_F': np.float64(0.1552), 'numeric_p_F128': np.float64(0.6966)}
rt: {'spatial_vs_identity_p': np.float64(0.0), 'temporal_vs_identity_p': np.float64(0.0), 'three_level_chi2': 26.5562, 'three_level_p': 0.0, 'numeric_slope': np.float64(-225.9646), 'numeric_z': np.float64(-3.5113), 'numeric_p': np.float64(0.0004), 'numeric_F': np.float64(12.3294), 'numeric_p_F128': np.float64(0.0015)}
--- kept trials (b): mean and SD over subjects
acc rt
mean std mean std
cond
1 0.908 0.049 1756.292 587.745
2 0.921 0.082 1224.706 667.893
3 0.904 0.094 1296.786 629.930
elogit: {'spatial_vs_identity_p': np.float64(0.1599), 'temporal_vs_identity_p': np.float64(0.5002), 'three_level_chi2': 1.9765, 'three_level_p': 0.3722, 'numeric_slope': np.float64(0.0979), 'numeric_z': np.float64(0.6651), 'numeric_p': np.float64(0.506), 'numeric_F': np.float64(0.4423), 'numeric_p_F128': np.float64(0.5114)}
rt: {'spatial_vs_identity_p': np.float64(0.0), 'temporal_vs_identity_p': np.float64(0.0), 'three_level_chi2': 26.2517, 'three_level_p': 0.0, 'numeric_slope': np.float64(-229.7532), 'numeric_z': np.float64(-3.3878), 'numeric_p': np.float64(0.0007), 'numeric_F': np.float64(11.4772), 'numeric_p_F128': np.float64(0.0021)}
trial-level response time variant: p spatial 0.0 p temporal 0.0 3-level p 0.0
summary_file.csv response time, mean and SD over subjects: {1: {'mean': 1659.3, 'std': 701.3}, 2: {'mean': 1335.5, 'std': 574.3}, 3: {'mean': 1475.4, 'std': 733.9}}
rt (summary_file.csv): {'spatial_vs_identity_p': np.float64(0.0018), 'temporal_vs_identity_p': np.float64(0.0769), 'three_level_chi2': 9.7556, 'three_level_p': 0.0076, 'numeric_slope': np.float64(-91.9733), 'numeric_z': np.float64(-1.5537), 'numeric_p': np.float64(0.1203), 'numeric_F': np.float64(2.4139), 'numeric_p_F128': np.float64(0.1315)}
condition 1: accuracy 0.900 vs 0.9 +- 0.04: True; rt 1744 vs 1659 +- 701: True
condition 2: accuracy 0.920 vs 0.92 +- 0.09: True; rt 1237 vs 1335 +- 574: True
condition 3: accuracy 0.890 vs 0.89 +- 0.09: True; rt 1292 vs 1475 +- 734: True
reading (c), condition as one numeric term (paper: accuracy F(1,28) < 0.10, p > 0.75; rt F(1,28) < 2.55, p > 0.12) elogit trials all trial tables slope 0.062 F(1,28) 0.16 p 0.6966 effect False rt trials all trial tables slope -225.965 F(1,28) 12.33 p 0.0015 effect True elogit trials kept trial tables slope 0.098 F(1,28) 0.44 p 0.5114 effect False rt trials kept trial tables slope -229.753 F(1,28) 11.48 p 0.0021 effect True rt trials - summary_file.csv slope -91.973 F(1,28) 2.41 p 0.1315 effect False
Result: reproduced, resting on two assumptions. Under reading (c), the one the criterion
judges, neither model finds a condition effect on the data whose condition means are the paper's:
accuracy gives F(1,28) = 0.16, p = 0.70 over all trials (0.44, p = 0.51 over kept trials), and the
response times of summary_file.csv give F(1,28) = 2.41, p = 0.13, against the paper's F < 2.55,
p > 0.12. The accuracy F is above the paper's bound of 0.10, though far from an effect. The outcome
rests on the numeric coding of condition, which the criterion states as an assumption, and on
judging response time on summary_file.csv, whose values none of the trial-table summaries above
reproduces for 7 of 10 subjects: with the trial tables' response times, (c) finds an effect
(F(1,28) = 12.33, p = 0.0015 over all trials; 11.48, p = 0.0021 over kept trials). The condition
means are within the paper's SDs (accuracy 0.900, 0.920, 0.890; response time 1659, 1335, 1475 ms
from summary_file.csv and 1744, 1237, 1292 ms from the trial tables). Under the readings reported
but not judged, response time differs by condition in both sources (summary_file.csv 3-level p =
0.0076, spatial against identity p = 0.0018), and accuracy over all trials differs between spatial
and identity (p = 0.023) though not under the 3-level term (p = 0.054).
electrode-counts¶
After bipolar rereferencing there were 254 electrodes, 36 MTL, 116 lateral PFC and 102 OFC; MTL and PFC were covered in the same hemisphere in 9 of 10 subjects and MTL and OFC in 7 of 10.
cnt = chtab.region.value_counts()
print("electrodes per region:", cnt.to_dict(), "total", len(chtab))
per = chtab.groupby(["subject", "region", "hemi"]).size().unstack(["region", "hemi"]).fillna(0).astype(int)
print(per.to_string())
def same_hemi(a, b):
return sum(any(((chtab.subject == s) & (chtab.region == a) & (chtab.hemi == h)).any() and
((chtab.subject == s) & (chtab.region == b) & (chtab.hemi == h)).any() for h in "LR")
for s in fcx2.SUBJECTS)
n_pfc, n_ofc = same_hemi("MTL", "PFC"), same_hemi("MTL", "OFC")
print("subjects with MTL and PFC in one hemisphere:", n_pfc, "(expected 9)")
print("subjects with MTL and OFC in one hemisphere:", n_ofc, "(expected 7)")
pr = chtab.groupby(["subject", "region"]).size().unstack().fillna(0)
for reg in ("MTL", "PFC", "OFC"):
v = pr[reg][pr[reg] > 0]
print(f"{reg} per subject with any: mean {pr[reg].mean():.1f} SD {pr[reg].std():.1f}; range {int(v.min())}-{int(v.max())} in {len(v)} subjects")
electrodes per region: {'PFC': 116, 'OFC': 102, 'MTL': 36} total 254
region MTL OFC PFC MTL OFC PFC
hemi R R R L L L
subject
s1 2 5 8 0 0 0
s10 0 2 0 5 45 0
s2 0 3 11 7 0 4
s3 2 0 2 0 1 2
s4 1 2 7 4 0 5
s5 0 0 0 2 16 10
s6 0 0 0 1 19 28
s7 0 4 6 2 1 11
s8 4 0 0 1 0 4
s9 0 0 12 5 4 6
subjects with MTL and PFC in one hemisphere: 9 (expected 9)
subjects with MTL and OFC in one hemisphere: 7 (expected 7)
MTL per subject with any: mean 3.6 SD 2.0; range 1-7 in 10 subjects
PFC per subject with any: mean 11.6 SD 8.3; range 4-28 in 9 subjects
OFC per subject with any: mean 10.2 SD 14.4; range 1-47 in 9 subjects
Result: reproduced. The channel table lists 36 MTL, 116 PFC and 102 OFC electrodes (254), all present in the derived data, and MTL shares a hemisphere with PFC in 9 subjects and with OFC in 7.
correct-trial-counts¶
The final data held on average 100 correct trials per subject, 33 +- 3 identity (26 to 37), 34 +- 4 spatial (28 to 39) and 33 +- 3 temporal (28 to 37), and 10 +- 8 incorrect trials (0 to 25).
rows = []
for sid, r in R.items():
ti = r["trialinfo"]
c = ti[:, 1] == 1
rows.append({"subject": sid, "correct": int(c.sum()), "identity": int((c & (ti[:, 3] == 1)).sum()),
"spatial": int((c & (ti[:, 3] == 2)).sum()), "temporal": int((c & (ti[:, 3] == 3)).sum()),
"incorrect": int((~c).sum()), "kept": len(ti)})
tc = pd.DataFrame(rows).set_index("subject")
print(tc.to_string())
print(tc.agg(["mean", "std", "min", "max"]).round(2).to_string())
checks = {"correct": (100, 10, None), "identity": (33, 3, (26, 37)), "spatial": (34, 4, (28, 39)),
"temporal": (33, 3, (28, 37)), "incorrect": (10, 8, (0, 25))}
for k, (v, tol, rg) in checks.items():
m = tc[k].mean()
line = f"{k}: mean {m:.1f} vs {v} +- {tol}: {abs(m - v) <= tol}"
if rg:
lo, hi = rg[0] - 0.1 * rg[0], rg[1] + 0.1 * rg[1]
line += f"; all subjects in [{lo:.1f}, {hi:.1f}]: {bool(((tc[k] >= lo) & (tc[k] <= hi)).all())}"
print(line)
correct identity spatial temporal incorrect kept
subject
s1 102 33 36 33 9 111
s2 109 35 38 36 4 113
s3 96 37 31 28 19 115
s4 110 36 37 37 8 118
s5 95 33 32 30 25 120
s6 103 29 39 35 5 108
s7 100 32 35 33 0 100
s8 86 26 28 32 4 90
s9 101 35 33 33 19 120
s10 107 33 39 35 9 116
correct identity spatial temporal incorrect kept
mean 100.90 32.90 34.80 33.20 10.20 111.10
std 7.25 3.31 3.71 2.74 8.09 9.59
min 86.00 26.00 28.00 28.00 0.00 90.00
max 110.00 37.00 39.00 37.00 25.00 120.00
correct: mean 100.9 vs 100 +- 10: True
identity: mean 32.9 vs 33 +- 3: True; all subjects in [23.4, 40.7]: True
spatial: mean 34.8 vs 34 +- 4: True; all subjects in [25.2, 42.9]: True
temporal: mean 33.2 vs 33 +- 3: True; all subjects in [25.2, 40.7]: True
incorrect: mean 10.2 vs 10 +- 8: True; all subjects in [0.0, 27.5]: True
Result: reproduced. The kept trials hold on average 100.9 correct trials per subject (32.9 identity, 34.8 spatial, 33.2 temporal) and 10.2 incorrect, each within the paper's SD, and every subject's count lies in the widened ranges (identity 26 to 37, spatial 28 to 39, temporal 28 to 37, incorrect 0 to 25).
erp-no-condition-difference¶
ERPs did not differ between identity, spatial and temporal conditions in any electrode, over encoding, precue or postcue intervals.
The test is run per subject as erp_compute.m does (all of a subject's analysed electrodes in one
test, so the null is the largest cluster over the subject's electrodes), and per electrode (the
Methods' "clustered per electrode") as a variant. The baseline subtracted is the trial mean of
each trial's baseline mean, as erp_compute.m does it (lines 84 to 88, quoted above); each trial's
own baseline mean is a variant, and so are the code's windows.
rows = []
for tag, label in (("", "main: trial-mean baseline (code)"), ("_trial", "variant: per-trial baseline"), ("_alt", "variant: code's windows")):
for sid, r in R.items():
for test in ("erp_enc", "erp_post"):
d = r[test + tag]
rows.append({"reading": label, "subject": sid, "test": test, "n_el": len(d),
"sig_subject_null": int((d.p_subject < 0.05).sum()),
"sig_electrode_null": int((d.p_electrode < 0.05).sum()), "min_p_subject": round(d.p_subject.min(), 3),
"min_p_electrode": round(d.p_electrode.min(), 3)})
erp = pd.DataFrame(rows)
print(erp[erp.reading.str.startswith("main")].to_string(index=False))
n_el = len(chtab)
for tag, label in (("", "main: trial-mean baseline (code)"), ("_trial", "variant: per-trial baseline"), ("_alt", "variant: code's windows")):
for null in ("p_subject", "p_electrode"):
sig_any = sum(int(((R[s]["erp_enc" + tag][null] < 0.05).to_numpy() | (R[s]["erp_post" + tag][null] < 0.05).to_numpy()).sum()) for s in R)
where = [(s, R[s]["chans"].label[i]) for s in R for i in np.where((R[s]["erp_enc" + tag][null] < 0.05).to_numpy() | (R[s]["erp_post" + tag][null] < 0.05).to_numpy())[0]]
print(f"{label}, {null}: electrodes with a significant cluster in either test: {sig_any} of {n_el}"
+ (f" {where}" if null == "p_subject" else ""))
print(f"expected false positives at alpha 0.05 over {n_el} electrodes and two tests, per-electrode null: {0.05 * 2 * n_el:.1f}")
reading subject test n_el sig_subject_null sig_electrode_null min_p_subject min_p_electrode
main: trial-mean baseline (code) s1 erp_enc 15 0 1 0.460 0.008
main: trial-mean baseline (code) s1 erp_post 15 0 0 0.306 0.055
main: trial-mean baseline (code) s2 erp_enc 25 0 0 1.000 0.176
main: trial-mean baseline (code) s2 erp_post 25 0 1 0.811 0.035
main: trial-mean baseline (code) s3 erp_enc 7 0 0 0.484 0.176
main: trial-mean baseline (code) s3 erp_post 7 0 0 0.819 0.315
main: trial-mean baseline (code) s4 erp_enc 19 0 0 0.817 0.128
main: trial-mean baseline (code) s4 erp_post 19 0 0 0.948 0.150
main: trial-mean baseline (code) s5 erp_enc 28 0 2 0.072 0.012
main: trial-mean baseline (code) s5 erp_post 28 0 2 0.125 0.006
main: trial-mean baseline (code) s6 erp_enc 48 0 0 1.000 0.104
main: trial-mean baseline (code) s6 erp_post 48 0 3 0.138 0.005
main: trial-mean baseline (code) s7 erp_enc 24 0 3 0.132 0.024
main: trial-mean baseline (code) s7 erp_post 24 0 4 0.142 0.006
main: trial-mean baseline (code) s8 erp_enc 9 0 0 0.398 0.062
main: trial-mean baseline (code) s8 erp_post 9 0 0 0.967 0.325
main: trial-mean baseline (code) s9 erp_enc 27 1 7 0.036 0.006
main: trial-mean baseline (code) s9 erp_post 27 0 2 0.582 0.018
main: trial-mean baseline (code) s10 erp_enc 52 0 2 1.000 0.020
main: trial-mean baseline (code) s10 erp_post 52 0 3 0.573 0.033
main: trial-mean baseline (code), p_subject: electrodes with a significant cluster in either test: 1 of 254 [('s9', 'FORA_11')]
main: trial-mean baseline (code), p_electrode: electrodes with a significant cluster in either test: 27 of 254
variant: per-trial baseline, p_subject: electrodes with a significant cluster in either test: 0 of 254 []
variant: per-trial baseline, p_electrode: electrodes with a significant cluster in either test: 22 of 254
variant: code's windows, p_subject: electrodes with a significant cluster in either test: 1 of 254 [('s5', 'OFG14')]
variant: code's windows, p_electrode: electrodes with a significant cluster in either test: 13 of 254
expected false positives at alpha 0.05 over 254 electrodes and two tests, per-electrode null: 25.4
Result: not reproduced, resting on the baseline of the code. With the subject-wide null and the code's baseline, one electrode of 254 (s9, FORA_11, encoding t test, cluster p = 0.036) has a significant cluster, and the criterion allows none; with the code's windows one electrode does too (s5, OFG14). Subtracting each trial's own baseline mean leaves no electrode significant under the subject-wide null, which the criterion would call reproduced. With a per-electrode null 27, 22 and 13 electrodes have a significant cluster (code's baseline, per-trial baseline, code's windows), against 25.4 expected by chance over two tests, so the effect is no larger than chance.
power-theta-sustained¶
Task-induced power showed sustained theta band (3 to 7 Hz) activity in MTL, PFC and OFC over encoding and delay, with transient activity above 16 Hz, and alpha (8 to 13 Hz) desynchronized in the MTL.
Theta is the four filters centred at 3.5 to 6.5 Hz; alpha the three centred at 8 to 11.5 Hz. Time points: the 31 points of encoding and precue and the 19 of the postcue delay, at 50 ms, in the trial table's windows and, as a variant, the code's. All 254 analysed electrodes (the claim is about the power before the exclusions).
TH = [2, 3, 4, 5]
AL = [6, 7, 8]
HI = [i for i, c in enumerate(fcx2.CENTRES) if c > 16]
def zcurve(r, idx, bands, key):
zs = np.concatenate([r[key]["enc"][idx][:, bands].mean(axis=1),
r[key]["post"][idx][:, bands].mean(axis=1)], axis=-1)
return zs # (electrodes, 50 time points)
def power_table(key):
rows = []
for sid, r in R.items():
c = r["chans"]
for reg in ("MTL", "PFC", "OFC"):
idx = np.where(c.region == reg)[0]
if len(idx) == 0:
continue
th = zcurve(r, idx, TH, key)
al = zcurve(r, idx, AL, key)
hi = np.concatenate([r[key]["enc"][idx][:, [h for h in HI if h < r[key]["enc"].shape[1]]],
r[key]["post"][idx][:, [h for h in HI if h < r[key]["post"].shape[1]]]], axis=-1)
rows.append({"subject": sid, "region": reg, "n": len(idx),
"theta_frac_above": (th.mean(axis=0) > 1.96).mean(), "theta_median_z": np.median(th.mean(axis=0)),
"alpha_frac_below": (al.mean(axis=0) < -1.96).mean(), "alpha_median_z": np.median(al.mean(axis=0)),
"el_theta_sustained": ((th > 1.96).mean(axis=1) >= 0.5).mean(),
"el_alpha_desync": ((al < -1.96).mean(axis=1) >= 0.5).mean(),
"el_any_high_above": int((hi > 1.96).any(axis=(1, 2)).sum()),
"theta_z_range": (round(th.min(), 1), round(th.max(), 1))})
return pd.DataFrame(rows)
for key, label in (("power_z_mean", "trial table's windows (main)"), ("power_z_mean_alt", "code's windows (1.5 s later)")):
pw = power_table(key)
print(f"=== {label}")
print(pw.round(3).to_string(index=False))
for reg in ("MTL", "PFC", "OFC"):
d = pw[pw.region == reg]
print(f"{reg}: (a) subjects with region-average theta z > 1.96 at >= half the time points: {(d.theta_frac_above >= 0.5).sum()} of {len(d)}; "
f"(b) electrodes meeting the rule: {np.sum(d.el_theta_sustained * d.n):.0f} of {d.n.sum()}")
d = pw[pw.region == "MTL"]
print(f"MTL alpha: (a) subjects with alpha z < -1.96 at >= half the time points: {(d.alpha_frac_below >= 0.5).sum()} of {len(d)}; "
f"(b) electrodes {np.sum(d.el_alpha_desync * d.n):.0f} of {d.n.sum()}")
print("electrodes with any z > 1.96 above 16 Hz:", int(pw.el_any_high_above.sum()), "of", int(pw.n.sum()))
=== trial table's windows (main)
subject region n theta_frac_above theta_median_z alpha_frac_below alpha_median_z el_theta_sustained el_alpha_desync el_any_high_above theta_z_range
s1 MTL 2 0.00 -0.327 0.00 -0.346 0.000 0.000 2 (-3.1, 1.8)
s1 PFC 8 0.00 0.181 0.00 -0.076 0.000 0.000 8 (-4.7, 2.9)
s1 OFC 5 0.00 -0.500 0.00 0.100 0.000 0.000 5 (-4.9, 1.6)
s2 MTL 7 0.00 0.108 0.00 -0.517 0.000 0.000 7 (-3.0, 3.0)
s2 PFC 15 0.00 0.751 0.00 0.435 0.133 0.000 15 (-5.8, 4.8)
s2 OFC 3 0.00 -0.317 0.00 -0.036 0.000 0.000 3 (-3.4, 1.9)
s3 MTL 2 0.00 -0.241 0.00 0.403 0.000 0.000 2 (-3.0, 1.3)
s3 PFC 4 0.00 -0.174 0.00 -0.466 0.000 0.000 4 (-6.8, 1.8)
s3 OFC 1 0.00 0.055 0.00 1.261 0.000 0.000 1 (-0.8, 0.9)
s4 MTL 5 0.04 0.611 0.00 1.321 0.000 0.000 5 (-3.1, 8.4)
s4 PFC 12 0.00 0.824 0.00 0.951 0.083 0.000 12 (-4.2, 5.7)
s4 OFC 2 0.00 -0.124 0.00 0.051 0.000 0.000 2 (-3.2, 3.4)
s5 MTL 2 0.00 -0.809 0.00 0.146 0.000 0.000 2 (-3.2, 1.2)
s5 PFC 10 0.00 -1.128 0.26 -1.190 0.000 0.200 10 (-4.4, 4.5)
s5 OFC 16 0.04 0.435 0.00 0.051 0.000 0.000 16 (-3.4, 6.1)
s6 MTL 1 0.16 1.159 0.00 0.956 0.000 0.000 1 (-3.5, 2.8)
s6 PFC 28 0.10 0.260 0.00 0.379 0.036 0.000 28 (-4.5, 45.299999)
s6 OFC 19 0.00 0.732 0.00 -0.211 0.158 0.000 19 (-4.3, 5.9)
s7 MTL 2 0.00 -0.830 0.00 -1.155 0.000 0.000 2 (-2.6, 1.0)
s7 PFC 17 0.18 0.158 0.00 -0.730 0.000 0.059 17 (-4.6, 31.0)
s7 OFC 5 0.18 0.897 0.04 -0.691 0.200 0.000 5 (-4.4, 5.3)
s8 MTL 5 0.00 -0.310 0.00 -0.239 0.000 0.000 5 (-4.6, 3.1)
s8 PFC 4 0.00 -1.999 0.00 -0.685 0.000 0.500 4 (-4.5, 4.4)
s9 MTL 5 0.62 2.200 0.00 3.138 0.600 0.000 5 (-2.0, 23.5)
s9 PFC 18 0.24 0.406 0.00 0.695 0.000 0.000 18 (-3.9, 14.3)
s9 OFC 4 0.38 1.201 0.00 1.233 0.250 0.000 4 (-2.6, 32.700001)
s10 MTL 5 0.00 -1.107 0.16 -1.380 0.000 0.400 5 (-4.9, 0.6)
s10 OFC 47 0.00 0.480 0.00 0.385 0.064 0.000 47 (-4.5, 9.1)
MTL: (a) subjects with region-average theta z > 1.96 at >= half the time points: 1 of 10; (b) electrodes meeting the rule: 3 of 36
PFC: (a) subjects with region-average theta z > 1.96 at >= half the time points: 0 of 9; (b) electrodes meeting the rule: 4 of 116
OFC: (a) subjects with region-average theta z > 1.96 at >= half the time points: 0 of 9; (b) electrodes meeting the rule: 8 of 102
MTL alpha: (a) subjects with alpha z < -1.96 at >= half the time points: 0 of 10; (b) electrodes 2 of 36
electrodes with any z > 1.96 above 16 Hz: 254 of 254
=== code's windows (1.5 s later)
subject region n theta_frac_above theta_median_z alpha_frac_below alpha_median_z el_theta_sustained el_alpha_desync el_any_high_above theta_z_range
s1 MTL 2 0.02 0.840 0.00 0.204 0.000 0.000 2 (-0.8, 3.5)
s1 PFC 8 0.00 0.010 0.00 0.380 0.000 0.000 8 (-1.9, 2.8)
s1 OFC 5 0.00 -0.510 0.00 0.272 0.000 0.000 5 (-1.8, 1.3)
s2 MTL 7 0.00 0.770 0.00 0.355 0.143 0.000 7 (-1.5, 3.9)
s2 PFC 15 0.00 -0.098 0.00 -0.071 0.000 0.000 15 (-2.6, 2.5)
s2 OFC 3 0.00 -0.983 0.00 -0.559 0.000 0.000 3 (-2.5, 1.1)
s3 MTL 2 0.36 0.397 0.00 -0.344 0.000 0.000 2 (-1.5, 69.199997)
s3 PFC 4 0.14 0.504 0.00 0.341 0.000 0.000 3 (-1.5, 12.3)
s3 OFC 1 0.00 1.015 0.04 -0.257 0.000 0.000 1 (0.0, 1.5)
s4 MTL 5 0.00 -0.232 0.00 -0.112 0.000 0.000 5 (-2.4, 3.0)
s4 PFC 12 0.00 -0.467 0.00 -0.246 0.000 0.000 12 (-2.7, 2.3)
s4 OFC 2 0.00 -0.826 0.00 0.078 0.000 0.000 2 (-2.3, 1.3)
s5 MTL 2 0.00 -0.372 0.00 -0.294 0.000 0.000 2 (-2.5, 1.1)
s5 PFC 10 0.00 -1.785 0.36 -1.503 0.000 0.400 10 (-5.0, 0.4)
s5 OFC 16 0.00 0.033 0.00 -0.140 0.000 0.000 11 (-3.2, 4.6)
s6 MTL 1 0.00 -0.207 0.00 -0.810 0.000 0.000 0 (-1.1, 1.5)
s6 PFC 28 0.00 -0.279 0.00 0.060 0.036 0.000 25 (-3.5, 5.7)
s6 OFC 19 0.00 0.373 0.00 0.730 0.105 0.000 19 (-2.2, 4.8)
s7 MTL 2 0.00 -1.044 0.24 -0.507 0.000 0.000 2 (-3.1, 1.8)
s7 PFC 17 0.24 0.848 0.00 -0.605 0.000 0.294 17 (-2.3, 49.700001)
s7 OFC 5 0.00 0.158 0.10 -1.261 0.200 0.200 5 (-3.3, 6.0)
s8 MTL 5 0.08 0.821 0.00 -0.196 0.000 0.000 5 (-2.6, 3.7)
s8 PFC 4 0.00 -1.233 0.00 -0.865 0.000 0.000 4 (-4.0, 3.6)
s9 MTL 5 0.00 -0.341 0.00 -0.002 0.000 0.000 5 (-1.8, 3.0)
s9 PFC 18 0.00 -0.651 0.00 0.166 0.000 0.000 16 (-1.9, 2.3)
s9 OFC 4 0.00 -0.784 0.00 -0.644 0.000 0.000 4 (-2.0, 0.7)
s10 MTL 5 0.00 -0.391 0.00 0.352 0.000 0.000 5 (-3.2, 2.7)
s10 OFC 47 0.06 1.124 0.00 0.698 0.170 0.000 44 (-3.1, 9.7)
MTL: (a) subjects with region-average theta z > 1.96 at >= half the time points: 0 of 10; (b) electrodes meeting the rule: 1 of 36
PFC: (a) subjects with region-average theta z > 1.96 at >= half the time points: 0 of 9; (b) electrodes meeting the rule: 1 of 116
OFC: (a) subjects with region-average theta z > 1.96 at >= half the time points: 0 of 9; (b) electrodes meeting the rule: 11 of 102
MTL alpha: (a) subjects with alpha z < -1.96 at >= half the time points: 0 of 10; (b) electrodes 0 of 36
electrodes with any z > 1.96 above 16 Hz: 239 of 254
# filter edge effects of the trial table's windows (fcx2.edge_check). The baseline starts 0.65 s,
# encoding 0 s and the postcue delay 0.3 s after the first sample of their segment. Encoding and
# postcue power are compared at the same samples, filtered from their own segment and from the three
# segments of the trial joined into one trace. No data precede the baseline, so its edge effect is
# measured at an interior window of the same length, cut as pre is cut around the baseline. The
# 1-3 Hz band is used by no claim, and its filter order is capped differently on the joined trace.
print("samples inside a joined trace that no segment covers:", sum(r["edge"]["gaps"] for r in R.values()))
EB = [f"{lo:g}-{hi:g} Hz" for lo, hi in next(iter(R.values()))["edge"]["bands"]][1:]
def pooled(k):
return np.concatenate([r["edge"][k] for r in R.values()])[:, 1:] # 254 electrodes
print("\nbaseline: power 0.65 to 0.85 s after a 4.5 s cut's first sample over the joined trace's power, "
"median over electrodes")
print(pd.DataFrame({"band": EB, "trial_mean_ratio": np.median(pooled("base_ratio"), 0),
"across_trial_sd_ratio": np.median(pooled("base_sd_ratio"), 0)}).round(3).to_string(index=False))
for w, cols in (("enc", ["0-0.25", "0.25-0.5", "0.5-0.75", "0.75-1.0", "1.0-1.25", "1.25-1.5"]),
("post", ["0.3-0.55", "0.55-0.8", "0.8-1.05", "1.05-1.2"])):
print(f"\n{w}: trial-mean power from the segment over power from the joined trace, by s after the segment's "
"first sample, median over electrodes (10th and 90th percentile of the first bin)")
m = pooled(f"{w}_ratio_bins")
t = pd.DataFrame(np.median(m, 0), index=EB, columns=cols)
t["p10_first"], t["p90_first"] = np.percentile(m[..., 0], 10, axis=0), np.percentile(m[..., 0], 90, axis=0)
print(t.round(3).to_string())
for r in R.values():
r["power_z_mean_edge"] = r["edge"]["power_z_mean"]
pw = power_table("power_z_mean_edge")
print("\n=== trial table's windows, encoding and postcue power from the joined trace (bands up to 9-14 Hz)")
for reg in ("MTL", "PFC", "OFC"):
d = pw[pw.region == reg]
print(f"{reg}: (a) subjects with region-average theta z > 1.96 at >= half the time points: {(d.theta_frac_above >= 0.5).sum()} of {len(d)}; "
f"(b) electrodes meeting the rule: {np.sum(d.el_theta_sustained * d.n):.0f} of {d.n.sum()}")
d = pw[pw.region == "MTL"]
print(f"MTL alpha: (a) subjects with alpha z < -1.96 at >= half the time points: {(d.alpha_frac_below >= 0.5).sum()} of {len(d)}; "
f"(b) electrodes {np.sum(d.el_alpha_desync * d.n):.0f} of {d.n.sum()}")
samples inside a joined trace that no segment covers: 0
baseline: power 0.65 to 0.85 s after a 4.5 s cut's first sample over the joined trace's power, median over electrodes
band trial_mean_ratio across_trial_sd_ratio
1.5-4 Hz 0.999 0.999
2-5 Hz 1.000 1.000
3-6 Hz 1.000 1.000
4-7 Hz 1.000 1.000
5-8 Hz 1.000 1.000
6-10 Hz 1.000 1.000
7-12 Hz 1.000 1.000
9-14 Hz 1.000 1.000
enc: trial-mean power from the segment over power from the joined trace, by s after the segment's first sample, median over electrodes (10th and 90th percentile of the first bin)
0-0.25 0.25-0.5 0.5-0.75 0.75-1.0 1.0-1.25 1.25-1.5 p10_first p90_first
1.5-4 Hz 0.727 0.981 0.997 1.0 1.0 1.0 0.634 0.823
2-5 Hz 0.793 0.992 0.999 1.0 1.0 1.0 0.690 0.916
3-6 Hz 0.811 0.998 1.000 1.0 1.0 1.0 0.729 0.934
4-7 Hz 0.837 0.999 1.000 1.0 1.0 1.0 0.733 0.951
5-8 Hz 0.870 1.000 1.000 1.0 1.0 1.0 0.779 1.003
6-10 Hz 0.940 1.000 1.000 1.0 1.0 1.0 0.854 1.152
7-12 Hz 0.965 1.000 1.000 1.0 1.0 1.0 0.886 1.183
9-14 Hz 0.981 1.000 1.000 1.0 1.0 1.0 0.914 1.215
post: trial-mean power from the segment over power from the joined trace, by s after the segment's first sample, median over electrodes (10th and 90th percentile of the first bin)
0.3-0.55 0.55-0.8 0.8-1.05 1.05-1.2 p10_first p90_first
1.5-4 Hz 0.989 0.996 1.0 1.0 0.973 1.002
2-5 Hz 0.995 0.999 1.0 1.0 0.981 1.004
3-6 Hz 1.000 1.000 1.0 1.0 0.996 1.005
4-7 Hz 0.999 1.000 1.0 1.0 0.996 1.003
5-8 Hz 1.000 1.000 1.0 1.0 0.998 1.002
6-10 Hz 1.000 1.000 1.0 1.0 1.000 1.000
7-12 Hz 1.000 1.000 1.0 1.0 1.000 1.000
9-14 Hz 1.000 1.000 1.0 1.0 1.000 1.000
=== trial table's windows, encoding and postcue power from the joined trace (bands up to 9-14 Hz) MTL: (a) subjects with region-average theta z > 1.96 at >= half the time points: 1 of 10; (b) electrodes meeting the rule: 3 of 36 PFC: (a) subjects with region-average theta z > 1.96 at >= half the time points: 0 of 9; (b) electrodes meeting the rule: 5 of 116 OFC: (a) subjects with region-average theta z > 1.96 at >= half the time points: 0 of 9; (b) electrodes meeting the rule: 8 of 102 MTL alpha: (a) subjects with alpha z < -1.96 at >= half the time points: 0 of 10; (b) electrodes 2 of 36
Result: not reproduced. In the trial table's windows the region-average theta z is above 1.96 over half the time points in 1 of 10 subjects for MTL, 0 of 9 for PFC and 0 of 9 for OFC, and no subject shows MTL alpha below -1.96 over half the time points (0 of 10). Per electrode, 3 of 36 MTL, 4 of 116 PFC and 8 of 102 OFC electrodes meet the theta rule. In the code's windows the counts are 0, 0 and 0 subjects (1, 1 and 11 electrodes) and 0 of 10 for alpha. All 254 electrodes have some z above 1.96 above 16 Hz (239 in the code's windows).
Edge effects of the trial table's windows. Baseline power is not affected: at an interior window
cut as pre is cut around the baseline, the trial-mean power and its SD over trials are 0.999 to
1.000 of the joined trace's in every band from 1.5-4 to 9-14 Hz. Encoding power is lower than the
joined trace's in the first 250 ms only (median ratio 0.73 at 1.5-4 Hz, 0.79 to 0.87 at 2-5 to 5-8
Hz, 0.94 to 0.98 in alpha; 0.98 or more from 0.25 s on), and postcue power by at most 1.1%. With
encoding and postcue power taken from the joined trace, theta is sustained in 1 of 10, 0 of 9 and 0
of 9 subjects (3, 5 and 8 electrodes) and MTL alpha in 0 of 10, so the outcome does not rest on the
edge effects.
power-condition-exclusions¶
Power did not differ between conditions at any time and frequency in 246 of 254 electrodes; the 8 that differed (5 PFC and 3 OFC, in 4 of 10 subjects) were excluded from further analysis.
The baseline z is an affine map of power per electrode and frequency, shared by all trials, so the t and F statistics, and the test, are the same on z and on raw power (readings a and b of the claim give one result).
rows = []
for tag in ("", "_alt"):
for sid, r in R.items():
c = r["chans"]
for null in ("p_subject", "p_electrode"):
sig = (np.minimum(r["pow_enc" + tag][null], r["pow_post" + tag][null]) < 0.05).to_numpy()
for i in np.where(sig)[0]:
rows.append({"windows": "code" if tag else "trial table", "null": null, "subject": sid, "label": c.label[i],
"region": c.region[i], "p_enc": round(r["pow_enc" + tag][null][i], 3),
"p_post": round(r["pow_post" + tag][null][i], 3)})
ex = pd.DataFrame(rows)
print(ex[(ex.windows == "trial table") & (ex.null == "p_subject")].to_string(index=False))
print(ex[(ex.windows == "code") & (ex.null == "p_subject")].to_string(index=False))
for w in ("trial table", "code"):
for null in ("p_subject", "p_electrode"):
d = ex[(ex.windows == w) & (ex.null == null)]
print(f"{w} windows, {null}: {len(d)} electrodes ({d.region.value_counts().to_dict()}) in {d.subject.nunique()} subjects; expected 8 (5 PFC, 3 OFC) in 4")
windows null subject label region p_enc p_post
trial table p_subject s1 RTHD1 MTL 1.000 0.029
trial table p_subject s6 AOF1 OFC 0.551 0.003
trial table p_subject s6 FG22 PFC 1.000 0.025
trial table p_subject s8 AR_01 MTL 0.555 0.002
trial table p_subject s10 AVF5 OFC 1.000 0.030
trial table p_subject s10 FG17 OFC 0.038 1.000
trial table p_subject s10 FG23 OFC 0.024 1.000
windows null subject label region p_enc p_post
code p_subject s5 LTG41 PFC 0.881 0.033
code p_subject s6 AOF1 OFC 0.006 0.997
code p_subject s6 AOF5 OFC 0.038 1.000
code p_subject s6 POF5 OFC 0.036 1.000
code p_subject s6 FG22 PFC 0.004 1.000
code p_subject s6 FG23 PFC 0.004 0.890
code p_subject s7 ROF1 OFC 1.000 0.043
code p_subject s7 RAC10 PFC 1.000 0.007
code p_subject s7 LIN6 PFC 0.006 0.955
code p_subject s8 AR_01 MTL 0.004 0.028
code p_subject s8 FOAL_05 PFC 0.026 0.431
code p_subject s10 FG17 OFC 1.000 0.050
trial table windows, p_subject: 7 electrodes ({'OFC': 4, 'MTL': 2, 'PFC': 1}) in 4 subjects; expected 8 (5 PFC, 3 OFC) in 4
trial table windows, p_electrode: 57 electrodes ({'OFC': 25, 'PFC': 23, 'MTL': 9}) in 10 subjects; expected 8 (5 PFC, 3 OFC) in 4
code windows, p_subject: 12 electrodes ({'PFC': 6, 'OFC': 5, 'MTL': 1}) in 5 subjects; expected 8 (5 PFC, 3 OFC) in 4
code windows, p_electrode: 69 electrodes ({'PFC': 38, 'OFC': 28, 'MTL': 3}) in 9 subjects; expected 8 (5 PFC, 3 OFC) in 4
Result: not reproduced. In the trial table's windows the subject-wide null finds 7 electrodes (2 MTL, 1 PFC, 4 OFC) in 4 subjects (s1, s6, s8, s10), against 8 (5 PFC, 3 OFC) in 4; in the code's windows it finds 12 (6 PFC, 5 OFC, 1 MTL) in 5 subjects. The per-electrode null finds many more (57 and 69). The 7 are excluded from the analyses that follow, which leaves 34 MTL, 115 PFC and 98 OFC electrodes (the code's windows exclude their own 12).
plv-theta-peak¶
Phase-locking values over the delays peaked in the theta band within the MTL and between MTL and frontal (PFC and OFC) electrodes, with broader synchrony in the alpha range.
Readings: (a) imaginary PLV, |Im(mean over trials of exp(i(phi1 - phi2)))|; (b) the phase-lag index;
and the code's own form (plvanalysis.m: the PLV of the imaginary parts of the analytic signals
taken as angles) as a variant. Spectra are averaged over time and over the two delays; a peak is a
filter centred at 3.5 to 6.5 Hz larger than both neighbours.
cent = fcx2.CENTRES[fcx2.PLV_BANDS]
print("filter centres:", cent.tolist())
rows = []
for tag in ("", "_alt"):
for sid, r in R.items():
for g in ("MTL-MTL", "MTL-PFC", "MTL-OFC"):
if len(r["pairs" + tag][g]) == 0:
continue
for rd in ("implv", "pli", "code"):
spec = (r["plv" + tag]["pre"][g][rd].mean(axis=0) + r["plv" + tag]["post"][g][rd].mean(axis=0)) / 2
peaks = [cent[i] for i in range(1, len(spec) - 1) if spec[i] > spec[i - 1] and spec[i] > spec[i + 1]]
rows.append({"windows": "code" if tag else "table", "subject": sid, "group": g, "reading": rd, "pairs": len(r["pairs" + tag][g]),
"theta_peak": any(3 <= p <= 7 for p in peaks), "peaks_Hz": peaks,
"max_at_Hz": cent[int(np.argmax(spec))], "alpha_over_theta": spec[7:9].mean() / spec[2:6].mean(),
"spectrum": np.round(spec / spec.max(), 2).tolist()})
pl = pd.DataFrame(rows)
print(pl[pl.windows == "table"].drop(columns="spectrum").to_string(index=False))
print(pl.groupby(["windows", "reading", "group"]).theta_peak.agg(["sum", "size"]).to_string())
print(pl[(pl.reading == "implv") & (pl.windows == "table")][["subject", "group", "spectrum"]].to_string(index=False))
filter centres: [2.0, 2.75, 3.5, 4.5, 5.5, 6.5, 8.0, 9.5, 11.5, 13.5, 16.0]
windows subject group reading pairs theta_peak peaks_Hz max_at_Hz alpha_over_theta
table s1 MTL-PFC implv 8 True [5.5, 9.5] 2.00 1.087557
table s1 MTL-PFC pli 8 True [5.5, 9.5] 2.00 1.099862
table s1 MTL-PFC code 8 True [2.75, 6.5, 11.5] 2.75 0.999914
table s1 MTL-OFC implv 5 False [8.0] 2.00 0.973915
table s1 MTL-OFC pli 5 False [8.0] 2.00 0.924153
table s1 MTL-OFC code 5 True [2.75, 4.5, 8.0] 8.00 1.015522
table s2 MTL-MTL implv 21 True [3.5, 5.5] 3.50 0.706073
table s2 MTL-MTL pli 21 True [3.5] 3.50 0.713320
table s2 MTL-MTL code 21 False [11.5] 11.50 1.138217
table s2 MTL-PFC implv 28 False [2.75, 8.0, 13.5] 2.75 0.956866
table s2 MTL-PFC pli 28 False [2.75, 8.0, 13.5] 2.75 0.950792
table s2 MTL-PFC code 28 True [4.5, 11.5] 11.50 1.084985
table s3 MTL-MTL implv 1 True [6.5] 6.50 0.191527
table s3 MTL-MTL pli 1 True [6.5] 6.50 0.212656
table s3 MTL-MTL code 1 True [4.5] 16.00 1.761619
table s3 MTL-PFC implv 4 True [6.5] 6.50 0.405374
table s3 MTL-PFC pli 4 True [6.5] 6.50 0.425723
table s3 MTL-PFC code 4 False [2.75] 16.00 4.579552
table s4 MTL-MTL implv 6 False [2.75, 8.0] 8.00 1.006015
table s4 MTL-MTL pli 6 False [2.75, 8.0] 8.00 1.013070
table s4 MTL-MTL code 6 True [4.5, 8.0, 11.5] 4.50 0.996620
table s4 MTL-PFC implv 27 False [8.0] 2.00 1.125477
table s4 MTL-PFC pli 27 True [3.5, 8.0] 2.00 1.116772
table s4 MTL-PFC code 27 True [2.75, 5.5, 8.0] 16.00 0.998064
table s4 MTL-OFC implv 2 True [3.5, 8.0] 3.50 0.944592
table s4 MTL-OFC pli 2 True [3.5, 8.0] 3.50 0.910131
table s4 MTL-OFC code 2 True [2.75, 4.5, 8.0, 11.5] 4.50 1.000444
table s5 MTL-MTL implv 1 False [2.75, 8.0] 8.00 1.412456
table s5 MTL-MTL pli 1 True [3.5, 8.0] 8.00 1.385775
table s5 MTL-MTL code 1 True [4.5, 6.5, 11.5] 4.50 0.977535
table s5 MTL-PFC implv 20 True [3.5, 8.0, 11.5] 16.00 1.022498
table s5 MTL-PFC pli 20 True [5.5, 9.5] 16.00 1.021553
table s5 MTL-PFC code 20 True [2.75, 4.5, 9.5] 2.75 1.005512
table s5 MTL-OFC implv 32 True [5.5, 9.5] 2.00 1.038364
table s5 MTL-OFC pli 32 True [5.5, 8.0, 11.5] 2.00 1.026902
table s5 MTL-OFC code 32 True [4.5, 6.5, 11.5] 11.50 0.998229
table s6 MTL-PFC implv 27 True [5.5] 5.50 0.954524
table s6 MTL-PFC pli 27 True [5.5, 11.5] 5.50 0.957239
table s6 MTL-PFC code 27 True [3.5, 6.5, 13.5] 6.50 0.994588
table s6 MTL-OFC implv 18 True [4.5, 9.5] 4.50 0.993662
table s6 MTL-OFC pli 18 True [4.5, 6.5, 9.5] 4.50 0.972029
table s6 MTL-OFC code 18 True [2.75, 5.5, 8.0, 11.5] 16.00 1.000704
table s7 MTL-MTL implv 1 False [2.75, 8.0] 8.00 1.281051
table s7 MTL-MTL pli 1 False [8.0] 8.00 1.439273
table s7 MTL-MTL code 1 True [2.75, 6.5] 16.00 1.155911
table s7 MTL-PFC implv 22 True [5.5, 8.0] 5.50 0.867145
table s7 MTL-PFC pli 22 True [3.5] 3.50 0.882899
table s7 MTL-PFC code 22 True [2.75, 6.5] 16.00 1.021227
table s7 MTL-OFC implv 2 True [2.75, 6.5, 9.5] 2.75 0.917696
table s7 MTL-OFC pli 2 True [2.75, 5.5, 9.5] 2.75 0.970362
table s7 MTL-OFC code 2 True [5.5, 11.5] 11.50 1.030875
table s8 MTL-MTL implv 3 False [9.5] 2.00 1.017299
table s8 MTL-MTL pli 3 True [2.75, 6.5, 9.5] 2.75 0.953003
table s8 MTL-MTL code 3 False [11.5] 16.00 1.606554
table s8 MTL-PFC implv 4 True [3.5, 9.5] 3.50 0.999170
table s8 MTL-PFC pli 4 True [3.5, 9.5] 2.00 1.011668
table s8 MTL-PFC code 4 True [2.75, 4.5, 9.5, 13.5] 2.75 1.001180
table s9 MTL-MTL implv 10 True [4.5] 2.00 0.803056
table s9 MTL-MTL pli 10 True [4.5] 2.00 0.790283
table s9 MTL-MTL code 10 True [4.5, 6.5, 9.5] 16.00 1.010578
table s9 MTL-PFC implv 30 True [3.5, 6.5, 11.5] 2.00 0.905895
table s9 MTL-PFC pli 30 True [3.5, 5.5] 2.00 0.926199
table s9 MTL-PFC code 30 True [4.5, 11.5] 16.00 1.009933
table s9 MTL-OFC implv 20 True [6.5] 2.00 0.987637
table s9 MTL-OFC pli 20 True [6.5] 6.50 0.988343
table s9 MTL-OFC code 20 True [2.75, 5.5, 11.5] 11.50 1.000764
table s10 MTL-MTL implv 10 True [3.5, 5.5] 3.50 0.609464
table s10 MTL-MTL pli 10 True [3.5] 3.50 0.600402
table s10 MTL-MTL code 10 True [3.5, 8.0, 13.5] 3.50 1.001278
table s10 MTL-OFC implv 210 False [2.75, 8.0] 2.75 0.901387
table s10 MTL-OFC pli 210 False [2.75, 8.0] 2.75 0.910441
table s10 MTL-OFC code 210 True [3.5, 8.0, 13.5] 3.50 0.999751
sum size
windows reading group
code code MTL-MTL 7 9
MTL-OFC 7 7
MTL-PFC 8 9
implv MTL-MTL 7 9
MTL-OFC 4 7
MTL-PFC 8 9
pli MTL-MTL 9 9
MTL-OFC 3 7
MTL-PFC 8 9
table code MTL-MTL 6 8
MTL-OFC 7 7
MTL-PFC 8 9
implv MTL-MTL 4 8
MTL-OFC 5 7
MTL-PFC 7 9
pli MTL-MTL 6 8
MTL-OFC 5 7
MTL-PFC 8 9
subject group spectrum
s1 MTL-PFC [1.0, 0.96, 0.8, 0.73, 0.85, 0.64, 0.75, 0.83, 0.81, 0.78, 0.79]
s1 MTL-OFC [1.0, 0.76, 0.68, 0.65, 0.6, 0.61, 0.67, 0.64, 0.6, 0.57, 0.63]
s2 MTL-MTL [0.66, 0.86, 1.0, 0.92, 0.93, 0.82, 0.79, 0.63, 0.66, 0.72, 0.73]
s2 MTL-PFC [0.97, 1.0, 0.88, 0.84, 0.8, 0.79, 0.81, 0.81, 0.77, 0.81, 0.78]
s3 MTL-MTL [0.16, 0.09, 0.09, 0.17, 0.97, 1.0, 0.28, 0.1, 0.11, 0.12, 0.12]
s3 MTL-PFC [0.4, 0.31, 0.3, 0.34, 0.78, 1.0, 0.39, 0.23, 0.26, 0.27, 0.28]
s4 MTL-MTL [0.92, 0.96, 0.85, 0.77, 0.89, 0.93, 1.0, 0.92, 0.81, 0.79, 0.67]
s4 MTL-PFC [1.0, 0.82, 0.78, 0.66, 0.64, 0.78, 0.89, 0.86, 0.74, 0.67, 0.66]
s4 MTL-OFC [0.6, 0.71, 1.0, 0.8, 0.7, 0.57, 0.83, 0.79, 0.66, 0.4, 0.45]
s5 MTL-MTL [0.22, 0.49, 0.45, 0.38, 0.58, 0.89, 1.0, 0.96, 0.66, 0.62, 0.54]
s5 MTL-PFC [0.96, 0.89, 0.96, 0.92, 0.94, 0.97, 0.99, 0.97, 0.97, 0.97, 1.0]
s5 MTL-OFC [1.0, 0.95, 0.89, 0.86, 0.96, 0.88, 0.91, 0.95, 0.92, 0.87, 0.88]
s6 MTL-PFC [0.94, 0.92, 0.93, 0.94, 1.0, 0.94, 0.92, 0.91, 0.9, 0.86, 0.9]
s6 MTL-OFC [0.93, 0.85, 0.9, 1.0, 0.86, 0.93, 0.94, 0.96, 0.88, 0.95, 0.97]
s7 MTL-MTL [0.36, 0.47, 0.35, 0.39, 0.46, 0.85, 1.0, 0.89, 0.42, 0.33, 0.36]
s7 MTL-PFC [0.93, 0.9, 0.96, 0.97, 1.0, 0.87, 0.88, 0.83, 0.82, 0.79, 0.84]
s7 MTL-OFC [0.84, 1.0, 0.82, 0.77, 0.81, 0.81, 0.72, 0.78, 0.69, 0.6, 0.63]
s8 MTL-MTL [1.0, 0.94, 0.85, 0.43, 0.56, 0.68, 0.71, 0.74, 0.54, 0.51, 0.45]
s8 MTL-PFC [0.92, 0.92, 1.0, 0.93, 0.92, 0.85, 0.78, 0.93, 0.92, 0.83, 0.86]
s9 MTL-MTL [1.0, 0.69, 0.57, 0.65, 0.62, 0.58, 0.56, 0.55, 0.42, 0.48, 0.51]
s9 MTL-PFC [1.0, 0.92, 0.93, 0.84, 0.85, 0.85, 0.82, 0.78, 0.8, 0.76, 0.77]
s9 MTL-OFC [1.0, 0.99, 0.9, 0.89, 0.87, 0.99, 0.96, 0.95, 0.86, 0.83, 0.8]
s10 MTL-MTL [0.83, 0.97, 1.0, 0.91, 0.91, 0.82, 0.67, 0.63, 0.48, 0.39, 0.39]
s10 MTL-OFC [0.91, 1.0, 0.89, 0.65, 0.61, 0.63, 0.64, 0.63, 0.62, 0.62, 0.62]
Result: reproduced. In the trial table's windows, the imaginary PLV (reading a) has a local maximum in 3 to 7 Hz in 4 of 8 subjects for MTL to MTL pairs, 7 of 9 for MTL to PFC and 5 of 7 for MTL to OFC; the phase-lag index gives 6 of 8, 8 of 9 and 5 of 7. In the code's windows the imaginary PLV gives 7 of 9, 8 of 9 and 4 of 7. The rule asks for one subject per group, a weak test; the peaks are often one of several local maxima, and the largest value is in 3 to 7 Hz in fewer subjects (column max_at_Hz).
psi-theta-shift¶
Theta-band PSI showed frontal-to-MTL leads during the precue delay and shifted toward MTL leads (a bidirectional network) after the test cue, for MTL to PFC and MTL to OFC pairs.
Readings of the spectral step: sliding 3-cycle windows, as M5 of the claims file gives the
Methods (main; at 3 Hz the 1 s window runs into the zero padding of the 900 ms segment), the code's
single Hanning window (mtmfft, psi_compute.m), and the code's own form of PSI (psianalysis.m,
per-trial PSI against a null of trial-mean coherency). Readings of M7: the response is the PSI z or
the raw PSI. Each in the trial table's windows and in the code's ("/ code win"). Positive PSI means
the MTL leads. The calibration table gives each form's postcue z with the second electrode's trials
shuffled, which removes any trial-by-trial coupling.
def pair_table(key, tag=""):
rows = []
for sid, r in R.items():
for g in ("MTL-PFC", "MTL-OFC"):
for a, b in r["pairs" + tag][g]:
for w in ("pre", "post"):
d = r["psi" + tag][(w, key)]
rows.append({"subject": sid, "net": g, "pair": f"{sid}-{a}-{b}", "interval": w,
"z": d["z"][a, b], "raw": d["raw"][a, b]})
return pd.DataFrame(rows)
def lmm_interval(d, y):
# Postcue minus precue with random intercepts for subject and pair: with two intervals per
# pair, the mixed model's F test of interval is the within-pair F test, F = t^2 of the
# paired differences (fcx2.within_unit_anova).
if len(d) == 0:
return np.nan, np.nan, np.nan
w = d.pivot_table(index="pair", columns="interval", values=y)
Y = w[["pre", "post"]].to_numpy()
tab, res_df = fcx2.within_unit_anova(Y)
diff = (Y[:, 1] - Y[:, 0]).mean()
return diff, float(tab.loc[0, "F"]), float(tab.loc[0, "p"])
rows = []
for key, tag in [(k, t) for t in ("", "_alt") for k in ("mtmfft", "sliding", "code")]:
pt = pair_table(key, tag)
for g in ("MTL-PFC", "MTL-OFC"):
d = pt[pt.net == g]
pre = d[d.interval == "pre"]
post = d[d.interval == "post"]
for y in ("z", "raw"):
b, t, p = lmm_interval(d, y)
rows.append({"reading": key + (" / code win" if tag else ""), "net": g, "pairs": len(pre), "subjects": pre.subject.nunique(), "response": y,
"pre_mean_z": pre.z.mean(), "pre_below": int((pre.z < -1.96).sum()), "pre_above": int((pre.z > 1.96).sum()),
"post_mean_z": post.z.mean(), "post_below": int((post.z < -1.96).sum()), "post_above": int((post.z > 1.96).sum()),
"post_minus_pre": b, "F": t, "p": p})
ps = pd.DataFrame(rows)
print(ps.round(4).to_string(index=False))
print("expected pairs: MTL-PFC 172 +- 17.2, MTL-OFC 303 +- 30.3")
for rd in ps.reading.unique():
for y in ("z", "raw"):
d = ps[(ps.reading == rd) & (ps.response == y)]
p1 = (d.pre_mean_z < 0) & (d.pre_below > d.pre_above)
p2 = (d.post_minus_pre > 0) & (d.p < 0.05)
print(f"{rd:16s} {y:3s}: part (1) holds in {int(p1.sum())} of 2 networks, part (2) in {int(p2.sum())} of 2 "
f"({', '.join(d.net[p2]) or 'none'})")
# calibration: postcue z with the second electrode's trials shuffled against the first's (no
# trial-by-trial coupling left), over the same pairs, against the real postcue z
rows = []
for key in ("mtmfft", "sliding", "code"):
real = np.concatenate([[r["psi"][("post", key)]["z"][a, b] for g in ("MTL-PFC", "MTL-OFC") for a, b in r["pairs"][g]] for r in R.values()])
shuf = np.concatenate([[r["psi"][("post", key, "shuf")]["z"][a, b] for g in ("MTL-PFC", "MTL-OFC") for a, b in r["pairs"][g]] for r in R.values()])
for name, v in (("real", real), ("trials shuffled", shuf)):
rows.append({"form": key, "data": name, "pairs": len(v), "z_sd": np.std(v), "frac_above_1.96": np.mean(v > 1.96),
"frac_below_-1.96": np.mean(v < -1.96)})
print("\ntheta PSI, postcue: calibration (nominal 0.025 in each tail)")
print(pd.DataFrame(rows).round(3).to_string(index=False))
reading net pairs subjects response pre_mean_z pre_below pre_above post_mean_z post_below post_above post_minus_pre F p
mtmfft MTL-PFC 170 9 z 0.0999 1 6 0.0453 6 7 -0.0547 0.1996 0.6556
mtmfft MTL-PFC 170 9 raw 0.0999 1 6 0.0453 6 7 0.0138 6.1515 0.0141
mtmfft MTL-OFC 289 7 z -0.0228 5 6 -0.2240 17 12 -0.2012 5.0936 0.0248
mtmfft MTL-OFC 289 7 raw -0.0228 5 6 -0.2240 17 12 -0.0062 11.0052 0.0010
sliding MTL-PFC 170 9 z 0.2484 45 55 0.2635 43 57 0.0151 0.0040 0.9497
sliding MTL-PFC 170 9 raw 0.2484 45 55 0.2635 43 57 0.0012 1.2082 0.2732
sliding MTL-OFC 289 7 z 0.0087 82 87 -0.4361 118 74 -0.4449 5.8637 0.0161
sliding MTL-OFC 289 7 raw 0.0087 82 87 -0.4361 118 74 -0.0046 17.4572 0.0000
code MTL-PFC 170 9 z 1.5630 69 86 5.9109 63 91 4.3479 1.1519 0.2847
code MTL-PFC 170 9 raw 1.5630 69 86 5.9109 63 91 0.0333 2.4784 0.1173
code MTL-OFC 289 7 z -4.0654 146 116 5.5512 89 172 9.6166 9.1133 0.0028
code MTL-OFC 289 7 raw -4.0654 146 116 5.5512 89 172 0.0808 45.3018 0.0000
mtmfft / code win MTL-PFC 172 9 z -0.1379 6 3 -0.0225 9 10 0.1154 1.2177 0.2714
mtmfft / code win MTL-PFC 172 9 raw -0.1379 6 3 -0.0225 9 10 0.0002 0.0008 0.9781
mtmfft / code win MTL-OFC 302 7 z -0.1276 7 14 -0.1756 17 5 -0.0480 0.3438 0.5581
mtmfft / code win MTL-OFC 302 7 raw -0.1276 7 14 -0.1756 17 5 -0.0009 0.2620 0.6091
sliding / code win MTL-PFC 172 9 z -0.2537 58 43 0.1901 48 58 0.4438 3.4356 0.0655
sliding / code win MTL-PFC 172 9 raw -0.2537 58 43 0.1901 48 58 0.0048 3.1192 0.0792
sliding / code win MTL-OFC 302 7 z -0.3866 115 70 -0.3607 112 73 0.0259 0.0221 0.8820
sliding / code win MTL-OFC 302 7 raw -0.3866 115 70 -0.3607 112 73 0.0025 4.9359 0.0270
code / code win MTL-PFC 172 9 z -3.9095 98 53 7.9657 53 105 11.8752 13.8742 0.0003
code / code win MTL-PFC 172 9 raw -3.9095 98 53 7.9657 53 105 0.0834 34.8513 0.0000
code / code win MTL-OFC 302 7 z -10.7334 196 76 7.6854 110 169 18.4188 37.1811 0.0000
code / code win MTL-OFC 302 7 raw -10.7334 196 76 7.6854 110 169 0.1391 113.1365 0.0000
expected pairs: MTL-PFC 172 +- 17.2, MTL-OFC 303 +- 30.3
mtmfft z : part (1) holds in 0 of 2 networks, part (2) in 0 of 2 (none)
mtmfft raw: part (1) holds in 0 of 2 networks, part (2) in 1 of 2 (MTL-PFC)
sliding z : part (1) holds in 0 of 2 networks, part (2) in 0 of 2 (none)
sliding raw: part (1) holds in 0 of 2 networks, part (2) in 0 of 2 (none)
code z : part (1) holds in 1 of 2 networks, part (2) in 1 of 2 (MTL-OFC)
code raw: part (1) holds in 1 of 2 networks, part (2) in 1 of 2 (MTL-OFC)
mtmfft / code win z : part (1) holds in 1 of 2 networks, part (2) in 0 of 2 (none)
mtmfft / code win raw: part (1) holds in 1 of 2 networks, part (2) in 0 of 2 (none)
sliding / code win z : part (1) holds in 2 of 2 networks, part (2) in 0 of 2 (none)
sliding / code win raw: part (1) holds in 2 of 2 networks, part (2) in 1 of 2 (MTL-OFC)
code / code win z : part (1) holds in 2 of 2 networks, part (2) in 2 of 2 (MTL-PFC, MTL-OFC)
code / code win raw: part (1) holds in 2 of 2 networks, part (2) in 2 of 2 (MTL-PFC, MTL-OFC)
theta PSI, postcue: calibration (nominal 0.025 in each tail)
form data pairs z_sd frac_above_1.96 frac_below_-1.96
mtmfft real 459 1.185 0.041 0.050
mtmfft trials shuffled 459 0.916 0.022 0.013
sliding real 459 2.266 0.285 0.351
sliding trials shuffled 459 2.255 0.242 0.368
code real 459 30.866 0.573 0.331
code trials shuffled 459 43.650 0.571 0.357
Result: not reproduced, resting on the window placement. With sliding windows in the trial table's windows, neither part holds in either network: precue mean z is 0.25 (MTL-PFC) and 0.01 (MTL-OFC), with fewer pairs below -1.96 than above (45 against 55, 82 against 87), and postcue does not exceed precue (MTL-PFC raw p = 0.27; MTL-OFC raw PSI falls, p < 0.0001). The code's single window is a variant the criterion does not judge, as M5 fixes sliding windows; it gives part (2) for MTL-PFC on raw PSI only (p = 0.014, while the z falls), with MTL-OFC raw PSI falling (p = 0.001). In the code's windows, sliding windows give part (1) in both networks and part (2) for MTL-OFC on raw PSI only (p = 0.027), the criterion's partial case, and the single window gives part (1) in one network and part (2) in neither. The code's own form of PSI gives both parts in both networks in the code's windows, and part (1) and part (2) in one network each in the table's (MTL-OFC postcue above precue, p = 0.0028 on z), but it is not calibrated: with trials shuffled 57% of pairs pass z > 1.96 (z SD 44), as many as on the real data (57%). The sliding-window z is also too wide (SD 2.3 with trials shuffled, 24% above 1.96), which bears on part (1) only; the single window is near nominal (SD 0.92, 2.2% above). The pair counts are 170 and 289 (expected 172 and 303, within tolerance). The outcome rests on the window placement: the data check places the events as the trial table does, but if the deposited scripts produced the paper's figures, the paper's PSI comes from the code's windows, where the sliding reading meets the criterion's partial case.
crossspectral-shift¶
Theta phase to amplitude directionality (cross-spectral PSI) was absent in the precue delay and shifted to theta phase leading amplitude after the test cue, within MTL, PFC and OFC and in all four interregional directions.
Readings: the PSI of the Methods (Nolte et al. 2008) from sliding 3-cycle windows (M5, main) and from the code's single window, and the code's own form of PSI as a variant; M7 response z or raw; each in the trial table's windows and in the code's. The calibration table below gives each form's postcue z with the amplitude electrode's trials shuffled against the phase electrode's.
def unit_frame(tag):
units = []
for sid, r in R.items():
for i, u in enumerate(r["units" + tag]):
units.append({"subject": sid, "uid": f"{sid}-{u['ph']}-{u['amp']}", "pair": f"{sid}-{min(u['ph'], u['amp'])}-{max(u['ph'], u['amp'])}",
"idx": i, **{k: v for k, v in u.items() if not k.startswith("zf")}})
return pd.DataFrame(units)
U, U_ALT = unit_frame(""), unit_frame("_alt")
SYSTEMS = ["MTL", "PFC", "OFC", "MTL->PFC", "PFC->MTL", "MTL->OFC", "OFC->MTL"]
rows = []
for key in ["mtmfft", "sliding", "code", "mtmfft / code win", "sliding / code win", "code / code win"]:
UU = U_ALT if "code win" in key else U
k0 = key.split(" /")[0]
for sname in SYSTEMS:
d = UU[UU.system == sname].rename(columns=lambda c: c.replace(f"_{k0}", f"_{key}") if c.startswith(("z_", "raw_")) and c.endswith(f"_{k0}") else c)
long = pd.concat([pd.DataFrame({"subject": d.subject, "pair": d.uid, "interval": w,
"z": d[f"z_{w}_{key}"], "raw": d[f"raw_{w}_{key}"]}) for w in ("pre", "post")])
for y in ("z", "raw"):
b, t, p = lmm_interval(long, y)
rows.append({"reading": key, "system": sname, "units": len(d), "subjects": d.subject.nunique(), "response": y,
"pre_mean_z": d[f"z_pre_{key}"].mean(), "post_mean_z": d[f"z_post_{key}"].mean(),
"pre_above_1.96": int((d[f"z_pre_{key}"] > 1.96).sum()),
"pre_frac_above": (d[f"z_pre_{key}"] > 1.96).mean(), "post_minus_pre": b, "F": t, "p": p})
cx = pd.DataFrame(rows)
print(cx.round(4).to_string(index=False))
print("expected electrodes in the models: MTL 36 +- 3.6, PFC 111 +- 11.1, OFC 99 +- 9.9")
for key in ["mtmfft", "sliding", "code", "mtmfft / code win", "sliding / code win", "code / code win"]:
for y in ("z", "raw"):
d = cx[(cx.reading == key) & (cx.response == y)]
print(f"{key}/{y}: systems with post > pre at p < 0.05: {int(((d.post_minus_pre > 0) & (d.p < 0.05)).sum())} of 7; "
f"systems with at most 5% precue units above 1.96: {int((d['pre_frac_above'] <= 0.05).sum())} of 7")# calibration: postcue z with the amplitude electrode's trials shuffled against the phase
# electrode's, against the real postcue z, every unit (nominal 0.025 above 1.96)
rows = []
for key in ("mtmfft", "sliding", "code"):
for sname in SYSTEMS:
d = U[U.system == sname]
for name, col in (("real", f"z_post_{key}"), ("trials shuffled", f"z_post_{key}_shuf")):
rows.append({"form": key, "system": sname, "data": name, "units": len(d), "z_sd": d[col].std(),
"frac_above_1.96": (d[col] > 1.96).mean()})
cal = pd.DataFrame(rows)
print("\ncross-spectral PSI, postcue: calibration")
print(cal.pivot_table(index=["form", "system"], columns="data", values="frac_above_1.96").round(3).to_string())
print(cal[cal.units > 0].groupby(["form", "data"]).apply(lambda g: pd.Series({"units": g.units.sum(), "z_sd_mean": g.z_sd.mean(),
"frac_above_1.96": np.average(g["frac_above_1.96"], weights=g.units)})).round(3).to_string())
print("paper's selection rates (counts of phase-directing-counts over the units of crossspectral-shift):",
{k: round(v / n, 2) for (k, v), n in zip({"MTL": 13, "PFC": 52, "OFC": 38, "MTL->PFC": 56, "PFC->MTL": 85, "MTL->OFC": 93, "OFC->MTL": 115}.items(),
(36, 111, 99, 172, 172, 303, 303))})
reading system units subjects response pre_mean_z post_mean_z pre_above_1.96 pre_frac_above post_minus_pre F p
mtmfft MTL 34 10 z -0.3290 -0.3040 0 0.0000 0.0249 0.0546 0.8167
mtmfft MTL 34 10 raw -0.3290 -0.3040 0 0.0000 0.0186 3.2792 0.0793
mtmfft PFC 115 9 z -0.2333 -0.2972 0 0.0000 -0.0639 1.8215 0.1798
mtmfft PFC 115 9 raw -0.2333 -0.2972 0 0.0000 -0.0009 0.5893 0.4443
mtmfft OFC 98 9 z -0.6037 -0.6224 0 0.0000 -0.0187 0.0794 0.7786
mtmfft OFC 98 9 raw -0.6037 -0.6224 0 0.0000 -0.0027 0.9585 0.3300
mtmfft MTL->PFC 170 9 z -0.1228 -0.0796 0 0.0000 0.0432 1.5943 0.2084
mtmfft MTL->PFC 170 9 raw -0.1228 -0.0796 0 0.0000 0.0006 1.1572 0.2836
mtmfft PFC->MTL 170 9 z -0.2741 -0.2505 0 0.0000 0.0236 0.2720 0.6027
mtmfft PFC->MTL 170 9 raw -0.2741 -0.2505 0 0.0000 -0.0033 3.1731 0.0767
mtmfft MTL->OFC 289 7 z -0.1419 -0.1507 0 0.0000 -0.0088 0.0791 0.7787
mtmfft MTL->OFC 289 7 raw -0.1419 -0.1507 0 0.0000 0.0001 0.0286 0.8658
mtmfft OFC->MTL 289 7 z -0.1451 -0.1109 0 0.0000 0.0342 1.3992 0.2378
mtmfft OFC->MTL 289 7 raw -0.1451 -0.1109 0 0.0000 0.0012 5.3169 0.0218
sliding MTL 34 10 z -0.8742 -0.5457 0 0.0000 0.3285 3.0229 0.0914
sliding MTL 34 10 raw -0.8742 -0.5457 0 0.0000 0.0081 2.1556 0.1515
sliding PFC 115 9 z -0.4759 -0.3363 1 0.0087 0.1397 2.5365 0.1140
sliding PFC 115 9 raw -0.4759 -0.3363 1 0.0087 0.0009 3.7126 0.0565
sliding OFC 98 9 z -1.0136 -1.1413 1 0.0102 -0.1277 1.6441 0.2028
sliding OFC 98 9 raw -1.0136 -1.1413 1 0.0102 -0.0013 1.5681 0.2135
sliding MTL->PFC 170 9 z -0.0596 -0.0883 0 0.0000 -0.0287 0.1548 0.6945
sliding MTL->PFC 170 9 raw -0.0596 -0.0883 0 0.0000 -0.0004 5.7588 0.0175
sliding PFC->MTL 170 9 z -0.4114 -0.2506 0 0.0000 0.1607 3.1960 0.0756
sliding PFC->MTL 170 9 raw -0.4114 -0.2506 0 0.0000 0.0002 0.1502 0.6988
sliding MTL->OFC 289 7 z -0.2083 -0.4261 1 0.0035 -0.2178 8.6460 0.0035
sliding MTL->OFC 289 7 raw -0.2083 -0.4261 1 0.0035 -0.0010 19.3832 0.0000
sliding OFC->MTL 289 7 z -0.1167 0.0420 0 0.0000 0.1587 5.6888 0.0177
sliding OFC->MTL 289 7 raw -0.1167 0.0420 0 0.0000 0.0010 10.9817 0.0010
code MTL 34 10 z -3.0500 -2.5916 13 0.3824 0.4584 0.0050 0.9441
code MTL 34 10 raw -3.0500 -2.5916 13 0.3824 0.0243 0.5985 0.4446
code PFC 115 9 z 3.5845 -1.0937 53 0.4609 -4.6782 2.3171 0.1307
code PFC 115 9 raw 3.5845 -1.0937 53 0.4609 -0.0255 2.2499 0.1364
code OFC 98 9 z 0.1485 4.1062 46 0.4694 3.9577 1.9940 0.1611
code OFC 98 9 raw 0.1485 4.1062 46 0.4694 0.0092 0.2936 0.5891
code MTL->PFC 170 9 z -1.4957 8.0382 63 0.3706 9.5339 16.1426 0.0001
code MTL->PFC 170 9 raw -1.4957 8.0382 63 0.3706 0.0509 15.1178 0.0001
code PFC->MTL 170 9 z -6.9255 -3.0305 62 0.3647 3.8950 1.6919 0.1951
code PFC->MTL 170 9 raw -6.9255 -3.0305 62 0.3647 0.0185 1.2959 0.2566
code MTL->OFC 289 7 z -3.2946 13.0584 116 0.4014 16.3530 154.3829 0.0000
code MTL->OFC 289 7 raw -3.2946 13.0584 116 0.4014 0.0907 203.7743 0.0000
code OFC->MTL 289 7 z -0.3667 5.0807 113 0.3910 5.4474 8.7919 0.0033
code OFC->MTL 289 7 raw -0.3667 5.0807 113 0.3910 0.0276 8.0131 0.0050
mtmfft / code win MTL 35 10 z -0.1983 -0.3457 0 0.0000 -0.1474 2.8443 0.1009
mtmfft / code win MTL 35 10 raw -0.1983 -0.3457 0 0.0000 -0.0136 3.2459 0.0805
mtmfft / code win PFC 110 9 z -0.2479 -0.2777 0 0.0000 -0.0298 0.4869 0.4868
mtmfft / code win PFC 110 9 raw -0.2479 -0.2777 0 0.0000 -0.0008 0.4499 0.5038
mtmfft / code win OFC 97 9 z -0.6940 -0.6624 0 0.0000 0.0316 0.1931 0.6613
mtmfft / code win OFC 97 9 raw -0.6940 -0.6624 0 0.0000 0.0026 0.5660 0.4537
mtmfft / code win MTL->PFC 172 9 z -0.1027 -0.0577 0 0.0000 0.0450 1.3775 0.2422
mtmfft / code win MTL->PFC 172 9 raw -0.1027 -0.0577 0 0.0000 0.0018 2.3482 0.1273
mtmfft / code win PFC->MTL 172 9 z -0.1189 -0.2553 0 0.0000 -0.1364 7.9431 0.0054
mtmfft / code win PFC->MTL 172 9 raw -0.1189 -0.2553 0 0.0000 -0.0042 4.8901 0.0283
mtmfft / code win MTL->OFC 302 7 z -0.2507 -0.1849 0 0.0000 0.0658 4.4433 0.0359
mtmfft / code win MTL->OFC 302 7 raw -0.2507 -0.1849 0 0.0000 0.0007 1.4748 0.2255
mtmfft / code win OFC->MTL 302 7 z -0.1352 -0.1432 0 0.0000 -0.0080 0.0806 0.7766
mtmfft / code win OFC->MTL 302 7 raw -0.1352 -0.1432 0 0.0000 -0.0002 0.0950 0.7581
sliding / code win MTL 35 10 z -0.3173 -0.4860 0 0.0000 -0.1687 1.0839 0.3052
sliding / code win MTL 35 10 raw -0.3173 -0.4860 0 0.0000 -0.0037 4.5015 0.0412
sliding / code win PFC 110 9 z -0.4353 -0.4152 0 0.0000 0.0202 0.0448 0.8327
sliding / code win PFC 110 9 raw -0.4353 -0.4152 0 0.0000 0.0000 0.0002 0.9892
sliding / code win OFC 97 9 z -1.1606 -1.3050 0 0.0000 -0.1445 2.1107 0.1495
sliding / code win OFC 97 9 raw -1.1606 -1.3050 0 0.0000 0.0003 0.0333 0.8555
sliding / code win MTL->PFC 172 9 z -0.0389 0.0404 0 0.0000 0.0793 1.2036 0.2741
sliding / code win MTL->PFC 172 9 raw -0.0389 0.0404 0 0.0000 0.0008 4.9641 0.0272
sliding / code win PFC->MTL 172 9 z 0.0383 -0.1184 4 0.0233 -0.1568 2.9865 0.0858
sliding / code win PFC->MTL 172 9 raw 0.0383 -0.1184 4 0.0233 -0.0010 5.2195 0.0236
sliding / code win MTL->OFC 302 7 z -0.5220 -0.2367 0 0.0000 0.2853 19.2889 0.0000
sliding / code win MTL->OFC 302 7 raw -0.5220 -0.2367 0 0.0000 0.0006 4.5151 0.0344
sliding / code win OFC->MTL 302 7 z -0.1071 -0.0986 2 0.0066 0.0085 0.0213 0.8842
sliding / code win OFC->MTL 302 7 raw -0.1071 -0.0986 2 0.0066 -0.0011 9.1204 0.0027
code / code win MTL 35 10 z 1.5135 5.5971 16 0.4571 4.0836 0.8636 0.3593
code / code win MTL 35 10 raw 1.5135 5.5971 16 0.4571 0.0398 2.3998 0.1306
code / code win PFC 110 9 z 2.5433 -0.4250 53 0.4818 -2.9683 1.3112 0.2547
code / code win PFC 110 9 raw 2.5433 -0.4250 53 0.4818 -0.0230 3.0166 0.0852
code / code win OFC 97 9 z 6.6393 -0.9749 53 0.5464 -7.6142 7.1697 0.0087
code / code win OFC 97 9 raw 6.6393 -0.9749 53 0.5464 -0.0339 3.9921 0.0485
code / code win MTL->PFC 172 9 z -3.4952 4.9360 56 0.3256 8.4312 23.0372 0.0000
code / code win MTL->PFC 172 9 raw -3.4952 4.9360 56 0.3256 0.0470 24.0440 0.0000
code / code win PFC->MTL 172 9 z 3.2856 -0.8629 84 0.4884 -4.1484 4.9090 0.0280
code / code win PFC->MTL 172 9 raw 3.2856 -0.8629 84 0.4884 -0.0226 5.2350 0.0234
code / code win MTL->OFC 302 7 z -8.9277 7.7518 73 0.2417 16.6796 122.1219 0.0000
code / code win MTL->OFC 302 7 raw -8.9277 7.7518 73 0.2417 0.1000 142.7964 0.0000
code / code win OFC->MTL 302 7 z 5.1026 4.1054 149 0.4934 -0.9972 0.2724 0.6021
code / code win OFC->MTL 302 7 raw 5.1026 4.1054 149 0.4934 -0.0104 1.1711 0.2800
expected electrodes in the models: MTL 36 +- 3.6, PFC 111 +- 11.1, OFC 99 +- 9.9
mtmfft/z: systems with post > pre at p < 0.05: 0 of 7; systems with at most 5% precue units above 1.96: 7 of 7
mtmfft/raw: systems with post > pre at p < 0.05: 1 of 7; systems with at most 5% precue units above 1.96: 7 of 7
sliding/z: systems with post > pre at p < 0.05: 1 of 7; systems with at most 5% precue units above 1.96: 7 of 7
sliding/raw: systems with post > pre at p < 0.05: 1 of 7; systems with at most 5% precue units above 1.96: 7 of 7
code/z: systems with post > pre at p < 0.05: 3 of 7; systems with at most 5% precue units above 1.96: 0 of 7
code/raw: systems with post > pre at p < 0.05: 3 of 7; systems with at most 5% precue units above 1.96: 0 of 7
mtmfft / code win/z: systems with post > pre at p < 0.05: 1 of 7; systems with at most 5% precue units above 1.96: 7 of 7
mtmfft / code win/raw: systems with post > pre at p < 0.05: 0 of 7; systems with at most 5% precue units above 1.96: 7 of 7
sliding / code win/z: systems with post > pre at p < 0.05: 1 of 7; systems with at most 5% precue units above 1.96: 7 of 7
sliding / code win/raw: systems with post > pre at p < 0.05: 2 of 7; systems with at most 5% precue units above 1.96: 7 of 7
code / code win/z: systems with post > pre at p < 0.05: 2 of 7; systems with at most 5% precue units above 1.96: 0 of 7
code / code win/raw: systems with post > pre at p < 0.05: 2 of 7; systems with at most 5% precue units above 1.96: 0 of 7
cross-spectral PSI, postcue: calibration
data real trials shuffled
form system
code MTL 0.412 0.529
MTL->OFC 0.654 0.664
MTL->PFC 0.618 0.618
OFC 0.480 0.571
OFC->MTL 0.588 0.550
PFC 0.426 0.478
PFC->MTL 0.447 0.471
mtmfft MTL 0.000 0.000
MTL->OFC 0.000 0.000
MTL->PFC 0.000 0.000
OFC 0.000 0.000
OFC->MTL 0.000 0.000
PFC 0.000 0.000
PFC->MTL 0.000 0.000
sliding MTL 0.000 0.000
MTL->OFC 0.010 0.000
MTL->PFC 0.000 0.000
OFC 0.000 0.000
OFC->MTL 0.007 0.003
PFC 0.000 0.000
PFC->MTL 0.006 0.000
units z_sd_mean frac_above_1.96
form data
code real 1165.0 22.028 0.558
trials shuffled 1165.0 23.363 0.571
mtmfft real 1165.0 0.481 0.000
trials shuffled 1165.0 0.346 0.000
sliding real 1165.0 0.927 0.005
trials shuffled 1165.0 0.779 0.001
paper's selection rates (counts of phase-directing-counts over the units of crossspectral-shift): {'MTL': 0.36, 'PFC': 0.47, 'OFC': 0.38, 'MTL->PFC': 0.33, 'PFC->MTL': 0.49, 'MTL->OFC': 0.31, 'OFC->MTL': 0.38}
Result: not reproduced. With the PSI of the Methods and sliding windows, at most 1% of precue units per system pass z > 1.96 (part 2 holds), but postcue exceeds precue at p < 0.05 in 1 of 7 systems (OFC to MTL) on z and on raw PSI, and MTL to OFC falls. The single window gives 0 of 7 on z and 1 of 7 on raw PSI; the code's form 3 of 7, with 36% to 47% of precue units above 1.96. In the code's windows the most any reading gives is 1 (single window), 2 (sliding) and 2 (code's form) of 7. No reading reaches the four systems that partial needs. The models hold 34 MTL, 115 PFC and 98 OFC electrodes (expected 36, 111 and 99, all within tolerance). Calibration: with trials shuffled, the code's form passes 57% of units (z SD 23), as many as on the real data (56%); the Methods' forms pass 0% (single window) and 0.1% (sliding).
phase-directing-counts¶
In the postcue delay, theta phase significantly led higher-frequency amplitude in 13 MTL, 52 PFC and 38 OFC electrodes, and in 56 MTL to PFC, 85 PFC to MTL, 93 MTL to OFC and 115 OFC to MTL electrode pairs.
EXP = {"MTL": 13, "PFC": 52, "OFC": 38, "MTL->PFC": 56, "PFC->MTL": 85, "MTL->OFC": 93, "OFC->MTL": 115}
EXP_SUBJ = {"MTL": 8, "PFC": 8, "OFC": 8, "MTL->PFC": 9, "PFC->MTL": 9, "MTL->OFC": 5, "OFC->MTL": 5}
rows = []
for key in ["mtmfft", "sliding", "code", "mtmfft / code win", "sliding / code win", "code / code win"]:
UU = U_ALT if "code win" in key else U
k0 = key.split(" /")[0]
for sname in SYSTEMS:
d = UU[(UU.system == sname) & (UU[f"z_post_{k0}"] > 1.96)]
rows.append({"reading": key, "system": sname, "count": len(d), "expected": EXP[sname],
"within_10pct": abs(len(d) - EXP[sname]) <= 0.1 * EXP[sname],
"subjects": d.subject.nunique(), "expected_subjects": EXP_SUBJ[sname],
"per_subject": d.subject.value_counts().to_dict()})
pdc = pd.DataFrame(rows)
print(pdc.to_string(index=False))
print(pdc.groupby("reading").within_10pct.sum().to_string())
reading system count expected within_10pct subjects expected_subjects per_subject
mtmfft MTL 0 13 False 0 8 {}
mtmfft PFC 0 52 False 0 8 {}
mtmfft OFC 0 38 False 0 8 {}
mtmfft MTL->PFC 0 56 False 0 9 {}
mtmfft PFC->MTL 0 85 False 0 9 {}
mtmfft MTL->OFC 0 93 False 0 5 {}
mtmfft OFC->MTL 0 115 False 0 5 {}
sliding MTL 0 13 False 0 8 {}
sliding PFC 0 52 False 0 8 {}
sliding OFC 0 38 False 0 8 {}
sliding MTL->PFC 0 56 False 0 9 {}
sliding PFC->MTL 1 85 False 1 9 {'s4': 1}
sliding MTL->OFC 3 93 False 1 5 {'s10': 3}
sliding OFC->MTL 2 115 False 1 5 {'s9': 2}
code MTL 14 13 True 5 8 {'s2': 5, 's10': 3, 's4': 2, 's5': 2, 's7': 2}
code PFC 49 52 True 9 8 {'s7': 13, 's6': 8, 's2': 7, 's5': 6, 's9': 5, 's1': 3, 's4': 3, 's3': 2, 's8': 2}
code OFC 47 38 False 8 8 {'s10': 19, 's5': 11, 's6': 8, 's1': 3, 's7': 3, 's2': 1, 's3': 1, 's9': 1}
code MTL->PFC 105 56 False 9 9 {'s7': 22, 's5': 20, 's2': 17, 's4': 16, 's9': 14, 's6': 11, 's1': 3, 's3': 1, 's8': 1}
code PFC->MTL 76 85 False 9 9 {'s2': 19, 's7': 19, 's4': 13, 's5': 8, 's9': 6, 's6': 4, 's1': 3, 's3': 3, 's8': 1}
code MTL->OFC 189 93 False 7 5 {'s10': 133, 's5': 32, 's9': 10, 's6': 9, 's1': 2, 's7': 2, 's4': 1}
code OFC->MTL 170 115 False 6 5 {'s10': 141, 's5': 19, 's1': 3, 's6': 3, 's7': 2, 's9': 2}
mtmfft / code win MTL 0 13 False 0 8 {}
mtmfft / code win PFC 0 52 False 0 8 {}
mtmfft / code win OFC 0 38 False 0 8 {}
mtmfft / code win MTL->PFC 0 56 False 0 9 {}
mtmfft / code win PFC->MTL 0 85 False 0 9 {}
mtmfft / code win MTL->OFC 0 93 False 0 5 {}
mtmfft / code win OFC->MTL 0 115 False 0 5 {}
sliding / code win MTL 0 13 False 0 8 {}
sliding / code win PFC 0 52 False 0 8 {}
sliding / code win OFC 0 38 False 0 8 {}
sliding / code win MTL->PFC 1 56 False 1 9 {'s6': 1}
sliding / code win PFC->MTL 1 85 False 1 9 {'s6': 1}
sliding / code win MTL->OFC 1 93 False 1 5 {'s6': 1}
sliding / code win OFC->MTL 0 115 False 0 5 {}
code / code win MTL 21 13 False 9 8 {'s2': 6, 's10': 4, 's4': 3, 's3': 2, 's9': 2, 's1': 1, 's5': 1, 's7': 1, 's8': 1}
code / code win PFC 43 52 False 9 8 {'s2': 7, 's6': 7, 's7': 7, 's4': 6, 's1': 4, 's5': 4, 's9': 4, 's3': 2, 's8': 2}
code / code win OFC 38 38 True 7 8 {'s10': 16, 's5': 9, 's6': 8, 's1': 2, 's4': 1, 's7': 1, 's9': 1}
code / code win MTL->PFC 106 56 False 7 9 {'s2': 25, 's9': 19, 's6': 18, 's7': 16, 's4': 12, 's5': 12, 's3': 4}
code / code win PFC->MTL 70 85 False 9 9 {'s2': 14, 's1': 11, 's9': 11, 's5': 10, 's6': 10, 's4': 7, 's7': 4, 's3': 2, 's8': 1}
code / code win MTL->OFC 200 93 False 5 5 {'s10': 154, 's5': 23, 's6': 13, 's9': 9, 's7': 1}
code / code win OFC->MTL 168 115 False 6 5 {'s10': 123, 's5': 20, 's6': 12, 's9': 9, 's1': 3, 's4': 1}
reading
code 2
code / code win 1
mtmfft 0
mtmfft / code win 0
sliding 0
sliding / code win 0
Result: not reproduced. With the PSI of the Methods and sliding windows the postcue counts are 0 MTL, 0 PFC, 0 OFC, 0 MTL to PFC, 1 PFC to MTL, 3 MTL to OFC and 2 OFC to MTL (0 of 7 within 10%); the single window selects none. The code's form gives 14, 49, 47, 105, 76, 189 and 170 (expected 13, 52, 38, 56, 85, 93, 115), 2 of 7 within 10%, with MTL electrodes in 5 subjects and MTL to OFC pairs in 7 (expected 8 and 5); in the code's windows 1 of 7. The code's form passes as many units with trials shuffled (57%) as on the real data, and its rates (41% to 65% per system) are of the order of the paper's (31% to 49%), so its counts are not evidence of phase direction.
crossspectral-equal-strength¶
Among phase-directing pairs, the strength of theta phase directionality did not differ across amplitude frequencies or between the MTL to frontal and frontal to MTL directions.
Blocked (methods_underspecified). The claim is about the phase-directing pairs. The Methods'
PSI selects 0 MTL to PFC pairs and 1 PFC to MTL pair (sliding windows; none with the single
window), too few for the model (the claim's own selection rule leaves no MTL to PFC pair), and against the
paper's 31% to 49% of units per system. The code's form selects 57% of pairs with trials shuffled, against
the 2.5% its z > 1.96 threshold implies, so it does not select phase-directing pairs, and no
selection with a defensible basis is left. The model on the code's selection is shown below as
a variant, not judged. Frequency (16 levels) is within pair, direction between pairs. With random
intercepts and every pair having all 16 frequencies, the mixed model's tests of frequency and
frequency x direction are the within-pair F tests computed by fcx2.within_unit_anova; the
direction main effect is tested on the pair means with a subject random intercept.
ZF = {}
for sid, r in R.items():
for i, u in enumerate(r["units"]):
ZF[(sid, i)] = u.get("zf_post_code")
def direction_tests(d, Y, groups):
tab, res_df = fcx2.within_unit_anova(Y, groups)
m = pd.DataFrame({"y": Y.reshape(len(Y), -1).mean(axis=1), "dir": groups, "subject": d.subject.to_numpy()})
md_ = smf.mixedlm("y ~ dir", m, groups=m["subject"]).fit(reml=True)
return tab, res_df, md_.params["dir"], md_.pvalues["dir"]
for net, (a, b) in {"MTL-PFC": ("MTL->PFC", "PFC->MTL"), "MTL-OFC": ("MTL->OFC", "OFC->MTL")}.items():
d = U[U.system.isin([a, b]) & (U.z_post_code > 1.96)]
Y = np.stack([ZF[(s, i)][:16] for s, i in zip(d.subject, d.idx)])
g = (d.system == b).astype(int).to_numpy()
tab, res_df, bdir, pdir_ = direction_tests(d, Y, g)
ss_f, ss_df_ = tab.loc[0, "ss"], tab.loc[1, "ss"]
res_ss = tab.attrs["res_ss"]
F_main = (ss_f / 15) / ((res_ss + ss_df_) / (res_df + 15))
print(f"{net}: {len(d)} pairs ({(g == 0).sum()} {a}, {(g == 1).sum()} {b}) in {d.subject.nunique()} subjects")
print(f" (b) with interaction: frequency F(15,{res_df}) = {tab.loc[0, 'F']:.2f}, p = {tab.loc[0, 'p']:.3g}; "
f"frequency x direction F = {tab.loc[1, 'F']:.2f}, p = {tab.loc[1, 'p']:.3g}")
print(f" (a) main effects only: frequency F(15,{res_df + 15}) = {F_main:.2f}, p = {stats.f.sf(F_main, 15, res_df + 15):.3g}")
print(f" direction (pair means, subject random intercept): {b} minus {a} = {bdir:.3f}, p = {pdir_:.3g}")
print(" mean z per frequency:", np.round(Y.mean(axis=0), 2).tolist())
for reg in ("MTL", "PFC", "OFC"):
d = U[(U.system == reg) & (U.z_post_code > 1.96)]
if len(d) < 2:
print(reg, "local variant: fewer than 2 electrodes")
continue
Y = np.stack([ZF[(s, i)][:16] for s, i in zip(d.subject, d.idx)])
tab, res_df = fcx2.within_unit_anova(Y)
print(f"local variant {reg}: {len(d)} electrodes, frequency F(15,{res_df}) = {tab.loc[0, 'F']:.2f}, p = {tab.loc[0, 'p']:.3g}")
# variant, not judged: the pairs the Methods' PSI selects with sliding windows (z > 1.96), with the
# sliding-window z per amplitude frequency
for net, (a, b) in {"MTL-PFC": ("MTL->PFC", "PFC->MTL"), "MTL-OFC": ("MTL->OFC", "OFC->MTL")}.items():
d = U[U.system.isin([a, b]) & (U.z_post_sliding > 1.96)]
g = (d.system == b).astype(int).to_numpy()
print(f"sliding selection {net}: {len(d)} pairs ({(g == 0).sum()} {a}, {(g == 1).sum()} {b}) in "
f"{d.subject.nunique()} subjects {sorted(d.subject.unique())}")
if (g == 0).sum() < 2 or (g == 1).sum() < 2:
print(" too few pairs in a direction for the model")
continue
Y = np.stack([R[s]["units"][i]["zf_post_sliding"][:16] for s, i in zip(d.subject, d.idx)])
tab, res_df = fcx2.within_unit_anova(Y, g)
print(f" frequency F(15,{res_df}) = {tab.loc[0, 'F']:.2f}, p = {tab.loc[0, 'p']:.3g}; "
f"frequency x direction F = {tab.loc[1, 'F']:.2f}, p = {tab.loc[1, 'p']:.3g}")
m = Y.mean(axis=1)
if d.subject.nunique() >= 3:
fit = smf.mixedlm("y ~ dir", pd.DataFrame({"y": m, "dir": g, "subject": d.subject.to_numpy()}),
groups=d.subject.to_numpy()).fit(reml=True)
print(f" direction (pair means, subject random intercept): p = {fit.pvalues['dir']:.3g}")
else:
# a subject random intercept cannot be estimated from fewer than 3 subjects; Welch t test
print(f" direction (pair means, Welch t test): {b} minus {a} = {m[g == 1].mean() - m[g == 0].mean():.3f}, "
f"p = {stats.ttest_ind(m[g == 1], m[g == 0], equal_var=False).pvalue:.3g}")
print(" mean z per frequency:", np.round(Y.mean(axis=0), 2).tolist())
MTL-PFC: 181 pairs (105 MTL->PFC, 76 PFC->MTL) in 9 subjects (b) with interaction: frequency F(15,2685) = 0.85, p = 0.617; frequency x direction F = 3.27, p = 1.95e-05 (a) main effects only: frequency F(15,2700) = 0.84, p = 0.629 direction (pair means, subject random intercept): PFC->MTL minus MTL->PFC = -3.755, p = 0.0204 mean z per frequency: [14.6, 21.54, 21.54, 18.33, 18.77, 19.86, 24.4, 18.61, 20.23, 22.06, 25.14, 19.34, 19.45, 20.37, 18.65, 18.4]
MTL-OFC: 359 pairs (189 MTL->OFC, 170 OFC->MTL) in 7 subjects (b) with interaction: frequency F(15,5355) = 4.85, p = 1.74e-09; frequency x direction F = 2.84, p = 0.000189 (a) main effects only: frequency F(15,5370) = 4.82, p = 2.03e-09 direction (pair means, subject random intercept): OFC->MTL minus MTL->OFC = -4.598, p = 0.00569 mean z per frequency: [16.37, 13.43, 17.37, 24.89, 24.1, 22.32, 25.71, 20.39, 24.44, 17.78, 31.43, 27.68, 19.22, 24.98, 22.72, 22.97] local variant MTL: 14 electrodes, frequency F(15,195) = 0.92, p = 0.54 local variant PFC: 49 electrodes, frequency F(15,720) = 1.26, p = 0.219 local variant OFC: 47 electrodes, frequency F(15,690) = 1.06, p = 0.389 sliding selection MTL-PFC: 1 pairs (0 MTL->PFC, 1 PFC->MTL) in 1 subjects ['s4'] too few pairs in a direction for the model sliding selection MTL-OFC: 5 pairs (3 MTL->OFC, 2 OFC->MTL) in 2 subjects ['s10', 's9'] frequency F(15,45) = 1.13, p = 0.361; frequency x direction F = 1.04, p = 0.437 direction (pair means, Welch t test): OFC->MTL minus MTL->OFC = 0.002, p = 0.995 mean z per frequency: [2.01, 2.18, 1.23, 1.43, 1.96, 2.51, 2.94, 1.73, 2.7, 2.92, 2.01, 1.33, 2.81, 3.05, 2.82, 2.63]
Result: blocked. On the pairs the code's form selects (not judged), frequency x direction is significant in both networks (p = 2e-05 and 0.00019), frequency in MTL-OFC (p = 2e-09) and direction in both (p = 0.020 and 0.0057). On the pairs the Methods' PSI selects with sliding windows (not judged), MTL-PFC has 1 pair (PFC to MTL, s4), too few for the model; MTL-OFC has 5 (3 MTL to OFC, 2 OFC to MTL, in s9 and s10), with no frequency (p = 0.36), frequency x direction (p = 0.44) or direction effect (Welch t test on pair means, p = 0.995, as a subject random intercept cannot be estimated from 2 subjects).
theta-peak-bands¶
Individual theta peaks were found at 2 to 5 Hz in 3 subjects, 3 to 6 Hz in 2, 4 to 7 Hz in 2 and 5 to 8 Hz in 3.
The six filters are 1.5-4, 2-5, 3-6, 4-7, 5-8 and 6-10 Hz. A maximum at 1.5-4 or 6-10 Hz has no 3 Hz wide band of the paper's list; it is counted apart, and for PAC the nearest band of the list is used (2-5 or 5-8 Hz, an assumption). Reading (b) is shown for the electrodes of the Methods' PSI (single window and sliding windows) and of the code's form.
names = {1: "1.5-4", 2: "2-5", 3: "3-6", 4: "4-7", 5: "5-8", 6: "6-10"}
rows = []
for sid, r in R.items():
rows.append({"subject": sid, "a_all_electrodes": names[r["peak_band_all"]],
"a_joined_trace": names[r["edge"]["peak_band_all"]], "a_code_windows": names[r["peak_band_all_alt"]],
"b_directing_methods_psi": names.get(r["peak_band_dir"], "none") if r["peak_band_dir"] else "no electrodes",
"b_directing_sliding_psi": names.get(r["peak_band_dir_sliding"], "none") if r["peak_band_dir_sliding"] else "no electrodes",
"b_directing_code_psi": names.get(r["peak_band_dir_code"], "none") if r["peak_band_dir_code"] else "no electrodes",
"z_curve_all": np.round(r["peak_curve_all"], 2).tolist(), "theta_band_used_for_PAC": r.get("theta_band_used")})
pk = pd.DataFrame(rows)
print(pk.to_string(index=False))
exp = {"2-5": 3, "3-6": 2, "4-7": 2, "5-8": 3}
for col in ("a_all_electrodes", "a_joined_trace", "a_code_windows", "b_directing_methods_psi", "b_directing_sliding_psi", "b_directing_code_psi"):
vc = pk[col].value_counts().to_dict()
overlap = sum(min(vc.get(k, 0), v) for k, v in exp.items())
print(f"{col}: {vc}; all four counts match: {all(vc.get(k, 0) == v for k, v in exp.items())}; overlap with the paper's counts {overlap} of 10")
subject a_all_electrodes a_joined_trace a_code_windows b_directing_methods_psi b_directing_sliding_psi b_directing_code_psi z_curve_all theta_band_used_for_PAC
s1 3-6 3-6 1.5-4 no electrodes no electrodes 3-6 [-0.54, -0.27, 0.11, -0.44, -0.24, -0.02] [3.0, 6.0]
s2 5-8 4-7 2-5 no electrodes no electrodes 5-8 [-0.54, -0.2, 0.39, 0.57, 0.6, 0.44] [5.0, 8.0]
s3 3-6 3-6 4-7 no electrodes no electrodes 6-10 [-0.47, -0.04, 0.27, -0.78, -0.74, -0.18] [3.0, 6.0]
s4 6-10 6-10 6-10 no electrodes 6-10 6-10 [0.52, 0.96, 0.78, 0.43, 0.5, 1.54] [5.0, 8.0]
s5 1.5-4 1.5-4 1.5-4 no electrodes no electrodes 1.5-4 [1.45, 0.79, 0.47, 0.27, 0.47, 0.5] [2.0, 5.0]
s6 1.5-4 1.5-4 6-10 no electrodes no electrodes 1.5-4 [2.11, 1.8, 0.55, 0.07, 0.08, 0.29] [2.0, 5.0]
s7 1.5-4 1.5-4 2-5 no electrodes no electrodes 1.5-4 [2.2, 2.15, 1.37, 0.65, 0.23, -0.23] [2.0, 5.0]
s8 2-5 1.5-4 5-8 no electrodes no electrodes 2-5 [-0.59, -0.48, -0.64, -0.75, -0.88, -0.64] [2.0, 5.0]
s9 1.5-4 1.5-4 6-10 no electrodes 1.5-4 1.5-4 [5.47, 4.45, 2.22, 1.47, 1.57, 1.36] [2.0, 5.0]
s10 3-6 3-6 1.5-4 no electrodes 6-10 3-6 [-0.6, -0.08, 0.22, -0.09, -0.05, 0.22] [3.0, 6.0]
a_all_electrodes: {'1.5-4': 4, '3-6': 3, '5-8': 1, '6-10': 1, '2-5': 1}; all four counts match: False; overlap with the paper's counts 4 of 10
a_joined_trace: {'1.5-4': 5, '3-6': 3, '4-7': 1, '6-10': 1}; all four counts match: False; overlap with the paper's counts 3 of 10
a_code_windows: {'1.5-4': 3, '6-10': 3, '2-5': 2, '4-7': 1, '5-8': 1}; all four counts match: False; overlap with the paper's counts 4 of 10
b_directing_methods_psi: {'no electrodes': 10}; all four counts match: False; overlap with the paper's counts 0 of 10
b_directing_sliding_psi: {'no electrodes': 7, '6-10': 2, '1.5-4': 1}; all four counts match: False; overlap with the paper's counts 0 of 10
b_directing_code_psi: {'1.5-4': 4, '3-6': 2, '6-10': 2, '5-8': 1, '2-5': 1}; all four counts match: False; overlap with the paper's counts 4 of 10
Result: not reproduced. Over all analysed electrodes (reading a) the maxima are at 1.5-4 Hz in 4 subjects, 3-6 Hz in 3, 2-5 Hz in 1, 5-8 Hz in 1 and 6-10 Hz in 1: 5 subjects peak outside the paper's four bands, and the overlap with the paper's counts is 4 of 10 (partial needs 7). For reading (b) the Methods' single-window PSI selects no electrodes, its sliding-window PSI selects electrodes in 3 subjects (overlap 0 of 10), and the code's form gives an overlap of 4 of 10. The power curves are flat in most subjects (z mostly within -0.9 to 2.2; s9 up to 5.5), so the maxima are weak. With encoding power from the joined trace (edge check) the overlap is 3 of 10 (1.5-4 Hz in 5 subjects), and in the code's windows 4 of 10.
PAC (claims pac-mtl-spatial to pac-mtl-ofc-direction)¶
All eight PAC claims are blocked (methods_underspecified). They are about the theta-phase directing electrodes and pairs. The Methods' PSI selects 0 MTL, 0 PFC, 0 OFC, 0 MTL to PFC, 1 PFC to MTL, 3 MTL to OFC and 2 OFC to MTL units (sliding windows; none with the single window), too few for any model, and the code's form, which selects enough, passes as many units with trials shuffled (57%) as on the real data, against the 2.5% its threshold implies. The models below run on the code's selection and are shown as a variant, not judged.
PAC z is computed for every unit that is phase-directing under the single-window PSI or the code's
form, in the trial table's postcue window. Readings of the surrogate: (a) amplitudes permuted across
trials (code), (b) amplitude bands shuffled within trials. Models as in M10, computed as within-unit
F tests (fcx2.within_unit_anova); a direction main effect on unit means with a subject random
intercept.
PAC = {}
for sid, r in R.items():
for p in r["pac"]:
PAC[(sid, p["unit"], p["cond"], p["reading"])] = p["z"][:16]
AMP_C = fcx2.CENTRES[fcx2.AMP_BANDS][:16]
TBIN = np.arange(19) * 0.05
EFF = {(0,): "condition", (1,): "frequency", (2,): "time", (0, 1): "cond x freq", (0, 2): "cond x time",
(1, 2): "freq x time", (0, 1, 2): "cond x freq x time"}
def pac_units(system):
d = U[(U.system == system) & (U.z_post_code > 1.96)]
return d
def pac_array(d, cond, rd):
return np.stack([np.stack([PAC[(s, i, 1, rd)], PAC[(s, i, cond, rd)]]) for s, i in zip(d.subject, d.idx)]) # (u, 2, 16, 19)
def pac_model(system, cond, rd):
d = pac_units(system)
Y = pac_array(d, cond, rd)
tab, res_df = fcx2.within_unit_anova(Y)
diff = (Y[:, 1] - Y[:, 0]).mean(axis=0) # (16, 19), relation minus identity
out = {"system": system, "model": {2: "spatial", 3: "temporal"}[cond], "reading": rd, "units": len(d),
"subjects": d.subject.nunique(), "res_df": res_df, "mean_diff": diff.mean(),
"peak_freq": AMP_C[int(np.argmax(diff.mean(axis=1)))], "peak_freq_idx": int(np.argmax(diff.mean(axis=1))),
"peak_time": TBIN[np.unravel_index(np.argmax(diff), diff.shape)[1]],
"peak_tf_freq_idx": int(np.unravel_index(np.argmax(diff), diff.shape)[0])}
for _, row in tab.iterrows():
out[EFF[row.effect]] = row.p
return out
rows = []
for system in SYSTEMS:
for cond in (2, 3):
for rd in ("a", "b"):
rows.append(pac_model(system, cond, rd))
PM = pd.DataFrame(rows)
print("Bonferroni threshold 0.05/7 =", round(0.05 / 7, 5))
print(PM.to_string(index=False, float_format=lambda v: f"{v:.3g}"))
def dir_model(a, b, cond, rd):
da, db = pac_units(a), pac_units(b)
d = pd.concat([da, db])
Y = np.concatenate([pac_array(da, cond, rd), pac_array(db, cond, rd)])
g = np.r_[np.zeros(len(da), int), np.ones(len(db), int)]
tab, res_df = fcx2.within_unit_anova(Y, g)
m = pd.DataFrame({"y": Y.mean(axis=(1, 2, 3)), "dir": g, "subject": d.subject.to_numpy()})
fit = smf.mixedlm("y ~ dir", m, groups=m["subject"]).fit(reml=True)
out = {"network": f"{a}/{b}", "model": {2: "spatial", 3: "temporal"}[cond], "reading": rd,
"units": f"{len(da)}+{len(db)}", "direction": fit.pvalues["dir"],
"mean_a": Y[g == 0].mean(), "mean_b": Y[g == 1].mean(),
"diff_a": (Y[g == 0][:, 1] - Y[g == 0][:, 0]).mean(), "diff_b": (Y[g == 1][:, 1] - Y[g == 1][:, 0]).mean()}
for _, row in tab.iterrows():
e = row.effect
name = ("direction x " if e[0] == "D" else "") + EFF[tuple(x for x in e if x != "D")]
out[name] = row.p
return out
rows = []
for a, b in (("MTL->PFC", "PFC->MTL"), ("MTL->OFC", "OFC->MTL")):
for cond in (2, 3):
for rd in ("a", "b"):
rows.append(dir_model(a, b, cond, rd))
DM = pd.DataFrame(rows)
print("\nDirection models, Bonferroni threshold 0.05/15 =", round(0.05 / 15, 5))
print(DM.T.to_string(float_format=lambda v: f"{v:.3g}"))
Bonferroni threshold 0.05/7 = 0.00714
system model reading units subjects res_df mean_diff peak_freq peak_freq_idx peak_time peak_tf_freq_idx condition frequency time cond x freq cond x time freq x time cond x freq x time
MTL spatial a 14 5 7891 -0.0102 11.5 1 0.1 3 0.559 0.201 0.0339 0.992 0.304 0.719 0.801
MTL spatial b 14 5 7891 -0.00737 11.5 1 0.1 3 0.672 0.213 0.0907 0.981 0.427 0.513 0.528
MTL temporal a 14 5 7891 -0.038 45.5 9 0.45 7 0.0285 0.0555 0.011 0.827 0.0506 0.444 0.872
MTL temporal b 14 5 7891 -0.0459 53.5 10 0.5 3 0.00775 0.109 0.0667 0.878 0.208 0.436 0.604
PFC spatial a 49 9 29136 0.0282 11.5 1 0.7 8 0.00256 0.514 0.255 8.26e-05 0.0048 0.99 0.983
PFC spatial b 49 9 29136 0.0216 11.5 1 0.1 4 0.0206 0.283 0.481 1.03e-05 0.0942 0.991 0.964
PFC temporal a 49 9 29136 0.00324 11.5 1 0.8 1 0.728 0.192 0.349 0.626 9.56e-05 0.355 0.652
PFC temporal b 49 9 29136 -0.00146 11.5 1 0.85 2 0.874 0.0175 0.501 0.702 0.0207 0.127 0.705
OFC spatial a 47 8 27922 0.0173 9.5 0 0.45 2 0.0743 0.0099 0.000496 0.734 0.0686 0.307 0.856
OFC spatial b 47 8 27922 0.0155 9.5 0 0.45 2 0.107 0.0296 0.0895 0.313 0.369 0.144 0.641
OFC temporal a 47 8 27922 0.0194 9.5 0 0.4 10 0.0448 0.152 0.0585 0.549 0.0358 0.435 0.597
OFC temporal b 47 8 27922 0.0241 9.5 0 0.15 0 0.0124 0.165 0.524 0.417 0.195 0.241 0.263
MTL->PFC spatial a 105 9 63128 0.00759 11.5 1 0.6 2 0.227 0.0973 0.000406 4.53e-05 0.0117 0.876 0.135
MTL->PFC spatial b 105 9 63128 0.00968 11.5 1 0.6 2 0.124 0.0976 0.00797 0.000363 0.0925 0.698 0.0571
MTL->PFC temporal a 105 9 63128 -0.00321 11.5 1 0.1 0 0.61 0.00191 0.0671 0.00956 0.00306 0.959 0.313
MTL->PFC temporal b 105 9 63128 -0.0033 11.5 1 0.1 0 0.6 0.000536 0.12 0.00111 0.0576 0.902 0.284
PFC->MTL spatial a 76 9 45525 0.0258 64 11 0.05 13 0.000398 7.75e-05 9.58e-07 0.0653 0.0153 8.44e-10 0.634
PFC->MTL spatial b 76 9 45525 0.0212 64 11 0.15 0 0.00358 1.59e-06 0.00319 0.00453 0.283 7.09e-11 0.443
PFC->MTL temporal a 76 9 45525 0.0109 64 11 0.7 3 0.14 0.000139 0.00418 0.444 7.4e-07 0.39 5.15e-06
PFC->MTL temporal b 76 9 45525 0.0104 64 11 0.7 3 0.156 6.24e-06 0.0317 0.708 3.54e-05 0.352 1.58e-07
MTL->OFC spatial a 189 7 114116 0.0064 19.5 4 0.1 4 0.176 2.45e-12 2.34e-11 0.0301 3.08e-10 3.6e-05 4.27e-08
MTL->OFC spatial b 189 7 114116 0.0025 19.5 4 0.1 4 0.6 4.83e-22 5.54e-07 0.00768 0.000114 1.7e-08 8.49e-11
MTL->OFC temporal a 189 7 114116 -0.0114 76.5 12 0.7 8 0.016 6.08e-10 0.000209 0.0151 5.47e-14 0.000247 1.11e-07
MTL->OFC temporal b 189 7 114116 -0.00715 76.5 12 0.75 6 0.133 1.21e-10 0.00351 2.16e-05 2.19e-08 6.63e-08 5.08e-15
OFC->MTL spatial a 170 6 102583 -0.0192 26.5 6 0.65 6 0.000102 0.127 5.33e-10 0.0239 1.79e-13 1.09e-11 4.42e-16
OFC->MTL spatial b 170 6 102583 -0.0107 128 15 0.65 6 0.0324 0.0621 7.14e-06 0.00413 2.14e-08 5.08e-11 2.96e-17
OFC->MTL temporal a 170 6 102583 0.00199 26.5 6 0.15 5 0.69 1.69e-06 0.0277 0.000503 7.46e-07 1.89e-06 3.55e-11
OFC->MTL temporal b 170 6 102583 0.00958 26.5 6 0.15 5 0.0569 1.3e-06 0.2 0.000345 0.000475 1.88e-09 6.82e-11
Direction models, Bonferroni threshold 0.05/15 = 0.00333
0 1 2 3 4 5 6 7
network MTL->PFC/PFC->MTL MTL->PFC/PFC->MTL MTL->PFC/PFC->MTL MTL->PFC/PFC->MTL MTL->OFC/OFC->MTL MTL->OFC/OFC->MTL MTL->OFC/OFC->MTL MTL->OFC/OFC->MTL
model spatial spatial temporal temporal spatial spatial temporal temporal
reading a b a b a b a b
units 105+76 105+76 105+76 105+76 189+170 189+170 189+170 189+170
direction 0.263 0.759 0.379 0.679 0.285 0.844 0.028 0.0205
mean_a 0.0058 -0.000474 0.000401 -0.00696 0.0135 -0.00587 0.00463 -0.0107
mean_b 0.0154 0.00171 0.0079 -0.0037 0.0077 -0.00419 0.0183 0.00595
diff_a 0.00759 0.00968 -0.00321 -0.0033 0.0064 0.0025 -0.0114 -0.00715
diff_b 0.0258 0.0212 0.0109 0.0104 -0.0192 -0.0107 0.00199 0.00958
condition 0.000528 0.00136 0.43 0.462 0.0607 0.236 0.173 0.726
direction x condition 0.0585 0.231 0.146 0.157 0.00018 0.0561 0.0519 0.0158
frequency 0.00027 2.3e-05 0.0644 0.0417 1.19e-10 4.45e-18 4.78e-13 6.89e-14
direction x frequency 0.016 0.0035 1.15e-06 1.34e-08 0.0264 0.000633 0.00118 0.00121
time 0.00131 0.0337 0.0442 0.0385 3.53e-12 2.21e-07 0.000337 0.106
direction x time 1.08e-07 0.000587 0.00445 0.0855 3.98e-09 1.96e-05 0.024 0.0109
cond x freq 0.00201 0.000436 0.265 0.261 0.00807 0.000756 0.00968 0.00134
direction x cond x freq 0.00819 0.00602 0.0452 0.0295 0.0799 0.0343 0.000671 5.67e-06
cond x time 0.00308 0.241 1.34e-05 0.000297 9.57e-14 1.18e-06 8.8e-15 1.23e-08
direction x cond x time 0.0558 0.14 7.02e-05 0.00387 4.12e-10 1.86e-06 8.38e-06 0.00124
freq x time 0.00365 0.000293 0.312 0.305 5.42e-07 1.15e-08 3.57e-08 2.95e-11
direction x freq x time 6.99e-05 3.59e-05 0.954 0.886 1.11e-09 6.15e-11 0.00314 1.8e-06
cond x freq x time 0.0916 0.0721 0.00496 0.000846 1.03e-09 9.11e-12 8.08e-10 3.05e-13
direction x cond x freq x time 0.82 0.522 0.000976 0.000261 1.75e-14 1.9e-16 3.58e-09 2.2e-12
B7, B15 = 0.05 / 7, 0.05 / 15
CONDFX = ["condition", "cond x freq", "cond x time", "cond x freq x time"]
ALLFX = list(EFF.values())
def sel(system, model, rd):
return PM[(PM.system == system) & (PM.model == model) & (PM.reading == rd)].iloc[0]
verdict = {}
for rd in ("a", "b"):
s, t = sel("MTL", "spatial", rd), sel("MTL", "temporal", rd)
p1 = s["condition"] < B7 and s["cond x freq"] < B7 and s.mean_diff > 0
p2 = abs(s.peak_freq_idx - 5) <= 1 or abs(s.peak_freq_idx - 11) <= 1
p3 = all(t[f] >= B7 for f in CONDFX)
verdict[("pac-mtl-spatial", rd)] = (p1, p2, p3)
verdict[("pac-frontal-no-condition", rd)] = all(sel(sy, mo, rd)[f] >= B7 for sy in ("PFC", "OFC") for mo in ("spatial", "temporal") for f in CONDFX)
s = sel("MTL->PFC", "spatial", rd)
q1 = all(s[f] < B7 for f in CONDFX) and s.mean_diff > 0
q2 = 1 <= s.peak_tf_freq_idx <= 4 and (0.1 <= s.peak_time <= 0.25 or 0.8 <= s.peak_time <= 0.9)
verdict[("pac-mtl-pfc-spatial", rd)] = (q1, q2, s["condition"] < B7 and s.mean_diff > 0)
t = sel("MTL->PFC", "temporal", rd)
verdict[("pac-mtl-pfc-temporal", rd)] = t["condition"] < B7 and t.mean_diff > 0
verdict[("pac-pfc-mtl-no-condition", rd)] = all(sel("PFC->MTL", mo, rd)[f] >= B7 for mo in ("spatial", "temporal") for f in CONDFX)
s, t = sel("MTL->OFC", "spatial", rd), sel("MTL->OFC", "temporal", rd)
r1 = s["condition"] < B7 and s["cond x freq"] < B7 and s.mean_diff > 0
r2 = s.peak_freq_idx <= 1
r3 = all(t[f] >= B7 for f in CONDFX) and all(sel("OFC->MTL", mo, rd)[f] >= B7 for mo in ("spatial", "temporal") for f in CONDFX)
verdict[("pac-mtl-ofc-spatial", rd)] = (r1, r2, r3)
for net, key in (("MTL->PFC/PFC->MTL", "pac-mtl-pfc-direction"), ("MTL->OFC/OFC->MTL", "pac-mtl-ofc-direction")):
out = []
for mo in ("spatial", "temporal"):
d = DM[(DM.network == net) & (DM.model == mo) & (DM.reading == rd)].iloc[0]
out.append({"model": mo, "cond_x_dir": d["direction x condition"], "cond_x_dir_larger_MTL_first": d.diff_a > d.diff_b,
"direction": d["direction"], "higher": "first (MTL->)" if d.mean_a > d.mean_b else "second (->MTL)",
"any_effect_below": any(d[c] < B15 for c in d.index if c not in ("network", "model", "reading", "units", "mean_a", "mean_b", "diff_a", "diff_b"))})
verdict[(key, rd)] = out
for k, v in verdict.items():
print(k, v)
('pac-mtl-spatial', 'a') (np.False_, np.False_, True)
('pac-frontal-no-condition', 'a') False
('pac-mtl-pfc-spatial', 'a') (False, np.False_, np.False_)
('pac-mtl-pfc-temporal', 'a') False
('pac-pfc-mtl-no-condition', 'a') False
('pac-mtl-ofc-spatial', 'a') (np.False_, np.False_, False)
('pac-mtl-pfc-direction', 'a') [{'model': 'spatial', 'cond_x_dir': np.float64(0.05846358660147321), 'cond_x_dir_larger_MTL_first': np.False_, 'direction': np.float64(0.2626395690287592), 'higher': 'second (->MTL)', 'any_effect_below': True}, {'model': 'temporal', 'cond_x_dir': np.float64(0.14637989418920466), 'cond_x_dir_larger_MTL_first': np.False_, 'direction': np.float64(0.3785618975765471), 'higher': 'second (->MTL)', 'any_effect_below': True}]
('pac-mtl-ofc-direction', 'a') [{'model': 'spatial', 'cond_x_dir': np.float64(0.00018036468692756195), 'cond_x_dir_larger_MTL_first': np.True_, 'direction': np.float64(0.28510542801896266), 'higher': 'first (MTL->)', 'any_effect_below': True}, {'model': 'temporal', 'cond_x_dir': np.float64(0.05188075784091033), 'cond_x_dir_larger_MTL_first': np.False_, 'direction': np.float64(0.02802895344930003), 'higher': 'second (->MTL)', 'any_effect_below': True}]
('pac-mtl-spatial', 'b') (np.False_, np.False_, True)
('pac-frontal-no-condition', 'b') False
('pac-mtl-pfc-spatial', 'b') (False, np.False_, np.False_)
('pac-mtl-pfc-temporal', 'b') False
('pac-pfc-mtl-no-condition', 'b') False
('pac-mtl-ofc-spatial', 'b') (np.False_, np.False_, False)
('pac-mtl-pfc-direction', 'b') [{'model': 'spatial', 'cond_x_dir': np.float64(0.23073470899014717), 'cond_x_dir_larger_MTL_first': np.False_, 'direction': np.float64(0.7590698781528318), 'higher': 'second (->MTL)', 'any_effect_below': True}, {'model': 'temporal', 'cond_x_dir': np.float64(0.15659861598203698), 'cond_x_dir_larger_MTL_first': np.False_, 'direction': np.float64(0.6793526479239476), 'higher': 'second (->MTL)', 'any_effect_below': True}]
('pac-mtl-ofc-direction', 'b') [{'model': 'spatial', 'cond_x_dir': np.float64(0.05613564749786221), 'cond_x_dir_larger_MTL_first': np.True_, 'direction': np.float64(0.8444498340643335), 'higher': 'second (->MTL)', 'any_effect_below': True}, {'model': 'temporal', 'cond_x_dir': np.float64(0.015756793209439013), 'cond_x_dir_larger_MTL_first': np.False_, 'direction': np.float64(0.020463242694496862), 'higher': 'second (->MTL)', 'any_effect_below': True}]
Result: blocked, all eight claims. On the code's selection (not judged) no claim's full pattern appears under either surrogate reading, and one reaches its criterion's partial case: under reading (a) the MTL to OFC spatial direction model has a condition x direction effect (p = 0.00018, below 0.05/15) with the spatial minus identity difference larger for MTL to OFC (0.0064 against -0.0192), one part of condition (1) of pac-mtl-ofc-direction, while its direction effect is p = 0.29 and the temporal model has effects below 0.05/15. For the rest: the MTL spatial condition effect is p = 0.56 (a), the frontal and PFC to MTL models have condition effects below 0.05/7 (PFC spatial condition x frequency p = 8.3e-05, PFC to MTL spatial condition p = 0.0004), the MTL to PFC condition effects are p = 0.23 (spatial) and 0.61 (temporal), the MTL to OFC spatial condition effect is p = 0.18, and the direction models have effects below 0.05/15 in every network and model.
Summary¶
Outcomes are in the attempt record: 5 claims reproduced (behaviour, electrode and trial counts, PLV
peak), 7 not reproduced and 9 blocked. The analysis follows the claims file and, for details it
lacks, the paper's Methods and the analysis code deposited with the data. The main differences from
the paper's method: the windows are placed by the trial table, 1.5 s earlier on the derived time
axes than the deposited code places them, because the 900 and 1150 ms delay trials part where the
table puts the delay-dependent events and not where the code does; the code's windows are run as a
variant. If the deposited scripts produced the paper's figures, the paper's numbers come from the
code's windows, so the main reading tests the claims against the events the Methods describe and
does not recompute the paper's numbers. The table's windows start 0 to 0.65 s after a segment's
first sample; joining the three segments of a trial shows that this leaves baseline power unchanged
and lowers theta power only in the first 250 ms of encoding, without changing an outcome. The phase-directing units on which crossspectral-equal-strength and the eight PAC claims
rest cannot be selected: the Methods' PSI selects at most 3 per system, and the code's form selects
as many units with trials shuffled as on the real data. The behaviour claim is judged with
condition as one numeric term, as the amended claims file says, on the response times of
summary_file.csv, whose condition means are the paper's; the trial tables' response times differ
in 7 of 10 subjects, no summary of them reproduces the file's values, and they would show a
condition effect. The mixed models use random intercepts.
What was found about the data set: the trial table and the derived time axes disagree with the
deposited code's windows by 1.5 s; the response times of summary_file.csv do not follow from the
trial tables in 7 of 10 subjects; s10's trial table is not on the derived sample grid; s8 and s9 are
at 512 Hz, not the 1000 Hz the descriptor gives; and the deposited PSI and PAC scripts depart from
the Methods (PSI without the conjugate and with a null of another statistic; PAC scripts that cannot
run as given).
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.
print(f"total run time {(time.time() - started) / 60:.1f} min")
total run time 52.8 min