OSCR

Laminar organization of cellular microcircuits modulating human interictal epileptiform discharges.

Code ↔ Paper

9 matches between paragraphs of the paper and lines of its authors' code, computed by the harvester (lexical-v1). Click a colored paragraph or line to see its counterpart.

The 9 matches
  1. [1] § Results › Antecedent IED prediction ↔ Fig6.ipynb, lines 590–727 · score 0.66 · low amplitude, high amplitude, cortical sites, IED amplitudes, AUROC, decoding
  2. [2] § Methods › Antecedent IED prediction from neuronal ensembles ↔ Fig6.ipynb, lines 590–727 · score 0.65 · low amplitude, high amplitude, IED amplitudes, AUROC, decoding, cortical
  3. [3] § Methods › Neuronal encoding during speech perception ↔ Fig5.ipynb, lines 197–343 · score 0.63 · Acoustic phonetic features, word, R2, regression, fit, correlation
  4. [4] § Methods › Assessing single-neuron coding of IED features ↔ Extended_Data_8.ipynb, lines 29–71 · score 0.60 · slow wave, 0–1, aftergoing, fit, antecedent, activity
  5. [5] § Methods › Isolation of single-neuron spiking ↔ +MTracer/SortingResult.m, lines 362–401 · score 0.60 · refractory period violations, Kilosort, Clusters, spikes
  6. [6] § Results › Neurocognitive correlates of IED generation circuit ↔ Fig5.ipynb, lines 197–343 · score 0.58 · acoustic phonetic features, neuron firing, r2, Schematic, fit, correlated
  7. [7] § Methods › Isolation of single-neuron spiking ↔ Extended_Data_2.ipynb, lines 58–76 · score 0.54 · spectrotemporal waveform, UMAP, embedded, clusters
  8. [8] § Methods › Isolation of IEDs ↔ Fig6.ipynb, lines 64–184 · score 0.54 · ECoG, NP LFP, LL, baseline, IEDs
  9. [9] § Results › Neuropixels recordings and IED processing ↔ Extended_Data_2.ipynb, lines 142–185 · score 0.51 · ROC curve, Trough peak, RS, FS, waveform

Paper

Loaded from Europe PMC by your browser, not stored by OSCR: doi.org · Europe PMC

The paper is loaded when this pane is shown.

The authors' code

