In [1]:
# # Keles et al. (2024) from dandiset 000623: units, behaviour, gaze and single-neuron selectivity
#
# Paper: Keles, Dubois, Le, Tyszka, Kahn, Reed, Chung, Mamelak, Adolphs and Rutishauser (2024),
# "Multimodal single-neuron, intracranial EEG, and fMRI brain responses during movie watching in
# human patients", Scientific Data 11, 214, doi:10.1038/s41597-024-03029-1.
#
# Dataset: DANDI:000623, version 0.240130.2108 (doi:10.48324/dandi.000623/0.240130.2108). This is
# the version the paper cites (reference 54). The three published versions (0.240121.2058,
# 0.240130.2108, 0.240227.2023) list the same 29 assets with the same asset identifiers and sizes,
# so the choice does not change the data; the check is printed below.
#
# Claims file: `claims/keles-2024.yaml`, written from the version of record
# (Europe PMC full text) and the paper's code, github.com/rutishauserlab/bmovie-release-NWB-BIDS at
# commit 8c35290, which the criteria follow and the helper `bmovie.py` ports.
#
# This notebook tests the claims on the units, behaviour, gaze and single neurons. The claims on
# HFB power of the microwire LFP and macro iEEG, the example units and channels of Figs. 6 and 7,
# and the comparison of modalities are in `hfb_keles_2024.ipynb`.
#
# | Claim | Here |
# |---|---|
# | cohort-emu-sessions, table1-demographics, neurons-total-and-areas, units-per-wire | tested |
# | firing-rate, isi-violations, waveform-snr, projection-distance, isolation-distance | tested |
# | gaze-missing-p53cs, gaze-similarity | tested |
# | recognition-auc, auc-run1-vs-run2, confidence-accuracy | tested |
# | memory-sessions-included, memory-cells-significant, memory-cells-not-significant | tested |
# | scenecut-labels (link), event-cells | tested, with the code's scene-cut annotations |
# | scanner-questions | `data: elsewhere`: tested on the code repository's copy of the in-scanner answers, not on the dandiset |
# | memory-lfp, memory-ieeg, event-lfp, event-ieeg, fig6-examples, fig7-examples, memory-modalities-differ, nwb-contents | in `hfb_keles_2024.ipynb` |
# | fmri-motion, fmri-tsnr, fmri-isc | blocked: the fMRI data on OpenNeuro hold no fMRIPrep derivatives, and fMRIPrep cannot be run here |
In [2]:
import os
os.environ.setdefault("OMP_NUM_THREADS", "4")
import json
import urllib.request
from concurrent.futures import ProcessPoolExecutor

import numpy as np
import pandas as pd
from scipy import stats

import bmovie as bm

pd.set_option("display.width", 160)
pd.set_option("display.max_columns", 30)

assets = bm.asset_urls()
with ProcessPoolExecutor(6) as ex:
    S = list(ex.map(bm.load_session, [u for _, u, _ in assets]))
cuts = bm.scenecuts()
ids = [s["identifier"] for s in S]
print(len(assets), "NWB assets;", round(sum(a[2] for a in assets) / 1e9, 2), "GB")

# the published versions hold the same assets
vers = {}
for v in ["0.240121.2058", "0.240130.2108", "0.240227.2023"]:
    with urllib.request.urlopen(f"https://api.dandiarchive.org/api/dandisets/000623/versions/{v}/assets/?page_size=100") as r:
        vers[v] = {a["path"]: (a["asset_id"], a["size"]) for a in json.load(r)["results"]}
for v, d in vers.items():
    print(v, len(d), "assets; identical to the pinned version:", d == vers[bm.DANDISET_VERSION])
29 NWB assets; 27.74 GB
0.240121.2058 29 assets; identical to the pinned version: True
0.240130.2108 29 assets; identical to the pinned version: True
0.240227.2023 29 assets; identical to the pinned version: True
In [3]:
U_all = pd.concat([bm.units_U(s) for s in S], ignore_index=True)
rows = []
for s in S:
    t0, t1 = bm.movie_window(s)
    r = bm.recog_trials(s)
    u = U_all[U_all.session == s["identifier"]]
    rows.append(dict(session=s["identifier"], subject=s["subject"]["subject_id"],
                     movie_start=t0, movie_stop=round(t1, 3), recog_trials=len(r),
                     novel=int((r.label == "new").sum()), familiar=int((r.label == "old").sum()),
                     units=len(u), units_U=int(u.in_U.sum()),
                     micro=s["lfp"].get("LFP_micro", {}).get("shape"),
                     macro=s["lfp"].get("LFP_macro", {}).get("shape"),
                     lfp_start=[round(v["starting_time"], 4) for v in s["lfp"].values()],
                     lfp_rate=sorted({float(v["rate"]) for v in s["lfp"].values()}),
                     gaze_rate=s["gaze_rate"], frames=len(s["frame_times"])))
sess = pd.DataFrame(rows)
print(sess.to_string())
print("\nsubjects:", sess.subject.nunique(), " sessions:", len(sess), " units:", len(U_all),
      " units with a spike in the movie:", int(U_all.in_U.sum()))

print("\nTrials table columns:", list(S[0]["trials"].columns))
print("Units table columns:", S[0]["units_columns"])
print("Electrodes table columns:", list(S[0]["electrodes"].columns))
print("Behavior module:", S[0]["behavior_modules"])
print("Recognition responses (all sessions):",
      pd.Series(np.concatenate([bm.recog_trials(s).actual_response for s in S])).value_counts().sort_index().to_dict())
print("Response codes agree with response_correct in every session:",
      all((bm.recog_trials(s).correct_code == (bm.recog_trials(s).response_correct == 1)).all() for s in S))
print("Movie frames: data 0 to", int(max(s["frame_data"].max() for s in S)), "; first frame time",
      sorted({round(s["frame_times"][0], 3) for s in S}), "; frame interval (s) median",
      round(float(np.median(np.concatenate([np.diff(s["frame_times"]) for s in S]))), 4),
      "range", round(float(min(np.diff(s["frame_times"]).min() for s in S)), 4), "to",
      round(float(max(np.diff(s["frame_times"]).max() for s in S)), 4))
print("Movie duration (s): ", round(sess.movie_stop.min(), 2), "to", round(sess.movie_stop.max(), 2),
      "(11971 frames at 25 Hz is", 11971 / 25, "s)")
print("Gaze unit:", sorted({s["gaze_unit"] for s in S}), "; gaze comments:", sorted({s["gaze_comments"] for s in S}))
print("LFP unit:", sorted({v["unit"] for s in S for v in s["lfp"].values()}))
q = U_all
for c in ["rate", "isibelow", "peakSNR", "meanSNR", "isolationdist"]:
    print(f"{c:14s} min {np.nanmin(q[c]):.4g}  median {np.nanmedian(q[c]):.4g}  max {np.nanmax(q[c]):.4g}  NaN {int(q[c].isna().sum())}")
print("isibelow is described in the file as:", "'The proportion of inter-spike intervals (ISIs) which are shorter than 3 ms'")
print("Units whose electrode location has no hemisphere prefix:",
      int((~U_all.area.isin(bm.AREAS)).sum()), "; electrodes table index is 0..n-1 in every file:",
      all((s["electrodes"].index == np.arange(len(s["electrodes"]))).all() for s in S))

# duplicates: identical spike trains, gaze traces or trial tables across files
def sig(a):
    return hash(np.asarray(a).tobytes())
spk = {s["identifier"]: sig(np.concatenate([np.asarray(x) for x in s["units"].spike_times])) for s in S}
gz = {s["identifier"]: sig(s["gaze"][:5000]) for s in S}
tri = {s["identifier"]: sig(bm.recog_trials(s).start_time.to_numpy()) for s in S}
for name, d in [("spike times", spk), ("gaze", gz), ("recognition onsets", tri)]:
    print(f"distinct {name}: {len(set(d.values()))} of {len(d)}")
     session subject  movie_start  movie_stop  recog_trials  novel  familiar  units  units_U          micro          macro         lfp_start  lfp_rate  gaze_rate  frames
