Reproducing Johnson et al. (2019) from CRCNS data set fcx-3¶
Paper. Johnson EL, King-Stephens D, Weber PB, Laxer KD, Lin JJ, Knight RT (2019). Spectral imprints of working memory for everyday associations in the frontoparietal network. Frontiers in Systems Neuroscience 12, 65. doi:10.3389/fnsys.2018.00065. The claims file was written from the version of record (PMC6333050, open access); the paper has no supplement.
Data set. CRCNS fcx-3, doi:10.6080/K06971S9, read from the
public bucket crcnsarchive under fcx-3/live/. CRCNS data sets are not versioned, so the version
is recorded as unversioned (docs/archives.md). The paper cites no version; live/ is the only
copy the bucket holds (there is no old/), with its files dated 2026-02-11 and the data
description version 0.5 of 2019-01-04, the original version. The MD5 sums of the files read, from
the data set's checksums.md5, are printed below, so that a later change is detectable.
What the data set holds. For each of the 7 subjects: the filtered continuous iEEG
(data_primary.mat), channel names, electrode positions, the preprocessed epochs
(data_derived.mat: pretrial, encoding and maintenance, and processing epochs of every channel
kept, with a per-trial table of accuracy, condition, delay and RT) and a trial table with the epoch
start samples. The docs list the analysed channels and give per-subject accuracy and RT. The
paper's MATLAB scripts (analysis_scripts.zip) are deposited with the data and are read here for
method details the paper leaves open (cited by file name).
Claims (claims/crcns-fcx-3/10.3389-fnsys.2018.00065.yaml), all tested:
| Claim | Tested on |
|---|---|
| table1-electrodes | channel list of the docs and the derived epochs |
| trial-counts | derived epochs and trial tables |
| fig1b-accuracy, fig1b-rt-identity-slower | docs/summary_file.csv and trial tables |
| erp-no-condition-difference | derived processing epochs |
| fig2-spatial-power, fig3-temporal-power, power-difficulty-subjects, power-low-frequencies | derived processing epochs |
| fig4-maintenance-parietal-led, fig4a-delta-theta-shift, fig4c-alpha-beta-shift, directional-pairs | derived maintenance and processing epochs |
| fig5a-delta-theta-epochs, fig5a-identity-direction, fig5a-spatiotemporal-bidirectional, fig5b-alpha-beta-no-sustained | derived processing epochs |
The data set's files are tar.gz archives (0.5 to 3.6 GB each), which cannot be read at random: each is streamed once, decompressed in memory, reduced to what the claims use, and released. The loading cell, which streams and analyses each subject in turn, takes nearly the whole run, 39 to 42 minutes of 40 to 43 in three runs.
import time
import warnings
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from scipy import stats
import fcx3
pd.set_option("display.width", 220)
pd.set_option("display.max_columns", 40)
pd.set_option("display.max_rows", 300)
warnings.filterwarnings("ignore", category=RuntimeWarning)
listing = fcx3.bucket_listing()
md5 = fcx3.checksums()
print(listing.to_string(index=False))
print("\nMD5 (checksums.md5) of the files read:")
for k in ["docs/summary_file.csv", "docs/summary_channel_analysis.csv", "analysis_scripts.zip"] + [f"data/{s}.tar.gz" for s in fcx3.SUBJECTS]:
print(f" {md5[k]} {k}")
key size modified etag
fcx-3/ 0 2026-02-11T01:18:50.000Z d41d8cd98f00b204e9800998ecf8427e
fcx-3/live/ 0 2026-02-11T01:18:51.000Z d41d8cd98f00b204e9800998ecf8427e
fcx-3/live/analysis_scripts.zip 6372 2026-02-11T01:24:52.000Z 0c85eb1b44f2098f5777a024603b5083
fcx-3/live/checksums.md5 714 2026-02-11T01:24:54.000Z 3317c34dc147bc9a755b3eccffba8597
fcx-3/live/data/ 0 2026-02-11T01:25:54.000Z d41d8cd98f00b204e9800998ecf8427e
fcx-3/live/data/s1.tar.gz 1144345044 2026-02-11T02:52:01.000Z f9095a61a92916cc86fadd098185906a-3
fcx-3/live/data/s2.tar.gz 1491455501 2026-02-11T02:48:59.000Z 5030342a18b56c77244839528edf2c4c-3
fcx-3/live/data/s3.tar.gz 3592865513 2026-02-11T02:38:30.000Z 94600bd3e1300ff877dec17d73b57908-8
fcx-3/live/data/s4.tar.gz 836483844 2026-02-11T02:55:41.000Z 7b8881b293455c222122f25bd294fca8-2
fcx-3/live/data/s5.tar.gz 2815586456 2026-02-11T02:40:49.000Z bb19e2149e5b014f2e081781530ed19e-6
fcx-3/live/data/s6.tar.gz 1329654513 2026-02-11T02:49:46.000Z cf47ebdcb4c1ba06defd21ce0942890d-3
fcx-3/live/data/s7.tar.gz 553878785 2026-02-11T02:57:17.000Z 0d6bad130c0505d9521058892512b96e-2
fcx-3/live/docs/ 0 2026-02-11T01:26:46.000Z d41d8cd98f00b204e9800998ecf8427e
fcx-3/live/docs/crcns_fcx-3_data_description.docx 29876 2026-02-11T03:00:12.000Z d16b39837f62dc55bd5f37b08f71487f
fcx-3/live/docs/crcns_fcx-3_data_description.pdf 91343 2026-02-11T03:00:01.000Z 82f45b52cd9eeb1d25d0c51077672654
fcx-3/live/docs/summary_channel_analysis.csv 1558 2026-02-11T03:00:16.000Z 96ac7a485a6855780e38da69cf684d35
fcx-3/live/docs/summary_file.csv 382 2026-02-11T03:00:17.000Z 230e7b00845424f273ea556c2ed49733
fcx-3/live/filelist.txt 796 2026-02-11T01:24:54.000Z faf411ab4c05c88fee1684517cfc4675
MD5 (checksums.md5) of the files read:
230e7b00845424f273ea556c2ed49733 docs/summary_file.csv
96ac7a485a6855780e38da69cf684d35 docs/summary_channel_analysis.csv
0c85eb1b44f2098f5777a024603b5083 analysis_scripts.zip
eadec32d00f25d3dcb59c2ce624095c2 data/s1.tar.gz
74bd18320bb4a446d58c8af2ca370ddd data/s2.tar.gz
239bf97cbdf05e3039dec6bcf009e49e data/s3.tar.gz
b3d3de174047eb02657d7fbc96dd8f01 data/s4.tar.gz
17d40604f26cea12bf2881d3e0ffe3be data/s5.tar.gz
1e846c8a7336ea8ccc23d4a0f1a9485b data/s6.tar.gz
994081bc1617117a8edcc171f8c18b18 data/s7.tar.gz
CHAN = fcx3.channel_table()
SUMMARY = fcx3.summary_file()
META, RES = {}, {}
started = time.time()
for sid in fcx3.SUBJECTS:
t0 = time.time()
chan = CHAN[CHAN.subject == sid].reset_index(drop=True)
META[sid], RES[sid] = fcx3.load_subject(sid, chan)
print(f"{sid}: streamed and analysed in {time.time() - t0:.0f} s", flush=True)
print(f"all subjects in {(time.time() - started) / 60:.1f} min")
s1: streamed and analysed in 229 s
s2: streamed and analysed in 312 s
s3: streamed and analysed in 744 s
s4: streamed and analysed in 180 s
s5: streamed and analysed in 396 s
s6: streamed and analysed in 151 s
s7: streamed and analysed in 85 s
all subjects in 34.9 min
Data check¶
Each check of the description against the values is stated under its output.
rows = []
for sid in fcx3.SUBJECTS:
m = META[sid]
ep = m["epochs"]
rows.append({"subject": sid, "fs": m["fs"], "primary (samples, channels)": m["primary_shape"],
"elec_labels": len(m["elec_labels"]), "elec_labels file": m["elec_labels_format"],
"derived channels": ep["data_proc"]["n_labels"], "analysed": ep["data_proc"]["shape"][1],
"trials (derived)": ep["data_proc"]["shape"][0], "trials (table)": len(m["trials"]),
"trialinfo = table": all(e["trialinfo_equals_table"] for e in ep.values()),
"hdr nSamples": int(ep["data_proc"]["hdr_nSamples"])})
print(pd.DataFrame(rows).to_string(index=False))
print("\nDescription: 7 subjects; S1-6 at 1 kHz, S7 at 512 Hz; derived 'fsample: 1000'; trialinfo 6 columns as listed.")
print("\nEpoch time axes (s), samples per trial, value ranges (microvolts as stored; the files give no unit):")
rows = []
for sid in fcx3.SUBJECTS:
for k, e in META[sid]["epochs"].items():
rows.append({"subject": sid, "epoch": k, "fs": e["fs"], "t0": e["t0"], "t1": e["t1"], "lengths": e["lengths"],
"starts": e["starts"], "min": round(e["min"], 1), "max": round(e["max"], 1), "sd": round(e["sd"], 2)})
print(pd.DataFrame(rows).to_string(index=False))
subject fs primary (samples, channels) elec_labels elec_labels file derived channels analysed trials (derived) trials (table) trialinfo = table hdr nSamples
s1 1000.0 (1140000, 72) 72 MATLAB 7.3 MAT-file 46 23 120 120 True 1140000
s2 1000.0 (940001, 96) 96 MATLAB 7.3 MAT-file 64 32 120 120 True 940001
s3 1000.0 (840656, 256) 256 MATLAB 5.0 MAT-file 155 68 120 120 True 840656
s4 1000.0 (793027, 116) 116 MATLAB 7.3 MAT-file 29 17 120 120 True 793027
s5 1000.0 (1017999, 172) 172 MATLAB 7.3 MAT-file 118 26 120 120 True 1017999
s6 1000.0 (985999, 108) 108 MATLAB 7.3 MAT-file 60 12 101 101 True 985999
s7 512.0 (445952, 101) 101 MATLAB 7.3 MAT-file 43 9 90 90 True 431506
Description: 7 subjects; S1-6 at 1 kHz, S7 at 512 Hz; derived 'fsample: 1000'; trialinfo 6 columns as listed.
Epoch time axes (s), samples per trial, value ranges (microvolts as stored; the files give no unit):
subject epoch fs t0 t1 lengths starts min max sd
s1 data_pre 1000.0 -1.5 3.000000 [4501] [-1.5] -242.6 313.3 31.21
s1 data_encmain 1000.0 -1.5 2.997000 [4498, 4499, 4500] [-1.5] -257.1 313.3 31.37
s1 data_proc 1000.0 -1.5 3.000000 [4501] [-1.5] -257.1 313.3 31.41
s2 data_pre 1000.0 -1.5 3.000000 [4501] [-1.5] -581.1 503.8 45.76
s2 data_encmain 1000.0 -1.5 2.997000 [4498, 4499] [-1.5] -581.1 486.1 43.70
s2 data_proc 1000.0 -1.5 3.000000 [4501] [-1.5] -581.1 503.8 44.28
s3 data_pre 1000.0 -1.5 3.000000 [4501] [-1.5] -431.1 438.7 21.62
s3 data_encmain 1000.0 -1.5 2.998000 [4499, 4500, 4501] [-1.5] -431.1 346.7 20.83
s3 data_proc 1000.0 -1.5 3.000000 [4501] [-1.5] -431.1 438.7 20.91
s4 data_pre 1000.0 -1.5 3.000000 [4501] [-1.5] -286.5 230.2 18.27
s4 data_encmain 1000.0 -1.5 2.998000 [4499, 4500] [-1.5] -235.6 151.9 18.06
s4 data_proc 1000.0 -1.5 3.000000 [4501] [-1.5] -252.5 230.2 18.18
s5 data_pre 1000.0 -1.5 3.000000 [4501] [-1.5] -840.7 702.0 65.39
s5 data_encmain 1000.0 -1.5 2.995000 [4496, 4497, 4498] [-1.5] -840.7 671.8 62.36
s5 data_proc 1000.0 -1.5 3.000000 [4501] [-1.5] -822.7 702.0 60.99
s6 data_pre 1000.0 -1.5 3.000000 [4501] [-1.5] -593.9 574.8 46.66
s6 data_encmain 1000.0 -1.5 2.996000 [4497, 4498] [-1.5] -593.9 494.5 40.24
s6 data_proc 1000.0 -1.5 3.000000 [4501] [-1.5] -548.1 620.1 42.49
s7 data_pre 512.0 -1.5 3.000000 [2305] [-1.5] -81.4 55.9 7.56
s7 data_encmain 512.0 -1.5 2.998047 [2304] [-1.5] -81.4 57.4 7.60
s7 data_proc 512.0 -1.5 3.000000 [2305] [-1.5] -83.5 57.4 7.58
The description says the derived structures have fsample: 1000; S7's say 512, as its sampling rate.
The derived epochs carry every channel kept after preprocessing (29 to 155 per subject), of which the
docs' channel list names 187 analysed channels in all (Table 1 gives 192; see table1-electrodes); only those are kept here. The
continuous data (hdr nSamples) of the derived files have a different length from the deposited
data_primary in S7 only. S3's elec_labels.mat is a MATLAB 5 file, the others MATLAB 7.3.
print("Trial tables: rows, trial numbers, accuracy, condition and jitter codes")
rows = []
for sid in fcx3.SUBJECTS:
t = META[sid]["trials"]
rows.append({"subject": sid, "rows": len(t), "trial numbers": f"{t.trial.min()}-{t.trial.max()}",
"unique": t.trial.is_unique, "correct": int(t.correct.sum()), "incorrect": int((t.correct == 0).sum()),
"type codes": sorted(t.type.unique()), "condition codes": sorted(t.condition.unique()),
"type matches condition": bool(((t.type == 1) == (t.condition == 1)).all()),
"jitter": sorted(t.jitter.unique()), "rt range ms": (int(t.rt.min()), int(t.rt.max())),
"H-G (s)": sorted(set(np.round((t.encmain_start - t.pre_start) / META[sid]["fs"], 2))),
"I-H-jitter (s)": sorted(set(np.round((t.proc_start - t.encmain_start) / META[sid]["fs"] - t.jitter / 1000, 2)))})
print(pd.DataFrame(rows).to_string(index=False))
print("\nTask timing (Methods, Behavioral Task): pretrial 1 s, start screen 0.8 s, fixation 0.1 s, stimuli 2 x 0.2 s,"
" delay 0.9 or 1.15 s, cue 0.8 s.")
Trial tables: rows, trial numbers, accuracy, condition and jitter codes
subject rows trial numbers unique correct incorrect type codes condition codes type matches condition jitter rt range ms H-G (s) I-H-jitter (s)
s1 120 1-120 True 102 18 [1, 2] [1, 2, 3] True [900, 1150] (349, 11416) [1.9] [1.4]
s2 120 1-120 True 95 25 [1, 2] [1, 2, 3] True [900, 1150] (519, 25044) [1.9] [1.4]
s3 120 1-120 True 103 17 [1, 2] [1, 2, 3] True [900, 1150] (394, 2300) [1.9] [1.4]
s4 120 1-120 True 112 8 [1, 2] [1, 2, 3] True [900, 1150] (384, 3102) [1.9] [1.4]
s5 120 1-120 True 95 25 [1, 2] [1, 2, 3] True [900, 1150] (435, 27953) [1.9] [1.4]
s6 101 1-120 True 77 24 [1, 2] [1, 2, 3] True [900, 1150] (952, 11331) [1.9] [1.4]
s7 90 1-120 True 86 4 [1, 2] [1, 2, 3] True [900, 1150] (499, 4529) [1.87, 1.88, 1.89, 1.9, 1.91, 1.92] [1.4]
Task timing (Methods, Behavioral Task): pretrial 1 s, start screen 0.8 s, fixation 0.1 s, stimuli 2 x 0.2 s, delay 0.9 or 1.15 s, cue 0.8 s.
The description says the trial table lists each trial; in S6 and S7 it lists only the trials kept after artifact rejection (101 and 90 of 120, numbered up to 120), and in S1 to S5 all 120. The pretrial start (G) precedes the encoding start (H) by 1.9 s in every trial (1.87 to 1.92 s in S7, sampled at 512 Hz), the pretrial fixation and start screen and fixation of the Methods (1.0 + 0.8 + 0.1 s). The processing start (I) follows H by 1.4 s plus the delay, which fits an encoding epoch of 0.6 s (the description's "600 ms + jitter") and a 0.8-s cue.
print("Derived epochs located in the continuous data (step 1: search; step 2: every analysed channel at the found offset).")
rows = []
for sid in fcx3.SUBJECTS:
ck = META[sid]["clock"]
ch = ck["channels"]
num = ch.apply(lambda r: fcx3.split_label(r.channel)[1] - fcx3.split_label(r.reference)[1]
if fcx3.split_label(r.channel)[0] == fcx3.split_label(r.reference)[0] else None, axis=1)
rows.append({"subject": sid, **{f"offset {k[5:]} (s)": round(v, 3) for k, v in ck["offsets_s"].items()},
"search r min": round(ck["search"].r.min(), 4),
"channels": len(ch), "r min": round(ch.r.min(), 4), "r median": round(ch.r.median(), 5),
"traces per channel": int(ch.n_traces.min()),
"reference = contact - k, k": dict(pd.Series(num).value_counts())})
print(pd.DataFrame(rows).to_string(index=False))
Derived epochs located in the continuous data (step 1: search; step 2: every analysed channel at the found offset).
subject offset pre (s) offset encmain (s) offset proc (s) search r min channels r min r median traces per channel reference = contact - k, k
s1 -1.401 -1.501 -1.801 0.9997 23 1.0000 1.0 24 {-1: 19, 1: 4}
s2 -1.401 -1.501 -1.801 0.9989 32 1.0000 1.0 24 {-1: 24, 1: 8}
s3 -1.401 -1.501 -1.801 0.9992 68 0.9998 1.0 24 {1: 54, 16: 14}
s4 -1.401 -1.501 -1.801 0.9997 17 1.0000 1.0 24 {1: 17}
s5 -1.401 -1.501 -1.801 0.9997 26 1.0000 1.0 24 {1.0: 16, -1.0: 9}
s6 -1.401 -1.501 -1.801 0.9991 12 1.0000 1.0 24 {8: 8, 1: 4}
s7 -1.402 -1.502 -1.803 0.9989 9 1.0000 1.0 24 {1: 9}
Each derived trace is the difference of the channel's contact and one other contact of the continuous data (correlation at least the minimum printed, over 8 random trials and all three epochs), so the derived channels are bipolar, labelled by one of their contacts. The reference is the contact numbered one above or below on strips and depth leads, and the next row of the grid on S3's 16 x 16 grid (16 below) and S6's 8 x 8 grid (8 below). The derived epochs start 1.4 s (pretrial), 1.5 s (encoding) and 1.8 s (processing) before the trial table's columns, in every subject, so their time axes are: pretrial, 0 at G + 0.1 s; encoding, 0 at H; processing, 0 at I - 0.3 s. The deposited scripts' windows are therefore the paper's: baseline [0.65, 0.85] s of the pretrial epoch is G + 0.75 to G + 0.95 s, 250 to 50 ms before the start screen; maintenance [0.6, 1.5] s of the encoding epoch is 0.9 s from H + 0.6 s; processing [0.3, 1.2] s is the 0.9 s from I. This shows that the derived data, the continuous data and the trial table share one clock. Whether the table's columns mark the screen events is checked next.
print("Timing contrast between 900-ms and 1150-ms delay trials (70-150 Hz amplitude; see fcx3.jitter_check).")
print("If the columns mark the events, the best shift is near 0 in every window; a shift beyond the shuffled maximum, with r")
print("above the shuffled maximum, means the events lie at different times relative to the column in the two groups.")
rows = []
for sid in fcx3.SUBJECTS:
for k, v in META[sid]["jitter"].items():
rows.append({"subject": sid, "epoch": k, "window (s)": fcx3.JITTER_WINDOWS[k], "shift 1150 vs 900 (s)": round(v["lag_s"], 3),
"r": round(v["r"], 2), "shuffled max |shift|": round(v["shuffled_abs_lag_max_s"], 3),
"shuffled max r": round(v["shuffled_r_max"], 2)})
jit = pd.DataFrame(rows)
jit["clear"] = (jit["r"] > jit["shuffled max r"]) & (jit["shift 1150 vs 900 (s)"].abs() > jit["shuffled max |shift|"])
print(jit.to_string(index=False))
Timing contrast between 900-ms and 1150-ms delay trials (70-150 Hz amplitude; see fcx3.jitter_check).
If the columns mark the events, the best shift is near 0 in every window; a shift beyond the shuffled maximum, with r
above the shuffled maximum, means the events lie at different times relative to the column in the two groups.
subject epoch window (s) shift 1150 vs 900 (s) r shuffled max |shift| shuffled max r clear
s1 data_pre (0.6, 1.6) -0.396 0.05 0.400 0.18 False
s1 data_encmain (-0.3, 1.0) -0.146 0.05 0.400 0.13 False
s1 data_proc (-0.9, 0.7) 0.290 0.15 0.400 0.18 False
s2 data_pre (0.6, 1.6) 0.020 0.55 0.123 0.62 False
s2 data_encmain (-0.3, 1.0) 0.296 0.28 0.374 0.25 False
s2 data_proc (-0.9, 0.7) 0.229 0.61 0.032 0.60 True
s3 data_pre (0.6, 1.6) -0.030 0.34 0.083 0.40 False
s3 data_encmain (-0.3, 1.0) 0.105 0.26 0.150 0.32 False
s3 data_proc (-0.9, 0.7) 0.214 0.47 0.056 0.45 True
s4 data_pre (0.6, 1.6) 0.009 0.32 0.128 0.39 False
s4 data_encmain (-0.3, 1.0) 0.263 0.65 0.119 0.55 True
s4 data_proc (-0.9, 0.7) 0.256 0.76 0.083 0.73 True
s5 data_pre (0.6, 1.6) -0.300 0.11 0.400 0.17 False
s5 data_encmain (-0.3, 1.0) 0.224 0.29 0.273 0.38 False
s5 data_proc (-0.9, 0.7) 0.276 0.37 0.379 0.47 False
s6 data_pre (0.6, 1.6) -0.376 0.30 0.398 0.38 False
s6 data_encmain (-0.3, 1.0) 0.242 0.49 0.140 0.61 False
s6 data_proc (-0.9, 0.7) 0.352 0.42 0.400 0.52 False
s7 data_pre (0.6, 1.6) 0.383 0.24 0.357 0.30 False
s7 data_encmain (-0.3, 1.0) -0.023 0.24 0.398 0.31 False
s7 data_proc (-0.9, 0.7) -0.016 0.22 0.346 0.30 False
# cue-locked 70-150 Hz amplitude (mean over channels and trials) per delay group, the traces behind the timing contrast above
fig, axes = plt.subplots(len(fcx3.SUBJECTS), 3, figsize=(13, 2.0 * len(fcx3.SUBJECTS)), sharex="col")
for i, sid in enumerate(fcx3.SUBJECTS):
for j, key in enumerate(fcx3.JITTER_WINDOWS):
v = META[sid]["jitter"][key]
ax = axes[i, j]
ax.plot(v["time"], v["trace_900"], color="tab:blue", lw=1, label="900-ms delay")
ax.plot(v["time"], v["trace_1150"], color="tab:orange", lw=1, label="1150-ms delay")
for x in {"data_pre": (), "data_encmain": (), "data_proc": (-0.5, 0.3)}[key]:
ax.axvline(x, color="0.5", lw=0.6, ls=":")
ax.axvspan(*fcx3.JITTER_WINDOWS[key], color="0.92", zorder=0)
if key == "data_proc":
ax.axvspan(*fcx3.PROC_WIN, color="tab:green", alpha=0.08, zorder=0)
ax.set_title(f"{sid} {key}", fontsize=8)
ax.tick_params(labelsize=7)
axes[0, 0].legend(fontsize=7)
for ax in axes[-1]:
ax.set_xlabel("time in the derived epoch (s)", fontsize=8)
fig.suptitle("70-150 Hz amplitude / its mean; grey: window of the contrast; dotted: test cue on and off (data_proc); green: processing window", fontsize=9)
plt.tight_layout()
plt.show()
The test is weak where the 70-150 Hz response is small; the column "clear" marks the windows where
the shift found exceeds every shuffled one and the alignment is better than every shuffled one.
In the traces, S4's response to the stimuli and to the test cue comes about 0.25 s later in the
1150-ms trials, relative to the columns, in the encoding and processing epochs. The shifts of S2
and S3 in the processing epoch (table) are small by eye, and in the other subjects the 70-150 Hz
response is small.
If the processing columns of 1150-ms trials lie about 0.25 s before the events, the processing
window of those trials would hold the end of the cue. The ERP and power tests and the task-induced
PSI are therefore also run on the trials with a 900-ms delay only (configuration methods_900, and
interval processing_900 for PSI), whose windows are not in question. With about half the trials
these tests have less power, so power is also run on a random draw of trials of both delays with
as many trials per condition (methods_half), which separates the loss of trials from the timing.
grid = pd.DataFrame([{"subject": sid, "grids (dims, spacing mm, contacts)": META[sid]["grid"]} for sid in fcx3.SUBJECTS])
print(grid.to_string(index=False))
print("\nNeighbour pairs per reading of the cluster test's 'neighboring electrodes':")
print(pd.DataFrame({sid: RES[sid]["neighbours"] for sid in fcx3.SUBJECTS}).to_string())
subject grids (dims, spacing mm, contacts)
s1 {'LIHA': ((1, 4), '10.0', 4), 'LIHP': ((1, 4), '10.0', 4), 'LLFP': ((1, 8), '10.0', 8), 'LLTA': ((1, 4), '10.0', 4), 'LLTP': ((1, 4), '10.0', 4), 'LMT': ((1, 4), '10.0', 4), 'LOF': ((1, 8), '10.0', 8), 'RIHA': ((1, 4), '10.0', 4), 'RIHP': ((1, 4), '10.0', 4), 'RLFP': ((1, 8), '10.0', 8), 'RLTA': ((1, 4), '10.0', 4), 'RLTP': ((1, 4), '10.0', 4), 'RMT': ((1, 4), '10.0', 4), 'ROF': ((1, 8), '10.0', 8)}
s2 {'CI': ((1, 4), '10.0', 4), 'CS': ((1, 4), '10.0', 4), 'G': ((8, 8), '10.0', 64), 'LLF': ((1, 8), '10.0', 8), 'LLP': ((1, 8), '10.0', 8), 'RFP': ((1, 4), '10.0', 4), 'RMT': ((1, 4), '10.0', 4), 'RSF': ((1, 4), '10.0', 4), 'RSP': ((1, 4), '10.0', 4)}
s3 {'HD_Grid': ((16, 16), '4.0', 256), 'AMV': ((1, 4), '10.0', 4), 'AMV_2': ((1, 5), '10.0', 5)}
s4 {'RLD': ((1, 12), '10.0', 12), 'ROF': ((1, 8), '10.0', 8), 'RAC': ((1, 12), '10.0', 12), 'RC': ((1, 12), '10.0', 12), 'RAD': ((1, 8), '10.0', 8), 'RPC': ((1, 12), '10.0', 12), 'LAC': ((1, 12), '10.0', 12), 'LOF': ((1, 12), '10.0', 12), 'LPC': ((1, 12), '10.0', 12), 'LAD': ((1, 8), '10.0', 8), 'LHD': ((1, 8), '10.0', 8)}
s5 {'PTP': ((8, 8), '10.0', 64), 'LTG': ((6, 8), '10.0', 48), 'OFG': ((4, 5), '10.0', 20), 'PST': ((2, 6), '10.0', 12), 'MST': ((2, 6), '10.0', 12), 'LAM': ((1, 8), '10.0', 8), 'LHH': ((1, 8), '10.0', 8)}
s6 {'FG': ((8, 8), '10.0', 64), 'PT': ((2, 6), '10.0', 12), 'AT': ((2, 4), '10.0', 8), 'OF': ((4, 4), '10.0', 16), 'AC': ((1, 6), '10.0', 6), 'ID': ((1, 10), '10.0', 10)}
s7 {'AL': ((1, 12), '10.0', 12), 'AR': ((1, 12), '10.0', 12), 'BL': ((1, 12), '10.0', 12), 'BR': ((1, 10), '10.0', 10), 'CL': ((1, 12), '10.0', 12), 'CR': ((1, 10), '10.0', 10), 'FOAL': ((1, 5), '10.0', 5), 'FOPL': ((1, 5), '10.0', 5), 'POAL': ((1, 8), '10.0', 8), 'POPL': ((1, 5), '10.0', 5), 'TOL': ((1, 5), '10.0', 5), 'WL': ((1, 5), '10.0', 5)}
Neighbour pairs per reading of the cluster test's 'neighboring electrodes':
s1 s2 s3 s4 s5 s6 s7
adjacent 13 21 56 11 19 8 5
distance 14 41 112 17 48 18 6
none 0 0 0 0 0 0 0
The 'distance' reading places each bipolar channel at the midpoint of its two contacts, taking
contact n as the n-th electrode of the grid named by the label's prefix in the subject's
_MNI_grid.csv (S3's RH1 to RH256 are its 256-contact grid HD_Grid); the files do not say how
contacts are numbered on a grid, so this placement is an assumption, and with the stated 10-mm
spacings 1.5 x spacing takes in diagonal neighbours on a grid.
import re
SCRIPTS = fcx3.script_files()
print("Deposited scripts (analysis_scripts.zip):", list(SCRIPTS))
pat = re.compile(r"statistic|neighbou?r|clusteralpha|correcttail|ft_prepare|montecarlo", re.I)
hits = [(f, i + 1, line.strip()) for f, t in SCRIPTS.items() for i, line in enumerate(t.splitlines()) if pat.search(line)]
print("Lines naming a statistics function, neighbours, a cluster alpha or a tail correction:", hits if hits else "none")
def show(f, *keys):
for i, line in enumerate(SCRIPTS[f].splitlines()):
if any(k in line for k in keys):
print(f" {f}:{i + 1}: {line.strip()}")
print("\nSpectral windows and padding:")
show("power_compute.m", "cfg.pad", "cfg.t_ftimwin", "cfg.toi", "cfgt.latency", "= ft_freqanalysis")
show("psi_compute.m", "cfg.pad", "cfg.toi", "cfgt.latency", "cfg.method =", "= ft_selectdata(cfgt", "subtracterp(")
print("\nERP filter and baseline:")
show("erp_compute.m", "cfg.lpf", "cfg.padding", "cfgb.", "ft_preprocessing(cfg", "nanmean", "ft_timelockanalysis(cfgf, pretrial)")
print("\nPSI and its null:")
show("subfunctions/psianalysis.m", ".*data.fourierspctrm;", "./sqrt(diag(cs(:,:,freqidx(fi)))", "psisub(:,:,freqbini) =",
"pp = squeeze(mean(pp))", "psisub2 = squeeze(mean(psisub2))", "nulldist(:,:,permi) =", "pp(:,:,randperm(nfidx))", "psimtx(:,:,freqbini) =")
print("\nTrial selection of the time-resolved PSI:")
show("subfunctions/subtracterp.m", "cfg.trials =")
Deposited scripts (analysis_scripts.zip): ['power_compute.m', 'erp_compute.m', 'subfunctions/psianalysis.m', 'subfunctions/subtracterp.m', 'subfunctions/zbaseline.m', 'psi_compute.m']
Lines naming a statistics function, neighbours, a cluster alpha or a tail correction: [('subfunctions/psianalysis.m', 1, '% Compute PSI, z-scored using statistical bootstrapping. Code adapted from'), ('subfunctions/zbaseline.m', 1, '% Z-score TFR data on the baseline using statistical bootstrapping.')]
Spectral windows and padding:
power_compute.m:38: cfg.t_ftimwin = 3./cfg.foi; % time window = 3 cycles/frequency
power_compute.m:39: cfg.pad = 7.5; % pad to 7500 ms
power_compute.m:56: cfg.toi = pretrial.time{1}(1):toi_res:pretrial.time{1}(end);
power_compute.m:57: pretrial = ft_freqanalysis(cfg, pretrial);
power_compute.m:59: cfg.toi = encmain.time{1}(1):toi_res:encmain.time{1}(end);
power_compute.m:60: encmain = ft_freqanalysis(cfg, encmain);
power_compute.m:62: cfg.toi = proc.time{1}(1):toi_res:proc.time{1}(end);
power_compute.m:63: proc = ft_freqanalysis(cfg, proc);
power_compute.m:66: cfgt.latency = [0.65 0.85];
power_compute.m:69: cfgt.latency = [0 1.5];
power_compute.m:72: cfgt.latency = [0.3 1.2];
psi_compute.m:34: cfg.pad = 7.5; % enough padding for 3 cycles 2-Hz buffers
psi_compute.m:57: cfgt.latency = [0.6 1.5];
psi_compute.m:59: data = subtracterp(encmain, 1); clear encmain
psi_compute.m:60: cfg.method = 'mtmfft';
psi_compute.m:62: cfgt.latency = [0.3 1.2];
psi_compute.m:64: data = subtracterp(proc, 1);
psi_compute.m:65: cfg.method = 'mtmfft';
psi_compute.m:67: cfgt.latency = [0.3 1.2];
psi_compute.m:69: data = subtracterp(proc, 3);
psi_compute.m:70: cfg.method = 'mtmconvol';
psi_compute.m:72: cfgt.latency = [0.3 1.2];
psi_compute.m:74: [~,data] = subtracterp(proc, 3);
psi_compute.m:75: cfg.method = 'mtmconvol';
psi_compute.m:77: cfgt.latency = [0.3 1.2];
psi_compute.m:79: [~,~,data] = subtracterp(proc, 3); clear proc
psi_compute.m:80: cfg.method = 'mtmconvol';
psi_compute.m:84: data = ft_selectdata(cfgt, data);
psi_compute.m:86: cfg.toi = data.time{1}(1):toi_res:data.time{1}(end);
psi_compute.m:92: data = ft_selectdata(cfgt, data); % select times
ERP filter and baseline:
erp_compute.m:34: cfg.lpfilter = 'yes'; % low-pass filter
erp_compute.m:35: cfg.lpfilttype = 'fir'; % finite impulse response filter
erp_compute.m:36: cfg.lpfreq = 30; % 30 Hz
erp_compute.m:37: cfg.padding = 7.5; % pad to 7500 ms
erp_compute.m:46: cfgb.latency = [0.65 0.85]; % -250 to 50 ms pretrial
erp_compute.m:47: cfgb.avgovertime = 'yes';
erp_compute.m:60: pretrial = ft_preprocessing(cfg, pretrial);
erp_compute.m:61: encmain = ft_preprocessing(cfg, encmain);
erp_compute.m:62: proc = ft_preprocessing(cfg, proc);
erp_compute.m:65: pretrial = ft_timelockanalysis(cfgf, pretrial); % ERP
erp_compute.m:76: repmat(nanmean(pretrial.trial), [size(encmain.trial,1) 1 size(encmain.trial,3)]);
erp_compute.m:78: repmat(nanmean(pretrial.trial), [size(proc.trial,1) 1 size(proc.trial,3)]);
PSI and its null:
subfunctions/psianalysis.m:24: csd(:,e,:,:) = repmat(data.fourierspctrm(:,e,:), [1 nchan 1]).*data.fourierspctrm;
subfunctions/psianalysis.m:39: ppsub(:,:,fi) = cs(:,:,freqidx(fi))./sqrt(diag(cs(:,:,freqidx(fi)))*diag(cs(:,:,freqidx(fi)))');
subfunctions/psianalysis.m:44: psisub(:,:,freqbini) = sum(imag(conj(ppsub(:,:,1:end-1)).*ppsub(:,:,2:end)),3);
subfunctions/psianalysis.m:51: pp = squeeze(mean(pp)); % trial mean
subfunctions/psianalysis.m:52: psisub2 = squeeze(mean(psisub2));
subfunctions/psianalysis.m:57: nulldist(:,:,permi) = sum(imag(conj(pp(:,:,randperm(nfidx))).*...
subfunctions/psianalysis.m:58: pp(:,:,randperm(nfidx))),3);
subfunctions/psianalysis.m:61: psimtx(:,:,freqbini) = (psisub2-mean(nulldist,3))./std(nulldist,[],3);
subfunctions/psianalysis.m:79: csd(:,e,:,:,:) = repmat(data.fourierspctrm(:,e,:,:), [1 nchan 1 1]).*data.fourierspctrm;
subfunctions/psianalysis.m:95: ppsub(:,:,fi) = cs(:,:,freqidx(fi))./sqrt(diag(cs(:,:,freqidx(fi)))*diag(cs(:,:,freqidx(fi)))');
subfunctions/psianalysis.m:100: psisub(:,:,freqbini) = sum(imag(conj(ppsub(:,:,1:end-1)).*ppsub(:,:,2:end)),3);
subfunctions/psianalysis.m:107: pp = squeeze(mean(pp)); % trial mean
subfunctions/psianalysis.m:108: psisub2 = squeeze(mean(psisub2));
subfunctions/psianalysis.m:113: nulldist(:,:,permi) = sum(imag(conj(pp(:,:,randperm(nfidx))).*...
subfunctions/psianalysis.m:114: pp(:,:,randperm(nfidx))),3);
Trial selection of the time-resolved PSI:
subfunctions/subtracterp.m:16: cfg.trials = find(data.trialinfo(:,2)==1);
subfunctions/subtracterp.m:26: cfg.trials = find(data.trialinfo(:,2)==1 & data.trialinfo(:,3)==1);
subfunctions/subtracterp.m:35: cfg.trials = find(data.trialinfo(:,2)==1 & data.trialinfo(:,3)==2);
subfunctions/subtracterp.m:46: cfg.trials = find(data.trialinfo(:,2)==1 & data.trialinfo(:,4)==1);
subfunctions/subtracterp.m:55: cfg.trials = find(data.trialinfo(:,2)==1 & data.trialinfo(:,4)==2);
subfunctions/subtracterp.m:64: cfg.trials = find(data.trialinfo(:,2)==1 & data.trialinfo(:,5)==2);
The deposited scripts settle some details and not others, as printed above. They hold no cluster
test (no FieldTrip statistics call, no neighbour definition, no cluster alpha), so the neighbour
rule and the alpha per tail are open in the paper and in the code alike; every reading is run.
power_compute.m and psi_compute.m compute the time-frequency windows over the whole derived epoch
(cfg.toi from its first to its last sample) and cut the processing window afterwards, so their
long windows take in data around the segment, while the Methods describe the 900-ms segments
"zero-padded to 7,500 ms". Where the Methods and the code differ, the Methods come first: the
zero-padded segment is the main reading here, and the code's whole-epoch windows are a variant.
erp_compute.m low-passes the whole epoch and subtracts the baseline mean over trials, one value per
channel, which cannot change a t-test. psianalysis.m z-scores the mean of per-trial PSI against a
null built from the trial-mean spectrum, a different statistic, and omits the conjugate of the
cross-spectrum; the PSI null used here follows the Methods' wording instead ("shuffled the
frequencies in one signal and re-computed PSI"), and the code's null is shown as a variant.
table1-electrodes¶
The analysed data comprise 192 bipolar virtual electrodes in seven subjects, 4 to 54 (mean 19) in PFC and 2 to 16 (mean 8) in parietal cortex per subject, as listed per subject in Table 1, forming 1129 same-hemisphere PFC-parietal pairs.
Counted from docs/summary_channel_analysis.csv (every listed channel is in the derived epochs, or
loading would have failed), with Table 1 typed from the paper for the comparison.
TABLE1 = {"s1": (21, "L+R", 2, "L+R"), "s2": (24, "L+R", 8, "L+R"), "s3": (54, "R", 14, "R"), "s4": (12, "L+R", 10, "R"),
"s5": (10, "L", 16, "L"), "s6": (8, "L", 4, "L"), "s7": (4, "L", 5, "L")}
rows = []
for sid in fcx3.SUBJECTS:
c = CHAN[CHAN.subject == sid]
hemi = lambda r: "+".join(sorted(c[c.region == r].hemisphere.unique()))
rows.append({"subject": sid, "PFC": int((c.region == "PFC").sum()), "PFC hemi": hemi("PFC"),
"parietal": int((c.region == "parietal").sum()), "parietal hemi": hemi("parietal"),
"Table 1 PFC": TABLE1[sid][0], "T1 PFC hemi": TABLE1[sid][1], "Table 1 parietal": TABLE1[sid][2],
"T1 par hemi": TABLE1[sid][3], "pairs": len(RES[sid]["pairs"])})
t1 = pd.DataFrame(rows)
print(t1.to_string(index=False))
n_el = int(t1.PFC.sum() + t1.parietal.sum())
n_pairs = int(t1.pairs.sum())
print(f"\nanalysed channels {n_el} (paper 192); PFC per subject {t1.PFC.min()}-{t1.PFC.max()} mean {t1.PFC.mean():.2f} (paper 4-54, 19);"
f" parietal {t1.parietal.min()}-{t1.parietal.max()} mean {t1.parietal.mean():.2f} (paper 2-16, 8)")
print(f"same-hemisphere PFC-parietal pairs {n_pairs} (paper 1129); difference {n_pairs - 1129} ({(n_pairs - 1129) / 1129:+.1%});"
f" channels {(n_el - 192) / 192:+.1%}")
mism = t1[(t1.PFC != t1["Table 1 PFC"]) | (t1.parietal != t1["Table 1 parietal"]) | (t1["PFC hemi"] != t1["T1 PFC hemi"]) | (t1["parietal hemi"] != t1["T1 par hemi"])]
print("subjects differing from Table 1:", list(mism.subject))
s4 = t1.set_index("subject").loc["s4"]
print(f"With Table 1's 10 right parietal channels in s4, its pairs would be 6 x 10 = 60, total {n_pairs - s4.pairs + 60}.")
subject PFC PFC hemi parietal parietal hemi Table 1 PFC T1 PFC hemi Table 1 parietal T1 par hemi pairs
s1 21 L+R 2 L+R 21 L+R 2 L+R 21
s2 24 L+R 8 L+R 24 L+R 8 L+R 116
s3 54 R 14 R 54 R 14 R 756
s4 12 L+R 5 R 12 L+R 10 R 30
s5 10 L 16 L 10 L 16 L 160
s6 8 L 4 L 8 L 4 L 32
s7 4 L 5 L 4 L 5 L 20
analysed channels 187 (paper 192); PFC per subject 4-54 mean 19.00 (paper 4-54, 19); parietal 2-16 mean 7.71 (paper 2-16, 8)
same-hemisphere PFC-parietal pairs 1135 (paper 1129); difference 6 (+0.5%); channels -2.6%
subjects differing from Table 1: ['s4']
With Table 1's 10 right parietal channels in s4, its pairs would be 6 x 10 = 60, total 1165.
Result: partially reproduced. The data set's channel list holds 187 analysed channels, not 192: S4 has 5 right parietal channels where Table 1 gives 10; every other subject's counts and hemispheres equal Table 1. PFC counts per subject are 4 to 54 (mean 19.00) and parietal 2 to 16 (mean 7.71), both within tolerance. The list gives 1135 same-hemisphere pairs, 6 more than the paper's 1129 (+0.5%); with Table 1's 10 parietal channels in S4 it would give 1165. The totals differ by no more than 10% (channels -2.6%), the criterion's partial match.
trial-counts¶
After artifact rejection subjects kept on average 96 correct trials, 32 +- 3 (26 to 35) identity, 33 +- 4 (27 to 39) spatial and 31 +- 6 (20 to 39) temporal, and had 17 +- 8 (4 to 25) incorrect trials per subject.
Correct trials kept are those of the derived epochs with accuracy 1 (trialinfo column 2, the
selection of the deposited scripts). The incorrect count is read (a) of all 120 trials, from the
per-subject accuracy of docs/summary_file.csv (over all 120 trials, by the data description;
40 trials per condition, Methods), and (b) of the trials kept.
rows = []
for sid in fcx3.SUBJECTS:
R = RES[sid]
s = SUMMARY[SUMMARY.subject.str.lower() == sid].iloc[0]
corr_all = int(round(40 * (s.acc_identity + s.acc_spatial + s.acc_temporal)))
rows.append({"subject": sid, "trials kept": R["n_trials"], "correct kept": R["n_correct"],
"identity": R["n_correct_by_cond"][1], "spatial": R["n_correct_by_cond"][2], "temporal": R["n_correct_by_cond"][3],
"incorrect (a) of 120": 120 - corr_all, "incorrect (b) kept": R["n_incorrect"], "correct of 120": corr_all})
tc = pd.DataFrame(rows)
print(tc.to_string(index=False))
summ = tc.drop(columns="subject").agg(["mean", "std", "min", "max"]).round(2)
print("\n", summ.to_string())
exp = {"correct kept": (96, None), "identity": (32, (26, 35)), "spatial": (33, (27, 39)), "temporal": (31, (20, 39)),
"incorrect (a) of 120": (17, (4, 25)), "incorrect (b) kept": (17, (4, 25))}
for k, (v, rg) in exp.items():
m = tc[k].mean()
within = abs(m - v) <= 0.1 * v
rg_ok = None if rg is None else (tc[k].min() >= rg[0] - 0.1 * rg[0] and tc[k].max() <= rg[1] + 0.1 * rg[1])
print(f"{k}: mean {m:.2f} vs {v} (within 10%: {within}); range {tc[k].min()}-{tc[k].max()} vs {rg} widened 10%: {rg_ok}")
print("\nCorrect trials kept equal all correct trials of 120 in:", list(tc.subject[tc["correct kept"] == tc["correct of 120"]]))
subject trials kept correct kept identity spatial temporal incorrect (a) of 120 incorrect (b) kept correct of 120
s1 120 102 33 36 33 18 18 102
s2 120 95 35 35 25 25 25 95
s3 120 103 34 33 36 17 17 103
s4 120 112 34 39 39 8 8 112
s5 120 95 33 32 30 25 25 95
s6 101 77 30 27 20 29 24 91
s7 90 86 26 28 32 6 4 114
trials kept correct kept identity spatial temporal incorrect (a) of 120 incorrect (b) kept correct of 120
mean 113.00 95.71 32.14 32.86 30.71 18.29 17.29 101.71
std 12.37 11.57 3.13 4.30 6.47 8.79 8.44 8.79
min 90.00 77.00 26.00 27.00 20.00 6.00 4.00 91.00
max 120.00 112.00 35.00 39.00 39.00 29.00 25.00 114.00
correct kept: mean 95.71 vs 96 (within 10%: True); range 77-112 vs None widened 10%: None
identity: mean 32.14 vs 32 (within 10%: True); range 26-35 vs (26, 35) widened 10%: True
spatial: mean 32.86 vs 33 (within 10%: True); range 27-39 vs (27, 39) widened 10%: True
temporal: mean 30.71 vs 31 (within 10%: True); range 20-39 vs (20, 39) widened 10%: True
incorrect (a) of 120: mean 18.29 vs 17 (within 10%: True); range 6-29 vs (4, 25) widened 10%: False
incorrect (b) kept: mean 17.29 vs 17 (within 10%: True); range 4-25 vs (4, 25) widened 10%: True
Correct trials kept equal all correct trials of 120 in: ['s1', 's2', 's3', 's4', 's5']
Result: reproduced. Correct trials kept average 95.71 per subject (paper 96); identity 32.14 +- 3.13 (26 to 35), spatial 32.86 +- 4.30 (27 to 39), temporal 30.71 +- 6.47 (20 to 39), the paper's means and ranges. Incorrect trials kept (reading (b)) average 17.29 +- 8.44 (4 to 25), the paper's 17 +- 8 (4 to 25); incorrect trials of all 120 (reading (a)) average 18.29 (6 to 29), outside the widened range. In S1 to S5 every correct trial of the 120 was kept.
fig1b-accuracy¶
All subjects were proficient at the task (accuracy 0.63 to 0.98, chance 0.5), and accuracy did not differ between conditions.
Accuracy per subject and condition is in docs/summary_file.csv, over all 120 trials (data
description), which is reading (a) of B1's "all trials" question; the trial tables of S6 and S7
list only kept trials, so single-trial accuracy over all 120 is rebuilt as counts out of 40 per
condition (Methods: "120 trials divided evenly"). The logit mixed model (condition fixed, subject
random intercept) is fitted by maximum likelihood with Gauss-Hermite quadrature
(fcx3.logit_mixed; the paper names the model, not the software), with condition as one
numeric term (the single degree of freedom of the paper's F(1,19) for RT) and, as a variant, as
two dummy terms. Reading (b) of B1 (accuracy over kept trials) is shown as a variant.
acc = SUMMARY[["subject", "acc_identity", "acc_spatial", "acc_temporal"]].copy()
acc["overall"] = acc[["acc_identity", "acc_spatial", "acc_temporal"]].mean(axis=1)
print(acc.round(3).to_string(index=False))
lo, hi = 0.63, 0.98
for name, vals in [("(a) per subject over conditions", acc.overall.values),
("(b) per subject and condition", acc[["acc_identity", "acc_spatial", "acc_temporal"]].values.ravel())]:
print(f"{name}: min {vals.min():.3f} (expected 0.63 +- 0.063: {abs(vals.min() - lo) <= 0.063}), max {vals.max():.3f} "
f"(expected 0.98 +- 0.098: {abs(vals.max() - hi) <= 0.098}); all inside [{lo - 0.063:.3f}, {hi + 0.098:.3f}]: "
f"{bool(((vals >= lo - 0.063) & (vals <= hi + 0.098)).all())}")
long = acc.melt(id_vars="subject", value_vars=["acc_identity", "acc_spatial", "acc_temporal"], var_name="cond", value_name="acc")
long["cond_code"] = long.cond.map({"acc_identity": 1, "acc_spatial": 2, "acc_temporal": 3})
long["k"] = np.round(long.acc * 40).astype(int)
long["n"] = 40
beta, se, ll1 = fcx3.logit_mixed(long.k.values, long.n.values, long.cond_code.values[:, None].astype(float), long.subject.values)
_, _, ll0 = fcx3.logit_mixed(long.k.values, long.n.values, np.zeros((len(long), 0)), long.subject.values)
z = beta[1] / se[1]
print(f"\n(a) all 120 trials, condition as one term: slope {beta[1]:.3f} (SE {se[1]:.3f}), Wald z {z:.2f}, p {2 * stats.norm.sf(abs(z)):.3f};"
f" likelihood ratio chi2(1) {2 * (ll1 - ll0):.2f}, p {stats.chi2.sf(2 * (ll1 - ll0), 1):.3f}")
D = np.column_stack([(long.cond_code == 2).astype(float), (long.cond_code == 3).astype(float)])
_, _, ll2 = fcx3.logit_mixed(long.k.values, long.n.values, D, long.subject.values)
print(f"(a) condition as two dummy terms: likelihood ratio chi2(2) {2 * (ll2 - ll0):.2f}, p {stats.chi2.sf(2 * (ll2 - ll0), 2):.3f}")
kept = pd.concat([META[s]["trials"].assign(subject=s) for s in fcx3.SUBJECTS])
kk = kept.groupby(["subject", "condition"]).correct.agg(["sum", "count"]).reset_index()
b2, se2, l1 = fcx3.logit_mixed(kk["sum"].values, kk["count"].values, kk.condition.values[:, None].astype(float), kk.subject.values)
_, _, l0 = fcx3.logit_mixed(kk["sum"].values, kk["count"].values, np.zeros((len(kk), 0)), kk.subject.values)
print(f"(b) kept trials, condition as one term: slope {b2[1]:.3f}, likelihood ratio chi2(1) {2 * (l1 - l0):.2f}, p {stats.chi2.sf(2 * (l1 - l0), 1):.3f}")
print("accuracy over kept trials per subject:", kept.groupby("subject").correct.mean().round(3).to_dict())
subject acc_identity acc_spatial acc_temporal overall
S1 0.825 0.900 0.825 0.850
S2 0.875 0.875 0.625 0.792
S3 0.850 0.825 0.900 0.858
S4 0.850 0.975 0.975 0.933
S5 0.825 0.800 0.750 0.792
S6 0.825 0.775 0.675 0.758
S7 0.900 0.975 0.975 0.950
(a) per subject over conditions: min 0.758 (expected 0.63 +- 0.063: False), max 0.950 (expected 0.98 +- 0.098: True); all inside [0.567, 1.078]: True
(b) per subject and condition: min 0.625 (expected 0.63 +- 0.063: True), max 0.975 (expected 0.98 +- 0.098: True); all inside [0.567, 1.078]: True
(a) all 120 trials, condition as one term: slope -0.128 (SE 0.120), Wald z -1.07, p 0.283; likelihood ratio chi2(1) 1.15, p 0.283
(a) condition as two dummy terms: likelihood ratio chi2(2) 3.66, p 0.160
(b) kept trials, condition as one term: slope -0.134, likelihood ratio chi2(1) 1.18, p 0.276
accuracy over kept trials per subject: {'s1': 0.85, 's2': 0.792, 's3': 0.858, 's4': 0.933, 's5': 0.792, 's6': 0.762, 's7': 0.956}
Result: reproduced. Under reading (b), per subject and condition, accuracy runs from 0.625 to 0.975, the paper's 0.63 to 0.98; under reading (a), per subject, it runs from 0.758 to 0.950, and the lowest value is outside 0.63 +- 0.063. The logit mixed model on all 120 trials finds no effect of condition (likelihood ratio p = 0.283 with condition as one term, p = 0.160 as two terms; kept trials p = 0.276), so the absence holds by the criterion (p > 0.05). The paper reports p > 0.50; the p obtained here is lower than that.
fig1b-rt-identity-slower¶
Response times differed by condition, being longer on identity than on spatial and temporal trials, with no difference between spatial and temporal trials.
Reading (a) of B1: one mean correct-trial RT per subject and condition (docs/summary_file.csv,
"calculated on all correct trials"), a linear mixed model with condition as one numeric term and a
subject random intercept (REML, statsmodels), F = t^2 on the residual degrees of freedom (21 - 2 =
19; pairs 14 - 2 = 12), as fitlme reports. Reading (b): single correct trials; only the kept trials
are in the trial tables (all correct trials in S1 to S5), so (b) is on those. Cohen's d is given as
the mean paired difference over its SD across subjects, one common definition (the paper does not
say which it used; d is reported, not judged).
import statsmodels.formula.api as smf
rt = SUMMARY.melt(id_vars="subject", value_vars=["rt_identity", "rt_spatial", "rt_temporal"], var_name="cond", value_name="rt")
rt["c"] = rt.cond.map({"rt_identity": 1, "rt_spatial": 2, "rt_temporal": 3})
print(SUMMARY[["subject", "rt_identity", "rt_spatial", "rt_temporal"]].round(0).to_string(index=False))
def lme_f(df, y, groups):
r = smf.mixedlm(f"{y} ~ c", df, groups=df[groups]).fit(reml=True)
t = r.tvalues["c"]
return r.params["c"], t ** 2, stats.f.sf(t ** 2, 1, len(df) - 2), len(df) - 2
def report(df, y, groups, label):
out = {}
b, F, p, dfr = lme_f(df, y, groups)
out["all"] = (b, F, p)
print(f"{label} omnibus: slope {b:.1f} ms per condition step, F(1,{dfr}) = {F:.2f}, p = {p:.4f}")
for a, bb, name in [(1, 2, "identity vs spatial"), (1, 3, "identity vs temporal"), (2, 3, "spatial vs temporal")]:
sub = df[df.c.isin([a, bb])].copy()
b2, F2, p2, dfr2 = lme_f(sub, y, groups)
out[name] = (b2, F2, p2)
print(f" {name}: difference {b2 * (bb - a):.1f} ms ({'first longer' if b2 < 0 else 'second longer'}), F(1,{dfr2}) = {F2:.2f}, p = {p2:.4f}")
return out
rt_a = report(rt, "rt", "subject", "(a) subject-condition means")
w = SUMMARY.set_index("subject")
for a, b in [("rt_identity", "rt_spatial"), ("rt_identity", "rt_temporal"), ("rt_spatial", "rt_temporal")]:
d = w[a] - w[b]
print(f" d ({a[3:]} - {b[3:]}): {d.mean() / d.std(ddof=1):.2f}; identity longer in {int((d > 0).sum())}/7 subjects")
tr = kept[kept.correct == 1].rename(columns={"condition": "c"})
rt_b = report(tr, "rt", "subject", "(b) single kept correct trials")
subject rt_identity rt_spatial rt_temporal
S1 1942.0 1129.0 1442.0
S2 2462.0 1291.0 1473.0
S3 888.0 868.0 798.0
S4 1110.0 947.0 985.0
S5 3175.0 2535.0 3142.0
S6 2965.0 2611.0 2440.0
S7 1469.0 1037.0 989.0
(a) subject-condition means omnibus: slope -195.8 ms per condition step, F(1,19) = 6.04, p = 0.0238
identity vs spatial: difference -513.1 ms (first longer), F(1,12) = 11.81, p = 0.0049
identity vs temporal: difference -391.5 ms (first longer), F(1,12) = 9.39, p = 0.0098
spatial vs temporal: difference 121.6 ms (second longer), F(1,12) = 1.43, p = 0.2544
d (identity - spatial): 1.30; identity longer in 7/7 subjects
d (identity - temporal): 1.16; identity longer in 7/7 subjects
d (spatial - temporal): -0.45; identity longer in 3/7 subjects
(b) single kept correct trials omnibus: slope -197.5 ms per condition step, F(1,668) = 5.58, p = 0.0184
identity vs spatial: difference -365.3 ms (first longer), F(1,453) = 4.38, p = 0.0369
identity vs temporal: difference -386.6 ms (first longer), F(1,438) = 8.21, p = 0.0044
spatial vs temporal: difference -36.0 ms (first longer), F(1,443) = 0.04, p = 0.8442
Result: reproduced. On subject-condition means (reading (a)), condition affects RT (F(1,19) = 6.04, p = 0.024), identity RT is longer than spatial (by 513 ms, F(1,12) = 11.81, p = 0.005) and temporal (by 392 ms, F(1,12) = 9.39, p = 0.010), and spatial and temporal do not differ (p = 0.254). Identity RT is the longest in all 7 subjects. The F values are below the paper's bounds (F > 6.50, > 13.78, > 10.95), and the d values (1.30, 1.16, by the definition used here) below its 2.14 and 1.91. Single kept trials (reading (b)) give the same pattern (p = 0.018, 0.037, 0.004 and 0.844).
erp-no-condition-difference¶
ERPs over the processing interval did not differ between identity and spatial or temporal trials in any subject.
Main reading, per the claim's criterion and the Methods (Event-Related Potentials, paragraph 1): the 200-ms pretrial baseline and 900-ms processing segments are cut, each zero padded to 7.5 s and low-passed at 30 Hz (FIR), and the baseline is the pretrial temporal mean averaged over trials, as erp_compute.m computes it (one value per channel, which cannot change a t-test). Variants: each trial corrected on its own pretrial mean (the Methods' "post-cue processing - pretrial mean" allows it); the Results' "1-30 Hz bandpass" in place of the low-pass; the whole derived epoch filtered before the windows are cut (erp_compute.m); the main reading on the 900-ms-delay trials only (Data check). Each is tested per subject by the cluster test of S2 over channels and time, identity against spatial and against temporal, 1000 shuffles. Readings of the neighbours: adjacent, distance, none; readings of the threshold: a cluster's p below 0.05 per tail (the Methods' "fewer than 5% of randomizations yielded a larger effect", and FieldTrip's behaviour when cfg.alpha = 0.05 and the tails are not corrected), or below 0.025. The deposited scripts hold no cluster test, so neither is settled by the code. The smallest cluster p per subject and contrast is printed for each. With 1000 shuffles a cluster p near 0.04 has a Monte Carlo standard error of about 0.006.
ERP_LABEL = {"methods": "segments padded, 30-Hz low-pass, baseline mean over trials (main)",
"per_trial_baseline": "as main, per-trial baseline", "bandpass": "as main, 1-30 Hz band-pass",
"code": "whole epoch filtered (erp_compute.m)", "methods_900": "as main, 900-ms-delay trials only"}
rows = []
for sid in fcx3.SUBJECTS:
for config, byc in RES[sid]["erp"].items():
for con, res in byc.items():
for nb, v in res.items():
pmin = min([p for _, p in v["pos"]] + [p for _, p in v["neg"]] + [1.0])
rows.append({"config": config, "subject": sid, "contrast": con, "neighbours": nb, "min cluster p": pmin})
erp = pd.DataFrame(rows)
ERP_COUNTS = []
for config in fcx3.ERP_CONFIGS:
print(f"==== {config}: {ERP_LABEL[config]}")
e = erp[erp.config == config]
print(e.pivot_table(index=["subject", "contrast"], columns="neighbours", values="min cluster p").round(3).to_string())
for nb in fcx3.NB_READINGS:
en = e[e.neighbours == nb]
r = {"config": config, "neighbours": nb, "p < 0.05": int((en["min cluster p"] < 0.05).sum()),
"p < 0.025": int((en["min cluster p"] < 0.025).sum()), "p <= 0.10": int((en["min cluster p"] <= 0.10).sum()),
"smallest p": round(en["min cluster p"].min(), 3)}
ERP_COUNTS.append(r)
ERP_COUNTS = pd.DataFrame(ERP_COUNTS)
print("\nSubject-contrasts (of 14) with a cluster at each threshold (paper: none, all p > 0.10):")
print(ERP_COUNTS.to_string(index=False))
print("\nCorrect trials with a 900-ms delay, per condition:", {sid: RES[sid]["n_correct_900_by_cond"] for sid in fcx3.SUBJECTS})
==== methods: segments padded, 30-Hz low-pass, baseline mean over trials (main)
neighbours adjacent distance none
subject contrast
s1 spatial 0.097 0.122 0.319
temporal 0.401 0.430 0.387
s2 spatial 0.400 0.486 0.376
temporal 0.041 0.088 0.024
s3 spatial 0.851 0.675 0.842
temporal 0.240 0.448 0.240
s4 spatial 0.197 0.208 0.121
temporal 0.239 0.250 0.143
s5 spatial 0.239 0.014 0.258
temporal 0.103 0.234 0.076
s6 spatial 0.336 0.296 0.204
temporal 0.185 0.208 0.093
s7 spatial 0.188 0.188 0.113
temporal 0.151 0.151 0.055
==== per_trial_baseline: as main, per-trial baseline
neighbours adjacent distance none
subject contrast
s1 spatial 0.107 0.130 0.173
temporal 0.114 0.140 0.109
s2 spatial 0.427 0.516 0.417
temporal 0.060 0.105 0.050
s3 spatial 0.808 0.779 0.615
temporal 0.198 0.325 0.029
s4 spatial 0.218 0.230 0.144
temporal 0.173 0.188 0.124
s5 spatial 0.030 0.021 0.223
temporal 0.089 0.173 0.070
s6 spatial 0.347 0.365 0.268
temporal 0.300 0.333 0.233
s7 spatial 0.475 0.405 0.416
temporal 0.066 0.067 0.023
==== bandpass: as main, 1-30 Hz band-pass
neighbours adjacent distance none
subject contrast
s1 spatial 0.297 0.326 0.286
temporal 0.355 0.394 0.344
s2 spatial 0.574 0.683 0.559
temporal 0.468 0.566 0.442
s3 spatial 0.598 0.235 0.892
temporal 0.176 0.618 0.420
s4 spatial 0.227 0.243 0.147
temporal 0.238 0.250 0.154
s5 spatial 0.144 0.032 0.107
temporal 0.097 0.223 0.077
s6 spatial 0.216 0.236 0.420
temporal 0.282 0.306 0.157
s7 spatial 0.420 0.422 0.320
temporal 0.085 0.086 0.320
==== code: whole epoch filtered (erp_compute.m)
neighbours adjacent distance none
subject contrast
s1 spatial 0.109 0.129 0.353
temporal 0.407 0.446 0.392
s2 spatial 0.378 0.490 0.360
temporal 0.031 0.073 0.020
s3 spatial 0.848 0.690 0.863
temporal 0.286 0.463 0.269
s4 spatial 0.215 0.229 0.132
temporal 0.206 0.216 0.121
s5 spatial 0.219 0.020 0.245
temporal 0.079 0.215 0.062
s6 spatial 0.331 0.293 0.208
temporal 0.174 0.202 0.083
s7 spatial 0.176 0.180 0.102
temporal 0.133 0.134 0.056
==== methods_900: as main, 900-ms-delay trials only
neighbours adjacent distance none
subject contrast
s1 spatial 0.402 0.433 0.493
temporal 0.315 0.354 0.306
s2 spatial 0.541 0.176 0.520
temporal 0.070 0.067 0.053
s3 spatial 0.086 0.253 0.289
temporal 0.080 0.419 0.280
s4 spatial 0.567 0.578 0.455
temporal 0.198 0.207 0.109
s5 spatial 0.670 0.539 0.644
temporal 0.023 0.122 0.059
s6 spatial 0.802 0.813 0.727
temporal 0.332 0.357 0.214
s7 spatial 0.598 0.599 0.499
temporal 0.434 0.435 0.522
Subject-contrasts (of 14) with a cluster at each threshold (paper: none, all p > 0.10):
config neighbours p < 0.05 p < 0.025 p <= 0.10 smallest p
methods adjacent 1 0 2 0.041
methods distance 1 1 2 0.014
methods none 1 1 4 0.024
per_trial_baseline adjacent 1 0 4 0.030
per_trial_baseline distance 1 1 2 0.021
per_trial_baseline none 2 1 4 0.023
bandpass adjacent 0 0 2 0.085
bandpass distance 1 0 2 0.032
bandpass none 0 0 1 0.077
code adjacent 1 0 2 0.031
code distance 1 1 2 0.020
code none 1 1 4 0.020
methods_900 adjacent 1 1 4 0.023
methods_900 distance 0 0 1 0.067
methods_900 none 0 0 2 0.053
Correct trials with a 900-ms delay, per condition: {'s1': {1: 15, 2: 17, 3: 19}, 's2': {1: 20, 2: 16, 3: 11}, 's3': {1: 14, 2: 17, 3: 18}, 's4': {1: 15, 2: 15, 3: 24}, 's5': {1: 15, 2: 13, 3: 18}, 's6': {1: 8, 2: 19, 3: 11}, 's7': {1: 16, 2: 12, 3: 14}}
Result: not reproduced, resting on an assumption. Under the main reading with neighbours adjacent by contact number and clusters judged at 0.05 per tail, S2 has a significant cluster for identity against temporal (p = 0.041); no other subject-contrast is below 0.05, and 2 of 14 have p <= 0.10 (the paper reports all p > 0.10). The outcome depends on the readings: at 0.025 per tail the adjacent reading finds no significant cluster (reproduced), while the distance reading (S5, p = 0.014) and the reading without spatial clustering (S2, p = 0.024) find one at either threshold. Among the variants, the 1-30 Hz band-pass gives no cluster below 0.05 with adjacent neighbours (smallest p 0.085); the per-trial baseline gives one (S5 identity against spatial, p = 0.030); filtering the whole epoch gives S2 p = 0.031; the 900-ms-delay trials alone give one (S5 identity against temporal, p = 0.023). Under the adopted reading the deciding p (0.041) is close to 0.05, so a different Monte Carlo draw could move it to either side; the distance reading's p = 0.014 is not close to the threshold.
fig2-spatial-power and fig3-temporal-power¶
In the identity against spatial contrast of processing-interval power, 5 of 7 subjects showed spatial > identity effects (54 +- 22% of electrodes per subject) and 2 of 7 showed identity > spatial effects (36 +- 12%).
In the identity against temporal contrast of processing-interval power, 4 of 7 subjects showed temporal > identity effects (68 +- 30% of electrodes per subject) and 2 of 7 showed identity > temporal effects (37 +- 10%).
Power with 3-cycle Hanning windows, 2 to 40 Hz, 10-ms steps over the 900-ms processing segment. Main reading: the segment alone, embedded in zeros, every window computed (Methods, Spectral Decomposition, "Data segments were zero-padded to 7,500 ms"; S1 reading (a)). Variant: the windows computed on the whole derived epoch and the processing window cut afterwards, as power_compute.m does (its lines are printed in the Data check), so that windows longer than the segment (below about 3.3 Hz) take in the cue and the response period. A further variant uses the main reading on the 900-ms-delay trials only. Power is z-scored on the bootstrapped pretrial baseline of all correct trials (zbaseline.m; r = all correct trials, settling S1's open r), which cannot change the t-tests. The cluster test of S2 over channel, frequency and time, 1000 shuffles. An electrode shows an effect of a sign when any of its points lies in a significant cluster of that sign (S2 reading (a)); reading (b) assigns an electrode in both to the sign with the larger summed t. Every combination of spectra, neighbour reading, threshold and assignment is shown, and the per-subject percentages under each reading.
def power_effects(contrast, nb, alpha=0.05, assign="a", config="methods"):
out = []
for sid in fcx3.SUBJECTS:
cl = RES[sid]["power"][config][contrast]["clusters"][nb]
n = len(RES[sid]["labels"])
ident, other = np.zeros(n, bool), np.zeros(n, bool)
ts_i, ts_o = np.zeros(n), np.zeros(n)
for c in cl["pos"]: # positive t: identity > other
if c["p"] < alpha:
ident |= c["elec_mask"]
ts_i += c["tsum_by_elec"]
for c in cl["neg"]:
if c["p"] < alpha:
other |= c["elec_mask"]
ts_o += -c["tsum_by_elec"]
if assign == "b":
both = ident & other
ident = ident & ~(both & (ts_o >= ts_i))
other = other & ~(both & (ts_i > ts_o))
out.append({"subject": sid, "n": n, "other>identity": int(other.sum()), "identity>other": int(ident.sum()),
"p other>identity": cl["neg_minp"], "p identity>other": cl["pos_minp"]})
return pd.DataFrame(out)
POWER_LABEL = {"methods": "segment zero-padded (main)", "code": "whole-epoch windows (power_compute.m)",
"methods_900": "segment zero-padded, 900-ms-delay trials only",
"methods_half": "segment zero-padded, random trials of both delays, as many per condition as methods_900 (control)"}
EXPECTED = {"spatial": (5, 2, 54, 36), "temporal": (4, 2, 68, 37)}
POWER_SUMMARY = []
PER_SUBJECT = {}
for config in fcx3.POWER_CONFIGS:
for contrast in ["spatial", "temporal"]:
for nb in fcx3.NB_READINGS:
for alpha in (0.05, 0.025):
for assign in ("a", "b"):
e = power_effects(contrast, nb, alpha, assign, config)
po = 100 * e["other>identity"] / e.n
pi = 100 * e["identity>other"] / e.n
PER_SUBJECT[(config, contrast, nb, alpha, assign)] = [f"{a:.0f}/{b:.0f}" for a, b in zip(po, pi)]
so, si = po[po > 0], pi[pi > 0]
ex = EXPECTED[contrast]
row = {"config": config, "contrast": contrast, "neighbours": nb, "alpha per tail": alpha, "assign": assign,
"subjects other>id": len(so), "subjects id>other": len(si),
"% other>id": f"{so.mean():.1f} +- {so.std(ddof=1):.1f}" if len(so) > 1 else (f"{so.mean():.1f}" if len(so) else "-"),
"% id>other": f"{si.mean():.1f} +- {si.std(ddof=1):.1f}" if len(si) > 1 else (f"{si.mean():.1f}" if len(si) else "-"),
"subjects other>id (list)": list(e.subject[po > 0]), "subjects id>other (list)": list(e.subject[pi > 0])}
row["counts match"] = len(so) == ex[0] and len(si) == ex[1]
row["% match"] = (len(so) > 0 and len(si) > 0 and abs(so.mean() - ex[2]) <= 0.1 * ex[2]
and abs(si.mean() - ex[3]) <= 0.1 * ex[3])
row["counts within 1"] = abs(len(so) - ex[0]) <= 1 and abs(len(si) - ex[1]) <= 1
POWER_SUMMARY.append(row)
POWER_SUMMARY = pd.DataFrame(POWER_SUMMARY)
for config in fcx3.POWER_CONFIGS:
print(f"==== {config}: {POWER_LABEL[config]}")
print(POWER_SUMMARY[POWER_SUMMARY.config == config].drop(columns=["config", "subjects other>id (list)", "subjects id>other (list)"]).to_string(index=False))
print("\nSubjects per effect, main spectra, 0.05 per tail, assignment (a):")
print(POWER_SUMMARY[(POWER_SUMMARY.config == "methods") & (POWER_SUMMARY["alpha per tail"] == 0.05) & (POWER_SUMMARY["assign"] == "a")][
["contrast", "neighbours", "subjects other>id (list)", "subjects id>other (list)"]].to_string(index=False))
print("\nTrials of the control (methods_half) by delay:", {sid: RES[sid]["n_correct_half_jitter"] for sid in fcx3.SUBJECTS})
print("Subjects per effect, 0.05 per tail, assignment (a): 900-ms-delay trials against the random-trial control")
print(POWER_SUMMARY[POWER_SUMMARY.config.isin(["methods_900", "methods_half"]) & (POWER_SUMMARY["alpha per tail"] == 0.05) & (POWER_SUMMARY["assign"] == "a")][
["config", "contrast", "neighbours", "subjects other>id (list)", "subjects id>other (list)"]].to_string(index=False))
==== methods: segment zero-padded (main)
contrast neighbours alpha per tail assign subjects other>id subjects id>other % other>id % id>other counts match % match counts within 1
spatial adjacent 0.050 a 5 1 37.7 +- 21.1 11.8 False False True
spatial adjacent 0.050 b 5 1 37.7 +- 21.1 11.8 False False True
spatial adjacent 0.025 a 5 0 33.8 +- 19.1 - False False False
spatial adjacent 0.025 b 5 0 33.8 +- 19.1 - False False False
spatial distance 0.050 a 5 1 48.2 +- 25.1 23.5 False False True
spatial distance 0.050 b 5 1 48.2 +- 25.1 11.8 False False True
spatial distance 0.025 a 5 1 48.2 +- 25.1 23.5 False False True
spatial distance 0.025 b 5 1 48.2 +- 25.1 11.8 False False True
spatial none 0.050 a 5 1 16.5 +- 7.8 5.9 False False True
spatial none 0.050 b 5 1 16.5 +- 7.8 5.9 False False True
spatial none 0.025 a 5 1 11.1 +- 6.3 5.9 False False True
spatial none 0.025 b 5 1 11.1 +- 6.3 5.9 False False True
temporal adjacent 0.050 a 5 2 37.4 +- 20.5 21.0 +- 17.4 False False True
temporal adjacent 0.050 b 4 2 41.2 +- 21.6 21.0 +- 17.4 True False True
temporal adjacent 0.025 a 5 2 34.8 +- 16.0 21.0 +- 17.4 False False True
temporal adjacent 0.025 b 4 2 38.0 +- 16.6 21.0 +- 17.4 True False True
temporal distance 0.050 a 6 2 49.7 +- 32.3 21.0 +- 17.4 False False False
temporal distance 0.050 b 5 2 55.2 +- 32.8 21.0 +- 17.4 False False True
temporal distance 0.025 a 6 2 47.8 +- 30.9 21.0 +- 17.4 False False False
temporal distance 0.025 b 5 2 52.9 +- 31.6 21.0 +- 17.4 False False True
temporal none 0.050 a 5 3 11.0 +- 5.8 10.8 +- 9.9 False False True
temporal none 0.050 b 5 3 11.0 +- 5.8 10.8 +- 9.9 False False True
temporal none 0.025 a 4 2 9.2 +- 1.8 13.3 +- 12.6 True False True
temporal none 0.025 b 4 2 9.2 +- 1.8 13.3 +- 12.6 True False True
==== code: whole-epoch windows (power_compute.m)
contrast neighbours alpha per tail assign subjects other>id subjects id>other % other>id % id>other counts match % match counts within 1
spatial adjacent 0.050 a 5 2 39.7 +- 15.0 22.5 +- 15.3 True False True
spatial adjacent 0.050 b 5 2 39.7 +- 15.0 22.5 +- 15.3 True False True
spatial adjacent 0.025 a 5 2 33.8 +- 19.1 22.5 +- 15.3 True False True
spatial adjacent 0.025 b 5 2 33.8 +- 19.1 22.5 +- 15.3 True False True
spatial distance 0.050 a 5 2 52.0 +- 23.3 28.4 +- 6.9 True False True
spatial distance 0.050 b 5 2 52.0 +- 23.3 22.5 +- 15.3 True False True
spatial distance 0.025 a 5 2 49.7 +- 27.2 28.4 +- 6.9 True False True
spatial distance 0.025 b 5 2 49.7 +- 27.2 22.5 +- 15.3 True False True
spatial none 0.050 a 5 1 17.6 +- 6.2 5.9 False False True
spatial none 0.050 b 5 1 17.6 +- 6.2 5.9 False False True
spatial none 0.025 a 5 1 13.8 +- 8.3 5.9 False False True
spatial none 0.025 b 5 1 13.8 +- 8.3 5.9 False False True
temporal adjacent 0.050 a 5 3 40.2 +- 19.3 17.4 +- 14.2 False False True
temporal adjacent 0.050 b 4 3 40.5 +- 23.7 17.4 +- 14.2 False False True
temporal adjacent 0.025 a 5 2 37.6 +- 15.0 23.2 +- 14.3 False False True
temporal adjacent 0.025 b 4 2 38.7 +- 17.1 23.2 +- 14.3 True False True
temporal distance 0.050 a 6 2 51.8 +- 31.1 23.2 +- 14.3 False False False
temporal distance 0.050 b 5 2 55.5 +- 33.2 23.2 +- 14.3 False False True
temporal distance 0.025 a 6 2 49.9 +- 29.8 23.2 +- 14.3 False False False
temporal distance 0.025 b 5 2 53.2 +- 32.1 23.2 +- 14.3 False False True
temporal none 0.050 a 6 3 11.0 +- 5.2 14.5 +- 16.3 False False False
temporal none 0.050 b 5 3 11.0 +- 5.8 14.5 +- 16.3 False False True
temporal none 0.025 a 5 3 9.5 +- 1.8 10.8 +- 9.9 False False True
temporal none 0.025 b 4 3 9.2 +- 1.8 10.8 +- 9.9 False False True
==== methods_900: segment zero-padded, 900-ms-delay trials only
contrast neighbours alpha per tail assign subjects other>id subjects id>other % other>id % id>other counts match % match counts within 1
spatial adjacent 0.050 a 2 0 14.2 +- 6.9 - False False False
spatial adjacent 0.050 b 2 0 14.2 +- 6.9 - False False False
spatial adjacent 0.025 a 2 0 9.8 +- 0.6 - False False False
spatial adjacent 0.025 b 2 0 9.8 +- 0.6 - False False False
spatial distance 0.050 a 3 0 46.2 +- 13.9 - False False False
spatial distance 0.050 b 3 0 46.2 +- 13.9 - False False False
spatial distance 0.025 a 2 0 52.1 +- 13.4 - False False False
spatial distance 0.025 b 2 0 52.1 +- 13.4 - False False False
spatial none 0.050 a 3 0 4.3 +- 1.7 - False False False
spatial none 0.050 b 3 0 4.3 +- 1.7 - False False False
spatial none 0.025 a 2 0 3.0 +- 0.1 - False False False
spatial none 0.025 b 2 0 3.0 +- 0.1 - False False False
temporal adjacent 0.050 a 2 1 36.1 +- 19.6 13.0 False False False
temporal adjacent 0.050 b 2 1 36.1 +- 19.6 13.0 False False False
temporal adjacent 0.025 a 1 1 19.2 13.0 False False False
temporal adjacent 0.025 b 1 1 19.2 13.0 False False False
temporal distance 0.050 a 2 1 41.9 +- 27.8 13.0 False False False
temporal distance 0.050 b 2 1 41.9 +- 27.8 13.0 False False False
temporal distance 0.025 a 1 1 61.5 13.0 False False False
temporal distance 0.025 b 1 1 61.5 13.0 False False False
temporal none 0.050 a 3 1 8.2 +- 2.7 4.3 False False True
temporal none 0.050 b 3 1 8.2 +- 2.7 4.3 False False True
temporal none 0.025 a 1 1 3.8 4.3 False False False
temporal none 0.025 b 1 1 3.8 4.3 False False False
==== methods_half: segment zero-padded, random trials of both delays, as many per condition as methods_900 (control)
contrast neighbours alpha per tail assign subjects other>id subjects id>other % other>id % id>other counts match % match counts within 1
spatial adjacent 0.050 a 2 1 6.1 +- 0.3 33.3 False False False
spatial adjacent 0.050 b 2 1 6.1 +- 0.3 33.3 False False False
spatial adjacent 0.025 a 1 0 6.2 - False False False
spatial adjacent 0.025 b 1 0 6.2 - False False False
spatial distance 0.050 a 3 1 36.6 +- 14.9 33.3 False False False
spatial distance 0.050 b 3 1 36.6 +- 14.9 33.3 False False False
spatial distance 0.025 a 3 0 36.6 +- 14.9 - False False False
spatial distance 0.025 b 3 0 36.6 +- 14.9 - False False False
spatial none 0.050 a 1 0 6.2 - False False False
spatial none 0.050 b 1 0 6.2 - False False False
spatial none 0.025 a 1 0 6.2 - False False False
spatial none 0.025 b 1 0 6.2 - False False False
temporal adjacent 0.050 a 3 1 22.7 +- 19.8 17.4 False False True
temporal adjacent 0.050 b 3 1 22.7 +- 19.8 17.4 False False True
temporal adjacent 0.025 a 2 1 31.0 +- 18.9 17.4 False False False
temporal adjacent 0.025 b 2 1 31.0 +- 18.9 17.4 False False False
temporal distance 0.050 a 3 1 32.5 +- 13.6 17.4 False False True
temporal distance 0.050 b 3 1 32.5 +- 13.6 17.4 False False True
temporal distance 0.025 a 3 1 21.1 +- 3.1 17.4 False False True
temporal distance 0.025 b 3 1 21.1 +- 3.1 17.4 False False True
temporal none 0.050 a 3 0 9.9 +- 10.9 - False False False
temporal none 0.050 b 3 0 9.9 +- 10.9 - False False False
temporal none 0.025 a 3 0 6.2 +- 4.8 - False False False
temporal none 0.025 b 3 0 6.2 +- 4.8 - False False False
Subjects per effect, main spectra, 0.05 per tail, assignment (a):
contrast neighbours subjects other>id (list) subjects id>other (list)
spatial adjacent [s2, s3, s4, s5, s6] [s4]
spatial distance [s2, s3, s4, s5, s6] [s4]
spatial none [s2, s3, s4, s5, s6] [s4]
temporal adjacent [s3, s4, s5, s6, s7] [s1, s7]
temporal distance [s2, s3, s4, s5, s6, s7] [s1, s7]
temporal none [s2, s3, s4, s5, s6] [s1, s4, s7]
Trials of the control (methods_half) by delay: {'s1': {900: 23, 1150: 28}, 's2': {900: 23, 1150: 24}, 's3': {900: 22, 1150: 27}, 's4': {900: 29, 1150: 25}, 's5': {900: 24, 1150: 22}, 's6': {900: 22, 1150: 16}, 's7': {900: 21, 1150: 21}}
Subjects per effect, 0.05 per tail, assignment (a): 900-ms-delay trials against the random-trial control
config contrast neighbours subjects other>id (list) subjects id>other (list)
methods_900 spatial adjacent [s2, s3] []
methods_900 spatial distance [s2, s3, s5] []
methods_900 spatial none [s2, s3, s5] []
methods_900 temporal adjacent [s5, s7] [s1]
methods_900 temporal distance [s5, s7] [s1]
methods_900 temporal none [s4, s5, s7] [s1]
methods_half spatial adjacent [s2, s3] [s7]
methods_half spatial distance [s2, s3, s5] [s7]
methods_half spatial none [s2] []
methods_half temporal adjacent [s3, s4, s7] [s1]
methods_half temporal distance [s3, s4, s7] [s1]
methods_half temporal none [s3, s4, s7] []
print("Per-subject % of electrodes, 'other > identity / identity > other', main spectra (paper: per-subject values only in Figures 2A and 3A, not read)")
for contrast in ["spatial", "temporal"]:
tab = pd.DataFrame({f"{nb[:4]} {alpha} {assign}": PER_SUBJECT[("methods", contrast, nb, alpha, assign)]
for nb in fcx3.NB_READINGS for alpha in (0.05, 0.025) for assign in ("a", "b")}, index=fcx3.SUBJECTS)
print(f"identity against {contrast} (columns: neighbours, alpha per tail, assignment)")
print(tab.to_string())
print("\nSmallest cluster p of each sign and subject, main spectra; paper: all p < 0.04 for the effects it reports")
rows = []
for contrast in ["spatial", "temporal"]:
for sid in fcx3.SUBJECTS:
cl = RES[sid]["power"]["methods"][contrast]["clusters"]
rows.append({"contrast": contrast, "subject": sid, **{f"{nb} other>id": round(cl[nb]["neg_minp"], 3) for nb in fcx3.NB_READINGS},
**{f"{nb} id>other": round(cl[nb]["pos_minp"], 3) for nb in fcx3.NB_READINGS}})
print(pd.DataFrame(rows).to_string(index=False))
Per-subject % of electrodes, 'other > identity / identity > other', main spectra (paper: per-subject values only in Figures 2A and 3A, not read) identity against spatial (columns: neighbours, alpha per tail, assignment) adja 0.05 a adja 0.05 b adja 0.025 a adja 0.025 b dist 0.05 a dist 0.05 b dist 0.025 a dist 0.025 b none 0.05 a none 0.05 b none 0.025 a none 0.025 b s1 0/0 0/0 0/0 0/0 0/0 0/0 0/0 0/0 0/0 0/0 0/0 0/0 s2 19/0 19/0 19/0 19/0 34/0 34/0 34/0 34/0 9/0 9/0 6/0 6/0 s3 46/0 46/0 46/0 46/0 75/0 75/0 75/0 75/0 25/0 25/0 19/0 19/0 s4 12/12 12/12 12/0 12/0 12/24 12/12 12/24 12/12 12/6 12/6 6/6 6/6 s5 54/0 54/0 35/0 35/0 62/0 62/0 62/0 62/0 12/0 12/0 8/0 8/0 s6 58/0 58/0 58/0 58/0 58/0 58/0 58/0 58/0 25/0 25/0 17/0 17/0 s7 0/0 0/0 0/0 0/0 0/0 0/0 0/0 0/0 0/0 0/0 0/0 0/0 identity against temporal (columns: neighbours, alpha per tail, assignment) adja 0.05 a adja 0.05 b adja 0.025 a adja 0.025 b dist 0.05 a dist 0.05 b dist 0.025 a dist 0.025 b none 0.05 a none 0.05 b none 0.025 a none 0.025 b s1 0/9 0/9 0/9 0/9 0/9 0/9 0/9 0/9 0/4 0/4 0/4 0/4 s2 0/0 0/0 0/0 0/0 19/0 19/0 19/0 19/0 3/0 3/0 0/0 0/0 s3 47/0 47/0 46/0 46/0 94/0 94/0 94/0 94/0 10/0 10/0 9/0 9/0 s4 24/0 24/0 24/0 24/0 24/0 24/0 24/0 24/0 18/6 18/6 12/0 12/0 s5 69/0 69/0 58/0 58/0 73/0 73/0 62/0 62/0 15/0 15/0 8/0 8/0 s6 25/0 25/0 25/0 25/0 67/0 67/0 67/0 67/0 8/0 8/0 8/0 8/0 s7 22/33 0/33 22/33 0/33 22/33 0/33 22/33 0/33 0/22 0/22 0/22 0/22 Smallest cluster p of each sign and subject, main spectra; paper: all p < 0.04 for the effects it reports contrast subject adjacent other>id distance other>id none other>id adjacent id>other distance id>other none id>other spatial s1 0.345 0.336 0.873 0.731 0.722 0.550 spatial s2 0.004 0.000 0.000 0.578 0.518 0.326 spatial s3 0.000 0.000 0.000 0.155 0.443 0.158 spatial s4 0.002 0.003 0.001 0.028 0.010 0.006 spatial s5 0.012 0.002 0.016 0.998 1.000 1.000 spatial s6 0.003 0.002 0.002 0.994 0.991 0.991 spatial s7 0.585 0.597 0.468 0.061 0.067 0.134 temporal s1 0.745 0.744 0.809 0.004 0.004 0.002 temporal s2 0.077 0.020 0.044 0.873 0.683 0.719 temporal s3 0.001 0.000 0.000 0.509 0.205 0.564 temporal s4 0.000 0.000 0.000 0.118 0.147 0.025 temporal s5 0.000 0.000 0.000 0.716 0.803 0.603 temporal s6 0.014 0.001 0.009 0.769 0.834 0.784 temporal s7 0.014 0.015 0.067 0.001 0.001 0.000
Result: partially reproduced. Under the main spectra, 5 subjects show spatial > identity effects (S2 to S6) under every neighbour reading and threshold, and 1 shows identity > spatial effects (S4; paper 2) under every reading but adjacent neighbours at 0.025 per tail, which finds none. With adjacent neighbours at 0.05 per tail the percentages are 37.7 +- 21.1% and 11.8% (S4 alone), below the paper's 54 +- 22% and 36 +- 12%. The counts match within one subject and 5 of 7 subjects have a significant cluster, the criterion's partial match. The paper's counts (5 and 2) appear only with the whole-epoch windows of power_compute.m, where S7 adds an identity > spatial effect; there the distance reading gives 52.0% (within tolerance of 54) and 28.4% (outside tolerance of 36), so no reading matches both percentages. The significant clusters of the main spectra have p <= 0.028. On the 900-ms-delay trials alone 2 or 3 subjects show spatial > identity effects and none identity > spatial. A random draw of as many trials from both delays loses about as much (1 to 3 subjects spatial > identity, 0 or 1 identity > spatial), so the loss on the 900-ms trials comes from having fewer trials and does not show that the effects depend on the 1150-ms trials' timing; with half the trials these tests cannot settle it either way, here or for power-difficulty-subjects, which rests on the same effects.
Result: partially reproduced. Under the main spectra, adjacent neighbours, 0.05 per tail and assignment (a), 5 subjects show temporal > identity effects (paper 4) and 2 identity > temporal effects (S1, S7; paper 2), with 37.4 +- 20.5% and 21.0 +- 17.4% of electrodes (paper 68 +- 30% and 37 +- 10%). Assignment (b) gives the paper's counts, 4 and 2, with 41.2% and 21.0%. No reading of spectra, neighbours, threshold or assignment brings both percentages within tolerance; the distance reading gives 47.8 to 55.2% for temporal > identity. The significant clusters of the reported effects have p <= 0.014 with adjacent neighbours, except S2, whose temporal > identity cluster is significant only under the distance reading (p = 0.020) and without spatial clustering (p = 0.044). On the 900-ms-delay trials alone 1 to 3 subjects show temporal > identity effects and 1 (S1) identity > temporal; the random draw of as many trials from both delays gives 2 or 3 and 0 or 1, as for fig2-spatial-power.
power-difficulty-subjects¶
The subjects with identity > spatial or temporal power effects were the same subjects who had both longer RTs and lower accuracy on identity trials.
Subjects with an identity > spatial or identity > temporal effect are taken from the power claims
(every spectra, neighbour and threshold reading, assignment (a)); accuracy (all 120 trials) and
mean correct RT per condition from docs/summary_file.csv.
w = SUMMARY.copy()
w["subject"] = w.subject.str.lower()
w = w.set_index("subject")
beh = pd.DataFrame({
"RT id > sp": w.rt_identity > w.rt_spatial, "acc id < sp": w.acc_identity < w.acc_spatial,
"RT id > tp": w.rt_identity > w.rt_temporal, "acc id < tp": w.acc_identity < w.acc_temporal,
"RT id > mean(sp,tp)": w.rt_identity > (w.rt_spatial + w.rt_temporal) / 2,
"acc id < mean(sp,tp)": w.acc_identity < (w.acc_spatial + w.acc_temporal) / 2})
beh["both (a) spatial"] = beh["RT id > sp"] & beh["acc id < sp"]
beh["both (a) temporal"] = beh["RT id > tp"] & beh["acc id < tp"]
beh["both (b)"] = beh["RT id > mean(sp,tp)"] & beh["acc id < mean(sp,tp)"]
print(beh.to_string())
for config in fcx3.POWER_CONFIGS:
for nb in fcx3.NB_READINGS:
for alpha in (0.05, 0.025):
sel = POWER_SUMMARY[(POWER_SUMMARY.config == config) & (POWER_SUMMARY.neighbours == nb) & (POWER_SUMMARY["alpha per tail"] == alpha)
& (POWER_SUMMARY["assign"] == "a")].set_index("contrast")
sp_ = set(sel.loc["spatial", "subjects id>other (list)"])
tp_ = set(sel.loc["temporal", "subjects id>other (list)"])
effect = sorted(sp_ | tp_)
ok_a = all((s not in sp_ or beh.loc[s, "both (a) spatial"]) and (s not in tp_ or beh.loc[s, "both (a) temporal"]) for s in effect)
ok_b = all(beh.loc[s, "both (b)"] for s in effect)
others_a = [s for s in beh.index if s not in effect and (beh.loc[s, "both (a) spatial"] or beh.loc[s, "both (a) temporal"])]
others_b = [s for s in beh.index if s not in effect and beh.loc[s, "both (b)"]]
print(f"{config}, {nb}, {alpha}: identity>spatial {sorted(sp_)}, identity>temporal {sorted(tp_)}; every one has both under (a): {ok_a},"
f" under (b): {ok_b}; other subjects with both, (a): {others_a}, (b): {others_b}")
RT id > sp acc id < sp RT id > tp acc id < tp RT id > mean(sp,tp) acc id < mean(sp,tp) both (a) spatial both (a) temporal both (b) subject s1 True True True False True True True False True s2 True False True False True False False False False s3 True False True True True True False True True s4 True True True True True True True True True s5 True False True False True False False False False s6 True False True False True False False False False s7 True True True True True True True True True methods, adjacent, 0.05: identity>spatial ['s4'], identity>temporal ['s1', 's7']; every one has both under (a): False, under (b): True; other subjects with both, (a): ['s3'], (b): ['s3'] methods, adjacent, 0.025: identity>spatial [], identity>temporal ['s1', 's7']; every one has both under (a): False, under (b): True; other subjects with both, (a): ['s3', 's4'], (b): ['s3', 's4'] methods, distance, 0.05: identity>spatial ['s4'], identity>temporal ['s1', 's7']; every one has both under (a): False, under (b): True; other subjects with both, (a): ['s3'], (b): ['s3'] methods, distance, 0.025: identity>spatial ['s4'], identity>temporal ['s1', 's7']; every one has both under (a): False, under (b): True; other subjects with both, (a): ['s3'], (b): ['s3'] methods, none, 0.05: identity>spatial ['s4'], identity>temporal ['s1', 's4', 's7']; every one has both under (a): False, under (b): True; other subjects with both, (a): ['s3'], (b): ['s3'] methods, none, 0.025: identity>spatial ['s4'], identity>temporal ['s1', 's7']; every one has both under (a): False, under (b): True; other subjects with both, (a): ['s3'], (b): ['s3'] code, adjacent, 0.05: identity>spatial ['s4', 's7'], identity>temporal ['s1', 's4', 's7']; every one has both under (a): False, under (b): True; other subjects with both, (a): ['s3'], (b): ['s3'] code, adjacent, 0.025: identity>spatial ['s4', 's7'], identity>temporal ['s1', 's7']; every one has both under (a): False, under (b): True; other subjects with both, (a): ['s3'], (b): ['s3'] code, distance, 0.05: identity>spatial ['s4', 's7'], identity>temporal ['s1', 's7']; every one has both under (a): False, under (b): True; other subjects with both, (a): ['s3'], (b): ['s3'] code, distance, 0.025: identity>spatial ['s4', 's7'], identity>temporal ['s1', 's7']; every one has both under (a): False, under (b): True; other subjects with both, (a): ['s3'], (b): ['s3'] code, none, 0.05: identity>spatial ['s4'], identity>temporal ['s1', 's4', 's7']; every one has both under (a): False, under (b): True; other subjects with both, (a): ['s3'], (b): ['s3'] code, none, 0.025: identity>spatial ['s4'], identity>temporal ['s1', 's4', 's7']; every one has both under (a): False, under (b): True; other subjects with both, (a): ['s3'], (b): ['s3'] methods_900, adjacent, 0.05: identity>spatial [], identity>temporal ['s1']; every one has both under (a): False, under (b): True; other subjects with both, (a): ['s3', 's4', 's7'], (b): ['s3', 's4', 's7'] methods_900, adjacent, 0.025: identity>spatial [], identity>temporal ['s1']; every one has both under (a): False, under (b): True; other subjects with both, (a): ['s3', 's4', 's7'], (b): ['s3', 's4', 's7'] methods_900, distance, 0.05: identity>spatial [], identity>temporal ['s1']; every one has both under (a): False, under (b): True; other subjects with both, (a): ['s3', 's4', 's7'], (b): ['s3', 's4', 's7'] methods_900, distance, 0.025: identity>spatial [], identity>temporal ['s1']; every one has both under (a): False, under (b): True; other subjects with both, (a): ['s3', 's4', 's7'], (b): ['s3', 's4', 's7'] methods_900, none, 0.05: identity>spatial [], identity>temporal ['s1']; every one has both under (a): False, under (b): True; other subjects with both, (a): ['s3', 's4', 's7'], (b): ['s3', 's4', 's7'] methods_900, none, 0.025: identity>spatial [], identity>temporal ['s1']; every one has both under (a): False, under (b): True; other subjects with both, (a): ['s3', 's4', 's7'], (b): ['s3', 's4', 's7'] methods_half, adjacent, 0.05: identity>spatial ['s7'], identity>temporal ['s1']; every one has both under (a): False, under (b): True; other subjects with both, (a): ['s3', 's4'], (b): ['s3', 's4'] methods_half, adjacent, 0.025: identity>spatial [], identity>temporal ['s1']; every one has both under (a): False, under (b): True; other subjects with both, (a): ['s3', 's4', 's7'], (b): ['s3', 's4', 's7'] methods_half, distance, 0.05: identity>spatial ['s7'], identity>temporal ['s1']; every one has both under (a): False, under (b): True; other subjects with both, (a): ['s3', 's4'], (b): ['s3', 's4'] methods_half, distance, 0.025: identity>spatial [], identity>temporal ['s1']; every one has both under (a): False, under (b): True; other subjects with both, (a): ['s3', 's4', 's7'], (b): ['s3', 's4', 's7'] methods_half, none, 0.05: identity>spatial [], identity>temporal []; every one has both under (a): True, under (b): True; other subjects with both, (a): ['s1', 's3', 's4', 's7'], (b): ['s1', 's3', 's4', 's7'] methods_half, none, 0.025: identity>spatial [], identity>temporal []; every one has both under (a): True, under (b): True; other subjects with both, (a): ['s1', 's3', 's4', 's7'], (b): ['s1', 's3', 's4', 's7']
Result: reproduced. Under the main spectra the subjects with identity > spatial or temporal effects are S1, S4 and S7 under every neighbour reading at 0.05 per tail (S4 for spatial, S1 and S7 for temporal, and S4 also for temporal without spatial clustering). Under reading (b), identity against the mean of spatial and temporal, each has longer identity RT and lower identity accuracy; under reading (a) S1 fails for the temporal contrast, where its identity and temporal accuracy are equal (0.825). The same holds under every other configuration printed. S3 also has both without an identity > effect, so the converse ("the same subjects", reading (ii)) does not hold. Identity RT is the longest in all 7 subjects, so only accuracy separates subjects here.
power-low-frequencies¶
Significant processing-interval power effects were most prominent at low frequencies, in distinct delta-theta (2 to 7 Hz) and alpha-beta (9 to 24 Hz) ranges, whatever the contrast.
Per subject and effect, the t values inside significant clusters (0.05 per tail) are averaged over electrodes and time per frequency, (a) over the masked points only, (b) over all points with the unmasked as zero; then averaged, in absolute value, over the subjects with the effect. The rule (2-24 Hz larger than 25-40 Hz, local maxima in 2-7 and 9-24 Hz) is the claims file's. A point at either end of the 2-40 Hz range counts as a local maximum when it exceeds its one neighbour (the usual definition on a closed range); the result without counting the 2-Hz end is shown as well. Every neighbour reading is shown, for the main spectra and the whole-epoch variant.
def density(nb, effect, reading, alpha=0.05, config="methods"):
out = {}
for sid in fcx3.SUBJECTS:
R = RES[sid]
dens = []
for contrast in (["spatial"] if effect == "spatial>identity" else ["temporal"] if effect == "temporal>identity" else ["spatial", "temporal"]):
cl = R["power"][config][contrast]["clusters"][nb]
sign = "neg" if effect != "identity>other" else "pos"
cs = [c for c in cl[sign] if c["p"] < alpha]
if not cs:
continue
tm = sum(c["t_masked"].astype(float) for c in cs) # ch x f x t
if reading == "a":
cnt = (tm != 0).sum(axis=(0, 2))
dens.append(np.where(cnt > 0, tm.sum(axis=(0, 2)) / np.maximum(cnt, 1), 0))
else:
dens.append(tm.mean(axis=(0, 2)))
if dens:
out[sid] = np.abs(np.mean(dens, axis=0))
return out
f = fcx3.FOI
LF = []
for config in ("methods", "code"):
for nb in fcx3.NB_READINGS:
for reading in ("a", "b"):
for effect in ["spatial>identity", "temporal>identity", "identity>other"]:
d = density(nb, effect, reading, config=config)
if not d:
LF.append({"config": config, "neighbours": nb, "reading": reading, "effect": effect, "subjects": 0})
continue
m = np.mean(list(d.values()), axis=0)
low, high = m[(f >= 2) & (f <= 24)].mean(), m[(f >= 25) & (f <= 40)].mean()
peaks = [int(f[i]) for i in range(len(f)) if (i == 0 or m[i] > m[i - 1]) and (i == len(f) - 1 or m[i] >= m[i + 1])]
inner = [p for p in peaks if 2 < p < 40]
LF.append({"config": config, "neighbours": nb, "reading": reading, "effect": effect, "subjects": len(d), "2-24 Hz": round(low, 3),
"25-40 Hz": round(high, 3), "low > high": low > high, "local maxima (Hz)": peaks,
"max in 2-7": any(2 <= p <= 7 for p in peaks), "max in 9-24": any(9 <= p <= 24 for p in peaks),
"max in 2-7, 2-Hz edge not counted": any(2 < p <= 7 for p in inner), "peak Hz": int(f[np.argmax(m)])})
LF = pd.DataFrame(LF)
print(LF.to_string(index=False))
ok = LF[LF.subjects > 0].groupby(["config", "neighbours", "reading"]).apply(
lambda g: pd.Series({"all three meet the rule": bool((g["low > high"] & g["max in 2-7"] & g["max in 9-24"]).all() and len(g) == 3),
"same, 2-Hz edge not counted": bool((g["low > high"] & g["max in 2-7, 2-Hz edge not counted"] & g["max in 9-24"]).all() and len(g) == 3)}))
print("\nCombinations where every effect meets the claims file's rule:")
print(ok.to_string())
fig, axes = plt.subplots(1, 3, figsize=(12, 3), sharey=False)
for ax, effect in zip(axes, ["spatial>identity", "temporal>identity", "identity>other"]):
for sid, v in density("adjacent", effect, "b").items():
ax.plot(f, v, lw=0.8, label=sid)
ax.set_title(effect + " (main spectra, adjacent, b)")
ax.set_xlabel("Hz")
axes[0].set_ylabel("|mean significant t|")
axes[0].legend(fontsize=7)
plt.tight_layout()
plt.show()
print("All densities plotted are within the axes (autoscaled).")
config neighbours reading effect subjects 2-24 Hz 25-40 Hz low > high local maxima (Hz) max in 2-7 max in 9-24 max in 2-7, 2-Hz edge not counted peak Hz
methods adjacent a spatial>identity 5 2.234 1.804 True [2, 5, 9, 15, 20, 22, 26, 29, 40] True True True 15
methods adjacent a temporal>identity 5 2.261 2.000 True [9, 14, 28, 30, 32, 37] False True False 14
methods adjacent a identity>other 3 1.905 2.524 False [2, 11, 14, 17, 23, 26, 29, 36, 38, 40] True True False 40
methods adjacent b spatial>identity 5 0.099 0.021 True [2, 9, 16] True True False 16
methods adjacent b temporal>identity 5 0.097 0.032 True [3, 9, 11, 15] True True True 3
methods adjacent b identity>other 3 0.057 0.018 True [2, 14] True True False 2
methods distance a spatial>identity 5 2.263 1.976 True [4, 9, 16, 20, 22, 29, 40] True True True 16
methods distance a temporal>identity 6 2.232 2.490 False [9, 14, 28, 30, 32, 35, 37] False True False 14
methods distance a identity>other 3 2.058 2.524 False [2, 4, 7, 11, 14, 17, 23, 26, 29, 36, 38, 40] True True True 40
methods distance b spatial>identity 5 0.126 0.032 True [6, 8, 14] True True True 14
methods distance b temporal>identity 6 0.123 0.037 True [4, 8, 11, 15] True True True 11
methods distance b identity>other 3 0.060 0.018 True [2, 14] True True False 2
methods none a spatial>identity 5 2.269 1.802 True [2, 5, 9, 17, 20, 22, 24, 26, 29, 33] True True True 17
methods none a temporal>identity 5 2.463 2.071 True [3, 12, 28, 32] True True True 12
methods none a identity>other 3 1.902 2.339 False [2, 15, 26, 29, 36, 38, 40] True True False 15
methods none b spatial>identity 5 0.070 0.013 True [2, 7, 16] True True True 16
methods none b temporal>identity 5 0.056 0.014 True [3, 9, 16] True True True 3
methods none b identity>other 3 0.039 0.015 True [2, 9, 14, 21] True True False 2
code adjacent a spatial>identity 5 2.341 1.806 True [5, 9, 16, 20, 22, 26, 29, 40] True True True 16
code adjacent a temporal>identity 5 2.267 2.032 True [7, 17, 26, 28, 30, 32, 37, 39] True True True 17
code adjacent a identity>other 3 1.897 2.220 False [2, 9, 12, 14, 19, 26, 29, 36] True True False 14
code adjacent b spatial>identity 5 0.101 0.021 True [14] False True False 14
code adjacent b temporal>identity 5 0.090 0.032 True [3, 9, 11, 15] True True True 3
code adjacent b identity>other 3 0.043 0.014 True [2, 14] True True False 2
code distance a spatial>identity 5 2.354 1.974 True [3, 5, 9, 16, 20, 22, 25, 29, 40] True True True 16
code distance a temporal>identity 6 2.252 2.508 False [2, 12, 17, 21, 28, 30, 32, 37, 39] True True False 30
code distance a identity>other 3 2.142 2.452 False [3, 8, 11, 14, 20, 23, 26, 29, 34, 36] True True True 11
code distance b spatial>identity 5 0.131 0.033 True [6, 8, 14] True True True 14
code distance b temporal>identity 6 0.115 0.037 True [3, 8, 11, 15] True True True 11
code distance b identity>other 3 0.045 0.016 True [2, 14] True True False 2
code none a spatial>identity 5 2.282 1.807 True [3, 9, 12, 16, 20, 22, 24, 26, 29] True True True 16
code none a temporal>identity 6 2.238 2.190 True [3, 12, 16, 28, 32, 37] True True True 16
code none a identity>other 3 1.870 2.333 False [2, 15, 17, 26, 30, 36] True True False 17
code none b spatial>identity 5 0.072 0.014 True [15] False True False 15
code none b temporal>identity 6 0.048 0.015 True [3, 17] True True True 3
code none b identity>other 3 0.047 0.013 True [2, 9, 14] True True False 2
Combinations where every effect meets the claims file's rule:
all three meet the rule same, 2-Hz edge not counted
config neighbours reading
code adjacent a False False
b False False
distance a False False
b True False
none a False False
b False False
methods adjacent a False False
b True False
distance a False False
b True False
none a False False
b True False
All densities plotted are within the axes (autoscaled).
Result: reproduced, resting on an assumption. Under the main spectra with the density over all points (reading (b)), every neighbour reading meets the rule. With adjacent neighbours, each effect is larger over 2 to 24 Hz than over 25 to 40 Hz (0.099 against 0.021 for spatial > identity, 0.097 against 0.032 for temporal > identity, 0.057 against 0.018 for identity > other), with local maxima in 2 to 7 Hz (2, 3 and 2 Hz) and in 9 to 24 Hz. The match rests on counting the 2-Hz end of the range as a local maximum: without it, the identity > other density (maxima at 2 and 14 Hz) has no maximum in 2 to 7 Hz in any combination with reading (b), which would be the partial match. Over masked points only (reading (a)) the identity > other density is larger above 24 Hz under every combination. With the whole-epoch windows only the distance reading meets the rule.
Task-induced PSI: fig4-maintenance-parietal-led, fig4a-delta-theta-shift, fig4c-alpha-beta-shift, directional-pairs¶
During maintenance, PFC-parietal connectivity was unidirectional, parietal to PFC, in both the delta-theta (z < -40.03 +- 8.73) and alpha-beta (z < -30.37 +- 2.60) ranges.
After the test cue, delta-theta directionality shifted from a unidirectional parietal-led network to a bidirectional frontoparietal one, with net PFC-led connectivity above zero in 6 of 7 subjects during processing (z > 6.01 +- 6.42).
Alpha-beta directionality also shifted with the test cue, but all subjects remained net parietal-led during processing (z < -12.60 +- 7.51).
During processing, 1008 pairs were significantly directional in the delta-theta range and 984 in the alpha-beta range.
PSI per P1, with the details psi_compute.m and psianalysis.m settle: the ERP subtracted is the mean over all correct trials (P1 "raw trial-wise mean", reading (a); subtracterp.m with one condition); spectra are one Hanning-tapered FFT of each 900-ms segment padded to 7.5 s ('mtmfft', P1 spectra reading (a)); PSI is one value per band summed over adjacent 1-Hz bins (band reading (a)). PSI is computed (a) from the trial-averaged coherency (Nolte et al. 2008) or (b) per trial from the per-trial normalised cross-spectrum, averaged over trials (the structure of psianalysis.m), with the conjugate the Methods' cross-spectral density implies.
The null follows the Methods: "we randomly shuffled the frequencies in one signal and re-computed
PSI 1,000 times". Each shuffle permutes the frequency bins of the parietal spectrum (the same
permutation for every trial and pair, P1 null reading (a)) and recomputes the same statistic, so
that the null and the observed value measure the same thing (fcx3.psi_z). psianalysis.m builds
its null differently, from the slope of the trial-mean spectrum with both factors shuffled, which
is not the statistic it z-scores; reading (b) against that null is shown as a variant (b_code).
The deposited code without the conjugate, whose measure equals plus or minus exp(2i x the second
channel's phase) and so depends on one channel only, is shown with either channel first for the
record of that code mismatch; it is not a reading of the paper and decides no outcome. As a check of
calibration on these data, each subject's processing PSI is also computed with the parietal trials
paired with other trials' PFC data, which removes any trial-locked coupling; a calibrated z then
exceeds 1.96 in about 5% of pairs. Positive z: PFC leads.
P1 also leaves open whether each shuffle permutes the bins in the same way for all trials (null
reading (a), used above) or with its own permutation per trial (null reading (b)); both are run for
readings (a) and (b) (a_trial, b_trial).
Which reading is adopted. Where the readings give different outcomes, reading (a) with null reading (a) is adopted: it is the first P1 lists, the measure of Nolte et al. (2008), and the one whose z is calibrated. On the trial-shuffled data below, its z has mean -0.05 (delta-theta) and 0.02 (alpha-beta), SD 1.01 and 1.04, and passes |z| > 1.96 in 6.0% and 6.9% of pairs. Reading (b) has mean -0.29 and SD 0.60 in delta-theta (0.1% of pairs pass), and its subject means on the trial-shuffled data run from -1.25 to 0.52 in alpha-beta, where the true value is 0. On independent synthetic signals (the cell after the calibration) its mean z is -0.21 to -0.37, where reading (a) gives -0.07 to -0.15 with SD near 1. Moving the FFT's time origin to the centre of the segment brings reading (b)'s mean to -0.06 to 0.12, which is consistent with the offset coming from the phase slope that each trial's spectrum carries from the segment's position in the padded window: the per-trial phasors of reading (b) keep it, the frequency shuffle breaks it, and the trial-averaged cross-spectrum of reading (a) cancels it. One permutation per trial does not help reading (b) (mean -0.51 in delta-theta, 17% of alpha-beta pairs past 1.96). The first revision adopted reading (b), for the structure of psianalysis.m; the second verification round found it uncalibrated. Three outcomes rested on it (fig4c-alpha-beta-shift, fig5a-spatiotemporal-bidirectional, fig5b-alpha-beta-no-sustained); the change that reading (a) gives was proposed for a third round, whose verifier agreed with all three, and they now rest on reading (a).
READ = {"a": "(a) trial-averaged coherency", "b": "(b) per-trial PSI averaged",
"a_trial": "(a), one permutation per trial (P1 null (b))", "b_trial": "(b), one permutation per trial (P1 null (b))",
"b_code": "(b) against psianalysis.m's null (variant)",
"code": "deposited code, PFC first (not a reading)", "code_rev": "deposited code, parietal first, sign reversed (not a reading)"}
psi_rows = []
for sid in fcx3.SUBJECTS:
for band in fcx3.BANDS:
for iv in ("maintenance", "processing", "processing_900"):
zs = {**RES[sid]["psi"][band][iv], **RES[sid]["psi_deposited"][band].get(iv, {})}
for k, z in zs.items():
for (pfc, par, hemi), v in zip(RES[sid]["pairs"], z):
psi_rows.append({"subject": sid, "band": band, "interval": iv, "reading": k, "pair": f"{sid}:{pfc}-{par}", "z": v})
PSI = pd.DataFrame(psi_rows)
print("Pairs per subject:", PSI[(PSI.band == "delta-theta") & (PSI.interval == "maintenance") & (PSI.reading == "a")].groupby("subject").size().to_dict())
print("Frequencies read (Hz):", {b: np.round(RES[fcx3.SUBJECTS[0]]['psi'][b]['freqs'], 3).tolist() for b in fcx3.BANDS})
persub = PSI.groupby(["band", "interval", "reading", "subject"]).z.mean().unstack("subject")
print("\nPer-subject mean PSI z over pairs:")
print(persub.round(2).to_string())
grp = PSI.groupby(["band", "interval", "reading", "subject"]).z.mean().groupby(["band", "interval", "reading"]).agg(["mean", "std", "min", "max"])
grp.columns = ["mean over subjects", "SD over subjects", "min subject", "max subject"]
pairs_ = PSI.groupby(["band", "interval", "reading"]).z.agg(["mean", "std", "min", "max", lambda z: np.mean(np.abs(z) > 1.96)])
pairs_.columns = ["mean over pairs", "SD over pairs", "min pair", "max pair", "fraction |z| > 1.96"]
print("\n", pd.concat([grp, pairs_], axis=1).round(2).to_string())
Pairs per subject: {'s1': 21, 's2': 116, 's3': 756, 's4': 30, 's5': 160, 's6': 32, 's7': 20}
Frequencies read (Hz): {'delta-theta': [2.0, 3.067, 4.0, 5.067, 6.0, 7.067], 'alpha-beta': [9.067, 10.0, 11.067, 12.0, 13.067, 14.0, 15.067, 16.0, 17.067, 18.0, 19.067, 20.0, 21.067, 22.0, 23.067, 24.0]}
Per-subject mean PSI z over pairs:
subject s1 s2 s3 s4 s5 s6 s7
band interval reading
alpha-beta maintenance a -0.42 -0.15 0.01 -0.67 -0.19 0.04 -0.28
a_trial -0.47 -0.12 0.00 -0.73 -0.18 0.05 -0.25
b -0.25 -0.27 -0.37 -0.25 -0.48 -0.05 -0.18
b_code 1.94 2.22 0.34 2.56 -1.24 4.71 4.21
b_trial -0.34 -0.37 -0.53 -0.38 -0.70 -0.02 -0.19
code 69.64 79.37 77.48 75.01 70.70 51.98 62.18
code_rev -75.32 -71.47 -82.01 -75.49 -71.92 -52.74 -59.85
processing a -0.31 -0.05 0.18 -0.16 -0.31 -0.49 0.19
a_trial -0.33 -0.04 0.18 -0.22 -0.30 -0.45 0.20
b -1.07 -0.51 0.46 -0.61 -0.72 -1.35 -0.18
b_code -11.72 -1.91 16.28 -0.40 -5.00 -14.70 4.56
b_trial -1.61 -0.66 0.69 -0.86 -0.98 -1.70 -0.22
code 92.24 70.01 67.29 74.88 68.16 57.39 69.66
code_rev -86.45 -68.70 -74.31 -83.56 -68.14 -61.80 -71.21
processing_900 a -0.54 0.18 0.22 0.01 -0.13 -0.59 -0.15
b -1.21 -0.24 0.35 -0.27 -0.40 -1.27 -0.05
delta-theta maintenance a 0.15 -0.16 -0.26 0.08 -0.03 0.05 -0.39
a_trial -0.03 -0.11 -0.34 0.39 -0.02 -0.01 -0.41
b -0.57 -0.64 -0.61 -0.67 -0.39 0.05 -0.26
b_code -5.84 -10.13 -5.80 -10.23 1.39 15.80 12.61
b_trial -1.13 -1.27 -1.15 -1.20 -0.69 0.06 -0.54
code 65.02 61.71 60.54 66.88 45.98 39.83 70.74
code_rev -67.46 -59.72 -58.00 -56.94 -48.99 -49.01 -48.16
processing a -0.28 -0.01 -0.15 -0.00 -0.06 -0.45 -0.23
a_trial -0.35 -0.01 -0.14 -0.09 -0.09 -0.59 -0.24
b -1.10 -0.24 -0.21 -0.53 -0.59 -0.24 -0.11
b_code -18.83 5.24 7.16 -5.03 -2.38 6.28 6.75
b_trial -2.15 -0.34 -0.37 -1.02 -0.86 -0.37 -0.23
code 65.90 37.19 51.01 69.39 45.40 41.67 45.57
code_rev -75.56 -53.49 -51.09 -60.95 -44.46 -40.99 -39.71
processing_900 a -0.16 0.01 -0.04 -0.34 -0.20 -0.34 0.08
b -0.94 -0.31 -0.17 -0.60 -0.41 -0.07 0.42
mean over subjects SD over subjects min subject max subject mean over pairs SD over pairs min pair max pair fraction |z| > 1.96
band interval reading
alpha-beta maintenance a -0.24 0.25 -0.67 0.04 -0.06 1.05 -4.51 3.04 0.07
a_trial -0.24 0.27 -0.73 0.05 -0.07 1.07 -4.72 3.07 0.07
b -0.26 0.14 -0.48 -0.05 -0.36 0.91 -3.32 2.24 0.04
b_code 2.10 2.07 -1.24 4.71 0.59 17.39 -79.68 68.46 0.91
b_trial -0.36 0.22 -0.70 -0.02 -0.51 1.28 -4.64 3.06 0.14
code 69.48 9.60 51.98 79.37 75.52 27.03 21.09 272.64 1.00
code_rev -69.83 10.08 -82.01 -52.74 -78.00 25.80 -183.04 -26.96 1.00
processing a -0.14 0.26 -0.49 0.19 0.05 1.10 -5.12 3.53 0.09
a_trial -0.14 0.26 -0.45 0.20 0.05 1.10 -5.56 3.21 0.08
b -0.57 0.59 -1.35 0.46 0.07 1.06 -3.04 2.83 0.07
b_code -1.84 10.36 -14.70 16.28 9.38 20.10 -51.61 101.56 0.92
b_trial -0.76 0.82 -1.70 0.69 0.15 1.46 -4.04 4.12 0.19
code 71.37 10.61 57.39 92.24 68.11 24.53 21.16 219.68 1.00
code_rev -73.46 8.79 -86.45 -61.80 -72.93 26.19 -215.93 -17.15 1.00
processing_900 a -0.14 0.32 -0.59 0.22 0.12 1.14 -3.09 4.72 0.09
b -0.44 0.60 -1.27 0.35 0.08 1.05 -3.27 3.08 0.07
delta-theta maintenance a -0.08 0.20 -0.39 0.15 -0.20 1.06 -3.66 4.13 0.07
a_trial -0.08 0.26 -0.41 0.39 -0.24 1.21 -5.06 4.94 0.11
b -0.44 0.26 -0.67 0.05 -0.55 0.58 -2.13 1.23 0.01
b_code -0.31 10.68 -10.23 15.80 -4.42 29.10 -275.37 140.50 0.90
b_trial -0.85 0.48 -1.27 0.06 -1.05 1.17 -5.67 1.99 0.20
code 58.67 11.42 39.83 70.74 58.45 46.51 -1.51 512.32 1.00
code_rev -55.47 7.16 -67.46 -48.16 -56.63 45.52 -526.08 -2.33 1.00
processing a -0.17 0.16 -0.45 -0.00 -0.13 1.03 -3.39 3.55 0.07
a_trial -0.21 0.20 -0.59 -0.01 -0.13 1.17 -4.86 5.31 0.09
b -0.43 0.34 -1.10 -0.11 -0.29 0.59 -2.11 1.64 0.00
b_code -0.12 9.57 -18.83 7.16 4.78 27.06 -142.02 480.10 0.89
b_trial -0.76 0.68 -2.15 -0.23 -0.49 0.99 -4.38 2.60 0.07
code 50.87 12.24 37.19 69.39 49.21 37.41 -0.07 333.58 1.00
code_rev -52.32 12.69 -75.56 -39.71 -50.63 49.02 -639.52 3.82 0.99
processing_900 a -0.14 0.17 -0.34 0.08 -0.07 1.03 -3.12 3.55 0.07
b -0.30 0.43 -0.94 0.42 -0.23 0.70 -2.30 2.03 0.01
print("Calibration on the data: processing PSI with each PFC trial paired with another trial's parietal data")
print("(trial order shuffled within subject, so no trial-locked coupling; a calibrated z has mean near 0, SD near 1, and |z| > 1.96 in about 5% of pairs)")
rows = []
SURMEAN = {}
for band in fcx3.BANDS:
for k in ("a", "b", "a_trial", "b_trial", "b_code"):
z = np.concatenate([RES[sid]["psi_surrogate"][band][k] for sid in fcx3.SUBJECTS])
by = {sid: round(float(np.mean(np.abs(RES[sid]["psi_surrogate"][band][k]) > 1.96)), 2) for sid in fcx3.SUBJECTS}
SURMEAN[(band, k)] = pd.Series({sid: float(np.mean(RES[sid]["psi_surrogate"][band][k])) for sid in fcx3.SUBJECTS})
rows.append({"band": band, "reading": READ[k], "pairs": len(z), "fraction |z| > 1.96": round(float(np.mean(np.abs(z) > 1.96)), 3),
"mean of z": round(float(z.mean()), 2), "SD of z": round(float(z.std()), 2), "|z| > 1.96 by subject": by})
print(pd.DataFrame(rows).to_string(index=False))
print("\nSurrogate mean z per subject (over the subject's pairs):")
print(pd.DataFrame({f"{b} {k}": v for (b, k), v in SURMEAN.items() if k != "b_code"}).round(2).T.to_string())
print("Trials left in place by the shuffle:", {sid: RES[sid]["psi_surrogate"]["delta-theta"]["same_trial_fraction"] for sid in fcx3.SUBJECTS})
Calibration on the data: processing PSI with each PFC trial paired with another trial's parietal data
(trial order shuffled within subject, so no trial-locked coupling; a calibrated z has mean near 0, SD near 1, and |z| > 1.96 in about 5% of pairs)
band reading pairs fraction |z| > 1.96 mean of z SD of z |z| > 1.96 by subject
delta-theta (a) trial-averaged coherency 1135 0.060 -0.05 1.01 {'s1': 0.14, 's2': 0.04, 's3': 0.06, 's4': 0.0, 's5': 0.08, 's6': 0.06, 's7': 0.1}
delta-theta (b) per-trial PSI averaged 1135 0.001 -0.29 0.60 {'s1': 0.0, 's2': 0.0, 's3': 0.0, 's4': 0.0, 's5': 0.0, 's6': 0.0, 's7': 0.0}
delta-theta (a), one permutation per trial (P1 null (b)) 1135 0.066 -0.06 1.02 {'s1': 0.14, 's2': 0.08, 's3': 0.05, 's4': 0.13, 's5': 0.08, 's6': 0.06, 's7': 0.15}
delta-theta (b), one permutation per trial (P1 null (b)) 1135 0.067 -0.51 1.00 {'s1': 0.29, 's2': 0.02, 's3': 0.06, 's4': 0.2, 's5': 0.09, 's6': 0.03, 's7': 0.05}
delta-theta (b) against psianalysis.m's null (variant) 1135 0.900 4.35 26.01 {'s1': 0.86, 's2': 0.89, 's3': 0.91, 's4': 0.9, 's5': 0.86, 's6': 0.91, 's7': 0.95}
alpha-beta (a) trial-averaged coherency 1135 0.069 0.02 1.04 {'s1': 0.05, 's2': 0.07, 's3': 0.07, 's4': 0.07, 's5': 0.07, 's6': 0.06, 's7': 0.0}
alpha-beta (b) per-trial PSI averaged 1135 0.063 0.15 1.04 {'s1': 0.24, 's2': 0.05, 's3': 0.06, 's4': 0.03, 's5': 0.06, 's6': 0.12, 's7': 0.0}
alpha-beta (a), one permutation per trial (P1 null (b)) 1135 0.063 0.02 1.04 {'s1': 0.05, 's2': 0.07, 's3': 0.06, 's4': 0.03, 's5': 0.05, 's6': 0.09, 's7': 0.05}
alpha-beta (b), one permutation per trial (P1 null (b)) 1135 0.171 0.18 1.41 {'s1': 0.48, 's2': 0.16, 's3': 0.16, 's4': 0.37, 's5': 0.14, 's6': 0.34, 's7': 0.05}
alpha-beta (b) against psianalysis.m's null (variant) 1135 0.920 9.11 19.35 {'s1': 0.9, 's2': 0.9, 's3': 0.94, 's4': 0.97, 's5': 0.85, 's6': 0.91, 's7': 0.8}
Surrogate mean z per subject (over the subject's pairs):
s1 s2 s3 s4 s5 s6 s7
delta-theta a -0.13 -0.10 -0.10 0.15 0.12 0.36 0.13
delta-theta b -0.88 -0.19 -0.23 -0.57 -0.53 -0.34 0.15
delta-theta a_trial -0.26 -0.07 -0.13 0.15 0.15 0.33 0.15
delta-theta b_trial -1.69 -0.31 -0.44 -1.06 -0.80 -0.50 0.15
alpha-beta a 0.01 -0.12 0.09 -0.38 -0.02 -0.40 -0.08
alpha-beta b -1.17 -0.40 0.52 -0.55 -0.60 -1.25 0.03
alpha-beta a_trial 0.04 -0.12 0.09 -0.36 -0.02 -0.48 -0.11
alpha-beta b_trial -1.67 -0.59 0.69 -0.89 -0.81 -1.61 0.06
Trials left in place by the shuffle: {'s1': 0.0, 's2': 0.0, 's3': 0.0, 's4': 0.017857142857142856, 's5': 0.0, 's6': 0.0, 's7': 0.0}
# Calibration on synthetic data (no data set files): independent PFC and parietal signals, so the true PSI is 0.
# 33 trials of 1/f or 1/f^2 noise, 900-ms segments, the same FFT, ERP removal and null as above (300 shuffles here).
# 'b, segment centred' moves the FFT's time origin to the centre of the segment (a diagnostic, not a reading).
rng_s = np.random.default_rng(fcx3.seed("synthetic"))
fs_s, n_s = 1000, 1300
t_s = np.arange(n_s) / fs_s - 0.2
def noise(kind, n_tr, n_ch):
w = rng_s.standard_normal((n_tr, n_ch, n_s))
if kind == "1/f^2":
return np.cumsum(w, -1)
f = np.fft.rfftfreq(n_s, 1 / fs_s)
f[0] = 1
return np.fft.irfft(np.fft.rfft(w, axis=-1) / np.sqrt(f), n=n_s, axis=-1)
rows = []
for kind in ("1/f", "1/f^2"):
for band, (lo, hi) in fcx3.BANDS.items():
zs = {}
for rep in range(40):
x = np.concatenate([noise(kind, 33, 4), noise(kind, 33, 4)], 1)
F, fr = fcx3.fft_segment(x, t_s, fs_s, (0.0, 0.9), np.arange(lo, hi + 1))
F = F - F.mean(0, keepdims=True)
ia_s, ib_s = np.repeat(np.arange(4), 4), np.tile(np.arange(4), 4)
out = fcx3.psi_z(F[:, :4, :, None], F[:, 4:, :, None], ia_s, ib_s, rng_s, n_perm=300, trial_null=True)
Fc = F * np.exp(2j * np.pi * fr * 0.45) # origin at the segment's centre (0.45 s)
out["b, segment centred"] = fcx3.psi_z(Fc[:, :4, :, None], Fc[:, 4:, :, None], ia_s, ib_s, rng_s, n_perm=300)["b"]
for k, v in out.items():
zs.setdefault(k, []).append(v[:, 0])
for k, v in zs.items():
v = np.concatenate(v)
rows.append({"noise": kind, "band": band, "reading": READ.get(k, k), "mean of z": round(float(v.mean()), 2),
"SE of mean (by run)": round(float(np.std([np.mean(u) for u in zs[k]], ddof=1) / np.sqrt(len(zs[k]))), 2),
"SD of z": round(float(v.std()), 2), "fraction |z| > 1.96": round(float(np.mean(np.abs(v) > 1.96)), 3)})
print(pd.DataFrame(rows).to_string(index=False))
noise band reading mean of z SE of mean (by run) SD of z fraction |z| > 1.96 1/f delta-theta (a) trial-averaged coherency -0.10 0.05 1.09 0.075 1/f delta-theta (b) per-trial PSI averaged -0.37 0.05 0.74 0.014 1/f delta-theta (a), one permutation per trial (P1 null (b)) -0.10 0.05 1.13 0.080 1/f delta-theta (b), one permutation per trial (P1 null (b)) -0.50 0.06 0.94 0.061 1/f delta-theta b, segment centred -0.06 0.06 1.06 0.066 1/f alpha-beta (a) trial-averaged coherency -0.09 0.04 1.00 0.064 1/f alpha-beta (b) per-trial PSI averaged -0.29 0.08 1.01 0.052 1/f alpha-beta (a), one permutation per trial (P1 null (b)) -0.09 0.04 1.02 0.055 1/f alpha-beta (b), one permutation per trial (P1 null (b)) -0.35 0.09 1.17 0.102 1/f alpha-beta b, segment centred -0.02 0.09 1.18 0.083 1/f^2 delta-theta (a) trial-averaged coherency -0.07 0.04 0.93 0.039 1/f^2 delta-theta (b) per-trial PSI averaged -0.21 0.05 0.85 0.020 1/f^2 delta-theta (a), one permutation per trial (P1 null (b)) -0.06 0.04 0.99 0.058 1/f^2 delta-theta (b), one permutation per trial (P1 null (b)) -0.26 0.06 1.01 0.056 1/f^2 delta-theta b, segment centred 0.12 0.06 1.09 0.070 1/f^2 alpha-beta (a) trial-averaged coherency -0.15 0.05 1.09 0.081 1/f^2 alpha-beta (b) per-trial PSI averaged -0.25 0.07 0.96 0.039 1/f^2 alpha-beta (a), one permutation per trial (P1 null (b)) -0.15 0.04 1.13 0.087 1/f^2 alpha-beta (b), one permutation per trial (P1 null (b)) -0.29 0.09 1.10 0.080 1/f^2 alpha-beta b, segment centred 0.05 0.09 1.13 0.072
print("fig4-maintenance-parietal-led: expected delta-theta -40.03 (tol 4.0 or more negative), alpha-beta -30.37 (tol 3.04 or more negative)")
for k in ("a", "b", "a_trial", "b_trial", "b_code", "code", "code_rev"):
m = persub.xs(("maintenance", k), level=("interval", "reading"))
for band, exp, tol in [("delta-theta", -40.03, 4.0), ("alpha-beta", -30.37, 3.04)]:
v = m.loc[band]
pooled = PSI[(PSI.band == band) & (PSI.interval == "maintenance") & (PSI.reading == k)].z
print(f" {READ[k]}, {band}: subjects below -1.96: {int((v < -1.96).sum())}/7; mean over subjects {v.mean():.2f} +- {v.std(ddof=1):.2f};"
f" pooled pairs {pooled.mean():.2f} +- {pooled.std(ddof=1):.2f}; pairs below -1.96 {int((pooled < -1.96).sum())}/{len(pooled)},"
f" above 1.96 {int((pooled > 1.96).sum())}; within tolerance or beyond: (a) {v.mean() <= exp + tol}, (b) {pooled.mean() <= exp + tol}")
fig4-maintenance-parietal-led: expected delta-theta -40.03 (tol 4.0 or more negative), alpha-beta -30.37 (tol 3.04 or more negative) (a) trial-averaged coherency, delta-theta: subjects below -1.96: 0/7; mean over subjects -0.08 +- 0.20; pooled pairs -0.20 +- 1.06; pairs below -1.96 46/1135, above 1.96 35; within tolerance or beyond: (a) False, (b) False (a) trial-averaged coherency, alpha-beta: subjects below -1.96: 0/7; mean over subjects -0.24 +- 0.25; pooled pairs -0.06 +- 1.05; pairs below -1.96 48/1135, above 1.96 29; within tolerance or beyond: (a) False, (b) False (b) per-trial PSI averaged, delta-theta: subjects below -1.96: 0/7; mean over subjects -0.44 +- 0.26; pooled pairs -0.55 +- 0.58; pairs below -1.96 8/1135, above 1.96 0; within tolerance or beyond: (a) False, (b) False (b) per-trial PSI averaged, alpha-beta: subjects below -1.96: 0/7; mean over subjects -0.26 +- 0.14; pooled pairs -0.36 +- 0.91; pairs below -1.96 39/1135, above 1.96 1; within tolerance or beyond: (a) False, (b) False (a), one permutation per trial (P1 null (b)), delta-theta: subjects below -1.96: 0/7; mean over subjects -0.08 +- 0.26; pooled pairs -0.24 +- 1.21; pairs below -1.96 83/1135, above 1.96 37; within tolerance or beyond: (a) False, (b) False (a), one permutation per trial (P1 null (b)), alpha-beta: subjects below -1.96: 0/7; mean over subjects -0.24 +- 0.27; pooled pairs -0.07 +- 1.07; pairs below -1.96 49/1135, above 1.96 29; within tolerance or beyond: (a) False, (b) False (b), one permutation per trial (P1 null (b)), delta-theta: subjects below -1.96: 0/7; mean over subjects -0.85 +- 0.48; pooled pairs -1.05 +- 1.17; pairs below -1.96 224/1135, above 1.96 1; within tolerance or beyond: (a) False, (b) False (b), one permutation per trial (P1 null (b)), alpha-beta: subjects below -1.96: 0/7; mean over subjects -0.36 +- 0.22; pooled pairs -0.51 +- 1.28; pairs below -1.96 141/1135, above 1.96 21; within tolerance or beyond: (a) False, (b) False (b) against psianalysis.m's null (variant), delta-theta: subjects below -1.96: 4/7; mean over subjects -0.31 +- 10.68; pooled pairs -4.42 +- 29.10; pairs below -1.96 564/1135, above 1.96 462; within tolerance or beyond: (a) False, (b) False (b) against psianalysis.m's null (variant), alpha-beta: subjects below -1.96: 0/7; mean over subjects 2.10 +- 2.07; pooled pairs 0.59 +- 17.39; pairs below -1.96 493/1135, above 1.96 539; within tolerance or beyond: (a) False, (b) False deposited code, PFC first (not a reading), delta-theta: subjects below -1.96: 0/7; mean over subjects 58.67 +- 11.42; pooled pairs 58.45 +- 46.51; pairs below -1.96 0/1135, above 1.96 1134; within tolerance or beyond: (a) False, (b) False deposited code, PFC first (not a reading), alpha-beta: subjects below -1.96: 0/7; mean over subjects 69.48 +- 9.60; pooled pairs 75.52 +- 27.03; pairs below -1.96 0/1135, above 1.96 1135; within tolerance or beyond: (a) False, (b) False deposited code, parietal first, sign reversed (not a reading), delta-theta: subjects below -1.96: 7/7; mean over subjects -55.47 +- 7.16; pooled pairs -56.63 +- 45.52; pairs below -1.96 1135/1135, above 1.96 0; within tolerance or beyond: (a) True, (b) True deposited code, parietal first, sign reversed (not a reading), alpha-beta: subjects below -1.96: 7/7; mean over subjects -69.83 +- 10.08; pooled pairs -78.00 +- 25.80; pairs below -1.96 1135/1135, above 1.96 0; within tolerance or beyond: (a) True, (b) True
Result: not reproduced. Under no PSI reading is maintenance parietal-led in any subject. Under reading (a), adopted, subject means are -0.39 to 0.15 (delta-theta, mean -0.08 +- 0.20) and -0.67 to 0.04 (alpha-beta, -0.24 +- 0.25); under reading (b) -0.67 to 0.05 and -0.48 to -0.05; with one permutation per trial the lowest subject mean is -1.27; none is below -1.96. The paper reports -40.03 +- 8.73 and -30.37 +- 2.60. Against psianalysis.m's null, reading (b) puts 4 of 7 subjects below -1.96 in delta-theta (mean -0.31 +- 10.68) and none in alpha-beta, but that null gives |z| > 1.96 in 90% and 92% of trial-shuffled pairs, so it does not measure direction. The deposited code without the conjugate gives every subject below -1.96 with the parietal channel first (means -55.47 and -69.83) and above +1.96 with the PFC channel first (+58.67 and +69.48); its sign follows the channel order.
LME = {}
for band in fcx3.BANDS:
for k in ("a", "b", "a_trial", "b_trial", "b_code", "code", "code_rev"):
d = PSI[(PSI.band == band) & (PSI.reading == k)].pivot_table(index=["subject", "pair"], columns="interval", values="z").reset_index()
eff, F, p, n = fcx3.paired_lme(d.maintenance.values, d.processing.values, d.subject.values)
LME[(band, k)] = (eff, F, p, n)
line = f"{band}, {READ[k]}: processing - maintenance {eff:.2f}, F(1,{2 * n - 2}) = {F:.1f}, p = {p:.3g} (pairs {n})"
if k in ("a", "b"):
e2, F2, p2 = fcx3.mixedlm_check(d.maintenance.values, d.processing.values, d.subject.values, d.pair.values)
line += f"; statsmodels MixedLM: {e2:.2f}, F {F2:.1f}, p {p2:.3g}"
# pairs share electrodes; a subject-level test does not treat them as independent
ps = d.groupby("subject")[["maintenance", "processing"]].mean()
tt = stats.ttest_rel(ps.processing, ps.maintenance)
line += f"; subject means, paired t(6) = {tt.statistic:.2f}, p {tt.pvalue:.3g}"
print(line)
print("Paper: delta-theta F(1,2256) = 1936.10, p < 8e-306; alpha-beta F(1,2256) = 2302.30, p = 0 (processing > maintenance).")
delta-theta, (a) trial-averaged coherency: processing - maintenance 0.06, F(1,2268) = 2.2, p = 0.14 (pairs 1135); statsmodels MixedLM: 0.06, F 2.2, p 0.14; subject means, paired t(6) = -0.85, p 0.43
/home/runner/work/_temp/executed/.venv/lib/python3.13/site-packages/statsmodels/base/model.py:589: SingularMatrixWarning: Random effects covariance is singular return -self.score(params, *args) / nobs
/home/runner/work/_temp/executed/.venv/lib/python3.13/site-packages/statsmodels/base/model.py:589: SingularMatrixWarning: Random effects covariance is singular return -self.score(params, *args) / nobs
/home/runner/work/encore/encore/entries/crcns-fcx-3-johnson-2019/fcx3.py:709: ConvergenceWarning: The MLE may be on the boundary of the parameter space. r = m.fit(reml=True)
delta-theta, (b) per-trial PSI averaged: processing - maintenance 0.27, F(1,2268) = 114.2, p = 4.93e-26 (pairs 1135); statsmodels MixedLM: 0.27, F 116.4, p 1.66e-26; subject means, paired t(6) = 0.07, p 0.947 delta-theta, (a), one permutation per trial (P1 null (b)): processing - maintenance 0.10, F(1,2268) = 4.3, p = 0.038 (pairs 1135) delta-theta, (b), one permutation per trial (P1 null (b)): processing - maintenance 0.56, F(1,2268) = 153.4, p = 3.93e-34 (pairs 1135) delta-theta, (b) against psianalysis.m's null (variant): processing - maintenance 9.20, F(1,2268) = 58.5, p = 2.97e-14 (pairs 1135) delta-theta, deposited code, PFC first (not a reading): processing - maintenance -9.24, F(1,2268) = 27.4, p = 1.83e-07 (pairs 1135) delta-theta, deposited code, parietal first, sign reversed (not a reading): processing - maintenance 6.00, F(1,2268) = 9.1, p = 0.00252 (pairs 1135)
alpha-beta, (a) trial-averaged coherency: processing - maintenance 0.11, F(1,2268) = 6.7, p = 0.00965 (pairs 1135); statsmodels MixedLM: 0.11, F 6.7, p 0.00965; subject means, paired t(6) = 0.75, p 0.483
/home/runner/work/_temp/executed/.venv/lib/python3.13/site-packages/statsmodels/base/model.py:589: SingularMatrixWarning: Random effects covariance is singular return -self.score(params, *args) / nobs
/home/runner/work/encore/encore/entries/crcns-fcx-3-johnson-2019/fcx3.py:709: ConvergenceWarning: The MLE may be on the boundary of the parameter space. r = m.fit(reml=True)
alpha-beta, (b) per-trial PSI averaged: processing - maintenance 0.43, F(1,2268) = 97.9, p = 1.24e-22 (pairs 1135); statsmodels MixedLM: 0.43, F 107.1, p 1.5e-24; subject means, paired t(6) = -1.22, p 0.267 alpha-beta, (a), one permutation per trial (P1 null (b)): processing - maintenance 0.12, F(1,2268) = 7.2, p = 0.00723 (pairs 1135) alpha-beta, (b), one permutation per trial (P1 null (b)): processing - maintenance 0.66, F(1,2268) = 119.1, p = 4.57e-27 (pairs 1135) alpha-beta, (b) against psianalysis.m's null (variant): processing - maintenance 8.79, F(1,2268) = 115.3, p = 2.85e-26 (pairs 1135) alpha-beta, deposited code, PFC first (not a reading): processing - maintenance -7.41, F(1,2268) = 47.9, p = 5.85e-12 (pairs 1135) alpha-beta, deposited code, parietal first, sign reversed (not a reading): processing - maintenance 5.07, F(1,2268) = 21.9, p = 2.98e-06 (pairs 1135) Paper: delta-theta F(1,2256) = 1936.10, p < 8e-306; alpha-beta F(1,2256) = 2302.30, p = 0 (processing > maintenance).
print("fig4a-delta-theta-shift: expected 6 subjects with processing z > 0, mean 6.01 (tol 0.6 or larger), F 1936.10 +- 193.6")
for k in ("a", "b", "a_trial", "b_trial", "b_code", "code", "code_rev"):
v = persub.loc[("delta-theta", "processing", k)]
pos = v[v > 0]
eff, F, p, n = LME[("delta-theta", k)]
print(f" {READ[k]}: subjects above 0: {int((v > 0).sum())}/7 {list(v[v > 0].index)}; mean of 7 {v.mean():.2f} +- {v.std(ddof=1):.2f};"
f" mean of those above 0 {pos.mean() if len(pos) else float('nan'):.2f}; model effect {eff:+.2f}, F {F:.1f}, p {p:.3g}")
print("fig4c-alpha-beta-shift: expected every subject below 0 in processing, mean -12.60 (tol 1.26 or more negative), F 2302.30 +- 230.2")
for k in ("a", "b", "a_trial", "b_trial", "b_code", "code", "code_rev"):
v = persub.loc[("alpha-beta", "processing", k)]
eff, F, p, n = LME[("alpha-beta", k)]
print(f" {READ[k]}: subjects below 0: {int((v < 0).sum())}/7; mean {v.mean():.2f} +- {v.std(ddof=1):.2f}; model effect {eff:+.2f}, F {F:.1f}, p {p:.3g}")
print("\nfig4c: processing alpha-beta subject means against the same subject's trial-shuffled surrogate mean (an offset of the null shows in both)")
for k in ("a", "b", "a_trial", "b_trial"):
v = persub.loc[("alpha-beta", "processing", k)]
d = v - SURMEAN[("alpha-beta", k)]
print(f" {READ[k]}: observed {v.round(2).to_dict()}; surrogate {SURMEAN[('alpha-beta', k)].round(2).to_dict()};"
f" subjects below their surrogate {int((d < 0).sum())}/7; observed - surrogate {d.mean():.2f} +- {d.std(ddof=1):.2f}, paired t(6) p {stats.ttest_1samp(d, 0).pvalue:.3g}")
print("\nProcessing PSI on the 900-ms-delay trials only (subject means):")
for band in fcx3.BANDS:
for k in ("a", "b"):
v = persub.loc[(band, "processing_900", k)]
print(f" {band}, {READ[k]}: above 0 {int((v > 0).sum())}/7, below 0 {int((v < 0).sum())}/7; mean {v.mean():.2f} +- {v.std(ddof=1):.2f}; {v.round(2).to_dict()}")
fig4a-delta-theta-shift: expected 6 subjects with processing z > 0, mean 6.01 (tol 0.6 or larger), F 1936.10 +- 193.6
(a) trial-averaged coherency: subjects above 0: 0/7 []; mean of 7 -0.17 +- 0.16; mean of those above 0 nan; model effect +0.06, F 2.2, p 0.14
(b) per-trial PSI averaged: subjects above 0: 0/7 []; mean of 7 -0.43 +- 0.34; mean of those above 0 nan; model effect +0.27, F 114.2, p 4.93e-26
(a), one permutation per trial (P1 null (b)): subjects above 0: 0/7 []; mean of 7 -0.21 +- 0.20; mean of those above 0 nan; model effect +0.10, F 4.3, p 0.038
(b), one permutation per trial (P1 null (b)): subjects above 0: 0/7 []; mean of 7 -0.76 +- 0.68; mean of those above 0 nan; model effect +0.56, F 153.4, p 3.93e-34
(b) against psianalysis.m's null (variant): subjects above 0: 4/7 ['s2', 's3', 's6', 's7']; mean of 7 -0.12 +- 9.57; mean of those above 0 6.36; model effect +9.20, F 58.5, p 2.97e-14
deposited code, PFC first (not a reading): subjects above 0: 7/7 ['s1', 's2', 's3', 's4', 's5', 's6', 's7']; mean of 7 50.87 +- 12.24; mean of those above 0 50.87; model effect -9.24, F 27.4, p 1.83e-07
deposited code, parietal first, sign reversed (not a reading): subjects above 0: 0/7 []; mean of 7 -52.32 +- 12.69; mean of those above 0 nan; model effect +6.00, F 9.1, p 0.00252
fig4c-alpha-beta-shift: expected every subject below 0 in processing, mean -12.60 (tol 1.26 or more negative), F 2302.30 +- 230.2
(a) trial-averaged coherency: subjects below 0: 5/7; mean -0.14 +- 0.26; model effect +0.11, F 6.7, p 0.00965
(b) per-trial PSI averaged: subjects below 0: 6/7; mean -0.57 +- 0.59; model effect +0.43, F 97.9, p 1.24e-22
(a), one permutation per trial (P1 null (b)): subjects below 0: 5/7; mean -0.14 +- 0.26; model effect +0.12, F 7.2, p 0.00723
(b), one permutation per trial (P1 null (b)): subjects below 0: 6/7; mean -0.76 +- 0.82; model effect +0.66, F 119.1, p 4.57e-27
(b) against psianalysis.m's null (variant): subjects below 0: 5/7; mean -1.84 +- 10.36; model effect +8.79, F 115.3, p 2.85e-26
deposited code, PFC first (not a reading): subjects below 0: 0/7; mean 71.37 +- 10.61; model effect -7.41, F 47.9, p 5.85e-12
deposited code, parietal first, sign reversed (not a reading): subjects below 0: 7/7; mean -73.46 +- 8.79; model effect +5.07, F 21.9, p 2.98e-06
fig4c: processing alpha-beta subject means against the same subject's trial-shuffled surrogate mean (an offset of the null shows in both)
(a) trial-averaged coherency: observed {'s1': -0.31, 's2': -0.05, 's3': 0.18, 's4': -0.16, 's5': -0.31, 's6': -0.49, 's7': 0.19}; surrogate {'s1': 0.01, 's2': -0.12, 's3': 0.09, 's4': -0.38, 's5': -0.02, 's6': -0.4, 's7': -0.08}; subjects below their surrogate 3/7; observed - surrogate -0.01 +- 0.23, paired t(6) p 0.934
(b) per-trial PSI averaged: observed {'s1': -1.07, 's2': -0.51, 's3': 0.46, 's4': -0.61, 's5': -0.72, 's6': -1.35, 's7': -0.18}; surrogate {'s1': -1.17, 's2': -0.4, 's3': 0.52, 's4': -0.55, 's5': -0.6, 's6': -1.25, 's7': 0.03}; subjects below their surrogate 6/7; observed - surrogate -0.08 +- 0.09, paired t(6) p 0.0609
(a), one permutation per trial (P1 null (b)): observed {'s1': -0.33, 's2': -0.04, 's3': 0.18, 's4': -0.22, 's5': -0.3, 's6': -0.45, 's7': 0.2}; surrogate {'s1': 0.04, 's2': -0.12, 's3': 0.09, 's4': -0.36, 's5': -0.02, 's6': -0.48, 's7': -0.11}; subjects below their surrogate 2/7; observed - surrogate -0.00 +- 0.24, paired t(6) p 0.963
(b), one permutation per trial (P1 null (b)): observed {'s1': -1.61, 's2': -0.66, 's3': 0.69, 's4': -0.86, 's5': -0.98, 's6': -1.7, 's7': -0.22}; surrogate {'s1': -1.67, 's2': -0.59, 's3': 0.69, 's4': -0.89, 's5': -0.81, 's6': -1.61, 's7': 0.06}; subjects below their surrogate 4/7; observed - surrogate -0.07 +- 0.12, paired t(6) p 0.159
Processing PSI on the 900-ms-delay trials only (subject means):
delta-theta, (a) trial-averaged coherency: above 0 2/7, below 0 5/7; mean -0.14 +- 0.17; {'s1': -0.16, 's2': 0.01, 's3': -0.04, 's4': -0.34, 's5': -0.2, 's6': -0.34, 's7': 0.08}
delta-theta, (b) per-trial PSI averaged: above 0 1/7, below 0 6/7; mean -0.30 +- 0.43; {'s1': -0.94, 's2': -0.31, 's3': -0.17, 's4': -0.6, 's5': -0.41, 's6': -0.07, 's7': 0.42}
alpha-beta, (a) trial-averaged coherency: above 0 3/7, below 0 4/7; mean -0.14 +- 0.32; {'s1': -0.54, 's2': 0.18, 's3': 0.22, 's4': 0.01, 's5': -0.13, 's6': -0.59, 's7': -0.15}
alpha-beta, (b) per-trial PSI averaged: above 0 1/7, below 0 6/7; mean -0.44 +- 0.60; {'s1': -1.21, 's2': -0.24, 's3': 0.35, 's4': -0.27, 's5': -0.4, 's6': -1.27, 's7': -0.05}
Result: not reproduced. No subject has net delta-theta PSI z above 0 in processing under any reading (means -0.17 +- 0.16 under reading (a), adopted, and -0.43 +- 0.34 under (b); -0.21 and -0.76 with one permutation per trial; paper 6.01 +- 6.42 with 6 subjects above 0). Processing exceeds maintenance in the pair-level model under reading (b) (by 0.27, F(1,2268) = 114.2, p = 4.9e-26; paper F = 1936.10) but not under reading (a) (0.06, F = 2.2, p = 0.14), and on subject means the difference is absent under both (paired t(6) p = 0.43 and 0.95). The criterion's partial match needs at least 4 subjects above 0. Against psianalysis.m's null, reading (b) gives 4 subjects above 0 (mean of those 6.36) and F = 58.5, but that null is not calibrated (trial-shuffled pairs pass |z| > 1.96 in 90% of cases). On the 900-ms-delay trials alone 2 (a) or 1 (b) subjects are above 0 (means -0.14 and -0.30).
Result: not reproduced, resting on PSI reading (a). Under reading (a), whose z is calibrated and which is adopted, 5 of 7 subjects have processing alpha-beta PSI z below 0 (mean -0.14 +- 0.26), fewer than the 6 the partial match needs, and processing is higher than maintenance by 0.11 in the pair-level model (F = 6.7, p = 0.0097; paper F = 2302.30); one permutation per trial gives the same 5 of 7. Observed minus the trial-shuffled surrogate is -0.01 +- 0.23 (p = 0.93). Under reading (b), 6 of 7 subjects are below 0 (S3 is above, 0.46) and processing exceeds maintenance (by 0.43, F(1,2268) = 97.9, p = 1.2e-22), which would be the partial match by the letter, but the outputs above show that this comes from reading (b)'s null. On the trial-shuffled data, which have no trial-locked coupling, reading (b) gives subject means of -1.17, -0.40, 0.52, -0.55, -0.60, -1.25 and 0.03 (S1 to S7), close to the observed -1.07, -0.51, 0.46, -0.61, -0.72, -1.35 and -0.18 (observed minus surrogate -0.08 +- 0.09, paired t(6) p = 0.061), and on synthetic independent signals reading (b)'s mean z is -0.25 to -0.29 in alpha-beta. The second verification round reviewed partially reproduced under reading (b); the change was proposed and the third round agreed. Subject means are -0.49 to 0.19 under (a) and -1.35 to 0.46 under (b), against the paper's -12.60 +- 7.51; on subject means the interval difference is not significant under either reading (paired t(6) p = 0.48 and 0.27). On the 900-ms-delay trials alone 4 (a) or 6 (b) subjects are below 0.
print("directional-pairs: pairs with processing |z| > 1.96, expected delta-theta 1008 (+-100.8), alpha-beta 984 (+-98.4), of all pairs")
SEL = {}
for k in ("a", "b", "a_trial", "b_trial", "b_code", "code", "code_rev"):
for band, exp in [("delta-theta", 1008), ("alpha-beta", 984)]:
p = PSI[(PSI.band == band) & (PSI.interval == "processing") & (PSI.reading == k)]
n = int((p.z.abs() > 1.96).sum())
SEL[(band, k)] = set(p.pair[p.z.abs() > 1.96])
sur = ""
if k in ("a", "b", "a_trial", "b_trial", "b_code"):
zs = np.concatenate([RES[sid]["psi_surrogate"][band][k] for sid in fcx3.SUBJECTS])
sur = f"; trial-shuffled surrogate {int((np.abs(zs) > 1.96).sum())}"
print(f" {READ[k]}, {band}: {n} of {len(p)} ({n / len(p):.1%}); within tolerance {abs(n - exp) <= 0.1 * exp}{sur};"
f" by subject {p[p.z.abs() > 1.96].groupby('subject').size().to_dict()}")
print("Expected under a calibrated null with |z| > 1.96 at 5%:", round(0.05 * len(p)))
directional-pairs: pairs with processing |z| > 1.96, expected delta-theta 1008 (+-100.8), alpha-beta 984 (+-98.4), of all pairs
(a) trial-averaged coherency, delta-theta: 78 of 1135 (6.9%); within tolerance False; trial-shuffled surrogate 68; by subject {'s1': 2, 's2': 8, 's3': 50, 's4': 5, 's5': 6, 's6': 4, 's7': 3}
(a) trial-averaged coherency, alpha-beta: 104 of 1135 (9.2%); within tolerance False; trial-shuffled surrogate 78; by subject {'s1': 2, 's2': 13, 's3': 62, 's4': 3, 's5': 21, 's6': 2, 's7': 1}
(b) per-trial PSI averaged, delta-theta: 1 of 1135 (0.1%); within tolerance False; trial-shuffled surrogate 1; by subject {'s1': 1}
(b) per-trial PSI averaged, alpha-beta: 74 of 1135 (6.5%); within tolerance False; trial-shuffled surrogate 71; by subject {'s1': 5, 's2': 6, 's3': 44, 's4': 2, 's5': 14, 's6': 3}
(a), one permutation per trial (P1 null (b)), delta-theta: 98 of 1135 (8.6%); within tolerance False; trial-shuffled surrogate 75; by subject {'s1': 1, 's2': 10, 's3': 62, 's4': 10, 's5': 6, 's6': 6, 's7': 3}
(a), one permutation per trial (P1 null (b)), alpha-beta: 93 of 1135 (8.2%); within tolerance False; trial-shuffled surrogate 71; by subject {'s1': 2, 's2': 8, 's3': 56, 's4': 4, 's5': 20, 's6': 1, 's7': 2}
(b), one permutation per trial (P1 null (b)), delta-theta: 78 of 1135 (6.9%); within tolerance False; trial-shuffled surrogate 76; by subject {'s1': 12, 's2': 2, 's3': 48, 's4': 3, 's5': 12, 's7': 1}
(b), one permutation per trial (P1 null (b)), alpha-beta: 211 of 1135 (18.6%); within tolerance False; trial-shuffled surrogate 194; by subject {'s1': 11, 's2': 11, 's3': 141, 's4': 7, 's5': 30, 's6': 11}
(b) against psianalysis.m's null (variant), delta-theta: 1014 of 1135 (89.3%); within tolerance True; trial-shuffled surrogate 1022; by subject {'s1': 20, 's2': 95, 's3': 679, 's4': 27, 's5': 142, 's6': 31, 's7': 20}
(b) against psianalysis.m's null (variant), alpha-beta: 1041 of 1135 (91.7%); within tolerance True; trial-shuffled surrogate 1044; by subject {'s1': 20, 's2': 105, 's3': 704, 's4': 27, 's5': 135, 's6': 31, 's7': 19}
deposited code, PFC first (not a reading), delta-theta: 1133 of 1135 (99.8%); within tolerance False; by subject {'s1': 21, 's2': 116, 's3': 755, 's4': 30, 's5': 159, 's6': 32, 's7': 20}
deposited code, PFC first (not a reading), alpha-beta: 1135 of 1135 (100.0%); within tolerance False; by subject {'s1': 21, 's2': 116, 's3': 756, 's4': 30, 's5': 160, 's6': 32, 's7': 20}
deposited code, parietal first, sign reversed (not a reading), delta-theta: 1129 of 1135 (99.5%); within tolerance False; by subject {'s1': 21, 's2': 114, 's3': 753, 's4': 30, 's5': 160, 's6': 32, 's7': 19}
deposited code, parietal first, sign reversed (not a reading), alpha-beta: 1135 of 1135 (100.0%); within tolerance False; by subject {'s1': 21, 's2': 116, 's3': 756, 's4': 30, 's5': 160, 's6': 32, 's7': 20}
Expected under a calibrated null with |z| > 1.96 at 5%: 57
Result: not reproduced. With the Methods' null, 78 (reading (a), adopted) or 1 (reading (b)) of 1135 pairs have processing |z| > 1.96 in delta-theta, and 104 or 74 in alpha-beta, against the paper's 1008 and 984. The trial-shuffled surrogate gives 68 and 78 under (a) and 1 and 71 under (b), and a null at 5% would give about 57, so the counts are near what signals without trial-locked coupling give. With one permutation per trial the counts are 98 and 93 (a) and 78 and 211 (b), against 75 and 71, and 76 and 194, on the surrogate. Against psianalysis.m's null, reading (b) gives 1014 and 1041, within tolerance, but the trial-shuffled surrogate gives 1022 and 1044 under the same null, so that count does not reflect directionality. The deposited code as written (no conjugate) marks 1129 to 1135 of the 1135 pairs on the real data.
Time-resolved PSI: fig5a-delta-theta-epochs, fig5a-identity-direction, fig5a-spatiotemporal-bidirectional, fig5b-alpha-beta-no-sustained¶
Time-resolved delta-theta PSI differed between conditions in sustained epochs at 0 to 120 ms and 470 to 610 ms (identity against spatial) and at 0 to 170 ms and 660 to 860 ms (identity against temporal) after the test cue, the spatial late epoch ending about 50 ms before the temporal one begins.
In identity trials the PFC led parietal sites early in processing (z > 2.62 and z > 2.35 in the two contrasts' early epochs) and the parietal cortex led later (z < -3.04 and z < -3.57).
Delta-theta PSI during the selection of spatial and of temporal information stayed bidirectional (net near zero) throughout the processing interval.
Time-resolved alpha-beta PSI showed significant condition differences at some time points but no sustained effect for either condition in either contrast.
Per P2 and psi_compute.m: per condition, the condition's ERP removed (subtracterp.m with three
conditions), 3-cycle Hanning windows at 10-ms steps ('mtmconvol'), PSI z per pair and time point
against its own null (the Methods' frequency shuffle of one signal, as for the task-induced PSI),
on the pairs with processing |z| > 1.96 under the same reading (the selection of
directional-pairs). Main spectra: the 900-ms segment zero padded (Methods, Time-Resolved PSI,
"Spectral decomposition ... otherwise identical"); variant: windows on the whole derived epoch, as
psi_compute.m computes them. subtracterp.m selects the temporal trials with trialinfo(:,5)==2,
the delay column, which selects none; the condition column (4) is used here. At each time point the
mixed model (condition fixed, subject and pair random) is computed as the paired test over pairs
(fcx3.paired_lme, checked against statsmodels below), FDR (Benjamini-Hochberg) over the 91 time
points at 0.05, sustained when a run of significant points of one sign spans at least 100 ms (the
runs longer than 100 ms are printed as well, for the Figure 5 legend's ">100 ms").
TIMES = np.round(RES[fcx3.SUBJECTS[0]]["power_toi"] * 1000).astype(int)
TCFG = {"methods": "segment zero-padded (main)", "code": "whole-epoch windows (psi_compute.m)"}
TR = {}
for config in fcx3.PSI_T_CONFIGS:
for band in fcx3.BANDS:
for k in ("a", "b"):
z = {c: [] for c in (1, 2, 3)}
subj, pair = [], []
for sid in fcx3.SUBJECTS:
names = [f"{sid}:{a}-{b}" for a, b, _ in RES[sid]["pairs"]]
keep = np.array([nm in SEL[(band, k)] for nm in names])
for c in (1, 2, 3):
z[c].append(RES[sid]["psi_t"][config][band][c][k][keep])
subj += [sid] * int(keep.sum())
pair += [nm for nm, kk in zip(names, keep) if kk]
TR[(config, band, k)] = {"z": {c: np.concatenate(v) for c, v in z.items()}, "subject": np.array(subj), "pair": np.array(pair)}
def contrast_stats(config, band, k, other):
d = TR[(config, band, k)]
p, eff = [], []
for ti in range(len(TIMES)):
e, F, pv, n = fcx3.paired_lme(d["z"][other][:, ti], d["z"][1][:, ti], d["subject"])
p.append(pv)
eff.append(e) # identity minus other
p, eff = np.array(p), np.array(eff)
sig = fcx3.fdr_bh(p) if len(d["subject"]) > 1 else np.zeros(len(TIMES), bool)
runs = []
for sign in (1, -1):
for a, b in fcx3.runs(sig & (np.sign(eff) == sign), TIMES):
runs.append((int(a), int(b), sign, int(b - a) >= 100))
return p, eff, sig, sorted(runs)
def grand(config, band, k, c):
d = TR[(config, band, k)]
per = pd.DataFrame(d["z"][c]).groupby(d["subject"]).mean()
return per.mean(axis=0).values, per.std(axis=0, ddof=1).values / np.sqrt(len(per)), per
STATS = {}
for config in fcx3.PSI_T_CONFIGS:
for band in fcx3.BANDS:
for k in ("a", "b"):
for other, name in [(2, "spatial"), (3, "temporal")]:
STATS[(config, band, k, name)] = contrast_stats(config, band, k, other)
p, eff, sig, runs = STATS[(config, band, k, name)]
print(f"{config}, {band}, {READ[k]}, identity vs {name}: pairs {len(TR[(config, band, k)]['pair'])} in"
f" {len(set(TR[(config, band, k)]['subject']))} subjects; FDR-significant points {int(sig.sum())}/91;"
f" runs (start ms, end ms, sign of identity - other, sustained) {runs}")
d = TR[("methods", "delta-theta", "a")]
for ti in (0, 45, 90):
e2, F2, p2 = fcx3.mixedlm_check(d["z"][2][:, ti], d["z"][1][:, ti], d["subject"], d["pair"])
e1, F1, p1, _ = fcx3.paired_lme(d["z"][2][:, ti], d["z"][1][:, ti], d["subject"])
print(f"check at {TIMES[ti]} ms (main spectra, delta-theta, a, identity vs spatial): paired {e1:.3f}, F {F1:.2f}, p {p1:.3g}; MixedLM {e2:.3f}, F {F2:.2f}, p {p2:.3g}")
methods, delta-theta, (a) trial-averaged coherency, identity vs spatial: pairs 78 in 7 subjects; FDR-significant points 0/91; runs (start ms, end ms, sign of identity - other, sustained) [] methods, delta-theta, (a) trial-averaged coherency, identity vs temporal: pairs 78 in 7 subjects; FDR-significant points 0/91; runs (start ms, end ms, sign of identity - other, sustained) [] methods, delta-theta, (b) per-trial PSI averaged, identity vs spatial: pairs 1 in 1 subjects; FDR-significant points 0/91; runs (start ms, end ms, sign of identity - other, sustained) [] methods, delta-theta, (b) per-trial PSI averaged, identity vs temporal: pairs 1 in 1 subjects; FDR-significant points 0/91; runs (start ms, end ms, sign of identity - other, sustained) [] methods, alpha-beta, (a) trial-averaged coherency, identity vs spatial: pairs 104 in 7 subjects; FDR-significant points 0/91; runs (start ms, end ms, sign of identity - other, sustained) [] methods, alpha-beta, (a) trial-averaged coherency, identity vs temporal: pairs 104 in 7 subjects; FDR-significant points 0/91; runs (start ms, end ms, sign of identity - other, sustained) [] methods, alpha-beta, (b) per-trial PSI averaged, identity vs spatial: pairs 74 in 6 subjects; FDR-significant points 30/91; runs (start ms, end ms, sign of identity - other, sustained) [(40, 40, 1, False), (130, 130, 1, False), (170, 190, 1, False), (250, 250, -1, False), (280, 290, 1, False), (300, 300, -1, False), (340, 350, -1, False), (380, 400, 1, False), (410, 450, -1, False), (550, 550, -1, False), (650, 650, 1, False), (670, 670, 1, False), (690, 720, 1, False), (750, 760, -1, False), (870, 870, -1, False), (900, 900, -1, False)]
methods, alpha-beta, (b) per-trial PSI averaged, identity vs temporal: pairs 74 in 6 subjects; FDR-significant points 35/91; runs (start ms, end ms, sign of identity - other, sustained) [(40, 40, 1, False), (250, 260, -1, False), (280, 320, 1, False), (330, 360, -1, False), (380, 380, 1, False), (400, 400, 1, False), (420, 460, -1, False), (500, 500, -1, False), (540, 540, 1, False), (600, 610, 1, False), (640, 650, 1, False), (670, 680, 1, False), (730, 730, -1, False), (760, 770, -1, False), (790, 800, -1, False), (820, 830, 1, False), (860, 860, -1, False)] code, delta-theta, (a) trial-averaged coherency, identity vs spatial: pairs 78 in 7 subjects; FDR-significant points 0/91; runs (start ms, end ms, sign of identity - other, sustained) [] code, delta-theta, (a) trial-averaged coherency, identity vs temporal: pairs 78 in 7 subjects; FDR-significant points 0/91; runs (start ms, end ms, sign of identity - other, sustained) [] code, delta-theta, (b) per-trial PSI averaged, identity vs spatial: pairs 1 in 1 subjects; FDR-significant points 0/91; runs (start ms, end ms, sign of identity - other, sustained) [] code, delta-theta, (b) per-trial PSI averaged, identity vs temporal: pairs 1 in 1 subjects; FDR-significant points 0/91; runs (start ms, end ms, sign of identity - other, sustained) [] code, alpha-beta, (a) trial-averaged coherency, identity vs spatial: pairs 104 in 7 subjects; FDR-significant points 0/91; runs (start ms, end ms, sign of identity - other, sustained) [] code, alpha-beta, (a) trial-averaged coherency, identity vs temporal: pairs 104 in 7 subjects; FDR-significant points 0/91; runs (start ms, end ms, sign of identity - other, sustained) [] code, alpha-beta, (b) per-trial PSI averaged, identity vs spatial: pairs 74 in 6 subjects; FDR-significant points 36/91; runs (start ms, end ms, sign of identity - other, sustained) [(20, 20, -1, False), (120, 130, 1, False), (170, 190, 1, False), (250, 250, -1, False), (280, 290, 1, False), (310, 310, 1, False), (340, 350, -1, False), (370, 400, 1, False), (410, 450, -1, False), (550, 550, -1, False), (650, 650, 1, False), (670, 670, 1, False), (690, 720, 1, False), (750, 760, -1, False), (840, 890, -1, False)]
code, alpha-beta, (b) per-trial PSI averaged, identity vs temporal: pairs 74 in 6 subjects; FDR-significant points 37/91; runs (start ms, end ms, sign of identity - other, sustained) [(40, 40, 1, False), (250, 260, -1, False), (280, 320, 1, False), (330, 360, -1, False), (380, 380, 1, False), (400, 400, 1, False), (420, 460, -1, False), (500, 500, -1, False), (540, 540, 1, False), (600, 610, 1, False), (640, 650, 1, False), (670, 690, 1, False), (730, 730, -1, False), (760, 770, -1, False), (790, 790, -1, False), (810, 830, 1, False), (870, 880, -1, False)]
check at 0 ms (main spectra, delta-theta, a, identity vs spatial): paired 0.253, F 3.29, p 0.0716; MixedLM 0.253, F 3.72, p 0.0556 check at 450 ms (main spectra, delta-theta, a, identity vs spatial): paired 0.176, F 0.71, p 0.401; MixedLM 0.176, F 0.71, p 0.401 check at 900 ms (main spectra, delta-theta, a, identity vs spatial): paired -0.016, F 0.02, p 0.879; MixedLM -0.016, F 0.02, p 0.879
/home/runner/work/_temp/executed/.venv/lib/python3.13/site-packages/statsmodels/base/model.py:589: SingularMatrixWarning: Random effects covariance is singular return -self.score(params, *args) / nobs /home/runner/work/_temp/executed/.venv/lib/python3.13/site-packages/statsmodels/base/model.py:589: SingularMatrixWarning: Random effects covariance is singular return -self.score(params, *args) / nobs /home/runner/work/_temp/executed/.venv/lib/python3.13/site-packages/statsmodels/base/model.py:589: SingularMatrixWarning: Random effects covariance is singular return -self.score(params, *args) / nobs /home/runner/work/encore/encore/entries/crcns-fcx-3-johnson-2019/fcx3.py:709: ConvergenceWarning: The MLE may be on the boundary of the parameter space. r = m.fit(reml=True)
for k in ("a", "b"):
fig, axes = plt.subplots(2, 2, figsize=(12, 6), sharex=True)
for i, band in enumerate(fcx3.BANDS):
for j, (other, name) in enumerate([(2, "spatial"), (3, "temporal")]):
ax = axes[i, j]
for c, col, lab in [(1, "tab:blue", "identity"), (other, "tab:orange" if other == 2 else "tab:pink", name)]:
m, se, _ = grand("methods", band, k, c)
ax.plot(TIMES, m, color=col, label=lab)
ax.fill_between(TIMES, m - se, m + se, color=col, alpha=0.2)
sig = STATS[("methods", band, k, name)][2]
ax.plot(TIMES[sig], np.full(sig.sum(), ax.get_ylim()[0]), "k|")
ax.axhline(0, color="grey", lw=0.5)
ax.set_title(f"{band}, identity vs {name}, reading ({k})")
ax.legend(fontsize=7)
axes[1, 0].set_xlabel("ms after processing start")
axes[1, 1].set_xlabel("ms after processing start")
plt.tight_layout()
plt.show()
print("Main spectra. Grand mean +- SEM over subjects; black marks: FDR-significant time points. Axes autoscaled, every point shown.")
Main spectra. Grand mean +- SEM over subjects; black marks: FDR-significant time points. Axes autoscaled, every point shown.
EXP_EPOCH = {"spatial": [(0, 120), (470, 610)], "temporal": [(0, 170), (660, 860)]}
TOL = {"spatial": [(None, 12), (47, 61)], "temporal": [(None, 17), (66, 86)]}
for config in fcx3.PSI_T_CONFIGS:
for k in ("a", "b"):
print(f"{TCFG[config]}, {READ[k]}:")
late_end = {}
for name in ("spatial", "temporal"):
runs = [r for r in STATS[(config, "delta-theta", k, name)][3] if r[3]]
early = [r for r in runs if r[0] <= 10]
late = [r for r in runs if r[0] > 10]
print(f" identity vs {name}: sustained runs {runs}; early (start within one step of 0): {early}; later: {late}")
(e0, e1), (l0, l1) = EXP_EPOCH[name]
(_, te1), (tl0, tl1) = TOL[name]
ok_e = len(early) == 1 and abs(early[0][1] - e1) <= te1 and early[0][2] == 1
ok_l = len(late) == 1 and abs(late[0][0] - l0) <= tl0 and abs(late[0][1] - l1) <= tl1 and late[0][2] == -1
print(f" one early epoch, positive, end within tolerance: {ok_e}; one late epoch, negative, bounds within tolerance: {ok_l}")
late_end[name] = late
if late_end["spatial"] and late_end["temporal"]:
print(f" gap spatial late end to temporal late start: {late_end['temporal'][0][0] - late_end['spatial'][0][1]} ms (expected 50 +- 20)")
segment zero-padded (main), (a) trial-averaged coherency:
identity vs spatial: sustained runs []; early (start within one step of 0): []; later: []
one early epoch, positive, end within tolerance: False; one late epoch, negative, bounds within tolerance: False
identity vs temporal: sustained runs []; early (start within one step of 0): []; later: []
one early epoch, positive, end within tolerance: False; one late epoch, negative, bounds within tolerance: False
segment zero-padded (main), (b) per-trial PSI averaged:
identity vs spatial: sustained runs []; early (start within one step of 0): []; later: []
one early epoch, positive, end within tolerance: False; one late epoch, negative, bounds within tolerance: False
identity vs temporal: sustained runs []; early (start within one step of 0): []; later: []
one early epoch, positive, end within tolerance: False; one late epoch, negative, bounds within tolerance: False
whole-epoch windows (psi_compute.m), (a) trial-averaged coherency:
identity vs spatial: sustained runs []; early (start within one step of 0): []; later: []
one early epoch, positive, end within tolerance: False; one late epoch, negative, bounds within tolerance: False
identity vs temporal: sustained runs []; early (start within one step of 0): []; later: []
one early epoch, positive, end within tolerance: False; one late epoch, negative, bounds within tolerance: False
whole-epoch windows (psi_compute.m), (b) per-trial PSI averaged:
identity vs spatial: sustained runs []; early (start within one step of 0): []; later: []
one early epoch, positive, end within tolerance: False; one late epoch, negative, bounds within tolerance: False
identity vs temporal: sustained runs []; early (start within one step of 0): []; later: []
one early epoch, positive, end within tolerance: False; one late epoch, negative, bounds within tolerance: False
Result: not reproduced. No time point differs between conditions after FDR in delta-theta under either PSI reading or either spectra reading, in the pair-level model or in the subject-level test printed under fig5b-alpha-beta-no-sustained, so there is no sustained epoch. Under reading (a), adopted, the selection holds 78 pairs in 7 subjects; under reading (b) it holds 1 pair (S1), on which no test can be formed.
EPOCHS = [("spatial", (0, 120), 2.62, ">"), ("temporal", (0, 170), 2.35, ">"), ("spatial", (470, 610), -3.04, "<"), ("temporal", (660, 860), -3.57, "<")]
ok = lambda v, exp, rel: (v > 1.96 and (v >= exp - 0.1 * abs(exp))) if rel == ">" else (v < -1.96 and (v <= exp + 0.1 * abs(exp)))
for config in fcx3.PSI_T_CONFIGS:
for k in ("a", "b"):
print(f"{TCFG[config]}, {READ[k]}:")
mi, _, per = grand(config, "delta-theta", k, 1)
d = TR[(config, "delta-theta", k)]
for name, (a, b), exp, rel in EPOCHS:
m = (TIMES >= a) & (TIMES <= b)
other = 2 if name == "spatial" else 3
# readings: (a) grand mean over subjects averaged over the epoch; (b) all pairs pooled; (c) least extreme point; (B) identity - other
mo, _, _ = grand(config, "delta-theta", k, other)
ra = mi[m].mean()
rb = d["z"][1][:, m].mean()
rc = mi[m].min() if rel == ">" else mi[m].max()
rB = (mi - mo)[m].mean()
print(f" identity, {a}-{b} ms (expected {rel} {exp}): (a) {ra:.2f} {ok(ra, exp, rel)}, (b) pooled pairs {rb:.2f} {ok(rb, exp, rel)},"
f" (c) least extreme point {rc:.2f} {ok(rc, exp, rel)}, (B) identity - {name} {rB:.2f} {ok(rB, exp, rel)}")
print(" per-subject identity mean z over the four epochs:")
print(" ", {name + f" {a}-{b}": per.loc[:, (TIMES >= a) & (TIMES <= b)].mean(axis=1).round(2).to_dict() for name, (a, b), _, _ in EPOCHS})
segment zero-padded (main), (a) trial-averaged coherency:
identity, 0-120 ms (expected > 2.62): (a) 0.73 False, (b) pooled pairs 0.63 False, (c) least extreme point 0.42 False, (B) identity - spatial -0.06 False
identity, 0-170 ms (expected > 2.35): (a) 0.60 False, (b) pooled pairs 0.55 False, (c) least extreme point 0.14 False, (B) identity - temporal 0.03 False
identity, 470-610 ms (expected < -3.04): (a) 0.22 False, (b) pooled pairs 0.12 False, (c) least extreme point 0.28 False, (B) identity - spatial 0.33 False
identity, 660-860 ms (expected < -3.57): (a) -0.13 False, (b) pooled pairs -0.09 False, (c) least extreme point 0.25 False, (B) identity - temporal 0.30 False
per-subject identity mean z over the four epochs:
{'spatial 0-120': {'s1': 1.26, 's2': -0.44, 's3': 0.68, 's4': 1.13, 's5': 0.57, 's6': 1.53, 's7': 0.37}, 'temporal 0-170': {'s1': 1.07, 's2': -0.51, 's3': 0.63, 's4': 0.99, 's5': 0.47, 's6': 1.28, 's7': 0.25}, 'spatial 470-610': {'s1': 0.56, 's2': 0.58, 's3': 0.04, 's4': -0.27, 's5': 0.33, 's6': -0.12, 's7': 0.41}, 'temporal 660-860': {'s1': -0.5, 's2': -0.13, 's3': -0.08, 's4': 0.12, 's5': 0.05, 's6': -0.47, 's7': 0.08}}
segment zero-padded (main), (b) per-trial PSI averaged:
identity, 0-120 ms (expected > 2.62): (a) 1.31 False, (b) pooled pairs 1.31 False, (c) least extreme point 0.95 False, (B) identity - spatial -0.74 False
identity, 0-170 ms (expected > 2.35): (a) 0.93 False, (b) pooled pairs 0.93 False, (c) least extreme point -1.05 False, (B) identity - temporal -0.43 False
identity, 470-610 ms (expected < -3.04): (a) -1.98 False, (b) pooled pairs -1.98 False, (c) least extreme point -0.92 False, (B) identity - spatial -2.20 False
identity, 660-860 ms (expected < -3.57): (a) 0.13 False, (b) pooled pairs 0.13 False, (c) least extreme point 1.75 False, (B) identity - temporal 0.39 False
per-subject identity mean z over the four epochs:
{'spatial 0-120': {'s1': 1.31}, 'temporal 0-170': {'s1': 0.93}, 'spatial 470-610': {'s1': -1.98}, 'temporal 660-860': {'s1': 0.13}}
whole-epoch windows (psi_compute.m), (a) trial-averaged coherency:
identity, 0-120 ms (expected > 2.62): (a) 0.09 False, (b) pooled pairs -0.07 False, (c) least extreme point -0.08 False, (B) identity - spatial -0.13 False
identity, 0-170 ms (expected > 2.35): (a) 0.14 False, (b) pooled pairs 0.03 False, (c) least extreme point -0.08 False, (B) identity - temporal 0.44 False
identity, 470-610 ms (expected < -3.04): (a) 0.16 False, (b) pooled pairs 0.10 False, (c) least extreme point 0.23 False, (B) identity - spatial 0.28 False
identity, 660-860 ms (expected < -3.57): (a) 0.06 False, (b) pooled pairs 0.23 False, (c) least extreme point 0.24 False, (B) identity - temporal 0.32 False
per-subject identity mean z over the four epochs:
{'spatial 0-120': {'s1': -0.55, 's2': -0.32, 's3': -0.17, 's4': 0.99, 's5': -0.2, 's6': 0.33, 's7': 0.54}, 'temporal 0-170': {'s1': -0.49, 's2': -0.22, 's3': -0.04, 's4': 0.85, 's5': -0.18, 's6': 0.61, 's7': 0.46}, 'spatial 470-610': {'s1': 0.51, 's2': 0.61, 's3': 0.05, 's4': -0.37, 's5': 0.29, 's6': -0.35, 's7': 0.41}, 'temporal 660-860': {'s1': -0.4, 's2': 0.87, 's3': 0.25, 's4': -0.17, 's5': 0.3, 's6': -0.61, 's7': 0.17}}
whole-epoch windows (psi_compute.m), (b) per-trial PSI averaged:
identity, 0-120 ms (expected > 2.62): (a) 0.34 False, (b) pooled pairs 0.34 False, (c) least extreme point -0.11 False, (B) identity - spatial 1.55 False
identity, 0-170 ms (expected > 2.35): (a) 0.24 False, (b) pooled pairs 0.24 False, (c) least extreme point -0.57 False, (B) identity - temporal -1.70 False
identity, 470-610 ms (expected < -3.04): (a) -1.43 False, (b) pooled pairs -1.43 False, (c) least extreme point -0.19 False, (B) identity - spatial -1.79 False
identity, 660-860 ms (expected < -3.57): (a) 0.25 False, (b) pooled pairs 0.25 False, (c) least extreme point 1.46 False, (B) identity - temporal -0.45 False
per-subject identity mean z over the four epochs:
{'spatial 0-120': {'s1': 0.34}, 'temporal 0-170': {'s1': 0.24}, 'spatial 470-610': {'s1': -1.43}, 'temporal 660-860': {'s1': 0.25}}
Result: not reproduced. In the paper's four epochs, identity-trial delta-theta PSI z meets the criterion under no reading of the averaging, of what is measured, of PSI or of the spectra. Under the main spectra, reading (a) (adopted), the grand means are 0.73, 0.60, 0.22 and -0.13 (paper > 2.62,
2.35, < -3.04, < -3.57); under reading (b), on S1's one pair, 1.31, 0.93, -1.98 and 0.13, where the third has the right sign and passes -1.96 (-2.20 as identity minus spatial) but is outside the bound (-3.04 within 10%). Every value of the other readings is below 1.96 in absolute value.
for config in fcx3.PSI_T_CONFIGS:
for k in ("a", "b"):
for c, name in [(2, "spatial"), (3, "temporal")]:
m, se, per = grand(config, "delta-theta", k, c)
pooled = TR[(config, "delta-theta", k)]["z"][c].mean(0)
print(f"{TCFG[config]}, {READ[k]}, {name}: grand mean max |z| {np.abs(m).max():.2f} at {TIMES[np.argmax(np.abs(m))]} ms;"
f" points with |z| >= 1.96: {int((np.abs(m) >= 1.96).sum())}/91; >= 1.60: {int((np.abs(m) >= 1.60).sum())};"
f" pooled pairs max |z| {np.abs(pooled).max():.2f}; per-subject max |z| {per.abs().max(axis=1).round(2).to_dict()}")
# the same measure on identity trials, where the paper reports |z| above 2.35, as a check that the measure can show direction
for k in ("a", "b"):
m, _, _ = grand(config, "delta-theta", k, 1)
print(f"{TCFG[config]}, {READ[k]}, identity (reference): grand mean max |z| {np.abs(m).max():.2f}; points with |z| >= 1.96: {int((np.abs(m) >= 1.96).sum())}/91")
segment zero-padded (main), (a) trial-averaged coherency, spatial: grand mean max |z| 0.87 at 10 ms; points with |z| >= 1.96: 0/91; >= 1.60: 0; pooled pairs max |z| 0.80; per-subject max |z| {'s1': 1.83, 's2': 1.62, 's3': 0.83, 's4': 1.69, 's5': 1.65, 's6': 1.35, 's7': 1.74}
segment zero-padded (main), (a) trial-averaged coherency, temporal: grand mean max |z| 1.01 at 30 ms; points with |z| >= 1.96: 0/91; >= 1.60: 0; pooled pairs max |z| 1.01; per-subject max |z| {'s1': 1.57, 's2': 1.06, 's3': 1.07, 's4': 1.53, 's5': 1.12, 's6': 1.95, 's7': 1.2}
segment zero-padded (main), (b) per-trial PSI averaged, spatial: grand mean max |z| 3.07 at 140 ms; points with |z| >= 1.96: 16/91; >= 1.60: 27; pooled pairs max |z| 3.07; per-subject max |z| {'s1': 3.07}
segment zero-padded (main), (b) per-trial PSI averaged, temporal: grand mean max |z| 2.36 at 180 ms; points with |z| >= 1.96: 11/91; >= 1.60: 26; pooled pairs max |z| 2.36; per-subject max |z| {'s1': 2.36}
segment zero-padded (main), (a) trial-averaged coherency, identity (reference): grand mean max |z| 0.99; points with |z| >= 1.96: 0/91
segment zero-padded (main), (b) per-trial PSI averaged, identity (reference): grand mean max |z| 2.75; points with |z| >= 1.96: 9/91
whole-epoch windows (psi_compute.m), (a) trial-averaged coherency, spatial: grand mean max |z| 0.37 at 0 ms; points with |z| >= 1.96: 0/91; >= 1.60: 0; pooled pairs max |z| 0.25; per-subject max |z| {'s1': 1.75, 's2': 1.42, 's3': 0.33, 's4': 1.67, 's5': 0.97, 's6': 1.52, 's7': 2.09}
whole-epoch windows (psi_compute.m), (a) trial-averaged coherency, temporal: grand mean max |z| 0.56 at 880 ms; points with |z| >= 1.96: 0/91; >= 1.60: 0; pooled pairs max |z| 0.29; per-subject max |z| {'s1': 1.04, 's2': 1.07, 's3': 0.57, 's4': 1.35, 's5': 0.96, 's6': 2.02, 's7': 2.06}
whole-epoch windows (psi_compute.m), (b) per-trial PSI averaged, spatial: grand mean max |z| 2.54 at 410 ms; points with |z| >= 1.96: 8/91; >= 1.60: 16; pooled pairs max |z| 2.54; per-subject max |z| {'s1': 2.54}
whole-epoch windows (psi_compute.m), (b) per-trial PSI averaged, temporal: grand mean max |z| 3.03 at 60 ms; points with |z| >= 1.96: 23/91; >= 1.60: 41; pooled pairs max |z| 3.03; per-subject max |z| {'s1': 3.03}
whole-epoch windows (psi_compute.m), (a) trial-averaged coherency, identity (reference): grand mean max |z| 0.32; points with |z| >= 1.96: 0/91
whole-epoch windows (psi_compute.m), (b) per-trial PSI averaged, identity (reference): grand mean max |z| 2.48; points with |z| >= 1.96: 7/91
Result: reproduced, resting on PSI reading (a), and showing little. Under reading (a), adopted because its z is calibrated (see the task-induced PSI section and fig4c-alpha-beta-shift), the selection holds 78 pairs in 7 subjects and the grand means stay at or below 0.87 (spatial) and 1.01 (temporal), under 1.96 at every time point and under the paper's 1.60, which the criterion counts as reproduced. The absence shows little: under reading (a) the identity-trial grand mean also stays below 0.99, where the paper reports |z| above 2.35, so this measure shows no direction in any condition, and the 78 pairs are about as many as the trial-shuffled data select (68). Under reading (b) the selection leaves one pair (S1); its spatial-trial z reaches |z| = 3.07 (140 ms) and its temporal-trial z 2.36 (180 ms), with 16 and 11 of 91 time points at |z| >= 1.96, but its identity-trial z also passes 1.96 at 9 points, so on one pair such excursions are common. The second verification round reviewed not reproduced under reading (b); the change was proposed and the third round agreed. With the whole-epoch windows, reading (a) gives 0.37 and 0.56 and reading (b) 2.54 and 3.03.
for config in fcx3.PSI_T_CONFIGS:
for k in ("a", "b"):
for name in ("spatial", "temporal"):
p, eff, sig, runs = STATS[(config, "alpha-beta", k, name)]
longest = max([r[1] - r[0] for r in runs], default=None)
print(f"alpha-beta, {TCFG[config]}, {READ[k]}, identity vs {name}: FDR-significant points {int(sig.sum())}/91 (smallest p {p.min():.3g});"
f" runs {runs}; longest {longest} ms; sustained (>= 100 ms): {[r for r in runs if r[3]]}; (> 100 ms): {[r for r in runs if r[1] - r[0] > 100]}")
alpha-beta, segment zero-padded (main), (a) trial-averaged coherency, identity vs spatial: FDR-significant points 0/91 (smallest p 0.0015); runs []; longest None ms; sustained (>= 100 ms): []; (> 100 ms): [] alpha-beta, segment zero-padded (main), (a) trial-averaged coherency, identity vs temporal: FDR-significant points 0/91 (smallest p 0.00272); runs []; longest None ms; sustained (>= 100 ms): []; (> 100 ms): [] alpha-beta, segment zero-padded (main), (b) per-trial PSI averaged, identity vs spatial: FDR-significant points 30/91 (smallest p 2.35e-18); runs [(40, 40, 1, False), (130, 130, 1, False), (170, 190, 1, False), (250, 250, -1, False), (280, 290, 1, False), (300, 300, -1, False), (340, 350, -1, False), (380, 400, 1, False), (410, 450, -1, False), (550, 550, -1, False), (650, 650, 1, False), (670, 670, 1, False), (690, 720, 1, False), (750, 760, -1, False), (870, 870, -1, False), (900, 900, -1, False)]; longest 40 ms; sustained (>= 100 ms): []; (> 100 ms): [] alpha-beta, segment zero-padded (main), (b) per-trial PSI averaged, identity vs temporal: FDR-significant points 35/91 (smallest p 8.98e-13); runs [(40, 40, 1, False), (250, 260, -1, False), (280, 320, 1, False), (330, 360, -1, False), (380, 380, 1, False), (400, 400, 1, False), (420, 460, -1, False), (500, 500, -1, False), (540, 540, 1, False), (600, 610, 1, False), (640, 650, 1, False), (670, 680, 1, False), (730, 730, -1, False), (760, 770, -1, False), (790, 800, -1, False), (820, 830, 1, False), (860, 860, -1, False)]; longest 40 ms; sustained (>= 100 ms): []; (> 100 ms): [] alpha-beta, whole-epoch windows (psi_compute.m), (a) trial-averaged coherency, identity vs spatial: FDR-significant points 0/91 (smallest p 0.00139); runs []; longest None ms; sustained (>= 100 ms): []; (> 100 ms): [] alpha-beta, whole-epoch windows (psi_compute.m), (a) trial-averaged coherency, identity vs temporal: FDR-significant points 0/91 (smallest p 0.00296); runs []; longest None ms; sustained (>= 100 ms): []; (> 100 ms): [] alpha-beta, whole-epoch windows (psi_compute.m), (b) per-trial PSI averaged, identity vs spatial: FDR-significant points 36/91 (smallest p 4.45e-18); runs [(20, 20, -1, False), (120, 130, 1, False), (170, 190, 1, False), (250, 250, -1, False), (280, 290, 1, False), (310, 310, 1, False), (340, 350, -1, False), (370, 400, 1, False), (410, 450, -1, False), (550, 550, -1, False), (650, 650, 1, False), (670, 670, 1, False), (690, 720, 1, False), (750, 760, -1, False), (840, 890, -1, False)]; longest 50 ms; sustained (>= 100 ms): []; (> 100 ms): [] alpha-beta, whole-epoch windows (psi_compute.m), (b) per-trial PSI averaged, identity vs temporal: FDR-significant points 37/91 (smallest p 1.4e-12); runs [(40, 40, 1, False), (250, 260, -1, False), (280, 320, 1, False), (330, 360, -1, False), (380, 380, 1, False), (400, 400, 1, False), (420, 460, -1, False), (500, 500, -1, False), (540, 540, 1, False), (600, 610, 1, False), (640, 650, 1, False), (670, 690, 1, False), (730, 730, -1, False), (760, 770, -1, False), (790, 790, -1, False), (810, 830, 1, False), (870, 880, -1, False)]; longest 40 ms; sustained (>= 100 ms): []; (> 100 ms): []
# subject-level test of the time-resolved contrasts: per subject the mean z over its selected pairs, a paired t-test
# over subjects at each time point, Benjamini-Hochberg over the 91 points (pairs that share electrodes are not counted
# as independent)
def subject_stats(config, band, k, other):
d = TR[(config, band, k)]
zi = pd.DataFrame(d["z"][1]).groupby(d["subject"]).mean()
zo = pd.DataFrame(d["z"][other]).groupby(d["subject"]).mean()
if len(zi) < 3:
return None
t, p = stats.ttest_rel(zi.values, zo.values, axis=0)
sig = fcx3.fdr_bh(p)
runs = [(int(a), int(b), sign) for sign in (1, -1) for a, b in fcx3.runs(sig & (np.sign(t) == sign), TIMES)]
return len(zi), p, sig, sorted(runs)
for band in fcx3.BANDS:
for config in fcx3.PSI_T_CONFIGS:
for k in ("a", "b"):
for other, name in [(2, "spatial"), (3, "temporal")]:
r = subject_stats(config, band, k, other)
if r is None:
print(f"{band}, {TCFG[config]}, {READ[k]}, identity vs {name}: fewer than 3 subjects, no test")
continue
n, p, sig, runs = r
print(f"{band}, {TCFG[config]}, {READ[k]}, identity vs {name}: {n} subjects; FDR-significant points {int(sig.sum())}/91"
f" (smallest p {p.min():.3g}); runs {runs}")
for k in ("a", "b"):
d = TR[("methods", "alpha-beta", k)]
print(f"alpha-beta pairs per subject, {READ[k]}:", pd.Series(d["subject"]).value_counts().sort_index().to_dict())
delta-theta, segment zero-padded (main), (a) trial-averaged coherency, identity vs spatial: 7 subjects; FDR-significant points 0/91 (smallest p 0.167); runs []
delta-theta, segment zero-padded (main), (a) trial-averaged coherency, identity vs temporal: 7 subjects; FDR-significant points 0/91 (smallest p 0.115); runs []
delta-theta, segment zero-padded (main), (b) per-trial PSI averaged, identity vs spatial: fewer than 3 subjects, no test
delta-theta, segment zero-padded (main), (b) per-trial PSI averaged, identity vs temporal: fewer than 3 subjects, no test
delta-theta, whole-epoch windows (psi_compute.m), (a) trial-averaged coherency, identity vs spatial: 7 subjects; FDR-significant points 0/91 (smallest p 0.226); runs []
delta-theta, whole-epoch windows (psi_compute.m), (a) trial-averaged coherency, identity vs temporal: 7 subjects; FDR-significant points 0/91 (smallest p 0.00337); runs []
delta-theta, whole-epoch windows (psi_compute.m), (b) per-trial PSI averaged, identity vs spatial: fewer than 3 subjects, no test
delta-theta, whole-epoch windows (psi_compute.m), (b) per-trial PSI averaged, identity vs temporal: fewer than 3 subjects, no test
alpha-beta, segment zero-padded (main), (a) trial-averaged coherency, identity vs spatial: 7 subjects; FDR-significant points 0/91 (smallest p 0.0161); runs []
alpha-beta, segment zero-padded (main), (a) trial-averaged coherency, identity vs temporal: 7 subjects; FDR-significant points 0/91 (smallest p 0.0241); runs []
alpha-beta, segment zero-padded (main), (b) per-trial PSI averaged, identity vs spatial: 6 subjects; FDR-significant points 0/91 (smallest p 0.00289); runs []
alpha-beta, segment zero-padded (main), (b) per-trial PSI averaged, identity vs temporal: 6 subjects; FDR-significant points 0/91 (smallest p 0.00783); runs []
alpha-beta, whole-epoch windows (psi_compute.m), (a) trial-averaged coherency, identity vs spatial: 7 subjects; FDR-significant points 0/91 (smallest p 0.0169); runs []
alpha-beta, whole-epoch windows (psi_compute.m), (a) trial-averaged coherency, identity vs temporal: 7 subjects; FDR-significant points 0/91 (smallest p 0.0237); runs []
alpha-beta, whole-epoch windows (psi_compute.m), (b) per-trial PSI averaged, identity vs spatial: 6 subjects; FDR-significant points 0/91 (smallest p 0.00356); runs []
alpha-beta, whole-epoch windows (psi_compute.m), (b) per-trial PSI averaged, identity vs temporal: 6 subjects; FDR-significant points 0/91 (smallest p 0.00847); runs []
alpha-beta pairs per subject, (a) trial-averaged coherency: {'s1': 2, 's2': 13, 's3': 62, 's4': 3, 's5': 21, 's6': 2, 's7': 1}
alpha-beta pairs per subject, (b) per-trial PSI averaged: {'s1': 5, 's2': 6, 's3': 44, 's4': 2, 's5': 14, 's6': 3}
Result: partially reproduced, resting on PSI reading (a). Under reading (a), adopted (see fig4c-alpha-beta-shift; 104 pairs in 7 subjects), no point is significant after FDR in the pair-level model (smallest p 0.0015 and 0.0027) or in the subject-level test (0.016 and 0.024), under either spectra reading, the criterion's partial match. Under reading (b) (74 pairs in 6 subjects), 30 (identity against spatial) and 35 (against temporal) of 91 time points differ after FDR in the pair-level model, and the longest run of one sign lasts 40 ms (whole-epoch windows: 36 and 37 points, longest 50 and 40 ms). Those points come from the pair-level model alone. The 74 pairs are about as many as the trial-shuffled data select under the same reading (71), S3 supplies 44 of them, and the model treats pairs that share electrodes as independent; the paired test on the 6 subjects' means finds no point after FDR (smallest p 0.0029 and 0.0078). The second verification round reviewed reproduced under reading (b); the change was proposed and the third round agreed. No reading shows a sustained run.
Summary¶
A failure to reproduce here may be a failure of this attempt, not of the paper: see the reasoning and the differences from the paper's method.
| Claim | Outcome |
|---|---|
| table1-electrodes | partially reproduced |
| trial-counts | reproduced |
| fig1b-accuracy | reproduced |
| fig1b-rt-identity-slower | reproduced |
| erp-no-condition-difference | not reproduced (assumption: neighbours adjacent by contact number, 0.05 per tail) |
| fig2-spatial-power | partially reproduced |
| fig3-temporal-power | partially reproduced |
| power-difficulty-subjects | reproduced |
| power-low-frequencies | reproduced (assumption: the 2-Hz end of the range counts as a local maximum) |
| fig4-maintenance-parietal-led | not reproduced |
| fig4a-delta-theta-shift | not reproduced |
| fig4c-alpha-beta-shift | not reproduced (assumption: PSI reading (a)) |
| directional-pairs | not reproduced |
| fig5a-delta-theta-epochs | not reproduced |
| fig5a-identity-direction | not reproduced |
| fig5a-spatiotemporal-bidirectional | reproduced (assumption: PSI reading (a); the measure shows no direction in any condition) |
| fig5b-alpha-beta-no-sustained | partially reproduced (assumption: PSI reading (a)) |
How the analysis differs from the paper's. Everything is computed in Python from the derived epochs; FieldTrip itself was not run. Windows, trial selection and spectral parameters follow the Methods and the deposited MATLAB scripts; where they differ, the Methods are the main reading and the scripts a variant. (1) ERP and power segments are zero padded as the Methods say; the scripts filter and transform the whole epoch, so that low-frequency windows take in the data around the segment. (2) The PSI null shuffles the frequencies of one signal and recomputes the same statistic, as the Methods say. psianalysis.m z-scores the mean of per-trial PSI against the slope of the trial-mean spectrum, a different statistic, and on trial-shuffled data that null gives |z| > 1.96 in 90% of pairs; it is shown as a variant. With the Methods' null the trial-shuffled data give 6 to 7% (reading (a)) and 0.1% (delta-theta) or 6% (alpha-beta) under reading (b), and the real data give few directional pairs, so none of the large PSI effects of the paper appears. (3) The cluster test's neighbours and alpha per tail are stated neither in the paper nor in the scripts, which hold no cluster test: the adjacency of contact numbers and 0.05 per tail are adopted, and every reading is shown. (4) PSI from trial-averaged cross-spectra (reading (a), Nolte et al. 2008) or per trial (reading (b)), each with one permutation for all trials or one per trial: reading (a) with one permutation for all trials is now adopted where the readings differ, because its z is calibrated on trial-shuffled and on synthetic independent data and reading (b)'s is not (its mean is offset by up to -1.25 per subject on the trial-shuffled data). Three outcomes verified under reading (b) were changed to what reading (a) gives, after a third verification round agreed: fig4c-alpha-beta-shift to not reproduced, fig5a-spatiotemporal-bidirectional to reproduced (an absence the measure shows in every condition), and fig5b-alpha-beta-no-sustained to partially reproduced. (5) The baseline z-score of power is computed in closed form; it cannot change the condition t-tests. (6) The mixed models are computed as paired tests over pairs, which equal them when every pair has both values (checked against statsmodels). As in the paper's degrees of freedom, pairs that share electrodes are treated as independent, which inflates the pair-level F; subject-level tests are printed beside them for the task-induced and the time-resolved PSI.
What was found about the data set. The derived epochs, the continuous data and the trial
tables share one clock: every analysed channel's derived trace is a bipolar difference of two
contacts of the continuous data (r >= 0.9998), at fixed offsets from the table's columns that put the
scripts' windows where the Methods put them. The data set lists 187 analysed channels where the paper
reports 192 (S4 has 5 parietal channels, Table 1 10), and 1135 same-hemisphere pairs where the paper
reports 1129. The trial tables of S6 and S7 hold only the kept trials (101 and 90), unlike the
description. A timing contrast between trials with 900-ms and 1150-ms delays shows, where the
70-150 Hz response is clear (S2, S3, S4), that the responses in the processing epoch of the 1150-ms
trials occur 0.21 to 0.26 s later relative to the processing column than in the 900-ms trials, and
in S4 the same in the encoding epoch, while the pretrial epochs of these subjects show shifts of
0.03 s or less; this is consistent with the encoding and processing columns being about 0.25 s
early in 1150-ms trials, so that their processing window would include the end of the cue, but the
test does not prove it and is weak in the other subjects (S1, S5 and S6 show shifts of 0.28 to 0.35
s that do not pass the shuffle test). The ERP and power tests and the task-induced PSI on the
900-ms-delay trials alone are shown as variants; power on those trials loses most effects, and so
does power on a random draw of as many trials from both delays, so the loss reflects the smaller
number of trials and the test cannot tell whether the timing matters. The deposited psi_compute.m does not run as written (an undefined freq and
savDir, and an electrode argument tested with nargin > 2), subtracterp.m selects temporal
trials by the delay column, which selects none, and psianalysis.m omits the conjugate of the
cross-spectrum and z-scores against a null that is not the statistic it tests.