Jupyter notebook · 731 lines · 18 KB · no license · 3 matches

  1. # %%
  2. import matplotlib.pyplot as plt
  3. plt.rcParams.update({'font.size': 6})#, 'font.sans-serif': 'Arial'})
  4. plt.rcParams.update({'font.sans-serif':'Arial'})
  5. import matplotlib as mpl
  6. mpl.rcParams['axes.spines.top'] = False
  7. mpl.rcParams['axes.spines.right'] = False
  8. plt.rcParams['svg.fonttype'] = 'none'
  9. import matplotlib
  10. matplotlib.rcParams['pdf.fonttype'] = 42
  11. matplotlib.rcParams['ps.fonttype'] = 42
  12. import matplotlib.pyplot as plt
  13. from scipy.stats import sem
  14. def plot_single_erp(dat,ax=None,t_ar=None,alpha=0.3,color='b',label=None):
  15. if(ax is None):
  16. fig,ax = plt.subplots()
  17. if(label is None):
  18. label = '_hide'
  19. sig = dat.mean(0)
  20. err = sem(dat,axis=0)
  21. if(t_ar is None):
  22. t_ar = range(sig.shape[0])
  23. ax.plot(t_ar,sig,color=color,label=label)
  24. ax.fill_between(t_ar,sig+err,sig-err,color=color,alpha=alpha)
  25. return(ax,sig,err)
  26. def return_spk_raster(spks,times,t_ar=[-1,1]):
  27. cur_times = spks.copy()#quality.sua[quality.cluster_id == neuron_id].values[0]#spk_dictionary['sua'][neuron_id][0]
  28. cnt = -1
  29. all_elg_trial = []
  30. for i,tr in enumerate(times):
  31. elg_times = cur_times[ (cur_times >= (tr + t_ar[0]) ) & (cur_times <= (tr + t_ar[1]) ) ]
  32. elg_times -= tr
  33. all_elg_trial.append(elg_times)
  34. return(all_elg_trial)
  35. probe_mapper = {'NP34_B2_0': 'P1-S1-P1',
  36. 'NP34_B3_0': 'P1-S2-P1',
  37. 'NP35_B2_0': 'P2-S1-P1',
  38. 'NP66_B1_0': 'P3-S1-P1',
  39. 'NP66_B1_1': 'P3-S1-P2',
  40. 'NP66_B2_0': 'P3-S2-P1',
  41. 'NP66_B2_1': 'P3-S2-P2',
  42. 'NP86_B1_0': 'P4-S1-P1',
  43. 'NP86_B1_1': 'P4-S1-P2',}
  44. blk_mapper = {'NP34_B2': 'P1-S1',
  45. 'NP34_B3': 'P1-S2',
  46. 'NP35_B2': 'P2-S1',
  47. 'NP86_B1': 'P4-S1',
  48. 'NP66_B1': 'P3-S1',
  49. 'NP66_B2': 'P3-S2',}
  50. source_path = './source_data/FIG6/'
  51. output_dir = 'statistical_source/FIG6' # create folder if not yet existing
  52. import os
  53. if not os.path.exists(output_dir):
  54. os.makedirs(output_dir)
  55. # %%
  56. import numpy as np
  57. import matplotlib.pyplot as plt
  58. from matplotlib import gridspec
  59. # ============================================================
  60. # CREATE COMPOSITE LAYOUT
  61. # ============================================================
  62. fig = plt.figure(figsize=(7, 1.7))
  63. gs = gridspec.GridSpec(
  64. 2, 4,
  65. width_ratios=[1, 1, 1, 1.5],
  66. wspace=0.6,
  67. hspace=0.15
  68. )
  69. fig.subplots_adjust(left=0.06, right=0.95, top=0.975, bottom=0.19)
  70. # ============================================================
  71. # COLUMN 0 — BLANK
  72. # ============================================================
  73. ax_blank_top = fig.add_subplot(gs[0, 0])
  74. ax_blank_bot = fig.add_subplot(gs[1, 0])
  75. ax_blank_top.axis('off')
  76. ax_blank_bot.axis('off')
  77. # ============================================================
  78. # COLUMN 1 — ECoG ERP (2 x 1 panel, unchanged)
  79. # ============================================================
  80. d = np.load(f'{source_path}/ecog_decoding.npz')
  81. ied_erp = d['ied_erp']
  82. ll = d['ll']
  83. ax1 = fig.add_subplot(gs[0, 1])
  84. plot_single_erp(
  85. ied_erp,
  86. ax=ax1,
  87. t_ar=np.linspace(-0.5, 0.5, ied_erp.shape[1]),
  88. color='k',
  89. alpha=0.1
  90. )
  91. ax1.set(ylabel='ECoG LFP', xticks=[], yticks=[])
  92. ax2 = fig.add_subplot(gs[1, 1])
  93. plot_single_erp(
  94. ll,
  95. ax=ax2,
  96. t_ar=np.linspace(-0.5, 0.5, ied_erp.shape[1]),
  97. color='k',
  98. alpha=0.1
  99. )
  100. ax2.set(
  101. ylabel='ECoG line-length',
  102. xlabel='Time rel. to IED (s)',
  103. yticks=[],xlim=[-0.5,0.5]
  104. )
  105. # ============================================================
  106. # COLUMN 2 — AUROC DECODING TRACE
  107. # ============================================================
  108. d = np.load(f'{source_path}/ecog_decoding_trace.npz')
  109. rocs_null = d['rocs_null']
  110. rocs = d['rocs']
  111. ax3 = fig.add_subplot(gs[:, 2])
  112. t_ar = np.linspace(-0.5, 0.5, len(rocs))
  113. ax3.plot(t_ar, rocs, color='k', alpha=0.9, linewidth=2)
  114. ax3.axvline(0, color='k', linestyle='--')
  115. ax3.axhline(
  116. np.percentile(rocs_null, 99.5),
  117. color='k',
  118. linestyle='--'
  119. )
  120. ax3.set(
  121. ylabel='AUROC (IED vs baseline)',
  122. xlabel='Decoding up to timepoint (s)',xlim=[-0.5,0.5],ylim=[0.3,1],yticks=[0.3,0.6,0.9,1]
  123. )
  124. # ============================================================
  125. # COLUMN 3 — DEPTH × TIME LFP HEATMAP
  126. # ============================================================
  127. d = np.load(f'{source_path}/ex_lfp.npz')
  128. lfp = d['lfp']
  129. depth = d['depth']
  130. ax4 = fig.add_subplot(gs[:, 3])
  131. t_ar = np.linspace(-2.5, 1, lfp.shape[1])
  132. im = ax4.pcolormesh(
  133. t_ar,
  134. depth,
  135. lfp,
  136. cmap='bone_r',
  137. vmin=-80,
  138. vmax=80,
  139. rasterized=True
  140. )
  141. ax4.set(
  142. xlabel='Time rel. to IED (s)',
  143. ylabel='Depth (uM)',ylim=[0,6000],yticks=[0,2000,4000,6000],xlim=[-2.5,1],
  144. )
  145. ax4.invert_yaxis()
  146. plt.colorbar(im, ax=ax4, label='NP LFP (uV)',ticks=[-80,0,80])
  147. # ============================================================
  148. # FINALIZE
  149. # ============================================================
  150. # plt.savefig('./current_composite/ecog_combined.pdf',
  151. # transparent=True, dpi=800)
  152. plt.show()
  153. # %%
  154. import seaborn as sns
  155. d = np.load(f'{source_path}/ex_rasters_decoding.npz')
  156. psth_ied = d['psth_ied']
  157. spks1 = d['spks1']
  158. spks2 = d['spks2']
  159. ied_times = d['ied_times']
  160. fig, axes = plt.subplots(1, 3, figsize=(7, 1.3),width_ratios=[1,1,0.7]) # 1 x 3 layout
  161. fig.subplots_adjust(left=0.06, right=0.982, top=0.99, bottom=0.26)
  162. for i, spks in enumerate([spks1, spks2]):
  163. ax = axes[i]
  164. spk_raster = return_spk_raster(spks, ied_times, [-1.5, 1])
  165. r = [r for r in spk_raster if len(r) > 0]
  166. for ind, tr in enumerate(r):
  167. ax.scatter(
  168. tr,
  169. np.repeat(ind, len(tr)),
  170. color='k',
  171. alpha=0.3,
  172. clip_on=False,
  173. marker='|',
  174. s=3
  175. )
  176. ax.set_xlim([-1.5, 1])
  177. plot_single_erp(
  178. 12 * psth_ied[:, :, i],
  179. ax=ax,
  180. t_ar=np.linspace(-1.5, 1, psth_ied.shape[1]),
  181. color=sns.color_palette('Set2')[1],
  182. alpha=0.1
  183. )
  184. ax.set(yticks=[], ylabel='IEDs', xlabel='Time relative to IED (s)')
  185. if(i == 1): ax.set(ylabel='')
  186. # third subplot intentionally blank
  187. axes[2].axis('off')
  188. #plt.savefig('./current_composite/raster_row.pdf',transparent=True,dpi=800)
  189. # %%
  190. d = np.load(f'{source_path}/dec_schematic.npz')
  191. psth_ied = d['psth_ied']
  192. psth_baseline = d['psth_baseline']
  193. fig, axs = plt.subplots(2,1,figsize=(0.8,1.3),gridspec_kw=dict(hspace=0.5))
  194. fig.subplots_adjust(left=0.2, right=0.8, top=0.99, bottom=0.26)
  195. t_ar = np.linspace(-1,0.25,25)
  196. axs[0].pcolormesh(t_ar,range(psth_ied.shape[-1]),psth_ied.T,cmap='Reds',vmin=0,vmax=30)
  197. axs[0].set(xticks=[],yticks=[],xlabel='',ylabel='')
  198. axs[1].pcolormesh(t_ar,range(psth_ied.shape[-1]),psth_baseline.T,cmap='binary',vmin=0,vmax=30,rasterized=True)
  199. axs[1].set(xlabel='Time (up to 0.25s)',ylabel='Neurons',yticks=[])
  200. #plt.savefig('./current_composite/decode_schem.pdf',dpi=800,transparent=True)
  201. # %%
  202. d = np.load(f'{source_path}/dec_schematic_pca.npz')
  203. fig,axs = plt.subplots(1,2,gridspec_kw=dict(wspace=0.5),figsize=(0.2,1.5))
  204. axs[0].imshow(d['x1'].reshape((-1,1)),cmap='Reds',vmin=-10,vmax=10)
  205. axs[0].set(yticks=[],xticks=[])
  206. sns.despine(ax=axs[0],left=True,bottom=True)
  207. axs[1].imshow(d['x2'].reshape((-1,1)),cmap='binary',vmin=-10,vmax=10)
  208. axs[1].set(yticks=[],xticks=[])
  209. sns.despine(ax=axs[1],left=True,bottom=True)
  210. #plt.savefig('./current_composite/decode_pca.pdf',dpi=800,bbox_inches='tight',transparent=True)
  211. # %%
  212. d = np.load(f'{source_path}/ied_prediction.npz')
  213. rocs_null_ = d['rocs_null']
  214. keys = d['keys']
  215. rocs_ = d['rocs']
  216. best_ts = d['best_ts']
  217. import seaborn as sns
  218. import pandas as pd
  219. import numpy as np
  220. import matplotlib.pyplot as plt
  221. fig, axes = plt.subplots(
  222. 1, 5,
  223. figsize=(7, 1.7),
  224. gridspec_kw=dict(wspace=0.6),width_ratios=[1,0.8,0.4,1,0.8]
  225. )
  226. fig.subplots_adjust(left=0.06, right=0.982, top=0.975, bottom=0.26)
  227. # ---------- Panel 1: ROC (index 3) ----------
  228. t_ar = np.linspace(-1, 0.5, len(rocs_[0]))
  229. rocs = rocs_[3]
  230. rocs_null = rocs_null_[3]
  231. ax = axes[0]
  232. ax.plot(t_ar, rocs, color='k', alpha=0.9, linewidth=2)
  233. ax.axvline(0, color='k', linestyle='--')
  234. ax.axhline(np.percentile(np.array(rocs_null), 99, axis=0),
  235. color='k', linestyle='--')
  236. ax.set(
  237. ylabel='AUROC (IED vs baseline)',
  238. xlabel='Decoding up to \ntimepoint (s)',
  239. ylim=[0.3, 1],yticks=[0.3,0.5,0.7,1],xlim=[-1,0.5]
  240. )
  241. # ---------- Panel 2: ROC (index 4) ----------
  242. t_ar = np.linspace(-1, 0.5, len(rocs_[0]))
  243. rocs = rocs_[4]
  244. rocs_null = rocs_null_[4]
  245. ax = axes[1]
  246. ax.plot(t_ar, rocs, color='k', alpha=0.9, linewidth=2)
  247. ax.axvline(0, color='k', linestyle='--')
  248. ax.axhline(np.percentile(np.array(rocs_null), 99, axis=0),
  249. color='k', linestyle='--')
  250. ax.set(
  251. #ylabel='AUROC (IED vs baseline)',
  252. xlabel='Decoding up to \ntimepoint (s)',
  253. ylim=[0.3, 1],yticks=[],xlim=[-1,0.5]
  254. )
  255. # ---------- Panel 3: First above-chance time ----------
  256. ax = axes[2]
  257. sns.stripplot(best_ts, color='k', alpha=0.8, jitter=0.4, ax=ax)
  258. sns.boxplot(best_ts, color='k',
  259. boxprops=dict(alpha=0.2),
  260. fliersize=0,
  261. ax=ax)
  262. ax.axhline(0, linestyle='--', color='k', alpha=0.3)
  263. ax.set(
  264. ylabel='First above-chance \n decoding timepoint (s)',
  265. xticklabels=['Cortical site']
  266. )
  267. # ---------- Panel 4: Contribution by response type ----------
  268. contrib_df = pd.read_csv(f'{source_path}/contrib_dec_df.csv')
  269. ax = axes[3]
  270. sns.boxplot(
  271. orient='h',
  272. data=contrib_df,
  273. y='k_mean_cluster',
  274. x='pre_onset_contrib',
  275. palette='Set2',
  276. boxprops=dict(alpha=0.2),
  277. showfliers=False,
  278. ax=ax
  279. )
  280. sns.stripplot(
  281. orient='h',
  282. data=contrib_df,
  283. y='k_mean_cluster',
  284. x='pre_onset_contrib',
  285. s=2,
  286. palette='Set2',
  287. alpha=0.8,
  288. ax=ax
  289. )
  290. ax.set(
  291. xlabel='Decoding contrib. \n(log)',
  292. ylabel='',
  293. yticklabels=['Early\n act.', 'Supp.', 'Late\n act.']
  294. )
  295. # ---------- Panel 5: Contribution vs depth ----------
  296. ax = axes[4]
  297. sns.scatterplot(
  298. ax=ax,
  299. data=contrib_df,
  300. x='pre_onset_contrib',
  301. y='depth',
  302. s=7,
  303. palette='Set2',
  304. hue='k_mean_cluster',
  305. alpha=0.8,
  306. legend=None
  307. )
  308. ax.invert_yaxis()
  309. ax.set(
  310. xlabel='Decoding contrib. \n(log)',
  311. ylabel='Depth (uM)'
  312. )
  313. #plt.tight_layout()
  314. # plt.savefig('../figure_3/current_composite/predict_ied_row.pdf',
  315. # transparent=True, dpi=800)
  316. contrib_df.to_csv('./statistical_source/FIG6/panelgh.csv')
  317. # %%
  318. print(best_ts.min())
  319. print(best_ts.max())
  320. print(best_ts.mean())
  321. # %%
  322. from scipy.stats import mannwhitneyu,ttest_ind,ranksums
  323. for p in [[1,2],[1,3],[2,3]]:
  324. print(p)
  325. print(ranksums(contrib_df[(contrib_df.k_mean_cluster == p[0])
  326. & (contrib_df.pre_onset_contrib != -1*np.inf)].pre_onset_contrib,
  327. contrib_df[(contrib_df.k_mean_cluster == p[1])
  328. & (contrib_df.pre_onset_contrib != -1*np.inf)].pre_onset_contrib))
  329. for p in range(1,4):
  330. print(np.sum(contrib_df.k_mean_cluster ==p))
  331. # %%
  332. import numpy as np
  333. import matplotlib.pyplot as plt
  334. import pandas as pd
  335. import seaborn as sns
  336. from scipy.stats import sem
  337. from mne.stats import permutation_cluster_test
  338. # ============================================================
  339. # CREATE 1 x 3 COMPOSITE FIGURE
  340. # ============================================================
  341. fig, axes = plt.subplots(
  342. 1, 3,
  343. figsize=(7, 1.25),
  344. gridspec_kw=dict(wspace=0.4),width_ratios=[1,0.8,1.1]
  345. )
  346. fig.subplots_adjust(left=0.06, right=0.982, top=0.98, bottom=0.26)
  347. # ============================================================
  348. # PANEL 1 — Isolated vs Series LFP
  349. # ============================================================
  350. D = np.load(
  351. f"{source_path}/string_vs_iso_minimal_source.npz",
  352. allow_pickle=True
  353. )
  354. iso_trace = D["iso_trace"]
  355. series_trace = D["series_trace"]
  356. ax = axes[0]
  357. t_ar = np.linspace(-1, 1, iso_trace.shape[0])
  358. ax.plot(
  359. t_ar,
  360. iso_trace,
  361. color='b',
  362. alpha=0.5,
  363. linewidth=2,
  364. label='Isolated'
  365. )
  366. ax.plot(
  367. t_ar,
  368. series_trace,
  369. color='r',
  370. alpha=0.5,
  371. linewidth=2,
  372. label='Series'
  373. )
  374. ax.set(
  375. ylabel='LFP (uV)',
  376. xlabel='Time relative to first IED (s)',xlim=[-1,1]
  377. )
  378. ax.set_xticks([-1, -0.5, 0, 0.5, 1])
  379. ax.legend(
  380. loc=(0, 0.65),
  381. frameon=False
  382. )
  383. # ============================================================
  384. # PANEL 2 — ERP + Cluster Significance
  385. # ============================================================
  386. D = np.load(
  387. f"{source_path}/erp_cluster_minimal_source.npz",
  388. allow_pickle=True
  389. )
  390. psth_id_0 = D["psth_id_0"]
  391. psth_id_1 = D["psth_id_1"]
  392. psth_interest_0 = D["psth_interest_0"]
  393. psth_interest_1 = D["psth_interest_1"]
  394. t_ar = D["t_ar"]
  395. target_column = str(D["target_column"])
  396. i = int(D["index"])
  397. ax = axes[1]
  398. ax, _, _ = plot_single_erp(
  399. psth_id_0,
  400. ax,
  401. t_ar
  402. )
  403. ax, _, _ = plot_single_erp(
  404. psth_id_1,
  405. ax,
  406. t_ar,
  407. color='r'
  408. )
  409. ax.set(
  410. xlim=[-0.45, 0.25],
  411. xlabel='Time relative to first IED (s)',
  412. ylabel='Firing rate (Hz)'
  413. )
  414. ax.axvline(0, linestyle='--', color='k')
  415. # ----- permutation cluster test -----
  416. for_test = []
  417. for p in [psth_interest_0, psth_interest_1]:
  418. p = p[np.sum(p, axis=1) > 0, :]
  419. for_test.append(p)
  420. T_obs, clusters, p_values, H0 = permutation_cluster_test(
  421. for_test,
  422. verbose='ERROR'
  423. )
  424. signif_mask = np.zeros(T_obs.shape)
  425. for cluster_mask, p_val in zip(clusters, p_values):
  426. cluster_mask = cluster_mask[0].astype(int)
  427. if p_val < 0.05:
  428. signif_mask[cluster_mask[0]:cluster_mask[-1]] = 1
  429. ax.scatter(
  430. t_ar[signif_mask > 0],
  431. signif_mask[signif_mask > 0] - 1,
  432. color='k',
  433. s=12
  434. )
  435. # ============================================================
  436. # PANEL 3 — Decoding AUROC Boxplot
  437. # ============================================================
  438. plt_df = pd.read_csv(f'{source_path}/chain_decoding.csv')
  439. ax = axes[2]
  440. sns.boxplot(
  441. ax=ax,
  442. data=plt_df,
  443. x='column',
  444. y='Acc',
  445. hue='type',
  446. palette=['#404040', '#b6b7ba'],
  447. showfliers=False
  448. )
  449. ax.set(
  450. xlabel='',
  451. ylabel='AUROC \n(Isolated vs Series)',
  452. xticklabels=[probe_mapper[p.get_text()] for p in ax.get_xticklabels()]
  453. )
  454. ax.legend().set_visible(False)
  455. ax.axhline(50, color='k', linestyle='--', zorder=-100)
  456. plt_df.to_csv('./statistical_source/FIG6/panelk.csv')
  457. # ============================================================
  458. # FINALIZE
  459. # ============================================================
  460. # plt.savefig(
  461. # './current_composite/string_iso_row.pdf',
  462. # dpi=800,
  463. # transparent=True,
  464. # )
  465. # %%
  466. from scipy.stats import mannwhitneyu,ranksums
  467. import numpy as np
  468. for c in plt_df.column.unique():
  469. tmp_df = plt_df[plt_df.column == c]
  470. print(np.percentile(tmp_df[tmp_df.type == 'Shuffle'].Acc.values,95))
  471. print(np.mean(tmp_df[tmp_df.type == 'True'].Acc.values))
  472. print(c,ranksums(tmp_df[tmp_df.type == 'True'].Acc.values,
  473. tmp_df[tmp_df.type == 'Shuffle'].Acc.values))
  474. print(len(tmp_df[tmp_df.type == 'Shuffle'].Acc.values))
  475. # %%
  476. tmp_df
  477. # %%
  478. import numpy as np
  479. import pandas as pd
  480. import matplotlib.pyplot as plt
  481. import seaborn as sns
  482. # ============================================================
  483. # CREATE COMPOSITE FIGURE
  484. # ============================================================
  485. fig, axes = plt.subplots(
  486. 1, 4,
  487. figsize=(7, 1.6),
  488. gridspec_kw=dict(wspace=0.6),width_ratios=[1,1,0.9,0.3]
  489. )
  490. fig.subplots_adjust(left=0.06, right=0.982, top=0.98, bottom=0.2)
  491. # ============================================================
  492. # PANEL 1 — IED AMPLITUDE–SPLIT ERP
  493. # ============================================================
  494. D = np.load(
  495. f"{source_path}/ieds_amp_minimal_source.npz",
  496. allow_pickle=True
  497. )
  498. amp = D["amp"]
  499. erp = D["erp"]
  500. t_ar = D["t_ar"]
  501. key = str(D["key"])
  502. ax = axes[0]
  503. top = amp > np.percentile(amp, 75)
  504. bottom = amp < np.percentile(amp, 25)
  505. # High amplitude
  506. ax.plot(t_ar, erp[top].T, color='k', alpha=0.05)
  507. ax.plot(
  508. t_ar,
  509. erp[top].T.mean(1),
  510. color='k',
  511. alpha=0.9,
  512. label='High amp.'
  513. )
  514. # Low amplitude
  515. ax.plot(t_ar, erp[bottom].T, color='grey', alpha=0.05)
  516. ax.plot(
  517. t_ar,
  518. erp[bottom].T.mean(1),
  519. color='grey',
  520. alpha=0.9,
  521. label='Low amp.'
  522. )
  523. ax.axvline(0, color='k', linestyle='--')
  524. ax.set(
  525. xlabel='Time rel. to IED (S)',
  526. ylabel='LFP (uV)',
  527. xlim=[-0.25, 0.25],xticks=[-0.25,0,0.25]
  528. )
  529. ax.legend(
  530. frameon=False,
  531. loc=(0.01, 0.75),
  532. handletextpad=0.5,
  533. handlelength=0.9
  534. )
  535. # ============================================================
  536. # PANELS 2 & 3 — AMP DECODING AUROC TRACES
  537. # ============================================================
  538. D = np.load(
  539. f"{source_path}/amp_decoding_minimal_source.npz",
  540. allow_pickle=True
  541. )
  542. t_ar = D["t_ar"]
  543. rocs = D["rocs"]
  544. rocs_null = D["rocs_null"]
  545. best_ts = []
  546. for i, r, r_null in zip(range(len(rocs)), rocs, rocs_null):
  547. thresh = np.percentile(np.array(r_null), 99)
  548. try:
  549. best_ts.append(np.min(t_ar[r > thresh]))
  550. except:
  551. best_ts.append(-5)
  552. if i < 2:
  553. ax = axes[i + 1]
  554. ax.plot(t_ar, r, color='k')
  555. ax.axhline(thresh, color='k', linestyle='--')
  556. ax.axvline(0, color='k', linestyle='--')
  557. ax.set(
  558. ylabel='AUROC \n (Low vs High Amp. IED)',
  559. xlabel='Decoding up to timepoint (s)',ylim=[0.4,1],yticks=[0.4,0.6,0.8,1],xlim=[-1,0.5]
  560. )
  561. if(i == 1):
  562. ax.set(yticks=[],ylabel='')
  563. # ============================================================
  564. # PANEL 4 — FIRST ABOVE-CHANCE TIMEPOINT
  565. # ============================================================
  566. ax = axes[3]
  567. sns.stripplot(best_ts, color='k', alpha=0.6, jitter=0.4, ax=ax)
  568. sns.boxplot(best_ts, color='k', boxprops=dict(alpha=0.2), ax=ax)
  569. ax.axhline(0, linestyle='--', color='k', alpha=0.3)
  570. ax.set(
  571. ylabel='First above-chance \n decoding timepoint (s)',
  572. xticklabels=['Cortical site'],
  573. ylim=[-1, 0.5],
  574. yticks=[-1, -0.5, 0, 0.5]
  575. )
  576. # ============================================================
  577. # FINALIZE
  578. # ============================================================
  579. plt.tight_layout()
  580. # plt.savefig(
  581. # '../figure_3/current_composite/amp_decoding_row.pdf',
  582. # dpi=800,
  583. # transparent=True
  584. # )
  585. plt.show()
  586. # %%