0   P41CS_R1    CS41          0.0     478.855            40     20        20      7        7   (760044, 80)   (763964, 96)     [0.0, 0.0005]  [1000.0]      500.0   11971
1   P41CS_R2    CS41          0.0     478.859            40     20        20      7        7   (654918, 80)   (656310, 96)     [0.0, 0.0001]  [1000.0]      500.0   11971
2   P42CS_R1    CS42          0.0     478.854            40     20        20     50       50   (823957, 64)   (824069, 96)  [0.0001, 0.0004]  [1000.0]      500.0   11971
3   P42CS_R2    CS42          0.0     478.844            40     20        20     46       46   (806801, 64)   (807042, 96)  [0.0008, 0.0001]  [1000.0]      500.0   11971
4   P43CS_R1    CS43          0.0     478.849            40     20        20     32       32   (833676, 80)   (833868, 96)   [0.0008, 0.001]  [1000.0]      500.0   11971
5   P43CS_R2    CS43          0.0     478.857            40     20        20     32       32   (680582, 80)   (680790, 96)  [0.0001, 0.0005]  [1000.0]      500.0   11971
6   P44CS_R1    CS44          0.0     478.839            40     20        20     49       49   (897683, 64)   (897859, 96)  [0.0006, 0.0008]  [1000.0]      500.0   11971
7   P47CS_R1    CS47          0.0     478.034            40     20        20     75       74   (759238, 80)   (759447, 96)  [0.0006, 0.0001]  [1000.0]      500.0   11971
8   P47CS_R2    CS47          0.0     478.035            40     20        20     73       72   (735104, 80)   (741105, 96)  [0.0008, 0.0002]  [1000.0]      500.0   11971
9   P48CS_R1    CS48          0.0     478.848            40     20        20    143      143   (830810, 80)   (830840, 96)  [0.0004, 0.0008]  [1000.0]      500.0   11971
10  P48CS_R2    CS48          0.0     478.820            40     20        20    114      112   (809940, 80)   (810069, 96)  [0.0008, 0.0003]  [1000.0]      500.0   11971
11  P49CS_R1    CS49          0.0     478.850            40     20        20     12       12  (1035492, 80)  (1035540, 96)  [0.0007, 0.0009]  [1000.0]      500.0   11971
12  P49CS_R2    CS49          0.0     478.847            40     20        20     14       14   (775892, 80)   (784464, 96)   [0.0005, 0.001]  [1000.0]      500.0   11971
13  P51CS_R1    CS51          0.0     478.847            40     20        20     30       30   (862206, 80)  (862381, 128)   [0.0005, 0.001]  [1000.0]      500.0   11971
14  P51CS_R2    CS51          0.0     478.020            40     20        20     46       45   (851845, 80)  (851942, 128)  [0.0006, 0.0001]  [1000.0]      500.0   11971
15  P53CS_R1    CS53          0.0     478.843            40     20        20     34       34   (846154, 80)   (846266, 96)  [0.0005, 0.0009]  [1000.0]      500.0   11971
16  P53CS_R2    CS53          0.0     478.846            34     17        17     48       48   (721160, 80)   (725081, 96)  [0.0006, 0.0001]  [1000.0]      500.0   11971
17  P54CS_R1    CS54          0.0     478.838            40     20        20    123      123   (928748, 80)   (928924, 96)  [0.0001, 0.0006]  [1000.0]      500.0   11971
18  P54CS_R2    CS54          0.0     478.849            40     20        20    112      111   (917968, 80)   (918000, 96)  [0.0004, 0.0008]  [1000.0]        NaN   11971
19  P55CS_R1    CS55          0.0     478.843            40     20        20     57       56   (753229, 80)   (753297, 96)     [0.0, 0.0005]  [1000.0]      500.0   11971
20  P55CS_R2    CS55          0.0     478.830            40     20        20     29       29   (659184, 80)   (659334, 96)  [0.0007, 0.0001]  [1000.0]      500.0   11971
21  P56CS_R1    CS56          0.0     478.840            40     20        20     30       30   (986413, 80)  (986413, 106)  [0.0007, 0.0001]  [1000.0]        NaN   11971
22  P56CS_R2    CS56          0.0     478.835            40     20        20     29       29   (917411, 80)  (917411, 106)  [0.0001, 0.0005]  [1000.0]        NaN   11971
23  P57CS_R1    CS57          0.0     478.852            40     20        20     33       33   (718945, 80)  (718994, 102)  [0.0008, 0.0002]  [1000.0]      500.0   11971
24  P57CS_R2    CS57          0.0     478.849            40     20        20     28       28   (738953, 80)  (739114, 102)  [0.0009, 0.0004]  [1000.0]      500.0   11971
25  P58CS_R1    CS58          0.0     478.847            40     20        20     89       89   (705197, 80)   (705278, 86)  [0.0006, 0.0001]  [1000.0]      500.0   11971
26  P60CS_R1    CS60          0.0     478.839            40     20        20     27       27   (766075, 80)   (766139, 92)   [0.0005, 0.001]  [1000.0]      500.0   11971
27  P62CS_R1    CS62          0.0     478.834            40     20        20     44       44   (818181, 56)   (818374, 40)     [0.0006, 0.0]  [1000.0]      500.0   11971
28  P62CS_R2    CS62          0.0     478.835            40     20        20     44       44   (732343, 56)   (732519, 40)  [0.0004, 0.0008]  [1000.0]      500.0   11971

subjects: 16  sessions: 29  units: 1457  units with a spike in the movie: 1450

Trials table columns: ['start_time', 'stop_time', 'stim_phase', 'stimulus_file', 'response_correct', 'response_confidence', 'actual_response', 'response_time']
Units table columns: ['unit_id', 'unit_id_session', 'electrode_id', 'electrodegroup_label', 'origcluster_id', 'waveform_mean_encoding', 'waveform_mean_recognition', 'isolationdist', 'meanSNR', 'peakSNR', 'isibelow', 'cv2', 'waveform_mean_sampling_rate', 'spike_times', 'electrodes']
Electrodes table columns: ['location', 'group_name', 'origchannel', 'pairwise_distances', 'origchannel_name', 'x', 'y', 'z']
Behavior module: ['Blink', 'EyeTracking', 'Fixation', 'PupilTracking', 'Saccade']
Recognition responses (all sessions): {1.0: 324, 2.0: 104, 3.0: 75, 4.0: 76, 5.0: 157, 6.0: 418}
Response codes agree with response_correct in every session: True
Movie frames: data 0 to 11970 ; first frame time [np.float64(0.0)] ; frame interval (s) median 0.04 range 0.0085 to 0.216
Movie duration (s):  478.02 to 478.86 (11971 frames at 25 Hz is 478.84 s)
Gaze unit: ['pixels'] ; gaze comments: ['screen_width,screen_height=1024.0,768.0::display_w,display_h=819.2,614.4::display_area=102.0,76.0,922.0,692.0', 'screen_width,screen_height=1280.0,1024.0::display_w,display_h=1024.0,768.0::display_area=128.0,128.0,1152.0,896.0', 'screen_width,screen_height=1920.0,1080.0::display_w,display_h=1152.0,864.0::display_area=384.0,108.0,1536.0,972.0']
LFP unit: ['volts']
rate           min 0  median 1.334  max 37.86  NaN 0
isibelow       min 0  median 0.2415  max 10.35  NaN 9
peakSNR        min 0.03723  median 4.88  max 38.47  NaN 7
meanSNR        min 0.03723  median 1.701  max 13.1  NaN 7
isolationdist  min 3.107  median 24.98  max 3.448e+27  NaN 455
isibelow is described in the file as: 'The proportion of inter-spike intervals (ISIs) which are shorter than 3 ms'
Units whose electrode location has no hemisphere prefix: 0 ; electrodes table index is 0..n-1 in every file: True
distinct spike times: 29 of 29
distinct gaze: 29 of 29
distinct recognition onsets: 29 of 29

Checks of the description against the data, and of the clocks.

The LFP series store a starting time near 0 s, the movie start on the trials' clock. The Usage Notes say how to read this: "To create timepoints for the LFP samples, start at 10 seconds before the starting time (ElectricalSeries.starting_time)", so the first sample is 10 s before the movie, and the code does the same (prep_filterLFP.py, LFP_PAD_us = 10). The LFP is aligned here that way; hfb_keles_2024.ipynb checks the alignment with the HFB response to recognition images.

The spikes share the clock of the trials table if units respond to recognition-trial onsets at the stated times and less at shifted times. The next cell counts, for each shift, the units whose spike count in 0.2 to 1.7 s after onset differs from the 1.5 s before onset (Wilcoxon signed-rank over the 40 trials, p < 0.01).

In [4]:
rng_clock = np.random.default_rng(1)
shifts = [-3.0, -2.0, -1.0, 0.0, 1.0, 2.0, 3.0]
res = {}
for sh in shifts:
    n_sig = n_tot = 0
    for s in S:
        ons = bm.recog_trials(s).start_time.to_numpy() + sh
        for st, inU in zip(s["units"].spike_times, bm.units_U(s).in_U):
            if not inU:
                continue
            post = bm.window_counts(np.asarray(st), ons, (0.2, 1.7))
            pre = bm.window_counts(np.asarray(st), ons, (-1.5, -0.0001))
            n_tot += 1
            if np.any(post != pre) and stats.wilcoxon(post, pre).pvalue < 0.01:
                n_sig += 1
    res[sh] = (n_sig, n_tot)
for sh, (a, b) in res.items():
    print(f"onsets shifted by {sh:+.0f} s: {a} of {b} units respond ({100 * a / b:.1f}%)")
onsets shifted by -3 s: 30 of 1450 units respond (2.1%)
onsets shifted by -2 s: 67 of 1450 units respond (4.6%)
onsets shifted by -1 s: 85 of 1450 units respond (5.9%)
onsets shifted by +0 s: 192 of 1450 units respond (13.2%)
onsets shifted by +1 s: 86 of 1450 units respond (5.9%)
onsets shifted by +2 s: 94 of 1450 units respond (6.5%)
onsets shifted by +3 s: 31 of 1450 units respond (2.1%)

cohort-emu-sessions¶

The electrophysiology data come from 16 participants and 29 EMU sessions (runs); 13 participants performed two runs and P44CS, P58CS and P60CS one, as Table 1 lists.

In [5]:
table1_runs = {"P41CS": 2, "P42CS": 2, "P43CS": 2, "P44CS": 1, "P47CS": 2, "P48CS": 2, "P49CS": 2,
               "P51CS": 2, "P53CS": 2, "P54CS": 2, "P55CS": 2, "P56CS": 2, "P57CS": 2, "P58CS": 1,
               "P60CS": 1, "P62CS": 2}   # Table 1, '# of EMU runs'
runs = pd.Series([i.split("_")[0] for i in ids]).value_counts().sort_index()
print("sessions:", len(ids), " participants:", runs.size, " with two runs:", int((runs == 2).sum()))
print("subject_id (CSnn) agrees with the identifier (PnnCS) in every file:",
      all(s["subject"]["subject_id"] == "CS" + s["identifier"][1:3] for s in S))
cmp = pd.DataFrame({"dataset": runs, "table1": pd.Series(table1_runs)})
print(cmp.T.to_string())
print("every participant's run count matches Table 1:", bool((cmp.dataset == cmp.table1).all()))
sessions: 29  participants: 16  with two runs: 13
subject_id (CSnn) agrees with the identifier (PnnCS) in every file: True
         P41CS  P42CS  P43CS  P44CS  P47CS  P48CS  P49CS  P51CS  P53CS  P54CS  P55CS  P56CS  P57CS  P58CS  P60CS  P62CS
dataset      2      2      2      1      2      2      2      2      2      2      2      2      2      1      1      2
table1       2      2      2      1      2      2      2      2      2      2      2      2      2      1      1      2
every participant's run count matches Table 1: True

Result: reproduced. 29 sessions from 16 participants, 13 with two runs; every participant's run count matches Table 1.

table1-demographics¶

Of the 20 participants 11 are female, and their mean age is 37.75 years (SD 13.86); the age, sex and epilepsy diagnosis of each participant are as in Table 1.

