Reproducing Elliott, Andrews et al. (2026): spike-based claims¶
Paper: Elliott, Andrews et al., "Microscale maps of bursting dynamics across human hippocampal slices
from patients with epilepsy", J. Neurophysiol. (2026), doi:10.1152/jn.00217.2025. The claims file
(claims/elliott-2026.yaml) was written from the accepted author manuscript in PubMed Central
(PMC12931417) and its supplement (Extended Data).
Dataset: DANDI:001132, version 0.241130.1903 (doi:10.48324/dandi.001132/0.241130.1903), the raw HD-MEA recordings of Andrews et al. 2024. The paper cites the dandiset without a version. Two versions are published, 0.241119.1801 and 0.241130.1903; both list the same 69 assets with the same total size, so the most recent published version is pinned, as the protocol says for a paper that cites none.
Outside input: the curated spike sortings the paper analysed are not in the dandiset. They are read
into memory from the paper's repository, github.com/braingeneers/human_hippocampus at commit
0f83f704ee4c9b4d8d7f75eb53d94f525c85abb2 (the claims file's opening comment). Which sorting file is
which recording is taken from the paper's latency notebooks (figures/figure_3/latencies/t_test_try30_try3/),
which load one file per recording (see hippo.RECORDINGS).
This notebook holds the claims that need spikes only. The claims that need the raw voltage (LFP,
theta, phase locking) are in lfp_elliott_2026.ipynb.
| Claim | Here | Status |
|---|---|---|
| sorting-dandiset-link (link) | yes | tested |
| table1-unit-counts | yes | tested |
| fig1g-ka-synchronized-bursting | yes | tested |
| methods-burst-counts | yes | tested |
| methods-rate-increase-after-ka | yes | tested |
| methods-onset-latency | yes | blocked (metadata_insufficient: no time of KA application) |
| s4-ka-no-epileptiform | yes | tested |
| fig2c-sttc-two-clusters | yes | tested |
| ext9-sttc-eigenvector-gradient | yes | tested |
| ext9-sttc-beats-correlation | yes | tested |
| fig3a-significant-pairs | yes | tested |
| fig3a-bipolar-angle-histograms | yes | tested |
| ext10-baseline-same-circuit | yes | tested |
| table3-geometry-test | yes | tested |
| ext3, fig1j, ext4b, ext4, fig2a, table2 (two claims), fig2b | lfp notebook | |
| methods-rolling-wave-counts | lfp notebook | blocked (methods_underspecified) |
| ext12-simulation-recurrence | yes | blocked (not_runnable: the simulation's conda environment, section at the end) |
import time, zlib, resource
import multiprocessing as mp
import numpy as np, pandas as pd
import matplotlib.pyplot as plt
from concurrent.futures import ProcessPoolExecutor
from scipy import stats
from scipy.cluster import hierarchy
from scipy.spatial.distance import pdist
import hippo as H
T0 = time.time()
print('dandiset', H.DANDISET_ID, 'version', H.DANDISET_VERSION, '; code commit', H.CODE_COMMIT)
dandiset 001132 version 0.241130.1903 ; code commit 0f83f704ee4c9b4d8d7f75eb53d94f525c85abb2
Data check¶
The dandiset's files hold one ElectricalSeries each (raw voltage, uint16 with a conversion to volts,
20 kHz) and an electrode table with positions (rel_x, rel_y). They hold no units, no epochs, no
annotations and no stimulus or drug timing. Subjects are named by slice (sub-<n><patient>-<k>), and
the session start times are all the conversion date (2024-09-28).
assets = H.list_assets()
A = {a['path'].split('/')[0]: a for a in assets}
def meta(a):
f = H.open_nwb(a['asset_id'])
d = f['acquisition/ElectricalSeries/data']
e = H.electrodes(f)
g = lambda k: f[k][()].decode() if k in f else ''
return dict(subject=a['path'].split('/')[0], n_samples=d.shape[0], n_channels=d.shape[1],
rate=float(f['acquisition/ElectricalSeries/starting_time'].attrs['rate']),
conversion=float(d.attrs['conversion']), unit=d.attrs['unit'],
minutes=d.shape[0] / H.FS / 60, age=g('general/subject/age'), sex=g('general/subject/sex'),
start=g('session_start_time')[:10], groups=list(f.keys()), units='units' in f,
processing=list(f['processing'].keys()), intervals='intervals' in f,
stim=list(f['stimulus/presentation'].keys()),
locations=sorted({v.decode() if isinstance(v, bytes) else str(v) for v in f['general/extracellular_ephys/electrodes/location'][:]}), x_range=(e.x.min(), e.x.max()), y_range=(e.y.min(), e.y.max())), e
with ProcessPoolExecutor(4, mp_context=mp.get_context('fork')) as ex:
res = list(ex.map(meta, assets))
M = pd.DataFrame([r[0] for r in res]).sort_values('subject').reset_index(drop=True)
ELEC = {r[0]['subject']: r[1] for r in res}
print(len(M), 'files;', M.subject.str.extract(r'sub-(\d+[A-Z])')[0].nunique(), 'slices')
print('rates', M.rate.unique(), '; units tables', M.units.sum(), '; processing modules', M.processing.map(len).sum(),
'; intervals', M.intervals.sum(), '; stimulus series', M.stim.map(len).sum(), '; session dates', M.start.unique())
print('electrode locations in the electrodes tables of all files:', sorted(set(sum(M.locations, []))))
print('conversion (V per count)', M.conversion.unique(), M.unit.unique())
print('channels', M.n_channels.min(), 'to', M.n_channels.max(), '; electrode x', M.x_range.map(lambda r: r[0]).min(), 'to',
M.x_range.map(lambda r: r[1]).max(), 'um; y', M.y_range.map(lambda r: r[0]).min(), 'to', M.y_range.map(lambda r: r[1]).max(), 'um')
pd.set_option('display.width', 200)
print(M[['subject', 'n_channels', 'minutes', 'age', 'sex']].to_string())
69 files; 12 slices
rates [20000.] ; units tables 0 ; processing modules 0 ; intervals 0 ; stimulus series 0 ; session dates <StringArray>
['2024-09-28']
Length: 1, dtype: str
electrode locations in the electrodes tables of all files: ['unknown']
conversion (V per count) [1.5735626e-06 6.2942504e-06] <StringArray>
['volts']
Length: 1, dtype: str
channels 745 to 1017 ; electrode x 17.5 to 3832.5 um; y 0.0 to 2082.5 um
subject n_channels minutes age sex
0 sub-10F-0 887 5.219167 P52Y F
1 sub-10F-1 1009 2.109500 P52Y F
2 sub-10F-2 1009 3.549000 P52Y F
3 sub-10F-3 1009 3.337500 P52Y F
4 sub-10F-4 1009 5.167500 P52Y F
5 sub-10F-5 1009 5.334333 P52Y F
6 sub-10F-6 1009 6.001667 P52Y F
7 sub-10F-7 1009 6.502167 P52Y F
8 sub-10F-8 1009 6.502167 P52Y F
9 sub-11G-0 894 3.337333 P35Y M
10 sub-11G-1 894 6.502500 P35Y M
11 sub-11G-2 894 8.503833 P35Y M
12 sub-11G-3 894 6.002333 P35Y M
13 sub-11G-4 894 5.014667 P35Y M
14 sub-12G-0 997 3.337333 P35Y M
15 sub-12G-1 997 6.502000 P35Y M
16 sub-12G-2 997 8.502667 P35Y M
17 sub-12G-3 997 5.026500 P35Y M
18 sub-1A-0 995 6.973667 P20Y M
19 sub-2B-0 793 3.321000 P44Y F
20 sub-2B-1 793 5.044333 P44Y F
21 sub-2B-2 793 4.050833 P44Y F
22 sub-3C-0 972 0.913667 P40Y F
23 sub-3C-1 972 0.667333 P40Y F
24 sub-3C-2 972 0.667167 P40Y F
25 sub-3C-3 972 0.667333 P40Y F
26 sub-3C-4 972 0.667500 P40Y F
27 sub-3C-5 972 1.168000 P40Y F
28 sub-3C-6 972 2.000167 P40Y F
29 sub-3C-7 972 3.170833 P40Y F
30 sub-4C-0 745 3.170500 P40Y F
31 sub-4C-1 745 3.171167 P40Y F
32 sub-4C-2 745 3.170667 P40Y F
33 sub-4C-3 745 1.413000 P40Y F
34 sub-4C-4 745 7.701500 P40Y F
35 sub-4C-5 745 4.048500 P40Y F
36 sub-5C-0 942 3.671500 P40Y F
37 sub-5C-1 942 0.834500 P40Y F
38 sub-5C-2 942 2.884833 P40Y F
39 sub-5C-3 942 5.003000 P40Y F
40 sub-5C-4 942 6.044667 P40Y F
41 sub-5C-5 942 7.131667 P40Y F
42 sub-6C-0 947 3.671333 P40Y F
43 sub-6C-1 947 1.668667 P40Y F
44 sub-6C-2 947 1.668333 P40Y F
45 sub-6C-3 947 1.668000 P40Y F
46 sub-6C-4 947 1.507833 P40Y F
47 sub-7D-0 907 5.173000 P46Y F
48 sub-7D-1 907 5.172667 P46Y F
49 sub-7D-2 907 5.173167 P46Y F
50 sub-7D-3 907 3.502500 P46Y F
51 sub-7D-4 907 3.502167 P46Y F
52 sub-7D-5 907 4.001667 P46Y F
53 sub-7D-6 907 1.335000 P46Y F
54 sub-7D-7 907 1.334667 P46Y F
55 sub-8D-0 1017 5.173000 P46Y F
56 sub-8D-1 1017 3.508167 P46Y F
57 sub-8D-2 1017 3.503667 P46Y F
58 sub-8D-3 1017 3.502500 P46Y F
59 sub-8D-4 1017 4.001833 P46Y F
60 sub-9E-0 936 3.337333 P46Y F
61 sub-9E-1 936 2.667500 P46Y F
62 sub-9E-2 936 2.667500 P46Y F
63 sub-9E-3 936 3.334667 P46Y F
64 sub-9E-4 936 2.667500 P46Y F
65 sub-9E-5 936 3.334667 P46Y F
66 sub-9E-6 936 2.667500 P46Y F
67 sub-9E-7 936 5.141333 P46Y F
68 sub-9E-8 936 5.379000 P46Y F
Recordings deposited more than once: every pair of files of the same slice whose durations differ by less than 1 s is compared on one second of raw data (10 to 11 s, first 64 channels): the fraction of identical samples, and the mean correlation of the sample-to-sample changes (which removes slow shared drift). Independent recordings give values near 0.
from itertools import combinations
M['slice'] = M.subject.str.extract(r'sub-(\d+[A-Z])')[0]
pairs = [(a.subject, b.subject) for _, g in M.groupby('slice') for (_, a), (_, b) in combinations(g.iterrows(), 2)
if abs(a.minutes - b.minutes) * 60 < 1.0 and a.n_channels == b.n_channels]
def snippet(sub):
f = H.open_nwb(A[sub]['asset_id'])
return sub, f['acquisition/ElectricalSeries/data'][200000:220000, :64].astype(np.float64)
SNIP = dict(ProcessPoolExecutor(4, mp_context=mp.get_context('fork')).map(snippet, sorted({s for p in pairs for s in p})))
rows = []
for a, b in pairs:
x, y = SNIP[a], SNIP[b]
dx, dy = np.diff(x, axis=0), np.diff(y, axis=0)
cc = [np.corrcoef(dx[:, k], dy[:, k])[0, 1] for k in range(64) if dx[:, k].std() > 0 and dy[:, k].std() > 0]
rows.append(dict(file_a=a, file_b=b, minutes=round(M.set_index('subject').minutes[a], 3), identical_samples=np.mean(x == y),
diff_corr=np.mean(cc), all_identical=bool(np.array_equal(x, y))))
DUP = pd.DataFrame(rows)
print(DUP.round(3).to_string(index=False))
print('pairs compared', len(DUP), '; pairs with more than half the samples identical', int((DUP.identical_samples > 0.5).sum()))
file_a file_b minutes identical_samples diff_corr all_identical sub-10F-7 sub-10F-8 6.502 0.061 0.004 False sub-3C-1 sub-3C-2 0.667 0.792 0.862 False sub-3C-1 sub-3C-3 0.667 0.819 0.894 False sub-3C-1 sub-3C-4 0.667 0.803 0.861 False sub-3C-2 sub-3C-3 0.667 0.792 0.888 False sub-3C-2 sub-3C-4 0.667 0.784 0.872 False sub-3C-3 sub-3C-4 0.667 0.801 0.899 False sub-4C-0 sub-4C-1 3.170 0.058 0.008 False sub-4C-0 sub-4C-2 3.170 0.069 0.009 False sub-4C-1 sub-4C-2 3.171 0.074 0.009 False sub-6C-1 sub-6C-2 1.669 0.046 -0.000 False sub-6C-1 sub-6C-3 1.669 0.044 0.002 False sub-6C-2 sub-6C-3 1.668 0.075 0.000 False sub-7D-0 sub-7D-1 5.173 0.070 0.001 False sub-7D-0 sub-7D-2 5.173 0.064 0.000 False sub-7D-1 sub-7D-2 5.173 0.071 0.001 False sub-7D-3 sub-7D-4 3.502 0.066 0.003 False sub-7D-6 sub-7D-7 1.335 0.066 0.001 False sub-8D-1 sub-8D-2 3.508 0.066 -0.011 False sub-8D-1 sub-8D-3 3.508 0.071 -0.013 False sub-8D-2 sub-8D-3 3.504 0.065 0.011 False sub-9E-0 sub-9E-3 3.337 0.057 0.007 False sub-9E-0 sub-9E-5 3.337 0.056 0.006 False sub-9E-1 sub-9E-2 2.668 0.068 0.005 False sub-9E-1 sub-9E-4 2.668 0.078 0.007 False sub-9E-1 sub-9E-6 2.668 0.048 0.006 False sub-9E-2 sub-9E-4 2.668 0.073 0.005 False sub-9E-2 sub-9E-6 2.668 0.040 0.004 False sub-9E-3 sub-9E-5 3.335 0.074 0.005 False sub-9E-4 sub-9E-6 2.668 0.044 0.005 False pairs compared 30 ; pairs with more than half the samples identical 6
The six pairs of sub-3C-1 to sub-3C-4 share most samples in that second. To tell copies from a shared artifact, the six sub-3C files are compared over their first 40 s and all 972 channels, second by second: the fraction of identical samples, the fraction of samples at the limits of the 10-bit converter (0 or 1023 counts), the correlation of the 1 kHz means (20-sample means, the LFP) and of the sample-to-sample changes, per channel, averaged over channels. sub-3C-0 (0.91 min) and sub-3C-5 (1.17 min) have other lengths and serve as references. Copies would share the LFP at every second; seconds where any file is saturated are reported apart.
FILES3C = [f'sub-3C-{i}' for i in range(6)]
P3C = list(combinations(range(6), 2))
N40, STEP8 = int(40 * H.FS), int(8 * H.FS)
def dup_block(blk):
ds = [H.open_nwb(A[s]['asset_id'])['acquisition/ElectricalSeries/data'] for s in FILES3C]
c0, c1 = blk * 64, min(blk * 64 + 64, ds[0].shape[1])
ident = np.zeros((len(P3C), 40)); rail = np.zeros((6, 40))
lcorr = np.zeros((len(P3C), 40, c1 - c0)); dcorr = np.zeros((len(P3C), 40, c1 - c0))
z = lambda v: (v - v.mean(0)) / (v.std(0) + 1e-9)
for a in range(0, N40, STEP8):
X = [dd[a:a + STEP8, c0:c1].astype(np.int32) for dd in ds]
for sec in range(8):
seg = [x[sec * 20000:(sec + 1) * 20000] for x in X]
L = [z(x.reshape(-1, 20, x.shape[1]).mean(1)) for x in seg] # 1 kHz means (LFP)
D = [z(np.diff(x, axis=0).astype(float)) for x in seg] # sample-to-sample changes
s = a // 20000 + sec
for i, x in enumerate(seg):
rail[i, s] += np.sum((x == 0) | (x == 1023))
for k, (i, j) in enumerate(P3C):
ident[k, s] += np.sum(seg[i] == seg[j])
lcorr[k, s] = np.mean(L[i] * L[j], 0); dcorr[k, s] = np.mean(D[i] * D[j], 0)
return ident, rail, lcorr, dcorr
t = time.time()
with ProcessPoolExecutor(4, mp_context=mp.get_context('fork')) as ex:
R = list(ex.map(dup_block, range(int(np.ceil(972 / 64)))))
nch = 972
ident = sum(r[0] for r in R) / (20000 * nch); rail = sum(r[1] for r in R) / (20000 * nch)
lcorr = np.concatenate([r[2] for r in R], axis=2).mean(2); dcorr = np.concatenate([r[3] for r in R], axis=2).mean(2)
sat = (rail > 0.1).any(0)
print(f'{time.time()-t:.0f} s; first 40 s, all {nch} channels, per second')
print('fraction of samples at the ADC limits (0 or 1023 counts), seconds where it exceeds 0.1:')
for i, s in enumerate(FILES3C):
print(f' {s} ({M.set_index("subject").minutes[s]:.2f} min): seconds {np.where(rail[i] > 0.1)[0].tolist()}; largest {rail[i].max():.2f}; elsewhere {rail[i][~sat].max():.4f} at most')
rows = []
for k, (i, j) in enumerate(P3C):
rows.append(dict(file_a=FILES3C[i], file_b=FILES3C[j], same_length=bool(abs(M.set_index('subject').minutes[FILES3C[i]] - M.set_index('subject').minutes[FILES3C[j]]) * 60 < 1),
identical_all=ident[k].mean(), identical_saturated_s=ident[k][sat].mean(), identical_other_s=ident[k][~sat].mean(),
identical_other_s_max=ident[k][~sat].max(), lfp_corr_other_s=np.median(lcorr[k][~sat]), lfp_corr_other_s_max=lcorr[k][~sat].max(),
diff_corr_other_s=np.median(dcorr[k][~sat]), lfp_corr_above_half_s=np.where(lcorr[k] > 0.5)[0].tolist()))
DUP3C = pd.DataFrame(rows)
print('saturated seconds (any file above 0.1):', np.where(sat)[0].tolist())
print(DUP3C.round(3).to_string(index=False))
print(f'peak memory {resource.getrusage(resource.RUSAGE_SELF).ru_maxrss/1e6:.1f} GB')
138 s; first 40 s, all 972 channels, per second fraction of samples at the ADC limits (0 or 1023 counts), seconds where it exceeds 0.1: sub-3C-0 (0.91 min): seconds [3, 4, 5, 8, 9]; largest 0.89; elsewhere 0.0887 at most sub-3C-1 (0.67 min): seconds [10, 11, 12, 20, 21]; largest 0.88; elsewhere 0.0678 at most sub-3C-2 (0.67 min): seconds [10, 11, 12, 20, 21]; largest 0.87; elsewhere 0.0730 at most sub-3C-3 (0.67 min): seconds [10, 11, 12, 20, 21]; largest 0.88; elsewhere 0.0657 at most sub-3C-4 (0.67 min): seconds [10, 11, 12, 20, 21]; largest 0.87; elsewhere 0.0655 at most sub-3C-5 (1.17 min): seconds [10, 11, 12, 13, 20, 21]; largest 0.87; elsewhere 0.0664 at most saturated seconds (any file above 0.1): [3, 4, 5, 8, 9, 10, 11, 12, 13, 20, 21] file_a file_b same_length identical_all identical_saturated_s identical_other_s identical_other_s_max lfp_corr_other_s lfp_corr_other_s_max diff_corr_other_s lfp_corr_above_half_s sub-3C-0 sub-3C-1 False 0.007 0.000 0.009 0.032 0.010 0.054 0.909 [] sub-3C-0 sub-3C-2 False 0.007 0.000 0.009 0.029 0.002 0.068 0.908 [] sub-3C-0 sub-3C-3 False 0.006 0.000 0.009 0.027 0.006 0.049 0.906 [] sub-3C-0 sub-3C-4 False 0.007 0.000 0.009 0.027 0.004 0.190 0.907 [] sub-3C-0 sub-3C-5 False 0.006 0.000 0.008 0.024 0.002 0.057 0.908 [] sub-3C-1 sub-3C-2 True 0.104 0.261 0.044 0.084 0.077 0.908 0.927 [10, 11, 12, 13, 14, 15, 20, 21, 22, 23, 24] sub-3C-1 sub-3C-3 True 0.099 0.258 0.039 0.075 0.049 0.911 0.928 [10, 11, 12, 13, 15, 20, 21, 22, 23, 24] sub-3C-1 sub-3C-4 True 0.100 0.257 0.040 0.078 0.076 0.909 0.926 [10, 11, 12, 13, 14, 20, 21, 22, 23, 24, 25] sub-3C-1 sub-3C-5 False 0.100 0.259 0.040 0.079 0.033 0.911 0.927 [10, 11, 12, 13, 14, 15, 20, 21, 22, 23, 24] sub-3C-2 sub-3C-3 True 0.104 0.265 0.043 0.080 0.046 0.906 0.926 [10, 11, 12, 13, 15, 20, 21, 22, 23, 24] sub-3C-2 sub-3C-4 True 0.103 0.261 0.043 0.085 0.079 0.904 0.925 [10, 11, 12, 13, 14, 20, 21, 22, 23, 24] sub-3C-2 sub-3C-5 False 0.104 0.265 0.043 0.087 0.055 0.907 0.925 [10, 11, 12, 13, 14, 15, 20, 21, 22, 23, 24] sub-3C-3 sub-3C-4 True 0.103 0.260 0.043 0.086 0.035 0.910 0.929 [10, 11, 12, 13, 20, 21, 22, 23, 24] sub-3C-3 sub-3C-5 False 0.102 0.266 0.040 0.075 0.052 0.913 0.928 [10, 11, 12, 13, 20, 21, 22, 23, 24] sub-3C-4 sub-3C-5 False 0.101 0.260 0.040 0.079 0.071 0.909 0.928 [10, 11, 12, 13, 14, 20, 21, 22, 23, 24] peak memory 0.6 GB
t = time.time()
SORT = {r: H.load_sorting(r) for r in H.RECORDINGS}
rows = []
for r, s in SORT.items():
rates = np.array([len(x) for x in s['trains']]) / (s['length_ms'] / 1000)
rows.append(dict(rec=r, slice=H.RECORDINGS[r]['slice'], cond=H.RECORDINGS[r]['cond'], units=s['n'],
spikes=sum(len(x) for x in s['trains']), span_min=s['length_ms'] / 60000,
first_spike_s=min(x[0] for x in s['trains'] if len(x)) / 1000,
median_rate_hz=np.median(rates), x_um=f"{s['pos'][:,0].min():.0f}-{s['pos'][:,0].max():.0f}",
y_um=f"{s['pos'][:,1].min():.0f}-{s['pos'][:,1].max():.0f}",
unsorted_trains=sum(np.any(np.diff(x) < 0) for x in s['trains']),
empty=sum(len(x) == 0 for x in s['trains'])))
SUM = pd.DataFrame(rows)
print(SUM.to_string(index=False))
print(f'loaded in {time.time()-t:.0f} s')
rec slice cond units spikes span_min first_spike_s median_rate_hz x_um y_um unsorted_trains empty 1 S1 KA 212 320923 6.001633 0.01000 3.239396 192-2502 18-1522 0 0 2 S1 baseline 249 293807 4.552481 0.00085 3.968532 210-2502 718-1732 0 0 3 S2 KA 180 209118 8.503611 0.00690 1.594421 1295-3115 0-1225 0 0 4 S2 baseline 51 36481 5.014579 0.00665 1.475697 2048-3150 18-928 0 0 5 S3 no drug 87 49667 6.973599 0.00620 0.712210 1418-3588 542-1838 0 0 6 S4 KA 109 76950 2.166667 0.00290 1.453846 1208-2555 280-1698 0 1 7 S5 no drug 136 95706 6.420634 0.01520 1.308282 490-1558 52-2048 0 0 8 S6 no drug 100 21177 1.775000 0.03290 0.685446 1242-3762 315-1295 0 0 loaded in 15 s
Which sorting file is which recording, printed from the paper's latency notebooks
(figures/figure_3/latencies/t_test_try30_try3/) at the pinned commit: the line of each notebook
that loads a sorting, and whether it names the file used here (hippo.RECORDINGS).
LAT = 'figures/figure_3/latencies/t_test_try30_try3/'
LAT_NB = {1: 'hc112823_acid.ipynb', 2: 'hc112823_base.ipynb', 3: 'elliott_chip21769_acid.ipynb', 4: 'elliott_chip21769_base.ipynb',
5: 'hc111_base.ipynb', 6: 'hc110723_acid.ipynb', 7: 'hc328.ipynb', 8: 'hc52_base.ipynb'}
for r, name in LAT_NB.items():
hits = [h for h in H.code_lines(LAT + name, r'data/ephys') if not h[2].startswith('#')]
print(r, H.RECORDINGS[r]['slice'], H.RECORDINGS[r]['cond'], f'| {name} cell {hits[0][0]} line {hits[0][1]}: {hits[0][2][:170]}',
'| names the file used here:', any(H.RECORDINGS[r]['path'] in h[2] for h in hits))
others = sorted(p.split('/')[-1] for p in H.code_tree() if p.startswith(LAT) and p.endswith('.ipynb') and p.split('/')[-1] not in LAT_NB.values())
for name in others:
print('not used:', name, [h[2][:170] for h in H.code_lines(LAT + name, r'data/ephys') if not h[2].startswith('#')])
1 S1 KA | hc112823_acid.ipynb cell 4 line 1: sd = read_autocurated_data( "/workspaces/human_hippocampus/data/ephys/2023-12-03-e-Hc112823_avv9hckcr1/derived/kilosort2/Hc112823_avv9hckcr1_21841_120323_3_acqm.zip" ) | names the file used here: True
2 S1 baseline | hc112823_base.ipynb cell 4 line 1: with open("/workspaces/human_hippocampus/data/ephys/2023-12-03-e-Hc112823_avv9hckcr1/curated_base_acqm.pkl", "rb") as filename: | names the file used here: True
3 S2 KA | elliott_chip21769_acid.ipynb cell 3 line 1: sd = read_phy_files("/workspaces/human_hippocampus/data/ephys/2023-12-11-e-Hc120523_aav9hckcr1_chip21769/elliott/elliott_chip21769_2.zip") | names the file used here: True
4 S2 baseline | elliott_chip21769_base.ipynb cell 3 line 1: sd = read_phy_files( "/workspaces/human_hippocampus/data/ephys/2023-12-11-e-Hc120523_aav9hckcr1_chip21769/elliott/elliott_chip21769_base.zip" ) | names the file used here: True
5 S3 no drug | hc111_base.ipynb cell 3 line 1: sd = read_phy_files( "/workspaces/human_hippocampus/data/ephys/2022-11-02-e-Hc11.1-chip16753/derived/kilosort2/hc11.1_plated-11.1_chip-16753_rec_11.2.22AM-immediate_curat | names the file used here: True
6 S4 KA | hc110723_acid.ipynb cell 4 line 2: with open("/workspaces/human_hippocampus/data/ephys/2023-11-13-e-Hc110723_hckcr1_21841/hc110723_sd.pkl", "rb") as f: | names the file used here: True
7 S5 no drug | hc328.ipynb cell 3 line 1: with open("/workspaces/human_hippocampus/data/ephys/2023-04-02-e-hc328_unperturbed/sd_ca1_curated.pkl", "rb") as filename: | names the file used here: True
8 S6 no drug | hc52_base.ipynb cell 3 line 1: with open('/workspaces/human_hippocampus/data/ephys/2023-05-10-e-hc52_18790_unperturbed/5-10-23s1-CutData.pkl', 'rb' ) as my_file: | names the file used here: True
not used: chip21769_acid.ipynb ['sd = read_autocurated_data( "/workspaces/human_hippocampus/data/ephys/2023-12-11-e-Hc120523_aav9hckcr1_chip21769/derived/kilosort2/Hc120523_aav9hckcr1_chip21769_121123_2_']
not used: chip21769_base.ipynb ['sd = read_autocurated_data( "/workspaces/human_hippocampus/data/ephys/2023-12-11-e-Hc120523_aav9hckcr1_chip21769/derived/kilosort2/Hc120523_aav9hckcr1_chip21769_121123_ba']
sorting-dandiset-link (link claim added by the author)¶
The curated sortings of the paper's repository can be linked to the dandiset's raw recordings: each recording's units sit on the electrodes of one dandiset file, and its spike times align with the raw voltage of that file.
Matching: (1) the fraction of unit positions that fall on an electrode position of each file;
(2) in the files whose layout matches, an offset scan (hippo.offset_scan): the spike trains of
the three most active units are correlated with the high-passed voltage of their nearest electrode
at every offset over the whole file. A sorting from that file gives a peak far below the chance
level (the 100th most negative value), at the offset where the sorting starts.
layout = {}
for r, s in SORT.items():
P = set(map(tuple, np.round(s['pos'], 1)))
frac = {sub: len(P & set(zip(np.round(e.x, 1), np.round(e.y, 1)))) / len(P) for sub, e in ELEC.items()}
full = sorted(k for k, v in frac.items() if v == 1.0)
layout[r] = full
best_other = max(v for k, v in frac.items() if v < 1.0)
print(r, H.RECORDINGS[r]['slice'], H.RECORDINGS[r]['cond'], '-> all units on electrodes of', full,
f'; best other file {best_other:.2f}')
1 S1 KA -> all units on electrodes of ['sub-10F-1', 'sub-10F-2', 'sub-10F-3', 'sub-10F-4', 'sub-10F-5', 'sub-10F-6', 'sub-10F-7', 'sub-10F-8'] ; best other file 0.26 2 S1 baseline -> all units on electrodes of ['sub-10F-0'] ; best other file 0.04 3 S2 KA -> all units on electrodes of ['sub-11G-0', 'sub-11G-1', 'sub-11G-2', 'sub-11G-3', 'sub-11G-4'] ; best other file 0.18 4 S2 baseline -> all units on electrodes of ['sub-11G-0', 'sub-11G-1', 'sub-11G-2', 'sub-11G-3', 'sub-11G-4'] ; best other file 0.43 5 S3 no drug -> all units on electrodes of ['sub-1A-0'] ; best other file 0.13 6 S4 KA -> all units on electrodes of ['sub-9E-0', 'sub-9E-1', 'sub-9E-2', 'sub-9E-3', 'sub-9E-4', 'sub-9E-5', 'sub-9E-6', 'sub-9E-7', 'sub-9E-8'] ; best other file 0.11 7 S5 no drug -> all units on electrodes of ['sub-3C-0', 'sub-3C-1', 'sub-3C-2', 'sub-3C-3', 'sub-3C-4', 'sub-3C-5', 'sub-3C-6', 'sub-3C-7'] ; best other file 0.17 8 S6 no drug -> all units on electrodes of ['sub-8D-0', 'sub-8D-1', 'sub-8D-2', 'sub-8D-3', 'sub-8D-4'] ; best other file 0.18
t = time.time()
jobs = [(r, sub) for r in SORT for sub in layout[r]]
def scan(job):
r, sub = job
return (r, sub) + H.offset_scan(A[sub]['asset_id'], SORT[r])
with ProcessPoolExecutor(4, mp_context=mp.get_context('fork')) as ex:
SCAN = pd.DataFrame(list(ex.map(scan, jobs)), columns=['rec', 'file', 'offset_s', 'peak', 'chance'])
SCAN['ratio'] = SCAN.peak / SCAN.chance
print(SCAN.round(3).to_string(index=False))
print(f'scan took {time.time()-t:.0f} s')
rec file offset_s peak chance ratio 1 sub-10F-1 -117.804 -19.730 -14.711 1.341 1 sub-10F-2 -17.221 -21.692 -15.937 1.361 1 sub-10F-3 -19.622 -21.207 -15.878 1.336 1 sub-10F-4 -0.740 -21.343 -16.882 1.264 1 sub-10F-5 -17.994 -20.658 -17.125 1.206 1 sub-10F-6 0.000 -4016.703 -48.413 82.968 1 sub-10F-7 -18.785 -19.012 -16.035 1.186 1 sub-10F-8 -21.950 -20.799 -16.981 1.225 2 sub-10F-0 20.000 -1374.802 -17.741 77.493 3 sub-11G-0 -284.721 -19.000 -15.265 1.245 3 sub-11G-1 -86.795 -21.984 -16.887 1.302 3 sub-11G-2 -0.000 -2907.706 -18.069 160.918 3 sub-11G-3 -213.221 -24.175 -17.328 1.395 3 sub-11G-4 -169.195 -21.358 -15.892 1.344 4 sub-11G-0 -58.590 -22.222 -15.761 1.410 4 sub-11G-1 80.593 -20.525 -16.002 1.283 4 sub-11G-2 -17.112 -18.092 -14.307 1.265 4 sub-11G-3 32.176 -23.095 -16.826 1.373 4 sub-11G-4 0.000 -1691.315 -17.022 99.358 5 sub-1A-0 -0.000 -2992.837 -17.706 169.029 6 sub-9E-0 12.988 -18.751 -15.252 1.229 6 sub-9E-1 16.113 -20.768 -15.831 1.312 6 sub-9E-2 30.000 -1204.106 -16.308 73.833 6 sub-9E-3 50.647 -19.043 -15.392 1.237 6 sub-9E-4 -39.998 -19.123 -15.843 1.207 6 sub-9E-5 80.152 -19.300 -15.320 1.260 6 sub-9E-6 4.938 -21.628 -16.149 1.339 6 sub-9E-7 65.447 -18.058 -14.290 1.264 6 sub-9E-8 77.288 -18.278 -14.503 1.260 7 sub-3C-0 -43.002 -15.741 -13.078 1.204 7 sub-3C-1 -227.250 -16.433 -12.960 1.268 7 sub-3C-2 -245.056 -15.993 -13.110 1.220 7 sub-3C-3 -148.341 -15.818 -13.053 1.212 7 sub-3C-4 -127.716 -16.290 -13.023 1.251 7 sub-3C-5 -54.094 -16.309 -13.428 1.215 7 sub-3C-6 -53.423 -18.794 -14.290 1.315 7 sub-3C-7 -82.635 -18.577 -15.588 1.192 8 sub-8D-0 62.486 -19.527 -13.674 1.428 8 sub-8D-1 9.987 -19.963 -14.876 1.342 8 sub-8D-2 30.582 -17.461 -14.473 1.206 8 sub-8D-3 25.787 -17.503 -14.511 1.206 8 sub-8D-4 83.990 -18.271 -14.195 1.287 scan took 521 s
LINK = {}
for r in SORT:
d = SCAN[SCAN.rec == r]
hit = d[d.ratio > 10]
if len(hit) == 1:
LINK[r] = dict(file=hit.file.iloc[0], offset_s=round(float(hit.offset_s.iloc[0]), 3))
print(r, H.RECORDINGS[r]['slice'], H.RECORDINGS[r]['cond'], '->', LINK.get(r, 'no file matched'),
f'(best ratio {d.ratio.max():.1f}, files tried {len(d)})')
print('linked', len(LINK), 'of', len(SORT))
1 S1 KA -> {'file': 'sub-10F-6', 'offset_s': 0.0} (best ratio 83.0, files tried 8)
2 S1 baseline -> {'file': 'sub-10F-0', 'offset_s': 20.0} (best ratio 77.5, files tried 1)
3 S2 KA -> {'file': 'sub-11G-2', 'offset_s': -0.0} (best ratio 160.9, files tried 5)
4 S2 baseline -> {'file': 'sub-11G-4', 'offset_s': 0.0} (best ratio 99.4, files tried 5)
5 S3 no drug -> {'file': 'sub-1A-0', 'offset_s': -0.0} (best ratio 169.0, files tried 1)
6 S4 KA -> {'file': 'sub-9E-2', 'offset_s': 30.0} (best ratio 73.8, files tried 9)
7 S5 no drug -> no file matched (best ratio 1.3, files tried 8)
8 S6 no drug -> no file matched (best ratio 1.4, files tried 5)
linked 6 of 8
The scan correlates at every offset, including offsets where the sorting overlaps the file only in part (full-mode correlation), so a file that holds any stretch of a sorting's recording gives a peak. Scanning S5 against each sub-3C file in turn therefore covers the case where the S5 recording is split over several sub-3C files joined in index order. To show that the scan finds a short piece, the S3 sorting is scanned against only 100 to 140 s of its file: 40 s, the length of the shortest sub-3C files.
t = time.time()
part = H.offset_scan(A[LINK[5]['file']]['asset_id'], SORT[5], t0=100, t1=140)
print(f"S3 sorting against 100 to 140 s of {LINK[5]['file']}: offset {part[0]:.3f} s from 100 s (-100 expected), "
f"peak {part[1]:.0f}, chance {part[2]:.1f}, ratio {part[1] / part[2]:.1f}; {time.time() - t:.0f} s")
d7 = SCAN[SCAN.rec == 7]
print('S5 against the sub-3C files:', d7[['file', 'ratio']].round(2).to_dict('records'))
print('sub-3C durations (min):', M.set_index('subject').minutes[[f for f in d7.file]].round(2).to_dict(), '; S5 sorting span',
round(SORT[7]['length_ms'] / 60000, 2), 'min')
S3 sorting against 100 to 140 s of sub-1A-0: offset -100.000 s from 100 s (-100 expected), peak -506, chance -13.0, ratio 39.0; 11 s
S5 against the sub-3C files: [{'file': 'sub-3C-0', 'ratio': 1.2}, {'file': 'sub-3C-1', 'ratio': 1.27}, {'file': 'sub-3C-2', 'ratio': 1.22}, {'file': 'sub-3C-3', 'ratio': 1.21}, {'file': 'sub-3C-4', 'ratio': 1.25}, {'file': 'sub-3C-5', 'ratio': 1.21}, {'file': 'sub-3C-6', 'ratio': 1.32}, {'file': 'sub-3C-7', 'ratio': 1.19}]
sub-3C durations (min): {'sub-3C-0': 0.91, 'sub-3C-1': 0.67, 'sub-3C-2': 0.67, 'sub-3C-3': 0.67, 'sub-3C-4': 0.67, 'sub-3C-5': 1.17, 'sub-3C-6': 2.0, 'sub-3C-7': 3.17} ; S5 sorting span 6.42 min
Result: partially reproduced. Every unit position of each sorting is an electrode position of one slice's files (fraction 1.00; the best other file 0.04 to 0.43), and each sorting file is the one the paper's latency notebook for that recording loads. The offset scan finds recordings 1 to 6 in single files with peaks 74 to 169 times the chance level: S1 KA in sub-10F-6 and S1 baseline in sub-10F-0 (from 20.0 s), S2 KA in sub-11G-2 and S2 baseline in sub-11G-4, S3 in sub-1A-0, and S4 in sub-9E-2 (from 30.0 s). Recordings 7 (S5) and 8 (S6) are not found in any file with their electrode layout (sub-3C and sub-8D files, best ratio 1.3 and 1.4). The scan finds the S3 sorting in a 40 s piece of its file (ratio 39 at the expected offset), and every sub-3C file is at least 40 s long, so no sub-3C file holds a stretch of the S5 recording, joined to others or not. 6 of 8 recordings are linked.
table1-unit-counts¶
The eight recordings analysed hold 212, 249, 180, 51, 87, 109, 136 and 100 sorted units (recordings 1 to 8) and last 6, 5, 8.5, 5, 7, 2.2, 6.4 and 1.8 minutes.
Units are counted in the curated sortings; durations are read from the dandiset file each sorting is linked to (criterion). The span covered by the sorting is shown beside it.
exp_units = [212, 249, 180, 51, 87, 109, 136, 100]
exp_min = [6, 5, 8.5, 5, 7, 2.2, 6.4, 1.8]
rows = []
for r in SORT:
fmin = M.set_index('subject').minutes.get(LINK[r]['file']) if r in LINK else np.nan
u, eu, em = SORT[r]['n'], exp_units[r-1], exp_min[r-1]
rows.append(dict(rec=r, units=u, expected_units=eu, units_ok=abs(u-eu) <= 0.1*eu, file=LINK.get(r, {}).get('file', 'none'),
file_min=fmin, sorting_span_min=SORT[r]['length_ms']/60000, expected_min=em,
file_min_ok=bool(abs(fmin-em) <= 0.1*em) if fmin == fmin else False,
span_ok=abs(SORT[r]['length_ms']/60000-em) <= 0.1*em))
T1 = pd.DataFrame(rows)
T1['both_ok'] = T1.units_ok & T1.file_min_ok
print(T1.round(2).to_string(index=False))
print('recordings matching on units and dandiset duration:', int(T1.both_ok.sum()), 'of 8; units alone', int(T1.units_ok.sum()),
'; units and sorting span', int((T1.units_ok & T1.span_ok).sum()))
rec units expected_units units_ok file file_min sorting_span_min expected_min file_min_ok span_ok both_ok 1 212 212 True sub-10F-6 6.00 6.00 6.0 True True True 2 249 249 True sub-10F-0 5.22 4.55 5.0 True True True 3 180 180 True sub-11G-2 8.50 8.50 8.5 True True True 4 51 51 True sub-11G-4 5.01 5.01 5.0 True True True 5 87 87 True sub-1A-0 6.97 6.97 7.0 True True True 6 109 109 True sub-9E-2 2.67 2.17 2.2 False True False 7 136 136 True none NaN 6.42 6.4 False True False 8 100 100 True none NaN 1.78 1.8 False True False recordings matching on units and dandiset duration: 5 of 8; units alone 8 ; units and sorting span 8
Result: not reproduced. All eight unit counts equal the paper's (212, 249, 180, 51, 87, 109, 136, 100), and the spans of the sortings match all eight durations. On the dandiset's files, five recordings match on both units and duration; S4's file lasts 2.67 min against 2.2 (the sorting covers its 30 to 160 s), and the files of S5 and S6 are not in the dandiset, so 5 of 8 match where the criterion asks for at least 6.
fig1g-ka-synchronized-bursting¶
After kainic acid, slice S1 shows synchronized rhythmic bursting, with about 6 to 8 bursts grouped within larger burst epochs (superbursts).
Population rate as the Methods define it (sigma 10 and 20 ms). Burst thresholds, the readings the criterion names: (a) twice the mean over the pre-KA part, (b) mean plus 3 SD over the whole recording. The dandiset holds no time of KA application (data check) and bursting starts within the first seconds of both KA recordings, so the pre-KA part of reading (a) is taken as the separate baseline recording of the same slice (recordings 2 and 4, recorded before KA; Results, paragraph 10, "the non-epileptiform-like recordings prior to administering kainic acid"); for slices without a separate baseline (S3 to S6) the recording's own mean is used. Peaks closer than 50 ms are merged, epochs are runs of bursts separated by gaps under 5 s. Counts: (i) median bursts per epoch over the epochs that start in the first 150 s, (ii) bursts in the first epoch.
def burst_table(r, sigma, reading):
s = SORT[r]
rate = H.population_rate(s['trains'], s['length_ms'], sigma)
if reading == 'a':
ref = {1: 2, 3: 4}.get(r)
base = H.population_rate(SORT[ref]['trains'], SORT[ref]['length_ms'], sigma).mean() if ref else rate.mean()
thr = 2 * base
else:
thr = rate.mean() + 3 * rate.std()
bt, ep = H.detect_bursts(rate, thr)
return rate, thr, bt, ep
READINGS = [(sg, rd) for rd in ('a', 'b') for sg in (10, 20)]
BURSTS = {(r, sg, rd): burst_table(r, sg, rd) for r in SORT for sg, rd in READINGS}
rows = []
for sg, rd in READINGS:
rate, thr, bt, ep = BURSTS[(1, sg, rd)]
early = [len(e) for e in ep if e[0] < 150]
syn = H.burst_synchrony(SORT[1]['trains'], bt, SORT[1]['length_ms'])
rows.append(dict(reading=rd, sigma=sg, threshold_hz=thr, mean_rate=rate.mean(), bursts=len(bt), epochs=len(ep),
epoch_sizes_first150=early, median_first150=np.median(early) if early else np.nan,
first_epoch=len(ep[0]) if ep else 0, first_epoch_start_s=ep[0][0] if ep else np.nan,
median_frac_units_up=np.median(syn) if len(syn) else np.nan,
frac_bursts_majority=np.mean(syn > 0.5) if len(syn) else np.nan))
F1 = pd.DataFrame(rows)
F1['in_range_median'] = F1.median_first150.between(5.4, 8.8)
F1['in_range_first'] = F1.first_epoch.between(5.4, 8.8)
print(F1.round(2).to_string(index=False))
reading sigma threshold_hz mean_rate bursts epochs epoch_sizes_first150 median_first150 first_epoch first_epoch_start_s median_frac_units_up frac_bursts_majority in_range_median in_range_first
a 10 8.64 4.2 353 12 [4, 27, 31, 49, 86, 53] 40.0 4 0.73 0.49 0.39 False False
a 20 8.64 4.2 207 12 [2, 15, 17, 26, 52, 28] 21.5 2 0.90 0.50 0.46 False False
b 10 11.04 4.2 194 12 [3, 11, 17, 27, 54, 32] 22.0 3 0.89 0.52 0.59 False False
b 20 10.81 4.2 124 12 [2, 7, 12, 18, 35, 18] 15.0 2 0.90 0.53 0.62 False False
fig, ax = plt.subplots(2, 1, figsize=(11, 5))
for a, sg, rd in [(ax[0], 10, 'b'), (ax[1], 20, 'a')]:
rate, thr, bt, ep = BURSTS[(1, sg, rd)]
tt = np.arange(len(rate)) / 1000
m = tt < 150
a.plot(tt[m], rate[m], lw=0.5); a.axhline(thr, color='r', lw=0.8)
a.plot(bt[bt < 150], rate[(bt[bt < 150] * 1000).astype(int)], 'k.', ms=3)
a.set_ylabel('Hz per unit'); a.set_title(f'S1 KA, first 150 s, sigma {sg} ms, reading ({rd})', fontsize=9)
print(f'reading ({rd}) sigma {sg}: rate range {rate[m].min():.2f} to {rate[m].max():.1f} Hz in the first 150 s')
ax[1].set_xlabel('s'); plt.tight_layout(); plt.show()
reading (b) sigma 10: rate range 0.66 to 16.3 Hz in the first 150 s reading (a) sigma 20: rate range 0.90 to 15.8 Hz in the first 150 s
# the paper's code sets the S1 initiation sub-bursts by hand at 14.4 to 14.91 s (claims file, opening comment);
# where do the detected bursts and epochs fall relative to it?
for sg, rd in READINGS:
rate, thr, bt, ep = BURSTS[(1, sg, rd)]
print(f'({rd}) sigma {sg}: bursts before 14.4 s: {np.round(bt[bt < 14.4], 2)}; first burst at or after 14.4 s: {bt[bt >= 14.4][:1].round(2)}; '
f'epoch starts (s): {np.round([e[0] for e in ep], 1)[:14]}')
(a) sigma 10: bursts before 14.4 s: [ 0.73 0.89 2.31 2.37 13.15 13.76]; first burst at or after 14.4 s: [14.82]; epoch starts (s): [ 0.7 13.2 40.1 71.2 102.3 140.4 177.6 211.8 247.5 280.4 313.1 342.1] (a) sigma 20: bursts before 14.4 s: [ 0.9 2.37 13.76]; first burst at or after 14.4 s: [14.86]; epoch starts (s): [ 0.9 13.8 40.2 72. 102.3 140.4 177.7 211.8 247.6 280.4 313.2 342.1] (b) sigma 10: bursts before 14.4 s: [0.89 2.31 2.37]; first burst at or after 14.4 s: [14.98]; epoch starts (s): [ 0.9 15. 42.3 72. 102.3 140.5 177.9 211.8 247.6 282.4 313.2 342.1] (b) sigma 20: bursts before 14.4 s: [0.9 2.37]; first burst at or after 14.4 s: [15.05]; epoch starts (s): [ 0.9 15. 42.3 72. 103. 140.6 177.9 212.1 247.6 282.4 313.2 344.7]
# variant outside the criterion, shown for the question to a reader: the code's S1 sub-bursts are 170 to 180 ms
# apart (14.4, 14.57, 14.75, 14.91 s), so a 50 ms merge can count sub-bursts as bursts; peaks closer than 250 or
# 500 ms merged instead. This does not decide the outcome.
for sg, rd in READINGS:
rate, thr = BURSTS[(1, sg, rd)][:2]
for merge in (250, 500):
bt, ep = H.detect_bursts(rate, thr, merge_ms=merge)
early = [len(e) for e in ep if e[0] < 150]
print(f'({rd}) sigma {sg}, merge {merge} ms: {len(bt)} bursts, {len(ep)} epochs, sizes in the first 150 s {early}, '
f'median {np.median(early):.1f}, first epoch {len(ep[0])}')
(a) sigma 10, merge 250 ms: 109 bursts, 12 epochs, sizes in the first 150 s [2, 9, 14, 16, 24, 13], median 13.5, first epoch 2 (a) sigma 10, merge 500 ms: 83 bursts, 12 epochs, sizes in the first 150 s [2, 8, 11, 10, 14, 10], median 10.0, first epoch 2 (a) sigma 20, merge 250 ms: 90 bursts, 12 epochs, sizes in the first 150 s [2, 7, 10, 12, 19, 12], median 11.0, first epoch 2 (a) sigma 20, merge 500 ms: 76 bursts, 12 epochs, sizes in the first 150 s [2, 7, 10, 9, 12, 9], median 9.0, first epoch 2 (b) sigma 10, merge 250 ms: 76 bursts, 12 epochs, sizes in the first 150 s [2, 6, 8, 10, 17, 9], median 8.5, first epoch 2 (b) sigma 10, merge 500 ms: 67 bursts, 12 epochs, sizes in the first 150 s [2, 6, 8, 8, 12, 8], median 8.0, first epoch 2 (b) sigma 20, merge 250 ms: 65 bursts, 12 epochs, sizes in the first 150 s [2, 6, 8, 8, 13, 8], median 8.0, first epoch 2 (b) sigma 20, merge 500 ms: 60 bursts, 12 epochs, sizes in the first 150 s [2, 6, 8, 8, 9, 7], median 7.5, first epoch 2
Result: not reproduced. Under none of the four readings does the count fall in 5.4 to 8.8: the median bursts per epoch in the first 150 s is 15 to 40, and the first epoch holds 2 to 4 bursts (it starts at 0.73 to 0.90 s, before the paper's initiation at 14.4 s). The median fraction of units whose rate rises at a burst is 0.49 to 0.53. Bursts are grouped: all readings give 12 epochs. Outside the criterion, merging peaks closer than 500 ms (the code's sub-bursts are 170 to 180 ms apart) gives a median of 7.5 to 10 bursts per epoch, and 7.5 and 8.0 under reading (b); this reading of a burst is asked of a reader and does not decide the outcome.
methods-burst-counts¶
Slice S1 had 67 bursts grouped into 11 superbursts over about 350 s; S2 had 47 bursts, highly synchronized for the first 50 s and sporadic for the next 300 s; in both slices bursts occurred for about 350 s.
Same readings as above. Duration of bursting is the time from the first to the last burst. For S2, the duration of synchronized bursting is the span of the first epoch (a run of bursts with gaps under 5 s), the reading of "highly synchronized for the first 50 seconds" that the burst definitions allow.
rows = []
for sg, rd in READINGS:
_, _, b1, e1 = BURSTS[(1, sg, rd)]
_, _, b3, e3 = BURSTS[(3, sg, rd)]
vals = [len(b1), len(e1), b1[-1] - b1[0] if len(b1) else 0, len(b3), (e3[0][-1] - e3[0][0]) if e3 else 0, b3[-1] - b3[0] if len(b3) else 0]
exp = [67, 11, 350, 47, 50, 350]
ok = [abs(v - x) <= 0.1 * x for v, x in zip(vals, exp)]
rows.append(dict(reading=rd, sigma=sg, S1_bursts=vals[0], S1_superbursts=vals[1], S1_span_s=vals[2], S2_bursts=vals[3],
S2_first_epoch_s=vals[4], S2_span_s=vals[5], S1_ok=sum(ok[:3]), S2_ok=sum(ok[3:]), S2_epochs=len(e3),
S2_epoch_sizes=[len(e) for e in e3]))
F2 = pd.DataFrame(rows)
print(F2.round(1).to_string(index=False))
print('values within tolerance per reading (of 3 each for S1 and S2):', list(zip(F2.reading, F2.sigma, F2.S1_ok, F2.S2_ok)))
reading sigma S1_bursts S1_superbursts S1_span_s S2_bursts S2_first_epoch_s S2_span_s S1_ok S2_ok S2_epochs S2_epoch_sizes
a 10 353 12 344.1 157 19.4 490.8 2 0 12 [28, 36, 16, 9, 7, 3, 9, 1, 1, 1, 45, 1]
a 20 207 12 344.0 103 19.4 490.8 2 0 11 [19, 19, 12, 5, 4, 2, 6, 1, 1, 33, 1]
b 10 194 12 344.0 131 19.4 485.8 2 0 8 [28, 28, 9, 8, 5, 9, 1, 43]
b 20 124 12 343.8 89 19.4 485.8 2 0 8 [19, 17, 7, 5, 3, 6, 1, 31]
values within tolerance per reading (of 3 each for S1 and S2): [('a', 10, 2, 0), ('a', 20, 2, 0), ('b', 10, 2, 0), ('b', 20, 2, 0)]
# the paper's code lists S1 seizure windows (claims file, opening comment); count the windows and the
# bursts each reading puts inside them
s1_win = [(9,28),(38,52),(69,83),(100,113),(138,151),(176,187),(211,220),(246,254)]
for sg, rd in READINGS:
_, _, b1, e1 = BURSTS[(1, sg, rd)]
inside = sum(((b1 >= a) & (b1 < b)).sum() for a, b in s1_win)
print(f'({rd}) sigma {sg}: {inside} of {len(b1)} S1 bursts fall in the code\'s 8 seizure windows; epochs starting before 254 s: {sum(e[0] < 254 for e in e1)}')
(a) sigma 10: 321 of 353 S1 bursts fall in the code's 8 seizure windows; epochs starting before 254 s: 9 (a) sigma 20: 187 of 207 S1 bursts fall in the code's 8 seizure windows; epochs starting before 254 s: 9 (b) sigma 10: 176 of 194 S1 bursts fall in the code's 8 seizure windows; epochs starting before 254 s: 9 (b) sigma 20: 114 of 124 S1 bursts fall in the code's 8 seizure windows; epochs starting before 254 s: 9
Result: not reproduced. Under every reading S1 has 12 epochs (11 expected, within tolerance) over 344 s (within tolerance), but 124 to 353 bursts against 67. S2 has 89 to 157 bursts against 47, a first epoch of 19.4 s against 50, and bursts over 486 to 491 s against 350. No reading matches all S1 or all S2 values. In the first 254 s, where the code lists 8 seizure windows, every reading has 9 epochs, and 90 to 92% of S1 bursts fall in the code's windows.
methods-rate-increase-after-ka¶
Neural activity increased after kainic acid; the population firing rate rose by 0.5 spikes per second per unit in S1 and 0.9 in S2.
Mean rate per unit (spike count over duration, averaged over units). Readings: (a) the KA recording after KA onset against before it: not available, as the dandiset and the sortings hold no time of KA application; (b) the whole KA recording against the baseline recording of the same slice; (c) the bursting period (first to last burst, each burst reading) against the baseline recording.
def mean_rate(s, t0=0, t1=None):
t1 = s['length_ms'] if t1 is None else t1
return np.mean([np.sum((x >= t0) & (x < t1)) for x in s['trains']]) / ((t1 - t0) / 1000)
rows = []
for ka, base, exp in [(1, 2, 0.5), (3, 4, 0.9)]:
rb = mean_rate(SORT[base])
rows.append(dict(slice=H.RECORDINGS[ka]['slice'], reading='b', ka_rate=mean_rate(SORT[ka]), base_rate=rb,
increase=mean_rate(SORT[ka]) - rb, expected=exp))
for sg, rd in READINGS:
bt = BURSTS[(ka, sg, rd)][2]
rk = mean_rate(SORT[ka], bt[0] * 1000, bt[-1] * 1000)
rows.append(dict(slice=H.RECORDINGS[ka]['slice'], reading=f'c ({rd}, sigma {sg})', ka_rate=rk, base_rate=rb,
increase=rk - rb, expected=exp))
R1 = pd.DataFrame(rows)
R1['within_tol'] = (R1.increase - R1.expected).abs() <= 0.1 * R1.expected + 1e-9
print(R1.round(3).to_string(index=False))
# unit-matched variant is not possible: the KA and baseline sortings were curated separately (different unit counts)
print('units KA/baseline:', SORT[1]['n'], SORT[2]['n'], '|', SORT[3]['n'], SORT[4]['n'])
slice reading ka_rate base_rate increase expected within_tol S1 b 4.204 4.320 -0.116 0.5 False S1 c (a, sigma 10) 4.273 4.320 -0.046 0.5 False S1 c (a, sigma 20) 4.271 4.320 -0.049 0.5 False S1 c (b, sigma 10) 4.271 4.320 -0.049 0.5 False S1 c (b, sigma 20) 4.268 4.320 -0.051 0.5 False S2 b 2.277 2.377 -0.100 0.9 False S2 c (a, sigma 10) 2.334 2.377 -0.044 0.9 False S2 c (a, sigma 20) 2.334 2.377 -0.044 0.9 False S2 c (b, sigma 10) 2.343 2.377 -0.034 0.9 False S2 c (b, sigma 20) 2.343 2.377 -0.034 0.9 False units KA/baseline: 212 249 | 180 51
Result: not reproduced. The mean rate per unit is lower in the KA recordings than in the baseline recordings: S1 4.20 against 4.32 spikes/s (-0.12), S2 2.28 against 2.38 (-0.10); over the bursting periods the change is -0.03 to -0.05. Reading (a) cannot be run, as no time of KA application is recorded. The KA and baseline sortings were curated separately (212 and 249 units in S1, 180 and 51 in S2), so the comparison is between different unit sets.
methods-onset-latency (blocked)¶
Epileptiform-like activity began in S1 and S2 shortly after kainic acid was applied.
The criterion needs the time of KA application from the dandiset's metadata or annotations. The data
check above shows that the files hold no epochs, intervals, annotations or stimulus series, and the
session descriptions are empty, so the claim is blocked as metadata_insufficient. For reference,
the first detected burst is printed (it bounds the latency only if KA was applied at or before the
recording start, which nothing states).
for ka in (1, 3):
print(H.RECORDINGS[ka]['slice'], {f'({rd}) sigma {sg}': round(float(BURSTS[(ka, sg, rd)][2][0]), 2) for sg, rd in READINGS})
S1 {'(a) sigma 10': 0.73, '(a) sigma 20': 0.9, '(b) sigma 10': 0.89, '(b) sigma 20': 0.9}
S2 {'(a) sigma 10': 0.37, '(a) sigma 20': 0.37, '(b) sigma 10': 0.37, '(b) sigma 20': 0.37}
s4-ka-no-epileptiform¶
Slice S4 received kainic acid but showed no epileptiform-like behaviour, and none of S3 to S6 showed seizure-like activity.
A claim of absence. The criterion's test is synchronized bursting sustained for more than 10 s,
with bursts as in fig1g-ka-synchronized-bursting under each of its readings; the S1 and S2 KA
recordings must show it under the same reading. "Synchronized" is taken from the fig1g criterion,
which defines a synchronous burst as one that raises the rate of most units: a burst is kept when
more than half of the units fire above their mean rate within 50 ms of its peak
(hippo.burst_synchrony). Sustained is read as an epoch of kept bursts (gaps under 5 s) lasting
more than 10 s from its first to its last burst. The fraction is also run at 0.4 and 0.6, and with
every burst kept (the first version of this analysis, which dropped "synchronized"). The LFP part
of the paper's classification is not tested (claims file).
def sync_epochs(r, sg, rd, min_frac):
bt = BURSTS[(r, sg, rd)][2]
if min_frac is not None and len(bt):
bt = bt[H.burst_synchrony(SORT[r]['trains'], bt, SORT[r]['length_ms']) > min_frac]
ep = np.split(bt, np.where(np.diff(bt) >= 5.0)[0] + 1) if len(bt) else []
return bt, [e[-1] - e[0] for e in ep]
rows = []
for min_frac in (0.5, 0.4, 0.6, None):
for sg, rd in READINGS:
row = dict(units_rising='all bursts' if min_frac is None else f'> {min_frac}', reading=rd, sigma=sg)
for r in (1, 3, 5, 6, 7, 8):
bt, spans = sync_epochs(r, sg, rd, min_frac)
sl = H.RECORDINGS[r]['slice']
row[sl] = f"{len(bt)}: {sum(sp > 10 for sp in spans)} ({max(spans) if spans else 0:.0f} s)"
row[sl + '_yes'] = any(sp > 10 for sp in spans)
row['S3_to_S6_any'] = any(row[k + '_yes'] for k in ('S3', 'S4', 'S5', 'S6'))
row['S1_and_S2'] = row['S1_yes'] and row['S2_yes']
rows.append(row)
S4T = pd.DataFrame(rows)
print('cells: bursts kept: epochs longer than 10 s (longest epoch)')
print(S4T[['units_rising', 'reading', 'sigma', 'S1', 'S2', 'S3', 'S4', 'S5', 'S6', 'S3_to_S6_any', 'S1_and_S2']].to_string(index=False))
for sg, rd in READINGS:
print(f'S1 epoch spans (s), units rising > 0.5, ({rd}) sigma {sg}:', np.round(sync_epochs(1, sg, rd, 0.5)[1], 1).tolist())
cells: bursts kept: epochs longer than 10 s (longest epoch)
units_rising reading sigma S1 S2 S3 S4 S5 S6 S3_to_S6_any S1_and_S2
> 0.5 a 10 138: 0 (9 s) 134: 2 (19 s) 0: 0 (0 s) 0: 0 (0 s) 0: 0 (0 s) 0: 0 (0 s) False False
> 0.5 a 20 96: 0 (10 s) 91: 2 (19 s) 0: 0 (0 s) 0: 0 (0 s) 0: 0 (0 s) 0: 0 (0 s) False False
> 0.5 b 10 115: 0 (8 s) 131: 2 (19 s) 0: 0 (0 s) 0: 0 (0 s) 0: 0 (0 s) 0: 0 (0 s) False False
> 0.5 b 20 77: 0 (8 s) 89: 2 (19 s) 0: 0 (0 s) 0: 0 (0 s) 0: 0 (0 s) 0: 0 (0 s) False False
> 0.4 a 10 342: 0 (10 s) 136: 2 (19 s) 0: 0 (0 s) 1: 0 (0 s) 4: 0 (2 s) 5: 0 (0 s) False False
> 0.4 a 20 201: 0 (10 s) 92: 2 (19 s) 0: 0 (0 s) 1: 0 (0 s) 6: 0 (2 s) 5: 0 (0 s) False False
> 0.4 b 10 191: 0 (8 s) 131: 2 (19 s) 0: 0 (0 s) 1: 0 (0 s) 4: 0 (2 s) 5: 0 (0 s) False False
> 0.4 b 20 122: 0 (8 s) 89: 2 (19 s) 0: 0 (0 s) 1: 0 (0 s) 6: 0 (2 s) 5: 0 (0 s) False False
> 0.6 a 10 21: 0 (7 s) 129: 2 (19 s) 0: 0 (0 s) 0: 0 (0 s) 0: 0 (0 s) 0: 0 (0 s) False False
> 0.6 a 20 18: 0 (7 s) 88: 2 (19 s) 0: 0 (0 s) 0: 0 (0 s) 0: 0 (0 s) 0: 0 (0 s) False False
> 0.6 b 10 21: 0 (7 s) 129: 2 (19 s) 0: 0 (0 s) 0: 0 (0 s) 0: 0 (0 s) 0: 0 (0 s) False False
> 0.6 b 20 18: 0 (7 s) 88: 2 (19 s) 0: 0 (0 s) 0: 0 (0 s) 0: 0 (0 s) 0: 0 (0 s) False False
all bursts a 10 353: 0 (10 s) 157: 2 (19 s) 1119: 1 (418 s) 209: 1 (29 s) 540: 2 (273 s) 420: 1 (106 s) True False
all bursts a 20 207: 0 (10 s) 103: 2 (19 s) 355: 5 (157 s) 78: 1 (16 s) 128: 4 (67 s) 158: 1 (105 s) True False
all bursts b 10 194: 0 (8 s) 131: 2 (19 s) 281: 10 (64 s) 29: 1 (11 s) 178: 4 (78 s) 75: 2 (86 s) True False
all bursts b 20 124: 0 (8 s) 89: 2 (19 s) 125: 6 (34 s) 9: 0 (5 s) 89: 5 (16 s) 38: 1 (22 s) True False
S1 epoch spans (s), units rising > 0.5, (a) sigma 10: [0.0, 5.8, 8.8, 7.5, 8.6, 8.4, 8.2, 4.4, 0.2, 0.0]
S1 epoch spans (s), units rising > 0.5, (a) sigma 20: [0.0, 0.2, 9.7, 7.4, 9.2, 8.4, 8.2, 7.4, 0.1, 0.0]
S1 epoch spans (s), units rising > 0.5, (b) sigma 10: [0.0, 0.1, 0.0, 7.7, 7.4, 7.3, 8.3, 8.1, 4.4, 0.2, 0.0]
S1 epoch spans (s), units rising > 0.5, (b) sigma 20: [0.0, 0.0, 7.7, 7.4, 7.3, 6.8, 8.1, 5.6, 0.1, 0.0]
# size of the effect: bursts per minute and the threshold relative to the mean rate in each recording
rows = []
for r in (1, 3, 5, 6, 7, 8):
for sg, rd in READINGS:
rate, thr, bt, ep = BURSTS[(r, sg, rd)]
syn = H.burst_synchrony(SORT[r]['trains'], bt, SORT[r]['length_ms']) if len(bt) else np.array([np.nan])
rows.append(dict(slice=H.RECORDINGS[r]['slice'], reading=rd, sigma=sg, bursts_per_min=len(bt) / (SORT[r]['length_ms'] / 60000),
peak_rate_hz=rate.max(), thr_over_mean=thr / rate.mean(), median_frac_units_up=np.nanmedian(syn)))
print(pd.DataFrame(rows).round(2).to_string(index=False))
slice reading sigma bursts_per_min peak_rate_hz thr_over_mean median_frac_units_up S1 a 10 58.82 16.29 2.06 0.49 S1 a 20 34.49 15.85 2.06 0.50 S1 b 10 32.32 16.29 2.63 0.52 S1 b 20 20.66 15.85 2.57 0.53 S2 a 10 18.46 44.95 2.09 0.73 S2 a 20 12.11 42.78 2.09 0.73 S2 b 10 15.41 44.95 7.89 0.74 S2 b 20 10.47 42.78 7.75 0.74 S3 a 10 160.46 12.31 2.00 0.15 S3 a 20 50.91 9.07 2.00 0.17 S3 b 10 40.29 12.31 2.82 0.17 S3 b 20 17.92 9.07 2.39 0.21 S4 a 10 96.46 19.44 2.00 0.31 S4 a 20 36.00 16.99 2.00 0.34 S4 b 10 13.38 19.44 2.63 0.33 S4 b 20 4.15 16.99 2.55 0.32 S5 a 10 84.10 8.97 2.00 0.25 S5 a 20 19.94 6.40 2.00 0.32 S5 b 10 27.72 8.97 2.39 0.29 S5 b 20 13.86 6.40 2.10 0.32 S6 a 10 236.62 20.58 2.00 0.23 S6 a 20 89.01 12.97 2.00 0.28 S6 b 10 42.25 20.58 3.25 0.30 S6 b 20 21.41 12.97 2.68 0.34
Result: partially reproduced, resting on the reading of "sustained". With a burst counted as synchronized when more than half of the units rise (main), S3 to S6 have no synchronized burst at all under any reading (0 bursts), while S1 has 77 to 138 and S2 89 to 134. S2 has two epochs longer than 10 s (19 s) under every reading; S1 has none, its longest epoch lasting 8 to 10 s. So the test finds no sustained synchronized bursting in S3 to S6, the absence the claim states, but the positive control holds for S2 and not for S1. At a fraction of 0.4, S4 to S6 have 1 to 6 synchronized bursts and no epoch longer than 2 s; at 0.6 none. With every burst kept, as in the first version of this analysis, at least three of S3 to S6 have epochs longer than 10 s (longest 16 to 418 s) and the test does not separate the slices, because those bursts raise the rate of few units (median fraction 0.15 to 0.34, against 0.49 to 0.74 in S1 and S2).
STTC matrices¶
STTC with a 20 ms window over the whole sorting (claims file; braingeneers default), for every recording; used by the next five claims.
t = time.time()
def sttc_job(r):
return r, H.sttc(SORT[r]['trains'], SORT[r]['length_ms'], 20.0)
with ProcessPoolExecutor(4, mp_context=mp.get_context('fork')) as ex:
STTC = dict(ex.map(sttc_job, list(SORT)))
for r, S in STTC.items():
off = S[~np.eye(len(S), dtype=bool)]
print(r, H.RECORDINGS[r]['slice'], H.RECORDINGS[r]['cond'], S.shape, f'off-diagonal range {off.min():.3f} to {off.max():.3f}, '
f'98th percentile {np.percentile(off, 98):.3f}, symmetric {np.allclose(S, S.T)}')
print(f'{time.time()-t:.0f} s; peak memory {resource.getrusage(resource.RUSAGE_SELF).ru_maxrss/1e6:.1f} GB')
1 S1 KA (212, 212) off-diagonal range -0.248 to 0.885, 98th percentile 0.252, symmetric True 2 S1 baseline (249, 249) off-diagonal range -0.151 to 0.979, 98th percentile 0.056, symmetric True 3 S2 KA (180, 180) off-diagonal range -0.117 to 0.976, 98th percentile 0.854, symmetric True 4 S2 baseline (51, 51) off-diagonal range -0.045 to 0.903, 98th percentile 0.425, symmetric True 5 S3 no drug (87, 87) off-diagonal range -0.102 to 1.000, 98th percentile 0.148, symmetric True 6 S4 KA (109, 109) off-diagonal range -0.368 to 0.955, 98th percentile 0.409, symmetric True 7 S5 no drug (136, 136) off-diagonal range -0.089 to 1.000, 98th percentile 0.070, symmetric True 8 S6 no drug (100, 100) off-diagonal range -0.171 to 1.000, 98th percentile 0.410, symmetric True 6 s; peak memory 1.0 GB
fig2c-sttc-two-clusters¶
Hierarchical clustering of the STTC matrix of S1 gives two groups of units that divide the granule cell layer into the same two spatial modes, and S2 gives a similar result.
Code (figures/figure_3/sttc.ipynb): entries of 0.3 or more set to 0 (diagonal included), Euclidean
distances between rows, complete linkage, optimal leaf ordering; cut into 2 clusters (main) and, as
a variant, the two largest clusters of a cut at half the maximum distance; clipping at 0.3 as a
second variant. Unit positions along the layer from the degree-2 fit (hippo.layer_position). The
comparison with the phase-cluster split of fig2b, reading (a), uses the code's position thresholds
applied to all units of S1 (group 1: x < 940, or x = 945 with y < 1120, or x > 900 with y < 900).
def code_group1(pos):
x, y = pos[:, 0], pos[:, 1]
return (x < 940) | ((x == 945) & (y < 1120)) | ((x > 900) & (y < 900))
def sttc_clusters(S, mode='zero', cut='maxclust'):
M_ = S.copy()
if mode == 'zero':
M_[M_ >= 0.3] = 0
else:
M_ = np.minimum(M_, 0.3)
Z = hierarchy.linkage(pdist(M_, 'euclidean'), 'complete', optimal_ordering=True)
if cut == 'maxclust':
lab = hierarchy.fcluster(Z, 2, 'maxclust')
else:
lab = hierarchy.fcluster(Z, 0.5 * Z[:, 2].max(), 'distance')
big = pd.Series(lab).value_counts().index[:2]
lab = np.where(np.isin(lab, big), lab, 0)
return lab
CL = {}
rows = []
for r in (1, 3):
pos = SORT[r]['pos']; lp = H.layer_position(pos)
for mode in ('zero', 'clip'):
for cut in ('maxclust', 'half'):
lab = sttc_clusters(STTC[r], mode, cut)
ids = [k for k in pd.Series(lab[lab > 0]).value_counts().index[:2]]
a, b = (lab == ids[0]), (lab == ids[1]) if len(ids) > 1 else (lab == -1)
p = stats.mannwhitneyu(lp[a], lp[b]).pvalue if b.sum() else np.nan
row = dict(slice=H.RECORDINGS[r]['slice'], threshold=mode, cut=cut, n1=int(a.sum()), n2=int(b.sum()),
min_frac=min(a.sum(), b.sum()) / len(lab), med_pos1=np.median(lp[a]), med_pos2=np.median(lp[b]) if b.sum() else np.nan,
mw_p=p, dropped=int((lab == 0).sum()))
if r == 1:
g1 = code_group1(pos)
# which STTC cluster overlaps code group 1 most, and is it on the same side along the layer?
ov = [np.mean(g1[a]), np.mean(g1[b])]
c1 = 0 if ov[0] >= ov[1] else 1
lower_is_g1 = np.median(lp[g1]) < np.median(lp[~g1])
lower_is_c1 = [row['med_pos1'], row['med_pos2']][c1] < [row['med_pos1'], row['med_pos2']][1 - c1]
row.update(code_group1_frac_in_c1=ov[c1], code_group1_frac_in_other=ov[1 - c1], same_side=lower_is_g1 == lower_is_c1)
row['holds'] = row['min_frac'] >= 0.1 and p < 0.05 and row.get('same_side', True)
rows.append(row)
CL[(r, mode, cut)] = lab
F2C = pd.DataFrame(rows)
print(F2C.round(4).to_string(index=False))
print('code group 1 (all units of S1):', int(code_group1(SORT[1]['pos']).sum()), 'of', SORT[1]['n'])
slice threshold cut n1 n2 min_frac med_pos1 med_pos2 mw_p dropped code_group1_frac_in_c1 code_group1_frac_in_other same_side holds S1 zero maxclust 151 61 0.2877 31.0 24.0 0.2629 0 0.6557 0.5099 True False S1 zero half 57 49 0.2311 20.0 23.0 0.2047 106 0.7895 0.6735 True False S1 clip maxclust 128 84 0.3962 29.5 27.5 0.3848 0 0.5714 0.5391 True False S1 clip half 67 61 0.2877 24.0 22.0 0.5945 84 0.6567 0.6557 False False S2 zero maxclust 133 47 0.2611 77.0 61.0 0.0020 0 NaN NaN NaN True S2 zero half 80 28 0.1556 82.0 58.5 0.0001 72 NaN NaN NaN True S2 clip maxclust 163 17 0.0944 74.0 44.0 0.0000 0 NaN NaN NaN False S2 clip half 115 48 0.2667 80.0 60.0 0.0000 17 NaN NaN NaN True code group 1 (all units of S1): 117 of 212
fig, ax = plt.subplots(1, 2, figsize=(11, 4))
for a, r in zip(ax, (1, 3)):
lab = CL[(r, 'zero', 'maxclust')]; pos = SORT[r]['pos']
a.scatter(pos[:, 0], pos[:, 1], c=lab, cmap='coolwarm', s=10); a.invert_yaxis(); a.set_aspect('equal')
a.set_title(f"{H.RECORDINGS[r]['slice']} KA: STTC clusters (2-cluster cut)", fontsize=9)
print(H.RECORDINGS[r]['slice'], 'x', pos[:, 0].min(), 'to', pos[:, 0].max(), 'y', pos[:, 1].min(), 'to', pos[:, 1].max(), 'um')
plt.tight_layout(); plt.show()
S1 x 192.5 to 2502.5 y 17.5 to 1522.5 um S2 x 1295.0 to 3115.0 y 0.0 to 1225.0 um
Result: partially reproduced. In S2 the two clusters of the 2-cluster cut hold 133 and 47 units (26% the smaller) and differ in position along the layer (median index 77 against 61, Mann-Whitney p = 0.002); the half-distance variant agrees (p = 0.0001) and the clipping variant with the 2-cluster cut fails the 10% size rule (17 units). In S1 the clusters (151 and 61 units) do not differ in position (p = 0.26), and no variant gives p < 0.05 (0.20 to 0.59).
ext9-sttc-eigenvector-gradient¶
The first eigenvector of the STTC matrix, mapped onto the units, forms a gradient across the granule cell layer in both S1 and S2, reproducing the hierarchical clusters.
STTC without threshold, first eigenvector by numpy eigh in descending order with the code's sign convention (human_hip eigenvalues_eigenvectors). Spearman correlation with position along the layer; Mann-Whitney test of the eigenvector values between the two clusters of fig2c (2-cluster cut, the code's zeroing).
def eig_desc(Amat):
W, U = np.linalg.eigh(Amat)
U = U * ((-1) ** (U[0, :] < 0))[None, :]
return W[::-1], U[:, ::-1]
rows = []
for r in (1, 3):
W, U = eig_desc(STTC[r]); v = U[:, 0]
lp = H.layer_position(SORT[r]['pos']); lab = CL[(r, 'zero', 'maxclust')]
rho, p = stats.spearmanr(v, lp)
ids = pd.Series(lab).value_counts().index[:2]
pm = stats.mannwhitneyu(v[lab == ids[0]], v[lab == ids[1]]).pvalue
rows.append(dict(slice=H.RECORDINGS[r]['slice'], eig1=W[0], eig2=W[1], spearman_rho=rho, spearman_p=p, mw_p_clusters=pm,
median_v_c1=np.median(v[lab == ids[0]]), median_v_c2=np.median(v[lab == ids[1]]), holds=(p < 0.05) and (pm < 0.05)))
# variant: second eigenvector (the first is often a common mode)
rho2, p2 = stats.spearmanr(U[:, 1], lp)
pm2 = stats.mannwhitneyu(U[lab == ids[0], 1], U[lab == ids[1], 1]).pvalue
rows[-1].update(v2_spearman_rho=rho2, v2_spearman_p=p2, v2_mw_p=pm2)
print(H.RECORDINGS[r]['slice'], 'first eigenvector range', v.min().round(3), 'to', v.max().round(3), '; units with v<0:', int((v < 0).sum()))
print(pd.DataFrame(rows).to_string(index=False))
S1 first eigenvector range -0.041 to 0.185 ; units with v<0: 9 S2 first eigenvector range -0.01 to 0.12 ; units with v<0: 7 slice eig1 eig2 spearman_rho spearman_p mw_p_clusters median_v_c1 median_v_c2 holds v2_spearman_rho v2_spearman_p v2_mw_p S1 16.639905 6.820323 0.077682 2.601320e-01 4.154210e-29 0.064805 0.019391 False -0.345727 2.414285e-07 0.000561 S2 66.779687 5.069979 0.507474 3.584620e-13 7.841378e-11 0.088841 0.028611 True 0.123513 9.855750e-02 0.033997
Result: partially reproduced. In S2 the first eigenvector correlates with position along the layer (Spearman rho = 0.51, p = 3.6e-13) and differs between the two clusters (p = 7.8e-11). In S1 it differs between the clusters (p = 4.2e-29) but does not correlate with position (rho = 0.08, p = 0.26); there the second eigenvector does (rho = -0.35, p = 2.4e-7), a variant the criterion does not name.
ext9-sttc-beats-correlation¶
For S1, the STTC matrix has larger eigenvalues and a lower reconstruction error than the correlation matrix of the spike trains.
Correlation matrix of the 1 ms raster smoothed with a Gaussian of sigma 5 ms (human_hip correlation_matrix default). Reconstruction error (reading named in the claims file): ||A - A_k||_F / ||A||_F with A_k the rank-k eigen-reconstruction, k = 1 to 20.
from scipy.ndimage import gaussian_filter1d
s = SORT[1]
nb = int(np.ceil(s['length_ms'])) + 1
raster = np.zeros((s['n'], nb), np.float32)
for i, x in enumerate(s['trains']):
np.add.at(raster[i], np.clip(x.astype(int), 0, nb - 1), 1)
raster = gaussian_filter1d(raster, 5, axis=1)
CORR = np.corrcoef(raster); del raster
def recon_err(Amat, kmax=20):
W, U = eig_desc(Amat)
return W, np.array([np.linalg.norm(Amat - (U[:, :k] * W[:k]) @ U[:, :k].T) / np.linalg.norm(Amat) for k in range(1, kmax + 1)])
Ws, Es = recon_err(STTC[1]); Wc, Ec = recon_err(CORR)
E9 = pd.DataFrame(dict(k=np.arange(1, 21), eig_sttc=Ws[:20], eig_corr=Wc[:20], err_sttc=Es, err_corr=Ec))
print(E9.round(4).to_string(index=False))
print('eigenvalue larger for STTC:', int((E9.eig_sttc > E9.eig_corr).sum()), 'of 20; error lower for STTC:', int((E9.err_sttc < E9.err_corr).sum()), 'of 20')
print('sums of eigenvalues (traces):', round(float(np.trace(STTC[1])), 1), round(float(np.trace(CORR)), 1),
'; smallest eigenvalues', round(float(Ws.min()), 3), round(float(Wc.min()), 3))
k eig_sttc eig_corr err_sttc err_corr 1 16.6399 8.2969 0.7031 0.8708 2 6.8203 3.7687 0.6399 0.8417 3 5.1603 2.8926 0.6007 0.8241 4 2.6156 1.8458 0.5902 0.8168 5 2.1571 1.7699 0.5830 0.8100 6 1.9256 1.6278 0.5771 0.8043 7 1.7860 1.4910 0.5721 0.7994 8 1.6512 1.4182 0.5677 0.7950 9 1.6005 1.3581 0.5636 0.7909 10 1.5303 1.2441 0.5598 0.7875 11 1.4977 1.2380 0.5561 0.7840 12 1.4683 1.2323 0.5525 0.7806 13 1.4409 1.1840 0.5491 0.7775 14 1.3891 1.1752 0.5459 0.7743 15 1.3576 1.1598 0.5428 0.7713 16 1.3549 1.1499 0.5397 0.7683 17 1.3337 1.1431 0.5367 0.7653 18 1.3274 1.1427 0.5337 0.7623 19 1.3215 1.1313 0.5307 0.7593 20 1.3134 1.1285 0.5277 0.7564 eigenvalue larger for STTC: 20 of 20; error lower for STTC: 20 of 20 sums of eigenvalues (traces): 212.0 212.0 ; smallest eigenvalues -2.644 0.128
Result: reproduced. For S1 each of the first 20 eigenvalues is larger for STTC than for the correlation matrix (16.6 against 8.3 for the first), and the relative reconstruction error is lower for STTC at every k from 1 to 20 (0.70 against 0.87 at k = 1, 0.53 against 0.76 at k = 20). The STTC matrix has negative eigenvalues (smallest -2.64), so it is not positive semidefinite as the Methods state.
fig3a-significant-pairs¶
Of about 45,000 neuron pairs in S1, 784 have a significant directed latency; the other recordings give 1940 (S2 KA), 304 (S1 baseline), 37 (S2 baseline), 79 (S3), 37 (S4), 172 (S5) and 92 (S6).
Pair selection as the criterion gives it (hippo.significant_pairs).
t = time.time()
def pairs_job(r):
return r, H.significant_pairs(SORT[r]['trains'], STTC[r])
with ProcessPoolExecutor(4, mp_context=mp.get_context('fork')) as ex:
PAIRS = dict(ex.map(pairs_job, list(SORT)))
exp_pairs = {1: 784, 3: 1940, 2: 304, 4: 37, 5: 79, 6: 37, 7: 172, 8: 92}
rows = []
for r in SORT:
n = SORT[r]['n']; S = STTC[r]
cand = int((S[np.triu_indices(n, 1)] > 0.01).sum())
rows.append(dict(rec=r, slice=H.RECORDINGS[r]['slice'], cond=H.RECORDINGS[r]['cond'], units=n, n_squared=n * n,
pairs_sttc_above_001=cand, significant=len(PAIRS[r]), expected=exp_pairs[r],
within_tol=abs(len(PAIRS[r]) - exp_pairs[r]) <= 0.1 * exp_pairs[r]))
P3 = pd.DataFrame(rows)
print(P3.to_string(index=False))
print('within tolerance:', int(P3.within_tol.sum()), 'of 8;', f'{time.time()-t:.0f} s')
rec slice cond units n_squared pairs_sttc_above_001 significant expected within_tol 1 S1 KA 212 44944 17530 784 784 True 2 S1 baseline 249 62001 9297 304 304 True 3 S2 KA 180 32400 14299 1940 1940 True 4 S2 baseline 51 2601 935 37 37 True 5 S3 no drug 87 7569 1307 79 79 True 6 S4 KA 109 11881 2708 37 37 True 7 S5 no drug 136 18496 3563 172 172 True 8 S6 no drug 100 10000 2551 92 92 True within tolerance: 8 of 8; 6 s
# sensitivity: the same selection with the STTC threshold and minimum event count changed
for r in (1, 3):
for smin, mev in [(0.0, 25), (0.01, 10), (0.01, 50)]:
print(H.RECORDINGS[r]['slice'], H.RECORDINGS[r]['cond'], f'STTC > {smin}, >= {mev} latencies:',
len(H.significant_pairs(SORT[r]['trains'], STTC[r], sttc_min=smin, min_events=mev)))
S1 KA STTC > 0.0, >= 25 latencies: 828
S1 KA STTC > 0.01, >= 10 latencies: 841
S1 KA STTC > 0.01, >= 50 latencies: 667
S2 KA STTC > 0.0, >= 25 latencies: 1953
S2 KA STTC > 0.01, >= 10 latencies: 1979
S2 KA STTC > 0.01, >= 50 latencies: 1843
Result: reproduced. The counts are 784, 304, 1940, 37, 79, 37, 172 and 92 significant pairs, equal to the paper's for all eight recordings. S1 has 212 squared = 44,944 candidate pairs, the "45,000" of the text. Changing the STTC threshold or the minimum number of latencies moves the S1 count to 667 to 841.
fig3a-bipolar-angle-histograms¶
The latency-weighted propagation angle histograms are bipolar for S1 and S2, unimodal for S3 and S4, and bimodal but not bipolar for S5 and S6.
Angles from the sending to the receiving unit, weighted by the number of latency events. Measures named in the claims file: R1 (first-order resultant length), R2 (axial), and the angle between the two largest peaks of a 16-bin weighted histogram. Peaks are local maxima of the circular histogram. "One dominant peak" is not defined in the claims file; it is read here as the second-largest local maximum being below half the largest (a reading of the criterion's words, stated before the result was seen). Angles are computed with y as stored (image rows) and, as a variant, with y flipped. Unit positions lie on a 17.5 um grid, so many pair angles fall exactly on the 22.5 degree bin edges, and flipping y does not simply mirror the histogram: classes can change with the flip. The second cell counts the angles on bin edges and repeats the classes with the bins shifted by half a bin (11.25 degrees).
def angles(r, flip=False):
P = PAIRS[r]; pos = SORT[r]['pos'].copy()
if flip:
pos[:, 1] = -pos[:, 1]
d = pos[P.recv.values] - pos[P.send.values]
return np.arctan2(d[:, 1], d[:, 0]), P.n_events.values.astype(float)
def hist_shape(th, w, nbins=16, offset=0.0):
R1 = np.abs(np.sum(w * np.exp(1j * th))) / w.sum()
R2 = np.abs(np.sum(w * np.exp(2j * th))) / w.sum()
h, edges = np.histogram(np.mod(th - offset, 2 * np.pi), bins=nbins, range=(0, 2 * np.pi), weights=w)
peaks = [i for i in range(nbins) if h[i] > h[i - 1] and h[i] >= h[(i + 1) % nbins]]
peaks = sorted(peaks, key=lambda i: -h[i])
centers = (edges[:-1] + edges[1:]) / 2 + offset
sep = np.nan; ratio = 0.0
if len(peaks) >= 2:
dd = np.degrees(abs(centers[peaks[0]] - centers[peaks[1]])) % 360
sep = min(dd, 360 - dd)
ratio = h[peaks[1]] / h[peaks[0]]
if len(peaks) >= 2 and 150 <= sep <= 210 and R2 > R1:
cls = 'bipolar'
elif R1 > R2 and (len(peaks) < 2 or ratio < 0.5):
cls = 'unimodal'
elif len(peaks) >= 2 and 60 <= sep <= 120:
cls = 'bimodal not bipolar'
else:
cls = 'other'
return dict(R1=R1, R2=R2, n_peaks=len(peaks), peak_sep_deg=sep, second_over_first=ratio,
mode1_deg=np.degrees(centers[peaks[0]]) if peaks else np.nan,
mode2_deg=np.degrees(centers[peaks[1]]) if len(peaks) > 1 else np.nan, cls=cls, hist=h)
want = {1: 'bipolar', 3: 'bipolar', 5: 'unimodal', 6: 'unimodal', 7: 'bimodal not bipolar', 8: 'bimodal not bipolar', 2: 'bipolar', 4: 'bipolar'}
SH = {}
rows = []
for flip in (False, True):
for r in SORT:
th, w = angles(r, flip)
d = hist_shape(th, w); SH[(r, flip)] = d
rows.append(dict(rec=r, slice=H.RECORDINGS[r]['slice'], cond=H.RECORDINGS[r]['cond'], y_flipped=flip, pairs=len(th),
**{k: v for k, v in d.items() if k != 'hist'}, stated=want[r]))
AH = pd.DataFrame(rows)
print(AH.round(3).to_string(index=False))
main = AH[(~AH.y_flipped) & AH.rec.isin([1, 3, 5, 6, 7, 8])]
print('slices in their stated class (S1, S2, S3, S4, S5, S6):', int((main.cls == main.stated).sum()), 'of 6')
rec slice cond y_flipped pairs R1 R2 n_peaks peak_sep_deg second_over_first mode1_deg mode2_deg cls stated 1 S1 KA False 784 0.120 0.515 4 180.0 0.944 191.25 11.25 bipolar bipolar 2 S1 baseline False 304 0.079 0.340 4 180.0 0.939 191.25 11.25 bipolar bipolar 3 S2 KA False 1940 0.095 0.680 4 180.0 0.710 236.25 56.25 bipolar bipolar 4 S2 baseline False 37 0.316 0.666 3 157.5 0.543 236.25 33.75 bipolar bipolar 5 S3 no drug False 79 0.335 0.147 4 67.5 0.924 78.75 11.25 bimodal not bipolar unimodal 6 S4 KA False 37 0.347 0.262 5 67.5 0.704 123.75 191.25 bimodal not bipolar unimodal 7 S5 no drug False 172 0.184 0.215 4 45.0 0.984 281.25 236.25 other bimodal not bipolar 8 S6 no drug False 92 0.253 0.247 6 135.0 0.555 11.25 236.25 other bimodal not bipolar 1 S1 KA True 784 0.120 0.515 4 180.0 0.952 168.75 348.75 bipolar bipolar 2 S1 baseline True 304 0.079 0.340 5 180.0 0.941 168.75 348.75 bipolar bipolar 3 S2 KA True 1940 0.095 0.680 4 180.0 0.883 146.25 326.25 bipolar bipolar 4 S2 baseline True 37 0.316 0.666 3 157.5 0.746 123.75 326.25 bipolar bipolar 5 S3 no drug True 79 0.335 0.147 4 90.0 0.741 281.25 11.25 bimodal not bipolar unimodal 6 S4 KA True 37 0.347 0.262 6 45.0 0.746 236.25 191.25 other unimodal 7 S5 no drug True 172 0.184 0.215 6 112.5 0.888 78.75 191.25 bimodal not bipolar bimodal not bipolar 8 S6 no drug True 92 0.253 0.247 5 90.0 0.715 11.25 281.25 bimodal not bipolar bimodal not bipolar slices in their stated class (S1, S2, S3, S4, S5, S6): 2 of 6
fig, axs = plt.subplots(2, 4, subplot_kw=dict(projection='polar'), figsize=(12, 6))
for a, r in zip(axs.flat, SORT):
h = SH[(r, False)]['hist']; c = np.linspace(0, 2 * np.pi, 17)[:-1] + np.pi / 16
a.bar(c, h, width=2 * np.pi / 16); a.set_title(f"{r}: {H.RECORDINGS[r]['slice']} {H.RECORDINGS[r]['cond']}", fontsize=8)
a.set_yticklabels([])
plt.tight_layout(); plt.show()
print('histogram maxima (latency events per bin):', {r: int(SH[(r, False)]['hist'].max()) for r in SORT})
histogram maxima (latency events per bin): {1: 41356, 2: 16834, 3: 173964, 4: 1325, 5: 1401, 6: 2009, 7: 3309, 8: 2058}
# pair angles on the 22.5 degree bin edges, and the class of each slice with the bins as above and shifted by half a
# bin, under both y directions
rows = []
for r in SORT:
th, w = angles(r)
deg = np.mod(np.degrees(th), 22.5)
on = np.isclose(deg, 0, atol=1e-6) | np.isclose(deg, 22.5, atol=1e-6)
row = dict(rec=r, slice=H.RECORDINGS[r]['slice'], cond=H.RECORDINGS[r]['cond'], pairs=len(th), on_edges=int(on.sum()),
weight_on_edges=round(float(w[on].sum() / w.sum()), 3))
for flip in (False, True):
for off in (0.0, np.pi / 16):
th, w = angles(r, flip)
row[f"{'flipped' if flip else 'stored'}_offset_{np.degrees(off):.2f}"] = hist_shape(th, w, offset=off)['cls']
row['stated'] = want[r]
rows.append(row)
AH2 = pd.DataFrame(rows)
print(AH2.to_string(index=False))
for col in [c for c in AH2.columns if c.startswith(('stored', 'flipped'))]:
m = AH2[AH2.rec.isin([1, 3, 5, 6, 7, 8])]
print(col, '| S1 and S2 bipolar:', bool((m[m.rec.isin([1, 3])][col] == 'bipolar').all()), '| other slices bipolar:',
int((m[~m.rec.isin([1, 3])][col] == 'bipolar').sum()), '| slices in their stated class:', int((m[col] == m.stated).sum()), 'of 6')
rec slice cond pairs on_edges weight_on_edges stored_offset_0.00 stored_offset_11.25 flipped_offset_0.00 flipped_offset_11.25 stated 1 S1 KA 784 86 0.093 bipolar bipolar bipolar bipolar bipolar 2 S1 baseline 304 43 0.160 bipolar bipolar bipolar bipolar bipolar 3 S2 KA 1940 222 0.115 bipolar bipolar bipolar bipolar bipolar 4 S2 baseline 37 6 0.095 bipolar bipolar bipolar bipolar bipolar 5 S3 no drug 79 7 0.083 bimodal not bipolar bimodal not bipolar bimodal not bipolar bimodal not bipolar unimodal 6 S4 KA 37 5 0.244 bimodal not bipolar other other other unimodal 7 S5 no drug 172 23 0.128 other other bimodal not bipolar other bimodal not bipolar 8 S6 no drug 92 13 0.200 other bimodal not bipolar bimodal not bipolar bimodal not bipolar bimodal not bipolar stored_offset_0.00 | S1 and S2 bipolar: True | other slices bipolar: 0 | slices in their stated class: 2 of 6 stored_offset_11.25 | S1 and S2 bipolar: True | other slices bipolar: 0 | slices in their stated class: 3 of 6 flipped_offset_0.00 | S1 and S2 bipolar: True | other slices bipolar: 0 | slices in their stated class: 4 of 6 flipped_offset_11.25 | S1 and S2 bipolar: True | other slices bipolar: 0 | slices in their stated class: 3 of 6
Result: partially reproduced. S1 and S2 (KA) are bipolar (modes 180 degrees apart, R2 = 0.52 and 0.68 against R1 = 0.12 and 0.10), and no other slice is. S3 and S4 are not unimodal by the measure used (with y as stored, two peaks 67.5 degrees apart, second peak 0.92 and 0.70 of the first), and S5 and S6 are not bimodal at 60 to 120 degrees (peaks 45 and 135 degrees apart): 2 of 6 slices are in their stated class. 8 to 24% of the latency weight lies on angles exactly on the bin edges. With y flipped or the bins shifted by half a bin, S1 and S2 stay bipolar and no other slice becomes bipolar, while S4, S5 and S6 change class (3 or 4 of 6 in their stated class); S3 and S4 are never unimodal.
ext10-baseline-same-circuit¶
In S1 and S2 the baseline recordings before kainic acid show the same bipolar circuit as the recordings during epileptiform activity.
As above on recordings 2 and 4: bipolar, and each mode within 45 degrees of a mode of the KA recording of the same slice.
def ang_d(a, b):
d = abs(a - b) % 360
return min(d, 360 - d)
for ka, base in [(1, 2), (3, 4)]:
k, b = SH[(ka, False)], SH[(base, False)]
md_ = [min(ang_d(m, k['mode1_deg']), ang_d(m, k['mode2_deg'])) for m in (b['mode1_deg'], b['mode2_deg'])]
print(H.RECORDINGS[ka]['slice'], f"baseline class {b['cls']} (R1 {b['R1']:.3f}, R2 {b['R2']:.3f}, peaks {b['mode1_deg']:.0f} and {b['mode2_deg']:.0f} deg);",
f"KA class {k['cls']} (peaks {k['mode1_deg']:.0f} and {k['mode2_deg']:.0f} deg); baseline modes from nearest KA mode {md_[0]:.0f} and {md_[1]:.0f} deg;",
'holds' if b['cls'] == 'bipolar' and max(md_) <= 45 else 'does not hold')
S1 baseline class bipolar (R1 0.079, R2 0.340, peaks 191 and 11 deg); KA class bipolar (peaks 191 and 11 deg); baseline modes from nearest KA mode 0 and 0 deg; holds S2 baseline class bipolar (R1 0.316, R2 0.666, peaks 236 and 34 deg); KA class bipolar (peaks 236 and 56 deg); baseline modes from nearest KA mode 0 and 22 deg; holds
Result: reproduced. Both baseline recordings are bipolar (S1 R2 = 0.34 against R1 = 0.08, S2 0.67 against 0.32), and their modes lie 0 and 0 degrees (S1) and 0 and 22 degrees (S2) from the modes of the KA recording of the same slice.
table3-geometry-test¶
The circuit geometry test gives p-values orders of magnitude smaller for the slices with recurrent circuits than for the others.
Code (figures/figure_3/haussler/hc112823_acid.ipynb): all significant pairs, sending unit's position index along the degree-2 fit, angle = arctan2 of receiving minus sending position, Student's t-test of positions for angle >= 0 against angle < 0. Both directions of the y axis.
exp_lp = {1: 19.01, 2: 12.07, 3: 67.8, 4: 6.0, 5: 0.92, 6: 0.43, 7: 3.38, 8: 2.96}
rows = []
for flip in (False, True):
for r in SORT:
th, w = angles(r, flip)
lp = H.layer_position(SORT[r]['pos'])[PAIRS[r].send.values]
g1, g2 = lp[th >= 0], lp[th < 0]
p = stats.ttest_ind(g1, g2).pvalue if len(g1) > 1 and len(g2) > 1 else np.nan
rows.append(dict(rec=r, slice=H.RECORDINGS[r]['slice'], cond=H.RECORDINGS[r]['cond'], y_flipped=flip, n_pos=len(g1), n_neg=len(g2),
p=p, neglog10p=-np.log10(p), expected=exp_lp[r], within_tol=abs(-np.log10(p) - exp_lp[r]) <= 0.1 * exp_lp[r]))
G3 = pd.DataFrame(rows)
print(G3.to_string(index=False))
for flip in (False, True):
g = G3[G3.y_flipped == flip].set_index('rec')
worst_ab = g.loc[[1, 2, 3, 4], 'p'].max(); best_other = g.loc[[5, 6, 7, 8], 'p'].min()
print(f'y flipped {flip}: within tolerance {int(g.within_tol.sum())} of 8; largest p of S1/S2 {worst_ab:.2e}, smallest p of S3-S6 {best_other:.2e}, ratio {best_other/worst_ab:.1f}')
rec slice cond y_flipped n_pos n_neg p neglog10p expected within_tol 1 S1 KA False 405 379 9.656585e-20 19.015176 19.01 True 2 S1 baseline False 159 145 8.612884e-13 12.064851 12.07 True 3 S2 KA False 893 1047 2.556267e-68 67.592394 67.80 True 4 S2 baseline False 14 23 1.044482e-06 5.981099 6.00 True 5 S3 no drug False 52 27 1.150754e-01 0.939018 0.92 True 6 S4 KA False 23 14 3.655576e-01 0.437044 0.43 True 7 S5 no drug False 83 89 4.175000e-04 3.379344 3.38 True 8 S6 no drug False 34 58 1.082462e-03 2.965587 2.96 True 1 S1 KA True 415 369 8.046374e-23 22.094400 19.01 False 2 S1 baseline True 163 141 1.428422e-14 13.845143 12.07 False 3 S2 KA True 1104 836 5.813872e-74 73.235535 67.80 True 4 S2 baseline True 24 13 4.374088e-07 6.359112 6.00 True 5 S3 no drug True 30 49 7.041658e-02 1.152325 0.92 False 6 S4 KA True 18 19 1.468227e-01 0.833207 0.43 False 7 S5 no drug True 95 77 2.017177e-03 2.695256 3.38 False 8 S6 no drug True 62 30 2.129622e-02 1.671698 2.96 False y flipped False: within tolerance 8 of 8; largest p of S1/S2 1.04e-06, smallest p of S3-S6 4.17e-04, ratio 399.7 y flipped True: within tolerance 2 of 8; largest p of S1/S2 4.37e-07, smallest p of S3-S6 2.02e-03, ratio 4611.7
Result: reproduced. With y as stored, -log10 p is 19.02, 12.06, 67.59, 5.98, 0.94, 0.44, 3.38 and 2.97 for recordings 1 to 8, all within tolerance of the paper's (19.01, 12.07, 67.8, 6.0, 0.92, 0.43, 3.38, 2.96). With y flipped 2 of 8 are within tolerance. Under both, the largest p of S1 and S2 is 400 (y as stored) to 4600 (flipped) times smaller than the smallest p of S3 to S6.
ext12-simulation-recurrence (blocked, not_runnable)¶
In a simplified dentate gyrus network model, increasing recurrent connectivity between granule cells produces seizure-like bursting.
The criterion asks to run figures/supplement/simulation/simulation.py of the paper's repository as
committed. It needs the NEST simulator with a neuron model compiled by NESTML. The simulation's
environment (printed below) pins conda-forge nest-simulator=3.4.* and nestml==5.*; the registry
runs entries in a pip environment locked with hashes, which cannot hold the conda NEST build. While
preparing the attempt, outside this notebook, the PyPI release of NEST (nest-simulator 3.10.0) was
tried: NESTML 9.0.1 cannot parse the model, whose first line uses the older keyword neuron
(printed below; NESTML 9 expects model), and NESTML 5 calls nest.ll_api.sli_func, which NEST
3.10 no longer has. Those trials need packages outside the entry's lock, so they are not run here
and decide no number; the claim is blocked as not_runnable. The sweep (275 simulations of 30 s)
was not timed.
print(H._fetch('figures/supplement/simulation/environment.yml').decode())
model = H._fetch('figures/supplement/simulation/models/izh_cond_exp2syn.nestml').decode().splitlines()
print('model file, first line:', model[0])
name: AndrewsGengVoitiukEtAl
channels:
- conda-forge
dependencies:
- python=3.10.*
- nest-simulator=3.4.*
- tqdm
- pip
- pip:
- braingeneers
- nestml==5.*
model file, first line: neuron izh_cond_exp2syn:
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 |
|---|---|
| sorting-dandiset-link (link) | partially reproduced (6 of 8 recordings found) |
| table1-unit-counts | not reproduced (units 8 of 8; durations on the dandiset 5 of 8) |
| fig1g-ka-synchronized-bursting | not reproduced |
| methods-burst-counts | not reproduced |
| methods-rate-increase-after-ka | not reproduced |
| methods-onset-latency | blocked (metadata_insufficient) |
| s4-ka-no-epileptiform | partially reproduced (resting on an assumption) |
| fig2c-sttc-two-clusters | partially reproduced (S2 holds, S1 does not) |
| ext9-sttc-eigenvector-gradient | partially reproduced (S2 holds, S1 does not) |
| ext9-sttc-beats-correlation | reproduced |
| fig3a-significant-pairs | reproduced (8 of 8 counts equal) |
| fig3a-bipolar-angle-histograms | partially reproduced |
| ext10-baseline-same-circuit | reproduced |
| table3-geometry-test | reproduced (8 of 8) |
| ext12-simulation-recurrence | blocked (not_runnable) |
The other claims are in lfp_elliott_2026.ipynb and the attempt record.
How the analysis differs from the paper's: the spike sortings are the paper's own, read from its repository (outside input); bursts, superbursts and their counts use readings named in the claims file, as neither the paper nor its code defines them; the pre-KA reference for burst reading (a) is the separate baseline recording, as no time of KA application is recorded; a synchronized burst is one that raises the rate of most units, and sustained bursting an epoch of such bursts lasting more than 10 s; the measures of cluster position, eigenvector gradient and histogram shape are those the claims file names, not the paper's visual judgement.
What was found about the dataset: the dandiset holds raw voltage only, with no units, no epochs and no record of when kainic acid was applied; its session start times are the conversion date. The paper's analysed recordings 1 to 6 are in it (two of them as parts of longer files), and recordings 7 and 8 (S5 and S6) are not in any file with their electrode layout. Subject identifiers name slices, not patients, and the patient letters differ from the paper's (paper patient A, 52 F, is sub-10F; patient C, 20 M, is sub-1A). Every electrode's location is "unknown". In one second (10 to 11 s, 64 channels) the files sub-3C-1 to sub-3C-4 share 78 to 82% of their samples, which first suggested copies of one recording; over their first 40 s and all 972 channels they are not copies: sub-3C-1 to sub-3C-5 (sub-3C-5 has another length) are saturated at the converter's limits (0 or 1023 counts) at the same seconds (10 to 12 or 13 and 20 to 21 s), where the identical samples lie (26 to 27% there, 4% elsewhere), and outside those seconds their LFP correlates at a median of 0.03 to 0.08 (above 0.5 only in the saturated seconds and up to 4 s after them). Nothing in the files records what caused the saturation.
print(f'notebook ran in {(time.time()-T0)/60:.1f} min; peak memory {resource.getrusage(resource.RUSAGE_SELF).ru_maxrss/1e6:.1f} GB')
notebook ran in 13.2 min; peak memory 1.6 GB