Fig6.ipynb at commit 6a3676c, no license · at the source

Overview

Authors: Alexander B Silva1,2,3, Siddharth A Marathe1,2,4, Quinn R Greicius1,2,3, Duo Xu1, Shailee Jain1, Jason E Chung1, Xiaofang Yang1, Ankit N Khambhati1, Matthew K Leonard1,2,3, Jonathan K Kleen2,4, Edward F Chang1,2,3
  1. Department of Neurological Surgery, University of California, San Francisco, San Francisco, CA USA
  2. Weill Institute for Neuroscience, University of California, San Francisco, San Francisco, CA USA
  3. University of California, Berkeley, San Francisco Graduate Program in Bioengineering, Berkeley, CA USA
  4. Department of Neurology, University of California, San Francisco, San Francisco, CA USA
Journal: Nature neuroscience, volume 29, issue 6, pages 1462-1475
Dates: received 15 May 2025; accepted 6 March 2026; published online 30 April 2026; in print 2026
Type: Research article · Language: English
License: CC BY
Identifiers: DOI 10.1038/s41593-026-02258-4 · PMID 42062597 · PMCID PMC13246451 · OpenAlex W7159607259
Open access: hybrid, a free copy (OpenAlex)
Status: code verified
Categories: EEG (modality), human (organism), epilepsy (population), systems (subfield)
Methods: Preprocessing, Connectivity, Statistics, Smoothing, state filtering, decompositions, Machine learning, Spectral & time-frequency, fMRI & imaging, Single-unit activity, calcium imaging, Physiology & signal measures
Keywords: Neuronal physiology, Epilepsy, Neural circuits, Perception, Neural decoding
MeSH: Epilepsy*, Neocortex*, Nerve Net*, Neurons*, Action Potentials, Adult, Electroencephalography, Female, Humans, Male, Young Adult (* major topic)
Topic: Neurological disorders and treatments (Neurology, Medicine), according to OpenAlex
Funding: NIDCD NIH HHS (F30 DC021872, R01 DC012379); NINDS NIH HHS (K23 NS110920)
Citations: cited by 3 papers (Europe PMC); 92 references in the paper