The four fMRI-only participants are not in the dandiset; their values are those of Table 1, as gen_table1_subj_info.py enters them by hand (an outside input, with_inputs).

In [6]:
table1 = pd.DataFrame([
    ("P41CS", 21, "F", "Left Other"), ("P42CS", 25, "F", "Not Localized"),
    ("P43CS", 42, "F", "Left Mesial Temporal"), ("P44CS", 53, "F", "Right Mesial Temporal"),
    ("P45CS", 29, "F", "Bitemporal"), ("P46CS", 41, "M", "NA"),
    ("P47CS", 32, "M", "Right Mesial Temporal"), ("P48CS", 32, "F", "Left Mesial Temporal"),
    ("P49CS", 24, "F", "Left Mesial Temporal"), ("P50CS", 25, "M", "Right Temporal Neocortical"),
    ("P51CS", 17, "M", "Not Localized"), ("P53CS", 60, "M", "Bilateral Independent Temporal"),
    ("P54CS", 59, "F", "Right Mesial Temporal"), ("P55CS", 43, "F", "Right Mesial Temporal"),
    ("P56CS", 48, "M", "Bilateral Independent Temporal"), ("P57CS", 46, "M", "Left Other"),
    ("P58CS", 32, "F", "Right Lateral Frontal"), ("P59CS", 34, "M", "Left Mesial Temporal"),
    ("P60CS", 67, "M", "Left Mesial Temporal"), ("P62CS", 25, "F", "Right Mesial Temporal"),
], columns=["ID", "age", "sex", "diagnosis"]).set_index("ID")   # Table 1 of the paper
fmri_only = ["P45CS", "P46CS", "P50CS", "P59CS"]
emu = {}
for s in S:
    pid = s["identifier"].split("_")[0]
    emu.setdefault(pid, set()).add((int(s["subject"]["age"].removeprefix("P").removesuffix("Y")),
                                    s["subject"]["sex"],
                                    s["subject"]["description"].removeprefix("epilepsy diagnosis: ")))
print("participants whose two runs disagree on age, sex or diagnosis:", [k for k, v in emu.items() if len(v) > 1])
emu_df = pd.DataFrame([(k, *list(v)[0]) for k, v in emu.items()], columns=["ID", "age", "sex", "diagnosis"]).set_index("ID")
chk = emu_df.join(table1.add_suffix("_table1"))
chk["match"] = (chk.age == chk.age_table1) & (chk.sex == chk.sex_table1) & (chk.diagnosis == chk.diagnosis_table1)
print(chk.to_string())
all20 = pd.concat([emu_df, table1.loc[fmri_only]])
print("\nparticipants:", len(all20), " female:", int((all20.sex == "F").sum()))
print("mean age %.2f, SD (ddof 0) %.2f, SD (ddof 1) %.2f" % (all20.age.mean(), all20.age.std(ddof=0), all20.age.std(ddof=1)))
print("EMU participants only (16): mean %.2f, SD %.2f" % (emu_df.age.mean(), emu_df.age.std(ddof=0)))
participants whose two runs disagree on age, sex or diagnosis: []
       age sex                       diagnosis  age_table1 sex_table1                diagnosis_table1  match
ID                                                                                                          
P41CS   21   F                      Left Other          21          F                      Left Other   True
P42CS   25   F                   Not Localized          25          F                   Not Localized   True
P43CS   42   F            Left Mesial Temporal          42          F            Left Mesial Temporal   True
P44CS   53   F           Right Mesial Temporal          53          F           Right Mesial Temporal   True
P47CS   32   M           Right Mesial Temporal          32          M           Right Mesial Temporal   True
P48CS   32   F            Left Mesial Temporal          32          F            Left Mesial Temporal   True
P49CS   24   F            Left Mesial Temporal          24          F            Left Mesial Temporal   True
P51CS   17   M                   Not Localized          17          M                   Not Localized   True
P53CS   60   M  Bilateral Independent Temporal          60          M  Bilateral Independent Temporal   True
P54CS   59   F           Right Mesial Temporal          59          F           Right Mesial Temporal   True
P55CS   43   F           Right Mesial Temporal          43          F           Right Mesial Temporal   True
P56CS   48   M  Bilateral Independent Temporal          48          M  Bilateral Independent Temporal   True
P57CS   46   M                      Left Other          46          M                      Left Other   True
P58CS   32   F           Right Lateral Frontal          32          F           Right Lateral Frontal   True
P60CS   67   M            Left Mesial Temporal          67          M            Left Mesial Temporal   True
P62CS   25   F           Right Mesial Temporal          25          F           Right Mesial Temporal   True

participants: 20  female: 11
mean age 37.75, SD (ddof 0) 13.86, SD (ddof 1) 14.22
EMU participants only (16): mean 39.12, SD 14.89

Result: reproduced. The 16 EMU participants' age, sex and diagnosis in the files match Table 1, and with the four fMRI-only participants from Table 1 the 20 have 11 women and a mean age of 37.75 years (SD 13.86, ddof 0).

neurons-total-and-areas¶

The dataset holds 1450 single units from amygdala (479), hippocampus (261), ACC (236), preSMA (299) and vmPFC (175).

In [7]:
U = U_all[U_all.in_U]
print("units in the files:", len(U_all), " units of U (a spike in the movie):", len(U))
print(pd.DataFrame({"U": U.area.value_counts(), "all units": U_all.area.value_counts()}).T.to_string())
print("units without a spike in the movie:", U_all[~U_all.in_U][["session", "unit_id_session", "area"]].to_string())
print("area lookup by .iloc and by .loc agree for every unit:", bool((U_all.area == U_all.area_loc).all()))
print("\nper session:")
print(U.groupby(["session", "area"]).size().unstack(fill_value=0).to_string())
units in the files: 1457  units of U (a spike in the movie): 1450
area       amygdala  preSMA  hippocampus  ACC  vmPFC
U               479     299          261  236    175
all units       482     300          264  236    175
units without a spike in the movie:        session       unit_id_session         area
240   P47CS_R1  P47CS_R1_19_4_1280_4     amygdala
317   P47CS_R2  P47CS_R2_22_1_8375_4     amygdala
599   P48CS_R2  P48CS_R2_58_3_6420_1  hippocampus
612   P48CS_R2  P48CS_R2_62_2_2097_1  hippocampus
719   P51CS_R2  P51CS_R2_48_4_5337_7       preSMA
995   P54CS_R2  P54CS_R2_31_1_2534_2  hippocampus
1075  P55CS_R1  P55CS_R1_49_2_5469_3     amygdala
area lookup by .iloc and by .loc agree for every unit: True

per session:
area      ACC  amygdala  hippocampus  preSMA  vmPFC
session                                            
P41CS_R1    4         1            0       0      2
P41CS_R2    4         1            0       0      2
P42CS_R1   16        12            4      18      0
P42CS_R2   16         8            3      19      0
P43CS_R1    0         1           18       0     13
P43CS_R2    0         1           18       0     13
P44CS_R1   13         8            8      20      0
P47CS_R1    0        46            1       8     19
P47CS_R2    0        39            5      10     18
P48CS_R1   36        30           40      31      6
P48CS_R2   25        34           26      18      9
P49CS_R1    3         3            0       5      1
P49CS_R2    0         1            8       3      2
P51CS_R1   10         7            8       5      0
P51CS_R2   22         6           10       4      3
P53CS_R1    3        11            1      16      3
P53CS_R2   18         6            4      19      1
P54CS_R1    4        37           39      21     22
P54CS_R2    3        45           27      18     18
P55CS_R1    2        26            6      16      6
P55CS_R2    0        18            0       9      2
P56CS_R1    2        16            2       5      5
P56CS_R2    5        13            3       2      6
P57CS_R1    7         8            1       8      9
P57CS_R2    3         8            1       9      7
P58CS_R1   28        18           25      18      0
P60CS_R1   10         5            3       5      4
P62CS_R1    1        35            0       6      2
P62CS_R2    1        35            0       6      2

Result: reproduced. 1450 units of U: amygdala 479, hippocampus 261, ACC 236, preSMA 299 and vmPFC 175, each as stated. The files hold 1457 units; 7 have no spike in the movie.

units-per-wire¶

There were on average 1.99 units per wire, counting only wires with at least one unit.

In [8]:
per_wire = U_all.groupby(["session", "electrode_id"]).size()
print("session-wire pairs with a unit:", len(per_wire), " units:", int(per_wire.sum()))
print("mean units per wire: %.3f" % per_wire.mean(), " distribution:", per_wire.value_counts().sort_index().to_dict())
print("units of U only: %.3f" % U.groupby(["session", "electrode_id"]).size().mean())
session-wire pairs with a unit: 732  units: 1457
mean units per wire: 1.990  distribution: {1: 331, 2: 208, 3: 115, 4: 49, 5: 13, 6: 9, 7: 6, 8: 1}
units of U only: 1.981

Result: reproduced. 1.990 units per wire with at least one unit, over 732 session and wire pairs and all 1457 units (1.981 with the 1450 units of U).

firing-rate¶

The mean firing rate of the neurons was 2.47 +- 3.32 spikes/s (mean +- s.d.).

In [9]:
print("units:", len(U), " mean %.3f  s.d. (ddof 0) %.3f  s.d. (ddof 1) %.3f  range %.3f to %.2f spikes/s"
      % (U.rate.mean(), U.rate.std(ddof=0), U.rate.std(ddof=1), U.rate.min(), U.rate.max()))
print("by participant:")
print(U.assign(p=U.session.str[:5]).groupby("p").rate.agg(["count", "mean", "std"]).round(2).T.to_string())
units: 1450  mean 2.471  s.d. (ddof 0) 3.326  s.d. (ddof 1) 3.327  range 0.002 to 37.86 spikes/s
by participant:
p      P41CS  P42CS  P43CS  P44CS   P47CS   P48CS  P49CS  P51CS  P53CS   P54CS  P55CS  P56CS  P57CS  P58CS  P60CS  P62CS
count   14.0  96.00  64.00  49.00  146.00  255.00  26.00  75.00  82.00  234.00  85.00  59.00  61.00  89.00  27.00  88.00
mean     1.2   3.09   4.34   2.85    2.26    1.44   2.01   1.47   2.14    2.35   4.46   4.76   2.47   1.39   4.39   2.41
std      1.2   2.84   5.39   2.99    3.44    2.11   2.84   2.69   2.42    3.01   5.41   4.20   2.20   2.15   3.62   3.05