Abstract

Interictal epileptiform discharges (IEDs) are pathological bursts of brain activity between seizures in people with epilepsy. Despite their importance in diagnosis, cognitive comorbidities and therapeutic implications as biomarkers for neurostimulation, it is unknown how IEDs arise from structured large-scale neuronal firing across human cortical lamina. We used high-density Neuropixels probes to record from epileptogenic tissue in patients undergoing resective surgery, sampling 1,152 neurons during 1,094 IEDs across nine neocortical sites. We identified microcircuits for IEDs organized by firing pattern, neocortical depth and putative cell type. Regular-spiking cells, concentrated in superficial cortical lamina, initiated and coded the amplitude of the sharp discharge and excitatory–inhibitory imbalances across neocortical lamina preceded IEDs, enabling IED prediction up to 1,000 ms in advance. Most neurons that were modulated during IEDs also encoded cognitive information and adhered to physiological rhythms at baseline. Thus, neocortical IEDs are generated from predictable laminar–cellular interactions, providing the groundwork for new neurostimulation therapies that harness the granularity of single neurons.

Reproduced under the paper's license (CC BY), from the paper cited above.

Repositories

Its files are read in the Code ↔ Paper reader above, with 9 matches between paragraphs and lines of code.

Kleen-Lab/Linelength-spike-detector-MATLAB

License: CC0-1.0
State: the link answers, verified on 30 September 2026
Evidence: files inventoried
Commit: 3c73b037b0f55e3bc634f08e1632ee06861c6241, 21 June 2023
Languages: MATLAB (1)
Size: 3 files, 1 script
Software Heritage: not archived
Found in: “Code availability”
Holds: README, license file
Not found: CITATION.cff, environment file, tests, continuous integration, documentation
Availability: 1 check, the latest on 30 September 2026: the link answers
  • 30 September 2026: the link answers
3 files

yaxigeigei/MTracer

License: none: the authors keep all their rights
State: the link answers, verified on 30 September 2026
Evidence: files inventoried
Commit: 2c193a57ddf5b8f05343d7793bb60d2866fc6253, 12 August 2026
Languages: MATLAB (131), Jupyter (1)
Size: 155 files, 132 scripts
Software Heritage: not archived
Found in: “Code availability”
Holds: README, 2 notebooks
Not found: license file, CITATION.cff, environment file, tests, continuous integration, documentation
Availability: 1 check, the latest on 30 September 2026: the link answers
  • 30 September 2026: the link answers
133 files

asilvaalex4/NP_IEDs

License: none: the authors keep all their rights
State: the link answers, verified on 30 September 2026
Evidence: files inventoried
Commit: 6a3676cde02e8fc17d32ab92e9fcbd6d3870d073, 1 April 2026
Languages: Jupyter (17), Python (2)
Size: 45 files, 19 scripts
Software Heritage: not archived
Found in: “Code availability”
Holds: README, 17 notebooks
Not found: license file, CITATION.cff, environment file, tests, continuous integration, documentation
Tools: Matplotlib (19 files), NumPy (19 files), SciPy (19 files), seaborn (19 files), pandas (17 files), scikit-learn (4 files), statsmodels (2 files), MNE-Python (1 file)
Availability: 1 check, the latest on 30 September 2026: the link answers
  • 30 September 2026: the link answers