Result: reproduced. Mean 2.471 spikes/s, s.d. 3.326 (ddof 0; 3.327 with ddof 1) over the 1450 units of U.

isi-violations¶

The percentage of interspike intervals below 3 ms was 0.40% +- 0.53%.

In [10]:
a = U.isibelow
b = a[a < 3]
print("(a) all units of U: n %d, mean %.3f, s.d. %.3f (ddof 1 %.3f)" % (len(a), a.mean(), a.std(ddof=0), a.std(ddof=1)))
print("(b) units with isibelow < 3: n %d, mean %.3f, s.d. %.3f (ddof 1 %.3f)" % (len(b), b.mean(), b.std(ddof=0), b.std(ddof=1)))
print("range of isibelow: %.3f to %.3f; units at or above 3: %d" % (a.min(), a.max(), int((a >= 3).sum())))
(a) all units of U: n 1450, mean 0.462, s.d. 0.727 (ddof 1 0.728)
(b) units with isibelow < 3: n 1426, mean 0.404, s.d. 0.529 (ddof 1 0.529)
range of isibelow: 0.000 to 10.355; units at or above 3: 22

Result: reproduced. Under reading (b), the 1426 units with less than 3% plotted in Fig. 2c, the mean is 0.404% and the s.d. 0.529%, both within tolerance. Under reading (a), all 1450 units, 0.462% and 0.727%, both outside. The column is described in the files as a proportion, but its values (up to 10.35) are percentages, as the paper reports them.

waveform-snr¶

The peak SNR of the mean waveform was 5.95 +- 3.48 and the mean SNR of the whole waveform 2.07 +- 1.13.

In [11]:
for c in ["peakSNR", "meanSNR"]:
    print("%s: n %d, mean %.3f, s.d. %.3f (ddof 1 %.3f), range %.2f to %.2f"
          % (c, U[c].notna().sum(), U[c].mean(), U[c].std(ddof=0), U[c].std(ddof=1), U[c].min(), U[c].max()))
peakSNR: n 1450, mean 5.948, s.d. 3.477 (ddof 1 3.479), range 0.04 to 38.47
meanSNR: n 1450, mean 2.066, s.d. 1.128 (ddof 1 1.129), range 0.04 to 13.10

Result: reproduced. Peak SNR 5.948 +- 3.477 and mean SNR 2.066 +- 1.128 over the 1450 units (ddof 0; ddof 1 changes the third decimal).

projection-distance¶

The pairwise projection distance between neurons isolated on the same wire was 11.98 +- 8.93 s.d. units.

In [12]:
pairs = []
n_entries = 0
for s in S:
    for v in s["electrodes"]["pairwise_distances"]:
        if v != "NA" and v != "":
            n_entries += 1
            pairs.extend(map(float, v.split("_")))
pairs = np.array(pairs)
print("wires with an entry:", n_entries, " pairs:", len(pairs))
print("mean %.3f, s.d. %.3f (ddof 1 %.3f), range %.2f to %.2f" % (pairs.mean(), pairs.std(), pairs.std(ddof=1), pairs.min(), pairs.max()))
exp_pairs = int(sum(k * (k - 1) / 2 for k in per_wire))
print("pairs expected from units per wire (k(k-1)/2):", exp_pairs)