20 files

Zenodo 18651142

License: CC-BY-4.0
State: the link answers, verified on 30 September 2026
Evidence: files inventoried
Size: 1 file
Software Heritage: not checked
Found in: the text, “Statistical analysis”
Not found: README, license file, CITATION.cff, environment file, tests, continuous integration, documentation
Availability: 1 check, the latest on 30 September 2026: the link answers (HTTP 200)
  • 30 September 2026: the link answers (HTTP 200)
At the source:

Code availability

Code to replicate the main results and all figures of the manuscript is available at https://github.com/asilvaalex4/NP_IEDs. Code for IED detection via the line length algorithm is available at https://github.com/Kleen-Lab/Linelength-spike-detector-MATLAB. Code for spike sorting and cluster curation is available at https://github.com/yaxigeigei/MTracer.git.

Reproduced under the paper's license (CC BY), from the paper cited above.

Tracing map

Proposed by the machine: these links were found in the paper and verified at the source, without human review. The map will receive a Zenodo DOI once one of the paper's authors has validated it with their ORCID.

What the map holds:

  • 4 repositories of the authors' code, each at its verified commit, with its license and how the link was found in the paper;
  • 152 scripts, each with its path and the digest of its content;
  • 9 matches between paragraphs of the paper and lines of the code (method lexical-v1);
  • neither the text of the paper nor the code itself.

Its JSON (tracing-map.json) is deposited on Zenodo with its DOI once the map is validated.

Data

No dataset and no data link were found in the paper.

Data availability

Data to replicate the main findings and all figures of this manuscript are available at 10.5281/zenodo.18651142 (ref. 92). Given that participants at the onset of the study did not consent to public release of their data, raw data will be made available from the corresponding author (E.C.) upon request to protect patient privacy and consent. Source data are provided with this paper.

Reproduced under the paper's license (CC BY), from the paper cited above.

Versions

The history of this record: each version stored by the harvester or made by a correction of its authors or of the maintainers of its code, and what changed in its facts. The texts of the paper (its abstract, its availability statements) are not part of it; versions that changed only those are not listed.

Version 1, 30 September 2026: the first record

Recorded: type, language, journal, volume, issue, pages, dates, 11 authors, 5 keywords, 11 MeSH terms, 2 funders, 86 references.

Cite

This paper

Silva, A. B., Marathe, S. A., Greicius, Q. R., Xu, D., Jain, S., Chung, J. E., Yang, X., Khambhati, A. N., Leonard, M. K., Kleen, J. K., & Chang, E. F. (2026). Laminar organization of cellular microcircuits modulating human interictal epileptiform discharges. Nature neuroscience, 29(6), 1462-1475. https://doi.org/10.1038/s41593-026-02258-4

BibTeX