# where the 24 pairs go: compare, wire by wire, the entries with the units on the wire
pw = []
for s in S:
    u = s["units"]
    k_all = u.groupby("electrode_id").size()
    k_met = u[u.peakSNR.notna()].groupby("electrode_id").size()
    for eid, v in s["electrodes"]["pairwise_distances"].items():
        n = 0 if v in ("NA", "") else len(v.split("_"))
        ka, km = int(k_all.get(eid, 0)), int(k_met.get(eid, 0))
        pw.append(dict(session=s["identifier"], wire=eid, units=ka, units_with_metrics=km,
                       entries=n, expected=ka * (ka - 1) // 2))
pw = pd.DataFrame(pw)
print("\nwires whose entry count differs from k(k-1)/2:")
print(pw[pw.entries != pw.expected].to_string(index=False))
no_met = U_all[U_all.peakSNR.isna()]
print("units with no waveform metrics (peakSNR and isolation distance NaN):", len(no_met),
      "; of them in U:", int(no_met.in_U.sum()))
print("entries equal k'(k'-1)/2 with k' the units with metrics, on every wire with units:",
      bool((pw[pw.units > 0].entries == pw[pw.units > 0].units_with_metrics * (pw[pw.units > 0].units_with_metrics - 1) // 2).all()))
print("pairs from the units with metrics: %d; entries on wires with no unit: %d"
      % (int((pw.units_with_metrics * (pw.units_with_metrics - 1) // 2).sum()), int(pw[pw.units == 0].entries.sum())))
wires with an entry: 403  pairs: 1242
mean 11.982, s.d. 8.933 (ddof 1 8.937), range 3.55 to 77.15
pairs expected from units per wire (k(k-1)/2): 1266

wires whose entry count differs from k(k-1)/2:
 session  wire  units  units_with_metrics  entries  expected
P47CS_R1    18      5                   4        6        10
P47CS_R2    21      3                   2        1         3
P48CS_R2    57      8                   7       21        28
P48CS_R2    61      3                   2        1         3
P51CS_R2    47      5                   4        6        10
P54CS_R2    30      4                   3        3         6
P55CS_R1    48      5                   4        6        10
P58CS_R1    75      0                   0        1         0
P58CS_R1    79      0                   0        1         0
units with no waveform metrics (peakSNR and isolation distance NaN): 7 ; of them in U: 0
entries equal k'(k'-1)/2 with k' the units with metrics, on every wire with units: True
pairs from the units with metrics: 1240; entries on wires with no unit: 2

Result: reproduced. 11.982 +- 8.933 over 1242 pairs from 403 wires. The units per wire would give 1266 pairs; the 24 missing are explained wire by wire. Seven units have no waveform metrics (peakSNR and isolation distance NaN), and these are the 7 units without a spike in the movie, outside U. Each sits on a wire with other units, and that wire's entry holds only the pairs of the units with metrics (26 pairs fewer). Two wires of P58CS_R1 (ROFC4 and ROFC8) have one distance each but no unit in the file (2 pairs more). 1266 - 26 + 2 = 1242.

isolation-distance¶

The median isolation distance of the units was 24.90.

In [13]:
iso = U.isolationdist.to_numpy()
n_nan = int(np.isnan(iso).sum())
iso = iso[~np.isnan(iso)]
n_big = int((iso >= 1e18).sum())
iso = iso[iso < 1e18]
print("units:", len(U), " NaN removed:", n_nan, " >= 1e18 removed:", n_big, " kept:", len(iso))
print("median %.3f; range %.3g to %.3g" % (np.median(iso), iso.min(), iso.max()))
units: 1450  NaN removed: 448  >= 1e18 removed: 1  kept: 1001
median 24.904; range 3.11 to 7.46e+03

Result: reproduced. Median 24.904 over 1001 units; 448 units of U have no isolation distance (NaN) and one has 3.4e27, removed as the code does.

gaze-missing-p53cs¶

Gaze data were missing for more than half of the movie only for P53CS (74% in run 1, 84% in run 2), whose gaze was excluded from the eye-tracking analysis.

In [14]:
G = {}
for s in S:
    bins, miss, ppd = bm.gaze_bins(s)
    G[s["identifier"]] = dict(bins=bins, missing=miss, ppd=ppd,
                             n=sum(len(b) for b in bins))
gm = pd.Series({k: 100 * v["missing"] for k, v in G.items()}).sort_index()
print(gm.round(1).to_string())
print("sessions at or above 50%:", list(gm[gm >= 50].index))
print("sessions with gaze stored by timestamps:", [s["identifier"] for s in S if s["gaze_rate"] is None])
P41CS_R1     3.9
P41CS_R2     4.0
P42CS_R1     9.2
P42CS_R2     5.0
P43CS_R1     1.6
P43CS_R2     2.3
P44CS_R1     4.6
P47CS_R1     5.5
P47CS_R2     7.1
P48CS_R1     4.2
P48CS_R2     2.9
P49CS_R1     3.4
P49CS_R2     1.1
P51CS_R1     1.6
P51CS_R2     2.3
P53CS_R1    73.6
P53CS_R2    83.6
P54CS_R1     2.2
P54CS_R2     1.5
P55CS_R1     5.7
P55CS_R2    32.1
P56CS_R1     9.4
P56CS_R2    11.4
P57CS_R1     4.1
P57CS_R2     5.3
P58CS_R1    37.6
P60CS_R1     4.5
P62CS_R1     5.0
P62CS_R2     1.3
sessions at or above 50%: ['P53CS_R1', 'P53CS_R2']
sessions with gaze stored by timestamps: ['P54CS_R2', 'P56CS_R1', 'P56CS_R2']

Result: reproduced. P53CS has 73.6% of gaze missing in run 1 and 83.6% in run 2, and its two runs are the only sessions at or above 50%.

gaze-similarity¶

Each participant's gaze was highly correlated with the reference heatmap of the other participants (Pearson's r = 0.75 +- 0.12) and little gaze was missing (7% +- 8%).

In [15]:
keep = sorted(k for k in G if G[k]["missing"] < 0.5)
# code/ephys_qc/gen_figure3_eyetracking.py at commit 8c35290 takes sigma before it removes the
# excluded sessions, so the mean is over all 29 sessions:
#   line 120: sigma = np.mean(pixel_dva_ses) # Standard deviation for Gaussian kernel. Equal for both axes.
#   line 125: remove_subjs_indx = missingdata_ratio>=nan_ratio
#   line 130: pixel_dva_ses = pixel_dva_ses[~remove_subjs_indx]
sigma = np.mean([G[k]["ppd"] for k in sorted(G)])
print("sessions kept:", len(keep), " sigma (pixels per degree): %.3f" % sigma)
subj = np.array([k.split("_")[0] for k in keep])
corr = np.full((len(keep), bm.NBINS), np.nan)
for t in range(bm.NBINS):
    for p in np.unique(subj):
        others = np.vstack([G[k]["bins"][t] for k, sj in zip(keep, subj) if sj != p])
        ref = bm.heatmap(others, sigma)
        for i in np.where(subj == p)[0]:
            h = bm.heatmap(G[keep[i]]["bins"][t], sigma, nan_ratio=0.5)
            if h is not None and ref is not None:
                corr[i, t] = np.corrcoef(ref.ravel(), h.ravel())[0, 1]
z = np.nanmean(np.arctanh(corr), 1)
print("per session r:", dict(zip(keep, np.tanh(z).round(3))))
print("bins used per session: min %d, max %d of %d" % (np.isfinite(corr).sum(1).min(), np.isfinite(corr).sum(1).max(), bm.NBINS))
print("mean r = tanh(mean z) = %.3f; s.d. = tanh(s.d. z, ddof 0) = %.3f; ddof 1 %.3f"
      % (np.tanh(z.mean()), np.tanh(z.std()), np.tanh(z.std(ddof=1))))
print("per participant (mean z over runs): mean %.3f, s.d. %.3f" % (
    np.tanh(pd.Series(z, index=subj).groupby(level=0).mean().mean()),
    np.tanh(pd.Series(z, index=subj).groupby(level=0).mean().std(ddof=0))))
mk = gm[keep]
print("missing gaze (a) the %d kept sessions: mean %.2f%%, s.d. %.2f%% (ddof 1 %.2f)" % (len(mk), mk.mean(), mk.std(ddof=0), mk.std(ddof=1)))
print("missing gaze (b) all %d sessions: mean %.2f%%, s.d. %.2f%% (ddof 1 %.2f)" % (len(gm), gm.mean(), gm.std(ddof=0), gm.std(ddof=1)))
# a check of the gaze clock: the same correlation with each session's gaze shifted by 5 s
corr_sh = []
for i, k in enumerate(keep[:6]):
    vals = []
    for t in range(5, bm.NBINS):
        others = np.vstack([G[kk]["bins"][t] for kk, sj in zip(keep, subj) if sj != subj[i]])
        h = bm.heatmap(G[k]["bins"][t - 5], sigma, nan_ratio=0.5)
        if h is not None:
            vals.append(np.corrcoef(bm.heatmap(others, sigma).ravel(), h.ravel())[0, 1])
    corr_sh.append(np.tanh(np.nanmean(np.arctanh(vals))))
print("clock check, first 6 sessions: r with true timing", np.tanh(z[:6]).round(3), "; with gaze lagged 5 s", np.round(corr_sh, 3))
sessions kept: 27  sigma (pixels per degree): 32.900
per session r: {'P41CS_R1': np.float64(0.834), 'P41CS_R2': np.float64(0.784), 'P42CS_R1': np.float64(0.744), 'P42CS_R2': np.float64(0.737), 'P43CS_R1': np.float64(0.779), 'P43CS_R2': np.float64(0.766), 'P44CS_R1': np.float64(0.767), 'P47CS_R1': np.float64(0.701), 'P47CS_R2': np.float64(0.615), 'P48CS_R1': np.float64(0.813), 'P48CS_R2': np.float64(0.73), 'P49CS_R1': np.float64(0.771), 'P49CS_R2': np.float64(0.787), 'P51CS_R1': np.float64(0.785), 'P51CS_R2': np.float64(0.754), 'P54CS_R1': np.float64(0.779), 'P54CS_R2': np.float64(0.816), 'P55CS_R1': np.float64(0.752), 'P55CS_R2': np.float64(0.593), 'P56CS_R1': np.float64(0.785), 'P56CS_R2': np.float64(0.734), 'P57CS_R1': np.float64(0.678), 'P57CS_R2': np.float64(0.626), 'P58CS_R1': np.float64(0.73), 'P60CS_R1': np.float64(0.756), 'P62CS_R1': np.float64(0.73), 'P62CS_R2': np.float64(0.784)}
bins used per session: min 323, max 479 of 479
mean r = tanh(mean z) = 0.751; s.d. = tanh(s.d. z, ddof 0) = 0.122; ddof 1 0.125
per participant (mean z over runs): mean 0.751, s.d. 0.099
missing gaze (a) the 27 kept sessions: mean 6.63%, s.d. 8.40% (ddof 1 8.56)
missing gaze (b) all 29 sessions: mean 11.59%, s.d. 20.01% (ddof 1 20.36)
clock check, first 6 sessions: r with true timing [0.834 0.784 0.744 0.737 0.779 0.766] ; with gaze lagged 5 s [0.317 0.314 0.311 0.29  0.295 0.3  ]
In [16]:
# sensitivity: sigma from the 27 kept sessions only
sigma27 = np.mean([G[k]["ppd"] for k in keep])
print("pixels per degree by session:", sorted({round(G[k]["ppd"], 3) for k in G}))
print("sigma over 29 sessions %.3f, over the 27 kept %.3f" % (sigma, sigma27))
corr27 = np.full((len(keep), bm.NBINS), np.nan)
for t in range(bm.NBINS):
    for p in np.unique(subj):
        ref = bm.heatmap(np.vstack([G[k]["bins"][t] for k, sj in zip(keep, subj) if sj != p]), sigma27)
        for i in np.where(subj == p)[0]:
            h = bm.heatmap(G[keep[i]]["bins"][t], sigma27, nan_ratio=0.5)
            if h is not None and ref is not None:
                corr27[i, t] = np.corrcoef(ref.ravel(), h.ravel())[0, 1]
z27 = np.nanmean(np.arctanh(corr27), 1)
print("with sigma from the 27 sessions: mean r %.3f, s.d. %.3f (ddof 0)" % (np.tanh(z27.mean()), np.tanh(z27.std())))
pixels per degree by session: [np.float64(26.809), np.float64(34.628), np.float64(43.983)]
sigma over 29 sessions 32.900, over the 27 kept 33.351
with sigma from the 27 sessions: mean r 0.754, s.d. 0.123 (ddof 0)

Result: reproduced. Over the 27 sessions left, r = 0.751 with s.d. 0.122 (inverse Fisher-transformed, ddof 0). Missing gaze is 6.63% +- 8.40% under reading (a), the 27 sessions, within tolerance; under reading (b), all 29 sessions, 11.59% +- 20.01%, outside. The Gaussian sigma is the mean pixels per degree over all 29 sessions (32.90), because gen_figure3_eyetracking.py takes the mean (line 120) before it removes the excluded sessions (line 130); with sigma from the 27 kept sessions (33.35) r is 0.754 +- 0.123, also within tolerance. Lagging a session's gaze by 5 s lowers its correlation from between 0.737 and 0.834 to between 0.290 and 0.317 (first six sessions), consistent with the gaze sharing the movie's clock.

recognition-auc¶

Participants remembered the movie well; their recognition accuracy across confidence levels was 0.79 +- 0.19 AUC.

In [17]:
beh = []
for s in S:
    r = bm.recog_trials(s)
    resp = r.actual_response.to_numpy()
    auc = bm.session_auc((r.label == "old").to_numpy(), resp)
    ok, n_new, n_old = bm.rule_R(s)
    beh.append(dict(session=s["identifier"], participant=s["identifier"][:5], run=int(s["identifier"][-1]),
                    trials=len(r), auc=auc, correct_new=n_new, correct_old=n_old, ruleR=ok))
beh = pd.DataFrame(beh).set_index("session")
print(beh.round(3).to_string())
print("\n(a) 29 sessions: mean %.3f, s.d. %.3f (ddof 1 %.3f)" % (beh.auc.mean(), beh.auc.std(ddof=0), beh.auc.std(ddof=1)))
pp = beh.groupby("participant").auc.mean()
print("(b) %d participants: mean %.3f, s.d. %.3f (ddof 1 %.3f)" % (len(pp), pp.mean(), pp.std(ddof=0), pp.std(ddof=1)))
         participant  run  trials    auc  correct_new  correct_old  ruleR
session                                                                  
P41CS_R1       P41CS    1      40  0.812           15           17   True
P41CS_R2       P41CS    2      40  0.866           17           18   True
P42CS_R1       P42CS    1      40  0.826           14           16   True
P42CS_R2       P42CS    2      40  0.958           20           19   True
P43CS_R1       P43CS    1      40  0.830           13           18   True
P43CS_R2       P43CS    2      40  0.912           16           20   True
P44CS_R1       P44CS    1      40  0.726            0           20  False
P47CS_R1       P47CS    1      40  0.911           16           19   True
P47CS_R2       P47CS    2      40  0.920           16           20   True
P48CS_R1       P48CS    1      40  0.717           10           17   True
P48CS_R2       P48CS    2      40  0.947           16           19   True
P49CS_R1       P49CS    1      40  0.735           11           16   True
P49CS_R2       P49CS    2      40  0.948           15           20   True
P51CS_R1       P51CS    1      40  0.947           15           20   True
P51CS_R2       P51CS    2      40  0.101            3            0  False
P53CS_R1       P53CS    1      40  0.844           15           16   True
P53CS_R2       P53CS    2      34  0.823           17           13   True
P54CS_R1       P54CS    1      40  0.826           14           18   True
P54CS_R2       P54CS    2      40  0.918           18           16   True
P55CS_R1       P55CS    1      40  0.912           17           20   True
P55CS_R2       P55CS    2      40  0.921           13           19   True
P56CS_R1       P56CS    1      40  0.740           17           12   True
P56CS_R2       P56CS    2      40  0.537           17            6  False
P57CS_R1       P57CS    1      40  0.372            5           12  False
P57CS_R2       P57CS    2      40  0.522            5           15  False
P58CS_R1       P58CS    1      40  0.832           15           15   True
P60CS_R1       P60CS    1      40  0.761           18           12   True
P62CS_R1       P62CS    1      40  0.777           12           17   True
P62CS_R2       P62CS    2      40  0.929           15           19   True

(a) 29 sessions: mean 0.789, s.d. 0.189 (ddof 1 0.192)
(b) 16 participants: mean 0.787, s.d. 0.134 (ddof 1 0.138)

Result: reproduced. Over the 29 sessions (reading a) the AUC is 0.789 +- 0.189 (ddof 0), both within tolerance. Over the 16 participants (reading b) it is 0.787 +- 0.134, the s.d. outside tolerance; reading (a) is the legend's "all sessions".

auc-run1-vs-run2¶

Memory accuracy did not differ between the first and second run for the 13 participants with two runs (0.79 +- 0.14 against 0.79 +- 0.24 AUC, p = 0.960, paired t-test).

In [18]:
two = beh.groupby("participant").filter(lambda d: len(d) == 2)
r1 = two[two.run == 1].set_index("participant").auc
r2 = two[two.run == 2].set_index("participant").auc.loc[r1.index]
t = stats.ttest_rel(r1, r2)
print("participants:", len(r1))
print("run 1: mean %.3f, s.d. %.3f (ddof 1 %.3f)" % (r1.mean(), r1.std(ddof=0), r1.std(ddof=1)))
print("run 2: mean %.3f, s.d. %.3f (ddof 1 %.3f)" % (r2.mean(), r2.std(ddof=0), r2.std(ddof=1)))
print("paired t-test: t = %.3f, p = %.3f; mean difference (run 1 - run 2) %.3f" % (t.statistic, t.pvalue, (r1 - r2).mean()))
participants: 13
run 1: mean 0.788, s.d. 0.138 (ddof 1 0.144)
run 2: mean 0.792, s.d. 0.245 (ddof 1 0.255)
paired t-test: t = -0.054, p = 0.958; mean difference (run 1 - run 2) -0.004

Result: reproduced. For the 13 participants with two runs, run 1 0.788 +- 0.138 and run 2 0.792 +- 0.245 AUC (ddof 0), all four values within tolerance; paired t-test p = 0.958 (mean difference -0.004), so no difference is found.

confidence-accuracy¶

Recognition accuracy was significantly higher for high-confidence than for low-confidence judgments (p < 0.001, paired t-test).

In [19]:
ca = []
for s in S:
    r = bm.recog_trials(s)
    resp = r.actual_response.to_numpy()
    auc = beh.loc[s["identifier"], "auc"]
    if bm.check_inclusion(resp, auc):
        mode, hi, lo = bm.confidence_accuracy((r.label == "old").to_numpy(), resp)
        ca.append(dict(session=s["identifier"], split=mode, high=hi, low=lo))
ca = pd.DataFrame(ca).set_index("session")
print(ca.round(1).to_string())

# every session: responses per confidence level (1 sure new ... 6 sure old) and check_inclusion
inc = []
for s in S:
    resp = bm.recog_trials(s).actual_response.to_numpy()
    cnt = [int(np.sum(resp == i)) for i in range(1, 7)]
    auc = beh.loc[s["identifier"], "auc"]
    why = []
    if auc < 0.6:
        why.append("AUC < 0.6")
    if sum(c == 0 for c in cnt[:3]) > 1:
        why.append("two or more 'new' levels unused")
    if sum(c == 0 for c in cnt[3:]) > 1:
        why.append("two or more 'old' levels unused")
    inc.append(dict(session=s["identifier"], **{f"c{i}": c for i, c in enumerate(cnt, 1)},
                    auc=round(auc, 3), included=bm.check_inclusion(resp, auc), why="; ".join(why)))
inc = pd.DataFrame(inc).set_index("session")
print("\nall sessions:")
print(inc.to_string())
print("excluded:", int((~inc.included).sum()))
t = stats.ttest_rel(ca.high, ca.low)
print("\nsessions included:", len(ca), " high %.1f +- %.1f%%, low %.1f +- %.1f%%" % (ca.high.mean(), ca.high.std(ddof=0), ca.low.mean(), ca.low.std(ddof=0)))
print("paired t-test: t = %.3f, p = %.2g; high above low in %d of %d sessions" % (t.statistic, t.pvalue, int((ca.high > ca.low).sum()), len(ca)))
          split   high    low
session                      
P41CS_R1      1   81.8   50.0
P42CS_R1      1   86.2   50.0
P42CS_R2      1  100.0   85.7
P43CS_R1      1   82.4  100.0
P43CS_R2      1   92.9   87.5
P47CS_R1      1   92.3   83.3
P47CS_R2      1   94.3   66.7
P48CS_R1      1   69.0   66.7
P48CS_R2      1  100.0   50.0
P49CS_R1      1   75.9   75.0
P49CS_R2      1   97.1  100.0
P51CS_R1      1   97.0   60.0
P53CS_R1      1   92.0   62.5
P53CS_R2      1   85.2  100.0
P54CS_R1      1   84.2   77.8
P54CS_R2      1  100.0   62.5
P55CS_R1      1   93.3  100.0
P55CS_R2      1   96.4   57.1
P58CS_R1      1   92.9   58.8
P60CS_R1      1   78.1   57.1
P62CS_R1      1   86.7   64.7
P62CS_R2      1  100.0   69.2

all sessions:
          c1  c2  c3  c4  c5  c6    auc  included                                                               why
session                                                                                                            
P41CS_R1  17   1   0   1   5  16  0.812      True                                                                  
P41CS_R2  19   0   0   0   0  21  0.866     False  two or more 'new' levels unused; two or more 'old' levels unused
P42CS_R1  14   3   1   4   3  15  0.826      True                                                                  
P42CS_R2  14   7   0   0   3  16  0.958      True                                                                  
P43CS_R1  12   3   0   0   3  22  0.830      True                                                                  
P43CS_R2  10   5   1   2   4  18  0.912      True                                                                  
P44CS_R1   0   0   0   4   9  27  0.726     False                                   two or more 'new' levels unused
P47CS_R1  12   4   1   1   8  14  0.911      True                                                                  
P47CS_R2  15   1   0   2   2  20  0.920      True                                                                  
P48CS_R1   5   4   4   1   2  24  0.717      True                                                                  
P48CS_R2  13   4   0   4   4  15  0.947      True                                                                  
P49CS_R1  12   3   0   1   7  17  0.735      True                                                                  
P49CS_R2  14   1   0   0   5  20  0.948      True                                                                  
P51CS_R1  13   0   2   3   2  20  0.947      True                                                                  
P51CS_R2   4   2  17   4   3  10  0.101     False                                                         AUC < 0.6
P53CS_R1  13   5   1   2   7  12  0.844      True                                                                  
P53CS_R2  15   6   0   1   0  12  0.823      True                                                                  
P54CS_R1   7   1   8   9   3  12  0.826      True                                                                  
P54CS_R2   9   3  10   3   1  14  0.918      True                                                                  
P55CS_R1   5   9   3   0  13  10  0.912      True                                                                  
P55CS_R2  10   4   0   3   5  18  0.921      True                                                                  
P56CS_R1  24   1   0   0   0  15  0.740     False                                   two or more 'old' levels unused
P56CS_R2  22   9   0   0   5   4  0.537     False                                                         AUC < 0.6
P57CS_R1   3  10   0   8  16   3  0.372     False                                                         AUC < 0.6
P57CS_R2   0   3   7   4  23   3  0.522     False                                                         AUC < 0.6
P58CS_R1   8   5   7   5   9   6  0.832      True                                                                  
P60CS_R1  20   2   4   1   1  12  0.761      True                                                                  
P62CS_R1   6   4   5   8   8   9  0.777      True                                                                  
P62CS_R2   8   4   4   5   6  13  0.929      True                                                                  
excluded: 7

sessions included: 22  high 89.9 +- 8.5%, low 72.0 +- 16.8%
paired t-test: t = 4.364, p = 0.00027; high above low in 18 of 22 sessions

Result: reproduced. 22 sessions pass check_inclusion (all with split 1); accuracy is 89.9% for high and 72.0% for low confidence, higher in 18 of 22 sessions; paired t-test p = 0.00027. The table of all sessions shows the seven excluded and why: AUC below 0.6 (P51CS_R2, P56CS_R2, P57CS_R1, P57CS_R2), two or more of the three 'new' levels unused (P44CS_R1, P41CS_R2) and two or more of the three 'old' levels unused (P56CS_R1, P41CS_R2). The claims file's statement says "significantly higher" where the paper says "significantly different"; high is above low here, so the result holds under either.

memory-sessions-included¶

Of the 1450 neurons, 1266 entered the memory analysis; the rest came from runs excluded for poor behavior (P44CS run 1, P51CS run 2, P56CS run 2, P57CS runs 1 and 2).

In [20]:
listed = {"P44CS_R1", "P51CS_R2", "P56CS_R2", "P57CS_R1", "P57CS_R2"}
n_U = U.groupby("session").size()
readings = {
    "(a) rule R": set(beh.index[~beh.ruleR]),
    "(b) the five listed runs": listed,
    "(c) AUC <= 0.6 or rule R": set(beh.index[(beh.auc <= 0.6) | ~beh.ruleR]),
}
for name, rem in readings.items():
    print("%-26s removes %-60s units kept %d" % (name, sorted(rem), int(n_U.drop(sorted(rem), errors="ignore").sum())))
print("\nAUC and correct trials of the sessions any reading removes:")
print(beh.loc[sorted(set.union(*readings.values())), ["auc", "correct_new", "correct_old", "ruleR"]].round(3).to_string())
memory_sessions = sorted(set(beh.index) - readings["(a) rule R"])
(a) rule R                 removes ['P44CS_R1', 'P51CS_R2', 'P56CS_R2', 'P57CS_R1', 'P57CS_R2'] units kept 1266
(b) the five listed runs   removes ['P44CS_R1', 'P51CS_R2', 'P56CS_R2', 'P57CS_R1', 'P57CS_R2'] units kept 1266
(c) AUC <= 0.6 or rule R   removes ['P44CS_R1', 'P51CS_R2', 'P56CS_R2', 'P57CS_R1', 'P57CS_R2'] units kept 1266

AUC and correct trials of the sessions any reading removes:
            auc  correct_new  correct_old  ruleR
session                                         
P44CS_R1  0.726            0           20  False
P51CS_R2  0.101            3            0  False
P56CS_R2  0.537           17            6  False
P57CS_R1  0.372            5           12  False
P57CS_R2  0.522            5           15  False

Result: reproduced. All three readings remove the same five runs, the five the paper lists (P44CS run 1, P51CS run 2, P56CS run 2, P57CS runs 1 and 2), and keep 1266 units. P44CS run 1 is removed for having no correct novel trials although its AUC is 0.726.

memory-cells-significant and memory-cells-not-significant¶

Significant proportions of cells were memory selective in the amygdala (32/436, p = 0.015), ACC (22/186, p = 0.002) and vmPFC (14/150, p = 0.016).

The proportions of memory-selective cells in the hippocampus (14/238, p = 0.30) and preSMA (17/256, p = 0.17) were not significant.

Units of U in the sessions kept by rule R (the reading of memory-sessions-included that gives 1266 units); spike counts in 0.2 to 1.7 s after each trial's start; correct trials; bootstrap B (novel against familiar, balanced, seed 13); permutation test P with 2,000 shuffles (seed 0), on the code's spike rates (count / 1.5 s) as the observed test, so that ties between resampled means fall as the code's floating point has them. The null on exact counts is printed after it for comparison.

In [21]:
blocks_m, table_m = bm.cell_blocks(S, "memory", sessions=set(memory_sessions))
cells_m, sum_m = bm.selection_and_null(blocks_m, table_m, balanced=True, positive_only=False, seed=0,
                                      rate_window=bm.MEMORY_WINDOW[1] - bm.MEMORY_WINDOW[0])
paper = pd.DataFrame({"area": ["amygdala", "hippocampus", "ACC", "preSMA", "vmPFC"],
                      "paper_selective": [32, 14, 22, 17, 14], "paper_n": [436, 238, 186, 256, 150],
                      "paper_p": [0.015, 0.30, 0.002, 0.17, 0.016]})
print(sum_m.merge(paper).round(4).to_string())
print("\nselective cells: %d of %d; novel > familiar in %d" % (cells_m.selective.sum(), len(cells_m), int((cells_m.selective & (cells_m["diff"] > 0)).sum())))
print("by participant (selective / cells):")
cp = cells_m.assign(p=cells_m.session.str[:5]).groupby("p").agg(sel=("selective", "sum"), n=("selective", "size"))
print(cp.T.to_string())
# the same null on exact spike counts (as in the earlier runs), where ties between resampled means
# are exact; above, the null runs on the code's rates, as the observed test does
_, sum_c = bm.selection_and_null(blocks_m, table_m, balanced=True, positive_only=False, seed=0,
                                 rate_window=bm.MEMORY_WINDOW[1] - bm.MEMORY_WINDOW[0], null_rate_window=None)
print("\nnull on rates (above) against null on exact counts:")
print(sum_m[["area", "selective", "p_perm", "null_mean", "null_95th"]].merge(
    sum_c[["area", "p_perm", "null_mean", "null_95th"]], on="area", suffixes=("_rates", "_counts")).round(4).to_string())
          area    n  selective  p_perm  null_mean  null_95th   mc_se  paper_selective  paper_n  paper_p
0     amygdala  436         32  0.0095    21.0190       28.0  0.0022               32      436    0.015
1  hippocampus  238         14  0.2824    11.6970       17.0  0.0101               14      238    0.300
2          ACC  186         22  0.0005     9.5665       15.0  0.0005               22      186    0.002
3       preSMA  256         17  0.1824    13.2650       19.0  0.0086               17      256    0.170
4        vmPFC  150         14  0.0220     7.5700       12.0  0.0033               14      150    0.016

selective cells: 99 of 1266; novel > familiar in 35
by participant (selective / cells):
p    P41CS  P42CS  P43CS  P47CS  P48CS  P49CS  P51CS  P53CS  P54CS  P55CS  P56CS  P58CS  P60CS  P62CS
sel      0      9      6     13     19      1      2      4     12     10      1     11      2      9
n       14     96     64    146    255     26     30     82    234     85     30     89     27     88
null on rates (above) against null on exact counts:
          area  selective  p_perm_rates  null_mean_rates  null_95th_rates  p_perm_counts  null_mean_counts  null_95th_counts
0     amygdala         32        0.0095          21.0190             28.0         0.0065           19.9525              27.0
1  hippocampus         14        0.2824          11.6970             17.0         0.2269           11.1565              17.0
2          ACC         22        0.0005           9.5665             15.0         0.0005            9.0890              14.0
3       preSMA         17        0.1824          13.2650             19.0         0.1349           12.6610              19.0
4        vmPFC         14        0.0220           7.5700             12.0         0.0140            7.1755              12.0

Result: memory-cells-significant reproduced. Amygdala 32/436 (permutation p = 0.0095), ACC 22/186 (p = 0.0005) and vmPFC 14/150 (p = 0.022, 14 against a null 95th percentile of 12): each below 0.05, with the paper's counts and denominators.

Result: memory-cells-not-significant reproduced. Hippocampus 14/238 (p = 0.282) and preSMA 17/256 (p = 0.182), neither below 0.05, with the paper's counts.

The null on the code's rates has 0.4 to 1.1 cells more per area than the null on exact counts (null means 21.02 against 19.95 in the amygdala, 7.57 against 7.18 in vmPFC), and every p but the ACC's (0.0005 in both, the smallest possible) is higher, by 0.003 to 0.056 (amygdala 0.0095 against 0.0065, vmPFC 0.022 against 0.014). No decision changes. The p on rates are closer to the paper's (0.015, 0.30, 0.002, 0.17, 0.016).

scenecut-labels¶

The movie has 80 continuity cuts and 13 scene changes, and the annotation file's cuts can be placed in each session through the frame times in the NWB files.

In [22]:
print("cuts:", len(cuts), cuts.kind.value_counts().to_dict())
print("shot_start_fr range:", int(cuts.shot_start_fr.min()), "to", int(cuts.shot_start_fr.max()),
      "; frames per session:", sorted({len(s["frame_times"]) for s in S}))
ok = []
for s in S:
    t0, t1 = bm.movie_window(s)
    o = bm.cut_onsets(s, cuts)
    ok.append(bool(np.all((o >= t0) & (o <= t1)) and cuts.shot_start_fr.max() <= len(s["frame_times"])))
print("sessions where every cut onset falls in the movie window:", sum(ok), "of", len(S))
dev = np.concatenate([bm.cut_onsets(s, cuts) - cuts.shot_start_t.to_numpy() for s in S])
print("cut onset minus the file's shot_start_t (s): median %.3f, range %.3f to %.3f" % (np.median(dev), dev.min(), dev.max()))
cuts: 93 {'cont': 80, 'change': 13}
shot_start_fr range: 1 to 11887 ; frames per session: [11971]
sessions where every cut onset falls in the movie window: 29 of 29
cut onset minus the file's shot_start_t (s): median 0.002, range 0.000 to 0.020

Result: reproduced. The annotation file has 80 continuity cuts and 13 scene changes by rule S, and every cut onset falls in the movie window in all 29 sessions; the onsets from the frame times are within 0 to 20 ms of the file's own shot start times.

event-cells¶

Significant proportions of cells were event selective (scene change against continuity cut) in the vmPFC (10/175, p = 0.005) and preSMA (20/299, p < 0.001), but not in the amygdala (15/479, p = 0.081), ACC (7/236, p = 0.224) or hippocampus (8/261, p = 0.199).

In [23]:
blocks_e, table_e = bm.cell_blocks(S, "event", cuts=cuts)
cells_e, sum_e = bm.selection_and_null(blocks_e, table_e, balanced=False, positive_only=True, seed=0)
paper_e = pd.DataFrame({"area": ["amygdala", "hippocampus", "ACC", "preSMA", "vmPFC"],
                        "paper_selective": [15, 8, 7, 20, 10], "paper_n": [479, 261, 236, 299, 175],
                        "paper_p": [0.081, 0.199, 0.224, 0.001, 0.005]})
print(sum_e.merge(paper_e).round(4).to_string())
print("\nvariant, either direction (p < 0.05):",
      {a: int(cells_e.selective_any_direction[cells_e.area == a].sum()) for a in bm.AREAS})
print("cells selective with change < continuity:",
      {a: int((cells_e.selective_any_direction & (cells_e["diff"] < 0))[cells_e.area == a].sum()) for a in bm.AREAS})
cp = cells_e.assign(p=cells_e.session.str[:5]).groupby("p").agg(sel=("selective", "sum"), n=("selective", "size"))
print("by participant:"); print(cp.T.to_string())
          area    n  selective  p_perm  null_mean  null_95th   mc_se  paper_selective  paper_n  paper_p
0     amygdala  479         15  0.0865    10.0900      15.05  0.0063               15      479    0.081
1  hippocampus  261          8  0.2094     5.6710      10.00  0.0091                8      261    0.199
2          ACC  236          7  0.2294     4.9775       9.00  0.0094                7      236    0.224
3       preSMA  299         20  0.0005     6.4925      11.00  0.0005               20      299    0.001
4        vmPFC  175         10  0.0055     3.6705       7.00  0.0017               10      175    0.005

variant, either direction (p < 0.05): {'amygdala': 72, 'hippocampus': 23, 'ACC': 34, 'preSMA': 42, 'vmPFC': 23}
cells selective with change < continuity: {'amygdala': 57, 'hippocampus': 15, 'ACC': 27, 'preSMA': 22, 'vmPFC': 13}
by participant:
p    P41CS  P42CS  P43CS  P44CS  P47CS  P48CS  P49CS  P51CS  P53CS  P54CS  P55CS  P56CS  P57CS  P58CS  P60CS  P62CS
sel      0      2      3      1      9      6      2      3      3      8      3      3      4      8      3      2
n       14     96     64     49    146    255     26     75     82    234     85     59     61     89     27     88

Result: reproduced. The counts are the paper's in every area: vmPFC 10/175 (p = 0.0055), preSMA 20/299 (p = 0.0005), amygdala 15/479 (p = 0.087), ACC 7/236 (p = 0.229) and hippocampus 8/261 (p = 0.209). In either direction many more cells are selective (amygdala 72, preSMA 42), most of them with weaker responses to scene changes; the paper's numbers are those of the code's one-direction rule.

A check of the port of the bootstrap. The next cell recomputes, for every cell of the two analyses above, the observed bootstrap p with a literal port of the code's win_spike_rate, ms_test and scenechange_test (run_permutation=False, default_rng(13) per cell, spike rates from spike times relative to the onset) and get_bootstrappval, one cell at a time, and compares it with observed_selection, which draws the same resamples once per session.

In [24]:
def get_bootstrappval(x):                       # vizutils_neuron.py, two-sided
    x = np.array(x)
    if np.mean(x) > 0:
        p_1 = (np.sum(x <= 0) + 1.) / (x.size + 1.)
        p_2 = (np.sum(x > 0) + 1.) / (x.size + 1.)
    elif np.mean(x) < 0:
        p_1 = (np.sum(x < 0) + 1.) / (x.size + 1.)
        p_2 = (np.sum(x >= 0) + 1.) / (x.size + 1.)
    else:
        p_1 = (np.sum(x <= 0) + 1.) / (x.size + 1.)
        p_2 = (np.sum(x >= 0) + 1.) / (x.size + 1.)
    return 2. * np.min([p_1, p_2])

def win_spike_rate(ts, start, end):
    return sum(np.logical_and(ts >= start, ts <= end)) / (end - start)

def literal_p(s, k, task):
    st = np.asarray(s["units"].spike_times.iloc[k])
    if task == "memory":
        r = bm.recog_trials(s)
        rates = np.array([win_spike_rate(st[(st >= o - 1.) & (st <= o + 2.)] - o, 0.2, 1.7) for o in r.start_time])
        resp = np.where(r.actual_response <= 3., "new", "old")
        old = rates[(r.label.to_numpy() == "old") & (resp == "old")]
        new = rates[(r.label.to_numpy() == "new") & (resp == "new")]
        bal = min(len(new), len(old))
        rng = np.random.default_rng(13)
        i_new = rng.integers(len(new), size=(bal, 10000))
        i_old = rng.integers(len(old), size=(bal, 10000))
        dv = np.mean(new[i_new], 0) - np.mean(old[i_old], 0)
    else:
        ons = bm.cut_onsets(s, cuts)
        rates = np.array([win_spike_rate(st[(st >= o - 1.) & (st <= o + 2.)] - o, 0.0, 1.0) for o in ons])
        change, cont = rates[(cuts.kind == "change").to_numpy()], rates[(cuts.kind == "cont").to_numpy()]
        rng = np.random.default_rng(13)
        i_ch = rng.integers(len(change), size=(len(change), 10000))
        i_co = rng.integers(len(cont), size=(len(cont), 10000))
        dv = np.mean(change[i_ch], 0) - np.mean(cont[i_co], 0)
    return get_bootstrappval(dv)

by_id = {s["identifier"]: s for s in S}
for task, cells in [("memory", cells_m), ("event", cells_e)]:
    lit = []
    for sid, g in cells.groupby("session", sort=False):
        s = by_id[sid]
        pos = {u: k for k, u in enumerate(s["units"].unit_id_session)}
        lit.extend((u, literal_p(s, pos[u], task)) for u in g.unit_id_session)
    lit = pd.Series(dict(lit))
    ours = cells.set_index("unit_id_session").p.loc[lit.index]
    dif = (lit - ours).abs()
    print(f"{task}: {len(lit)} cells; literal port and observed_selection agree exactly in {int((dif == 0).sum())},"
          f" largest difference {dif.max():.2g}; selective at p < 0.05 by both: {int(((lit < 0.05) == (ours < 0.05)).sum())} of {len(lit)}")
memory: 1266 cells; literal port and observed_selection agree exactly in 1266, largest difference 0; selective at p < 0.05 by both: 1266 of 1266
event: 1450 cells; literal port and observed_selection agree exactly in 1450, largest difference 0; selective at p < 0.05 by both: 1450 of 1450

The literal port gives the same bootstrap p as observed_selection for all 1266 cells of the memory analysis and all 1450 cells of the event analysis, so the selection reproduces the code's own resamples. (The memory test uses the code's spike rates, counts divided by 1.5 s, so that near-ties between resampled means fall as in the code's floating point.)

scanner-questions¶

In the scanner, participants answered on average 5.97 +- 0.98 of seven questions on the movie correctly (across participants and runs).

Not in the dandiset (data: elsewhere), and not tested on it: the claims file's criterion is "Not tested on the dandiset". The protocol tests an elsewhere claim on the data where the paper deposited them, so the in-scanner answers are read from the code repository's assets/annotations/scanner_questionnaire.csv at commit 8c35290, which the claims file names as one of the two copies. The result is about that file, not about the dandiset, and the registry counts it apart from the dandiset's claims.

In [25]:
url_q = ("https://raw.githubusercontent.com/rutishauserlab/bmovie-release-NWB-BIDS/"
         f"{bm.CODE_COMMIT}/assets/annotations/scanner_questionnaire.csv")
with urllib.request.urlopen(url_q) as r:
    qn = pd.read_csv(r)
print(qn.to_string())
vals = pd.concat([qn["R1 (corrects)"], qn["R2 (corrects)"]]).dropna()
print("\nparticipants:", len(qn), " runs:", len(vals))
print("mean %.3f, s.d. %.3f (ddof 1 %.3f)" % (vals.mean(), vals.std(ddof=0), vals.std(ddof=1)))
sums_ok = all((qn[[f"R{k}_Q{i}" for i in range(1, 8)]].sum(axis=1) == qn[f"R{k} (corrects)"]).all() for k in (1, 2))
print("per-question answers sum to the totals:", sums_ok)
       ID  R1 (corrects)  R2 (corrects)  R1_Q1  R1_Q2  R1_Q3  R1_Q4  R1_Q5  R1_Q6  R1_Q7  R2_Q1  R2_Q2  R2_Q3  R2_Q4  R2_Q5  R2_Q6  R2_Q7
0   P41CS              5              7      1      1      1      1      0      1      0      1      1      1      1      1      1      1
1   P42CS              7              7      1      1      1      1      1      1      1      1      1      1      1      1      1      1
2   P43CS              6              7      1      1      1      1      1      0      1      1      1      1      1      1      1      1
3   P44CS              5              5      0      1      1      1      1      1      0      1      1      0      1      1      0      1
4   P45CS              5              6      1      0      1      1      0      1      1      1      1      1      1      1      0      1
5   P46CS              4              6      1      1      0      1      0      0      1      1      1      0      1      1      1      1
6   P47CS              4              7      0      0      1      1      1      0      1      1      1      1      1      1      1      1
7   P48CS              6              7      1      1      1      1      1      0      1      1      1      1      1      1      1      1
8   P50CS              6              7      1      1      1      1      1      0      1      1      1      1      1      1      1      1
9   P51CS              5              7      1      1      1      1      0      0      1      1      1      1      1      1      1      1
10  P53CS              6              6      1      1      1      1      1      1      0      1      1      1      1      1      1      0
11  P54CS              5              4      1      0      0      1      1      1      1      0      0      1      0      1      1      1
12  P59CS              6              7      1      1      0      1      1      1      1      1      1      1      1      1      1      1
13  P60CS              6              7      1      1      0      1      1      1      1      1      1      1      1      1      1      1
14  P62CS              6              7      1      1      1      1      1      0      1      1      1      1      1      1      1      1

participants: 15  runs: 30
mean 5.967, s.d. 0.983 (ddof 1 0.999)
per-question answers sum to the totals: True

Result: reproduced, on the code repository's file (data: elsewhere), not on the dandiset. Over 15 participants and 30 runs, 5.967 +- 0.983 correct answers (ddof 0), both within tolerance.

Summary¶

Claim Outcome
cohort-emu-sessions reproduced
table1-demographics reproduced (with the Table 1 values of the four fMRI-only participants)
neurons-total-and-areas reproduced
units-per-wire reproduced
firing-rate reproduced
isi-violations reproduced, under reading (b), units below 3%
waveform-snr reproduced
projection-distance reproduced
isolation-distance reproduced
gaze-missing-p53cs reproduced
gaze-similarity reproduced, missing gaze under reading (a), the 27 sessions kept
recognition-auc reproduced, under reading (a), the 29 sessions
auc-run1-vs-run2 reproduced
confidence-accuracy reproduced
memory-sessions-included reproduced (all readings agree)
memory-cells-significant reproduced
memory-cells-not-significant reproduced
scenecut-labels reproduced
event-cells reproduced
scanner-questions reproduced on the code repository's copy of the answers (data: elsewhere, counted apart from the dandiset)

The LFP, iEEG, example, modality and file-content claims are in hfb_keles_2024.ipynb; the fMRI claims are blocked (see the header).

How the analysis differs from the paper's. The permutation tests are seeded (seed 0, open detail 8 of the claims file) and share each shuffle's bootstrap resamples among the cells of a session (see bmovie.py); the paper's code draws them per cell and unseeded. The observed bootstrap p of every cell equals that of a literal port of the code, and the memory test's null, like the observed test, runs on the code's spike rates. Where the claims file names readings, all are shown.

What was found about the dataset. The files match the paper closely: every count of sessions, participants, units and cuts is exact, and the quality metrics, behaviour and selectivity counts match to the reported precision under the readings chosen; where the claims file names two readings, the other falls outside tolerance for the ISI violations (reading (a), all 1450 units), missing gaze (reading (b), all 29 sessions) and the s.d. of the AUC (reading (b), per participant). The units table describes isibelow as a proportion, but it holds percentages. 448 of the 1450 units have no isolation distance and one has 3.4e27. The electrodes table lists 1242 projection distances where the units per wire imply 1266 pairs: the pairs of the 7 units without waveform metrics (the 7 outside U) are left out, and two wires of P58CS_R1 with no unit have one distance each. Three sessions (P54CS run 2, P56CS runs 1 and 2) store gaze with timestamps, the others with a rate. P53CS run 2 has 34 recognition trials, not 40. The fMRI-only participants' demographics are not in the dandiset.