@article{silva2026laminar,
author = {Silva, Alexander B and Marathe, Siddharth A and Greicius, Quinn R and Xu, Duo and Jain, Shailee and Chung, Jason E and Yang, Xiaofang and Khambhati, Ankit N and Leonard, Matthew K and Kleen, Jonathan K and Chang, Edward F},
title = {{Laminar organization of cellular microcircuits modulating human interictal epileptiform discharges}},
journal = {Nature neuroscience},
year = {2026},
month = apr,
volume = {29},
number = {6},
pages = {1462--1475},
publisher = {Nature Portfolio},
issn = {1097-6256},
doi = {10.1038/s41593-026-02258-4},
url = {https://doi.org/10.1038/s41593-026-02258-4},
pmid = {42062597},
pmcid = {PMC13246451}
}

RIS

TY - JOUR
AU - Silva, Alexander B
AU - Marathe, Siddharth A
AU - Greicius, Quinn R
AU - Xu, Duo
AU - Jain, Shailee
AU - Chung, Jason E
AU - Yang, Xiaofang
AU - Khambhati, Ankit N
AU - Leonard, Matthew K
AU - Kleen, Jonathan K
AU - Chang, Edward F
TI - Laminar organization of cellular microcircuits modulating human interictal epileptiform discharges
T2 - Nature neuroscience
J2 - Nat Neurosci
PY - 2026
DA - 2026/04/30
VL - 29
IS - 6
SP - 1462
EP - 1475
SN - 1097-6256
PB - Nature Portfolio
DO - 10.1038/s41593-026-02258-4
UR - https://doi.org/10.1038/s41593-026-02258-4
LA - en
ER -

CSL-JSON

{
"id": "10.1038/s41593-026-02258-4",
"type": "article-journal",
"title": "Laminar organization of cellular microcircuits modulating human interictal epileptiform discharges",
"container-title": "Nature neuroscience",
"author": [
{
"family": "Silva",
"given": "Alexander B"
},
{
"family": "Marathe",
"given": "Siddharth A"
},
{
"family": "Greicius",
"given": "Quinn R"
},
{
"family": "Xu",
"given": "Duo"
},
{
"family": "Jain",
"given": "Shailee"
},
{
"family": "Chung",
"given": "Jason E"
},
{
"family": "Yang",
"given": "Xiaofang"
},
{
"family": "Khambhati",
"given": "Ankit N"
},
{
"family": "Leonard",
"given": "Matthew K"
},
{
"family": "Kleen",
"given": "Jonathan K"
},
{
"family": "Chang",
"given": "Edward F"
}
],
"container-title-short": "Nat Neurosci",
"volume": "29",
"issue": "6",
"page": "1462-1475",
"DOI": "10.1038/s41593-026-02258-4",
"PMID": "42062597",
"PMCID": "PMC13246451",
"ISSN": "1097-6256",
"publisher": "Nature Portfolio",
"URL": "https://doi.org/10.1038/s41593-026-02258-4",
"language": "en",
"issued": {
"date-parts": [
[
2026,
4,
30
]
]
}
}

The tracing map gets a citation of its own once an author has validated it and it has a DOI.

Similar papers

The papers with a page that share the most with this one: the tools found in their code, their categories, datasets, cited references and authors, the rarest counting most.

[1] doi:10.1038/s41593-026-02232-0 [code]
Entorhinal cortex represents task-relevant remote locations independently of CA1.
Journal: Nature neuroscience
In common: Kilosort, Image Processing Toolbox, Signal Processing Toolbox, 8 other tools, systems, 2 references
[2] doi:10.1038/s41467-026-71443-7 [code]
Large-scale single-neuron recording in the human cortex using an ultra-flexible electrode array.
Journal: Nature communications
In common: Signal Processing Toolbox, Statistics and Machine Learning Toolbox, 8 references
[3] doi:10.1016/j.neurot.2026.e01031
Single-neuron responses to neurostimulation: Insights for epilepsy.
Journal: Neurotherapeutics : the journal of the American Society for Experimental NeuroTherapeutics
In common: epilepsy, 8 references
[4] doi:10.1016/j.patter.2026.101590 [code]
Density-based longitudinal neuron tracking in high-density electrophysiological recordings.
Journal: Patterns (New York, N.Y.)
In common: Kilosort, Parallel Computing Toolbox, Signal Processing Toolbox, 8 other tools, 1 reference
[5] doi:10.1038/s41467-026-76581-6 [code]
Thalamocortical bursts encode reward contingencies and drive associative learning.
Journal: Nature communications
In common: Kilosort, Deep Learning Toolbox, Image Processing Toolbox, 7 other tools, systems
[6] doi:10.1038/s41467-026-76939-w [code]
HIPPIE: a generative model for electrophysiological analysis across species, technologies, and modalities.
Journal: Nature communications
In common: statsmodels, seaborn, scikit-learn, 4 other tools, 4 references
[7] doi:10.1038/s41586-026-10691-5 [code]
Mapping the neuronal building blocks of human language with language models.
Journal: Nature
In common: statsmodels, scikit-learn, pandas, 3 other tools, 5 references
[8] doi:10.1038/s41467-026-71331-0 [code]
A multimodal approach for visualizing and identifying electrophysiological cell types in vivo.
Journal: Nature communications
In common: seaborn, scikit-learn, pandas, 3 other tools, 5 references
[9] doi:10.1038/s42003-026-10276-y [code]
The cellular correlates and adolescent reorganisation of cortical myelination networks in the common marmoset.
Journal: Communications biology
In common: Parallel Computing Toolbox, Image Processing Toolbox, Signal Processing Toolbox, 8 other tools
[10] doi:10.1038/s41467-026-71151-2 [code]
Common and distinct neural correlates of social interaction processing and theory of mind in narratives.
Journal: Nature communications
In common: Parallel Computing Toolbox, Image Processing Toolbox, Signal Processing Toolbox, 8 other tools

Contribute

The authors of this paper can claim it, correct its record and validate its tracing map, and the maintainers of its code (its owner, or a public member of its organization) correct what it says of their repository; anyone signed in can ask for its removal. Every request goes to OSCR's own machine, which answers it; your account page follows them.

Sign in with ORCID to claim this paper as one of its authors, correct its record or validate its tracing map: when the paper's metadata lists your ORCID iD, you are recognized at once. Maintainers of its code: sign in with GitHub, then claim the repository on your account page.

Request its removal

To ask OSCR to remove this record, the copies of its authors' scripts or its tracing map, use the removal request page: signed in, you say who you are, what to remove and why, then review and confirm the request. Published rules decide every request (how).

Discussion, reproductions, activity

Discussion: questions and error reports about this paper and its code, from signed-in readers and its authors. It opens with sign-in.

Reproductions: reports from readers who ran the authors' code: what they reproduced, with which environment, commit and data. It opens with sign-in.

Activity: what happens around this paper: new versions of its record, its map's validation, discussions and reproductions. It opens with sign-in.