AI-Driven Mapping of Seizure Spread Patterns.
The 7 matches
- [1] § Materials and Methods › Generalized Linear Models to Quantify the Relationship Between Structural Connectivity and Timing of Spread ↔ papers/white_matter_iEEG/REVELL_MDPHD_THESIS_WORK.py, lines 580–641 · score 0.68 · linear_model, Tweedie regressor, power
- [2] § Materials and Methods › Generalized Linear Models to Quantify the Relationship Between Structural Connectivity and Timing of Spread ↔ papers/white_matter_iEEG/white_matter_iEEG.py, lines 613–674 · score 0.68 · linear_model, Tweedie regressor, power
- [3] § Materials and Methods › Validation of Seizure Spread Algorithms: Median Rank Percent of Seizure Onset Contacts ↔ papers/seizureSpread/Script_08_seizure_model_comparisons.py, lines 274–332 · score 0.64 · median ranking, absolute slope, CNN, LSTM, broadband, seizure spread
- [4] § Materials and Methods › Structural Connectivity › Structural Network Generation ↔ papers/brainAtlas/brainAtlasAnalysis.py, lines 178–202 · score 0.62 · tractography generates, DSI Studio, tracts, structural connectivity, atlas, network
- [5] § Materials and Methods › Structural Connectivity › Structural Network Generation ↔ papers/brainAtlas/structure_function_correlation.py, lines 15–160 · score 0.61 · DSI Studio, atlas regions, structural connectivity, tracking, transformed, log
- [6] § Materials and Methods › Validation of Seizure Spread Algorithms: Median Rank Percent of Seizure Onset Contacts ↔ papers/seizureSpread/Script_04_seizure_spread_vs_SOZ.py, lines 885–925 · score 0.57 · median ranking, absolute slope, CNN, LSTM, broadband, seizure spread
- [7] § Materials and Methods › Pre‐Processing of EEG ↔ packages/dataclass/dataclass_iEEG_metadata.py, lines 175–228 · score 0.53 · pre whitened, bipolar, downsampled, filtered, interictal, channel
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
Python · 1,423 lines · 68 KB · no license · 1 match
- """
- Andy Revell's MD/PHD thesis work
- 2021
- """
- #%% 1/4 Imports
- import sys
- import os
- import json
- import copy
- import time
- import bct
- import glob
- import math
- import random
- import pickle
- import pingouin
- import pkg_resources
- import pandas as pd
- import numpy as np
- import seaborn as sns
- import nibabel as nib
- import multiprocessing
- import networkx as nx
- import statsmodels.api as sm
- from scipy import signal, stats
- from itertools import repeat
- from matplotlib import pyplot as plt
- from matplotlib import gridspec
- from scipy import interpolate
- from scipy.integrate import simps
- from scipy.stats import pearsonr, spearmanr
- from os.path import join, splitext, basename
- from pathos.multiprocessing import ProcessingPool as Pool
- #revellLab
- #utilities, constants/parameters, and thesis helper functions
- from revellLab.packages.utilities import utils
- from revellLab.MDPHD_THESIS import constants_parameters as params
- from revellLab.MDPHD_THESIS import constants_plotting as plot
- from revellLab.paths import constants_paths as paths
- from revellLab.MDPHD_THESIS.helpers import thesis_helpers as helper
- #package functions
- from revellLab.packages.dataclass import dataclass_atlases, dataclass_iEEG_metadata
- from revellLab.packages.eeg.ieegOrg import downloadiEEGorg
- from revellLab.packages.atlasLocalization import atlasLocalizationFunctions as atl
- from revellLab.packages.eeg.echobase import echobase
- from revellLab.packages.imaging.tractography import tractography
- from revellLab.packages.imaging.makeSphericalRegions import make_spherical_regions
- #plotting
- from revellLab.MDPHD_THESIS.plotting import plot_GMvsWM
- from revellLab.MDPHD_THESIS.plotting import plot_seizure_distributions
- #% 2/4 Paths and File names
- with open(paths.METADATA_IEEG_DATA) as f: JSON_iEEG_metadata = json.load(f)
- with open(paths.ATLAS_FILES_PATH) as f: JSON_atlas_files = json.load(f)
- with open(paths.IEEG_USERNAME_PASSWORD) as f: IEEG_USERNAME_PASSWORD = json.load(f)
- #data classes
- atlases = dataclass_atlases.dataclass_atlases(JSON_atlas_files)
- metadata_iEEG = dataclass_iEEG_metadata.dataclass_iEEG_metadata(JSON_iEEG_metadata)
- #% 3/4 Paramters
- #ieeg.org username and password
- USERNAME = IEEG_USERNAME_PASSWORD["username"]
- PASSWORD = IEEG_USERNAME_PASSWORD["password"]
- #montaging
- MONTAGE = params.MONTAGE_BIPOLAR
- SAVE_FIGURES = plot.SAVE_FIGURES[1]
- #Frequencies
- FREQUENCY_NAMES = params.FREQUENCY_NAMES
- FREQUENCY_DOWN_SAMPLE = params.FREQUENCY_DOWN_SAMPLE
- #Functional Connectivity
- FC_TYPES = params.FC_TYPES
- #States
- STATE_NAMES = params.STATE_NAMES
- STATE_NUMBER = params.STATE_NUMBER_TOTAL
- #Imaging
- SESSION = params.SESSION_IMPLANT
- SESSION_RESEARCH3T = params.SESSION_RESEARCH3T
- ACQ = params.ACQUISITION_RESEARCH3T_T1_MPRAGE
- IEEG_SPACE = params.IEEG_SPACE
- #Tissue definitions
- TISSUE_DEFINITION = params.TISSUE_DEFINITION_PERCENT
- TISSUE_DEFINITION_NAME = TISSUE_DEFINITION[0]
- TISSUE_DEFINITION_GM = TISSUE_DEFINITION[1]
- TISSUE_DEFINITION_WM = TISSUE_DEFINITION[2]
- WM_DEFINITION_SEQUENCE = TISSUE_DEFINITION[3]
- WM_DEFINITION_SEQUENCE_IND = TISSUE_DEFINITION[4]
- #% 4/4 General Parameter calculation
- # get all the patients with annotated seizures
- patientsWithseizures = metadata_iEEG.get_patientsWithSeizuresAndInterictal()
- N = len(patientsWithseizures)
- iEEGpatientList = np.unique(list(patientsWithseizures["subject"]))
- iEEGpatientList = ["sub-" + s for s in iEEGpatientList]
- #%% Graphing summary statistics of seizures and patient population
- #plot distribution of seizures per patient
- plot_seizure_distributions.plot_distribution_seizures_per_patient(patientsWithseizures)
- utils.save_figure(f"{paths.FIGURES}/seizureSummaryStats/seizureCounts2.pdf", save_figure = True)
- #plot distribution of seizure lengths
- plot_seizure_distributions.plot_distribution_seizure_length(patientsWithseizures)
- utils.save_figure(f"{paths.FIGURES}/seizureSummaryStats/seizureLengthDistribution2.pdf", save_figure = True)
- #%% Electrode and atlas localization
- atl.atlasLocalizationBIDSwrapper(iEEGpatientList, paths.BIDS, "PIER", SESSION, IEEG_SPACE, ACQ, paths.BIDS_DERIVATIVES_RECONALL, paths.BIDS_DERIVATIVES_ATLAS_LOCALIZATION,
- paths.ATLASES, paths.ATLAS_LABELS, paths.MNI_TEMPLATE, paths.MNI_TEMPLATE_BRAIN, multiprocess=False, cores=12, rerun=False)
- #%% EEG download and preprocessing of electrodes
- for i in range(len(patientsWithseizures)):
- metadata_iEEG.get_precitalIctalPostictal(patientsWithseizures["subject"][i], "Ictal", patientsWithseizures["idKey"][i], USERNAME, PASSWORD,
- BIDS=paths.BIDS, dataset="derivatives/iEEGorgDownload", session = SESSION, secondsBefore=180, secondsAfter=180, load=False)
- # get intertical
- associatedInterictal = metadata_iEEG.get_associatedInterictal(patientsWithseizures["subject"][i], patientsWithseizures["idKey"][i])
- metadata_iEEG.get_iEEGData(patientsWithseizures["subject"][i], "Interictal", associatedInterictal, USERNAME, PASSWORD,
- BIDS=paths.BIDS, dataset="derivatives/iEEGorgDownload", session= SESSION, startKey="Start", load=False)
- #%% Power analysis
- ###################################
- #WM power as a function of distance
- fname = join(paths.DATA, "GMvsWM",f"power_{MONTAGE}_{params.TISSUE_DEFINITION_DISTANCE[0]}_GM_{params.TISSUE_DEFINITION_DISTANCE[1]}_WM_{params.TISSUE_DEFINITION_DISTANCE[2]}.pickle")
- if utils.checkIfFileDoesNotExist(fname): #if power analysis already computed, then don't run
- powerGMmean, powerWMmean, powerDistAvg, SNRAll, distAll, paientList, powerGM, powerWM = helper.power_analysis(patientsWithseizures, np.array(range(3, N)), metadata_iEEG, USERNAME, PASSWORD, SESSION, FREQUENCY_DOWN_SAMPLE, MONTAGE, paths, params.TISSUE_DEFINITION_DISTANCE[0] , params.TISSUE_DEFINITION_DISTANCE[1], params.TISSUE_DEFINITION_DISTANCE[2] )
- utils.save_pickle( [powerGMmean, powerWMmean, powerDistAvg, SNRAll, distAll, paientList, powerGM, powerWM], fname)
- powerGMmean, powerWMmean, powerDistAvg, SNRAll, distAll, paientList, powerGM, powerWM = utils.open_pickle(fname)
- #Plots
- #show figure for paper: Power vs Distance and SNR
- plot_GMvsWM.plot_power_vs_distance_and_SNR(powerGMmean, powerWMmean, powerDistAvg, SNRAll, distAll, paientList, powerGM, powerWM)
- utils.save_figure(join(paths.FIGURES, "GM_vs_WM", f"heatmap_pwr_vs_Distance_and_SNR_{MONTAGE}_{params.TISSUE_DEFINITION_DISTANCE[0]}_GM_{params.TISSUE_DEFINITION_DISTANCE[1]}_WM_{params.TISSUE_DEFINITION_DISTANCE[2]}.png"), save_figure= SAVE_FIGURES)
- #Show summary figure
- plot_GMvsWM.plotUnivariate(powerGMmean, powerWMmean, powerDistAvg, SNRAll, distAll, paientList, powerGM, powerWM)
- #boxplot comparing GM vs WM for the different seizure states (interictal, preictal, ictal, postictal)
- plot_GMvsWM.plot_boxplot_tissue_power_differences(powerGMmean, powerWMmean, powerDistAvg, SNRAll, distAll, paientList, powerGM, powerWM, plot.COLORS_TISSUE_LIGHT_MED_DARK[1], plot.COLORS_TISSUE_LIGHT_MED_DARK[2])
- utils.save_figure(join(paths.FIGURES, "GM_vs_WM", f"boxplot_GM_vs_WM_seizure_state_{MONTAGE}_{params.TISSUE_DEFINITION_DISTANCE[0]}_GM_{params.TISSUE_DEFINITION_DISTANCE[1]}_WM_{params.TISSUE_DEFINITION_DISTANCE[2]}.pdf"), save_figure= SAVE_FIGURES)
- #statistics
- helper.power_analysis_stats(powerGMmean, powerWMmean, powerDistAvg, SNRAll, distAll, paientList, powerGM, powerWM)
- ####################################
- #WM power as a function of WM percent
- fname = join(paths.DATA, "GMvsWM",f"power_{MONTAGE}_{params.TISSUE_DEFINITION_PERCENT[0]}_GM_{params.TISSUE_DEFINITION_PERCENT[1]}_WM_{params.TISSUE_DEFINITION_PERCENT[2]}.pickle")
- if utils.checkIfFileDoesNotExist(fname): #if power analysis already computed, then don't run
- powerGMmean, powerWMmean, powerDistAvg, SNRAll, distAll, paientList, powerGM, powerWM = helper.power_analysis(patientsWithseizures, np.array(range(3, N)), metadata_iEEG, USERNAME, PASSWORD, SESSION, FREQUENCY_DOWN_SAMPLE, MONTAGE, paths, params.TISSUE_DEFINITION_PERCENT[0] , params.TISSUE_DEFINITION_PERCENT[1],params.TISSUE_DEFINITION_PERCENT[2] )
- utils.save_pickle( [powerGMmean, powerWMmean, powerDistAvg, SNRAll, distAll, paientList, powerGM, powerWM], fname)
- powerGMmean, powerWMmean, powerDistAvg, SNRAll, distAll, paientList, powerGM, powerWM = utils.open_pickle(fname)
- #Plots
- #Show summary figure
- plot_GMvsWM.plotUnivariatePercent(powerGMmean, powerWMmean, powerDistAvg, SNRAll, distAll, paientList, powerGM, powerWM)
- #boxplot comparing GM vs WM for the different seizure states (interictal, preictal, ictal, postictal)
- plot_GMvsWM.plot_boxplot_tissue_power_differences(powerGMmean, powerWMmean, powerDistAvg, SNRAll, distAll, paientList, powerGM, powerWM, plot.COLORS_TISSUE_LIGHT_MED_DARK[1], plot.COLORS_TISSUE_LIGHT_MED_DARK[2])
- utils.save_figure(join(paths.FIGURES, "GM_vs_WM", f"boxplot_GM_vs_WM_seizure_state_{MONTAGE}_{params.TISSUE_DEFINITION_PERCENT[0]}_GM_{params.TISSUE_DEFINITION_PERCENT[1]}_WM_{params.TISSUE_DEFINITION_PERCENT[2]}.pdf"), save_figure= SAVE_FIGURES)
- #statistics
- helper.power_analysis_stats(powerGMmean, powerWMmean, powerDistAvg, SNRAll, distAll, paientList, powerGM, powerWM)
- #%% Calculating functional connectivity for whole seizure segment
- for fc in range(len(FC_TYPES)):
- for i in range(3, N):
- sub = patientsWithseizures["subject"][i]
- functionalConnectivityPath = join(paths.BIDS_DERIVATIVES_FUNCTIONAL_CONNECTIVITY_IEEG, f"sub-{sub}")
- utils.checkPathAndMake(functionalConnectivityPath, functionalConnectivityPath)
- metadata_iEEG.get_FunctionalConnectivity(patientsWithseizures["subject"][i], idKey = patientsWithseizures["idKey"][i], username = USERNAME, password = PASSWORD,
- BIDS =paths.BIDS, dataset ="derivatives/iEEGorgDownload", session = SESSION,
- functionalConnectivityPath = functionalConnectivityPath,
- secondsBefore=180, secondsAfter=180, startKey = "EEC",
- fsds = FREQUENCY_DOWN_SAMPLE, montage = MONTAGE, FCtype = FC_TYPES[fc])
- #%%
- #Combine FC from the above saved calculation, and calculate differences
- summaryStatsLong, FCtissueAll, seizure_number = helper.combine_functional_connectivity_from_all_patients_and_segments(patientsWithseizures, np.array(range(3, N)), metadata_iEEG, MONTAGE, FC_TYPES,
- STATE_NUMBER, FREQUENCY_NAMES, USERNAME, PASSWORD, FREQUENCY_DOWN_SAMPLE,
- paths, SESSION, params.TISSUE_DEFINITION_PERCENT[0], params.TISSUE_DEFINITION_PERCENT[1], params.TISSUE_DEFINITION_PERCENT[2])
- patient_outcomes_good = ["RID0238", "RID0267", "RID0279", "RID0294", "RID0307", "RID0309", "RID0320", "RID0365", "RID0440", "RID0424"]
- patient_outcomes_poor = ["RID0274", "RID0278", "RID0371", "RID0382", "RID0405", "RID0442", "RID0322"]
- patients = patient_outcomes_good + patient_outcomes_poor
- summaryStatsLong = helper.add_outcomes_to_summaryStatsLong(summaryStatsLong, patient_outcomes_good, patient_outcomes_poor)
- #%%
- #bootstrap
- medians_list = []
- means_deltaT_list = []
- cores = 12
- iterations = 12
- total = 409
- func = 2
- freq = 7
- for i in range(total):
- simulation = helper.deltaT_multicore_wrapper(cores, iterations, summaryStatsLong,
- FCtissueAll, STATE_NUMBER,seizure_number, FREQUENCY_NAMES,
- FC_TYPES,func ,freq , max_connections = 50)
- medians_list.append([a_tuple[0] for a_tuple in simulation])
- medians = [item for sublist in medians_list for item in sublist]
- means_deltaT_list.append([a_tuple[1] for a_tuple in simulation])
- means_deltaT = [item for sublist in means_deltaT_list for item in sublist]
- if i+1 ==total:
- medians = np.dstack(medians)
- means_deltaT = np.vstack(means_deltaT)
- utils.printProgressBar(i +1 , total)
- len(means_deltaT)
- fig, axes = utils.plot_make(c = STATE_NUMBER, size_length = 12, sharey = True)
- for x in range(STATE_NUMBER):
- data = pd.DataFrame( dict( gm = medians[0, x, :], wm = medians[1, x, :]))
- xlim = [math.floor(data.to_numpy().min() * 1000)/1000 , math.ceil(data.to_numpy().max() * 1000)/1000]
- sns.histplot(data =data, palette = plot.COLORS_TISSUE_LIGHT_MED_DARK[1], kde = True, ax = axes[x], bins = 10, line_kws=dict(linewidth = 8), edgecolor = None)
- #sns.kdeplot(data =data, palette = plot.COLORS_TISSUE_LIGHT_MED_DARK[1], ax = axes[x], linewidth = 10)
- axes[x].set_xlim(xlim)
- #axes[x].set_ylim([0,350])
- print(stats.wilcoxon(data["gm"], data["wm"])[1])
- axes[x].spines['top'].set_visible(False)
- axes[x].spines['right'].set_visible(False)
- pvalue = stats.wilcoxon(data["gm"], data["wm"])[1]
- axes[x].set_title(pvalue)
- #print(stats.mannwhitneyu(data["gm"], data["wm"])[1])
- utils.save_figure(join(paths.FIGURES, "GM_vs_WM",
- f"22boot_ECDF_all_patients_GMvsWM_ECDF2_{MONTAGE}_{params.TISSUE_DEFINITION_PERCENT[0]}_GM_{params.TISSUE_DEFINITION_PERCENT[1]}_WM_{params.TISSUE_DEFINITION_PERCENT[2]}.pdf"),
- save_figure=False)
- data = pd.DataFrame(means_deltaT, columns = STATE_NAMES)
- fig, axes = utils.plot_make()
- sns.histplot(data =data, palette = plot.COLORS_STATE4[1], kde = True, ax = axes, binwidth = 0.001, binrange = [-0.002,0.025],
- line_kws = dict(lw = 2), kde_kws = dict(bw_method = 1), edgecolor = None)
- #sns.kdeplot(data =data, palette = plot.COLORS_STATE4[1], ax = axes, lw = 5)
- data.mean()
- axes.set_xlim([-0.002,0.022])
- axes.spines['top'].set_visible(False)
- axes.spines['right'].set_visible(False)
- axes.set_title(f"{stats.wilcoxon(data['preictal'], data['ictal'])[1]} {stats.ttest_1samp(data['ictal'], 0)[1]}")
- for k in range(len(data.mean())):
- axes.axvline(x=data.mean()[k], color = plot.COLORS_STATE4[1][k], linestyle='--')
- axes.legend([],[], frameon=False)
- utils.save_figure(join(paths.FIGURES, "GM_vs_WM",
- f"22BOOTSTRAP_all_patients_GMvsWM_ECDF2_{MONTAGE}_{params.TISSUE_DEFINITION_PERCENT[0]}_GM_{params.TISSUE_DEFINITION_PERCENT[1]}_WM_{params.TISSUE_DEFINITION_PERCENT[2]}.pdf"),
- save_figure=False)
- FCtissueAll_bootstrap_flatten,_ = helper.FCtissueAll_flatten(FCtissueAll, STATE_NUMBER, func = 2 ,freq = 7, max_connections = 50)
- plot_GMvsWM.plot_FC_all_patients_GMvsWM_ECDF(FCtissueAll_bootstrap_flatten, STATE_NUMBER , plot)
- utils.save_figure(join(paths.FIGURES, "GM_vs_WM",
- f"2ECDF_all_patients_GMvsWM_ECDF2_{MONTAGE}_{params.TISSUE_DEFINITION_PERCENT[0]}_GM_{params.TISSUE_DEFINITION_PERCENT[1]}_WM_{params.TISSUE_DEFINITION_PERCENT[2]}.pdf"),
- save_figure=False)
- plot_GMvsWM.plot_boxplot_single_FC_deltaT(summaryStatsLong, FREQUENCY_NAMES, FC_TYPES, 2, 5, plot)
- utils.save_figure(join(paths.FIGURES, "GM_vs_WM",
- f"boxplot2_single_FC_deltaT_{MONTAGE}_{params.TISSUE_DEFINITION_PERCENT[0]}_GM_{params.TISSUE_DEFINITION_PERCENT[1]}_WM_{params.TISSUE_DEFINITION_PERCENT[2]}.pdf"),
- save_figure=False)
- plot_GMvsWM.plot_boxplot_all_FC_deltaT(summaryStatsLong, FREQUENCY_NAMES, FC_TYPES, plot.COLORS_STATE4[0], plot.COLORS_STATE4[1])
- utils.save_figure(join(paths.FIGURES, "GM_vs_WM",
- f"boxplot2_all_FC_deltaT_Supplement_{MONTAGE}_{params.TISSUE_DEFINITION_PERCENT[0]}_GM_{params.TISSUE_DEFINITION_PERCENT[1]}_WM_{params.TISSUE_DEFINITION_PERCENT[2]}.pdf"),
- save_figure=False)
- #%%
- #% Plot FC distributions for example patient
- #for i in range(3,N):
- i=43
- func = 2
- freq = 7
- state = 2
- sub = patientsWithseizures["subject"][i]
- FC_type = FC_TYPES[func]
- FC, channels, localization, localization_channels, dist, GM_index, WM_index, dist_order, FC_tissue = helper.get_functional_connectivity_and_tissue_subnetworks_for_single_patient(patientsWithseizures,
- i, metadata_iEEG, SESSION, USERNAME, PASSWORD, paths,
- FREQUENCY_DOWN_SAMPLE, MONTAGE, FC_TYPES,
- params.TISSUE_DEFINITION_PERCENT[0], params.TISSUE_DEFINITION_PERCENT[1], params.TISSUE_DEFINITION_PERCENT[2],
- func, freq)
- plot_GMvsWM.plot_FC_example_patient_ADJ(sub, FC, channels, localization, localization_channels, dist, GM_index, WM_index, dist_order, FC_tissue, FC_TYPES, FREQUENCY_NAMES, state ,func, freq, TISSUE_DEFINITION_GM, TISSUE_DEFINITION_WM, plot)
- plot_GMvsWM.plot_FC_example_patient_GMWMall(sub, FC, channels, localization, localization_channels, dist, GM_index, WM_index, dist_order,
- FC_tissue, FC_TYPES, FREQUENCY_NAMES, state ,func, freq, TISSUE_DEFINITION_GM, TISSUE_DEFINITION_WM, plot,
- xlim = [0,0.6])
- utils.save_figure(join(paths.FIGURES, "GM_vs_WM", f"hist_GM_vs_WM_distribution_of_FC_GMWM_{sub}_{FC_type}_{FREQUENCY_NAMES[freq]}.pdf"), save_figure=SAVE_FIGURES)
- plot_GMvsWM.plot_FC_example_patient_GMvsWM(sub, FC, channels, localization, localization_channels, dist, GM_index, WM_index, dist_order,
- FC_tissue, FC_TYPES, FREQUENCY_NAMES, state ,func, freq, TISSUE_DEFINITION_GM, TISSUE_DEFINITION_WM, plot,
- xlim = [0,0.6])
- utils.save_figure(join(paths.FIGURES, "GM_vs_WM", f"hist_GM_vs_WM_distribution_of_FC_GMvsWM_{sub}_{FC_type}_{FREQUENCY_NAMES[freq]}.pdf"), save_figure=SAVE_FIGURES)
- plot_GMvsWM.plot_FC_example_patient_GMvsWM_ECDF(sub, FC, channels, localization, localization_channels, dist, GM_index, WM_index, dist_order, FC_tissue, FC_TYPES, FREQUENCY_NAMES, state ,func, freq, TISSUE_DEFINITION_GM, TISSUE_DEFINITION_WM, plot)
- utils.save_figure(join(paths.FIGURES, "GM_vs_WM", f"ECDF_GM_vs_WM_distribution_of_FC_GMvsWM_{sub}_{FC_type}_{FREQUENCY_NAMES[freq]}.pdf"), save_figure=SAVE_FIGURES)
- #GM-to-WM connections
- plot_GMvsWM.plot_FC_example_patient_GMWM(sub, FC, channels, localization, localization_channels, dist, GM_index, WM_index, dist_order,
- FC_tissue, FC_TYPES, FREQUENCY_NAMES, state ,func, freq, TISSUE_DEFINITION_GM, TISSUE_DEFINITION_WM, plot,
- xlim = [0,0.6])
- utils.save_figure(join(paths.FIGURES, "GM_vs_WM", f"hist_GM_to_WM_distribution_of_FC_GMWM_{sub}_{FC_type}_{FREQUENCY_NAMES[freq]}.pdf"), save_figure=SAVE_FIGURES)
- plot_GMvsWM.plot_FC_example_patient_GMWM_ECDF(sub, FC, channels, localization, localization_channels, dist, GM_index, WM_index, dist_order, FC_tissue, FC_TYPES, FREQUENCY_NAMES, state ,func, freq, TISSUE_DEFINITION_GM, TISSUE_DEFINITION_WM, plot)
- utils.save_figure(join(paths.FIGURES, "GM_vs_WM", f"ECDF_GM_to_WM_distribution_of_FC_GMvsWM_{sub}_{FC_type}_{FREQUENCY_NAMES[freq]}.pdf"), save_figure=SAVE_FIGURES)
- #%% Calculate FC as a function of purity
- save_directory = join(paths.DATA, "GMvsWM")
- func = 2; freq = 0; state = 2
- ## WM definition = distance
- summaryStats_Wm_FC = helper.get_FC_vs_tissue_definition(save_directory, patientsWithseizures, range(3,5), MONTAGE, params.TISSUE_DEFINITION_DISTANCE,
- 0, FC_TYPES, FREQUENCY_NAMES, metadata_iEEG, SESSION, USERNAME, PASSWORD, paths, FREQUENCY_DOWN_SAMPLE, save_pickle = False , recalculate = False)
- summaryStats_Wm_FC_bootstrap_func_freq_long_state, result_lin = helper.bootstrap_FC_vs_WM_cutoff_summaryStats_Wm_FC(iterations, summaryStats_Wm_FC, FC_TYPES, FREQUENCY_NAMES, STATE_NAMES, func, freq, state, print_results = True)
- plot_GMvsWM.plot_FC_vs_contact_distance(summaryStats_Wm_FC_bootstrap_func_freq_long_state)
- plot_GMvsWM.plot_FC_vs_WM_cutoff(summaryStats_Wm_FC_bootstrap_func_freq_long_state)
- ## WM definition = percent
- summaryStats_Wm_FC = helper.get_FC_vs_tissue_definition(save_directory, patientsWithseizures, range(3,5), MONTAGE, params.TISSUE_DEFINITION_PERCENT,
- 1, FC_TYPES, FREQUENCY_NAMES, metadata_iEEG, SESSION, USERNAME, PASSWORD, paths, FREQUENCY_DOWN_SAMPLE, save_pickle = False , recalculate = False)
- summaryStats_Wm_FC_bootstrap_func_freq_long_state, result_lin = helper.bootstrap_FC_vs_WM_cutoff_summaryStats_Wm_FC(iterations, summaryStats_Wm_FC, FC_TYPES, FREQUENCY_NAMES, STATE_NAMES, func, freq, state, print_results = True)
- plot_GMvsWM.plot_FC_vs_contact_distance(summaryStats_Wm_FC_bootstrap_func_freq_long_state,xlim = [15,80] ,ylim = [0.02,0.2])
- plot_GMvsWM.plot_FC_vs_WM_cutoff(summaryStats_Wm_FC_bootstrap_func_freq_long_state)
- #%%
- ##################################################################
- ##################################################################
- ##################################################################
- ##################################################################
- ##################################################################
- #Structure-function Analysis
- #%% DWI correction and tractography
- #get patients in patientsWithseizures that have dti
- sfc_patient_list = tractography.get_patients_with_dwi(np.unique(patientsWithseizures["subject"]), paths, dataset = "PIER", SESSION_RESEARCH3T = SESSION_RESEARCH3T)
- cmd = tractography.print_dwi_image_correction_QSIprep(sfc_patient_list, paths, dataset = "PIER")
- tractography.get_tracts_loop_through_patient_list(sfc_patient_list, paths, SESSION_RESEARCH3T = SESSION_RESEARCH3T)
- tractography.get_tracts_loop_through_patient_list(['RID0682'], paths, SESSION_RESEARCH3T = SESSION_RESEARCH3T)
- make_spherical_regions.make_spherical_regions(sfc_patient_list, SESSION, paths, radius = 7, rerun = False, show_slices = False)
- #%%
- #Analyzing SFC
- means_list = []
- means_delta_corr_list = []
- cores = 24
- iterations = 24
- total = 416
- func = 2
- freq = 7
- for i in range(total):
- utils.printProgressBar(i, total)
- simulation = helper.multicore_sfc_wrapper(cores,iterations, params.TISSUE_TYPE_NAMES2, STATE_NUMBER, patientsWithseizures, sfc_patient_list, paths,
- FC_TYPES, STATE_NAMES, FREQUENCY_NAMES, metadata_iEEG, SESSION, USERNAME, PASSWORD,FREQUENCY_DOWN_SAMPLE, MONTAGE,
- params.TISSUE_DEFINITION_PERCENT[0], params.TISSUE_DEFINITION_PERCENT[1], params.TISSUE_DEFINITION_PERCENT[2],
- ratio_patients = 5, max_seizures = 1,
- func = 2, freq = 0, print_pvalues = False )
- means_list.append([a_tuple[0] for a_tuple in simulation])
- means = [item for sublist in means_list for item in sublist]
- means_delta_corr_list.append([a_tuple[1] for a_tuple in simulation])
- means_delta_corr = [item for sublist in means_delta_corr_list for item in sublist]
- utils.printProgressBar(i+1, total)
- if i+1 == total:
- means = np.dstack(means)
- means_delta_corr = np.vstack(means_delta_corr)
- cols = pd.MultiIndex.from_product([ params.TISSUE_TYPE_NAMES2, STATE_NAMES])
- means_df = pd.DataFrame(columns = ["tissue", "state", "SFC"])
- for t in range(len(params.TISSUE_TYPE_NAMES)):
- df_tissue = pd.DataFrame(means[:,t,:].T, columns = STATE_NAMES)
- df_tissue = pd.melt(df_tissue, var_name = ["state"], value_name = "SFC")
- df_tissue["tissue"] = params.TISSUE_TYPE_NAMES2[t]
- means_df = pd.concat([means_df, df_tissue])
- wm_preictal = means_df.query('tissue == "WM" and state == "preictal"')["SFC"]
- wm_ictal = means_df.query('tissue == "WM" and state == "ictal"')["SFC"]
- stats.ttest_rel(means_df.query('tissue == "WM" and state == "ictal"')["SFC"] ,means_df.query('tissue == "WM" and state == "preictal"')["SFC"])[1]
- print(stats.wilcoxon(wm_preictal, wm_ictal)[1])
- print(stats.mannwhitneyu(wm_preictal, wm_ictal)[1])
- palette_long = ["#808080", "#808080", "#282828", "#808080"] + ["#a08269", "#a08269", "#675241", "#a08269"] + ["#8a6ca1", "#8a6ca1", "#511e79", "#8a6ca1"]+ ["#76afdf", "#76afdf", "#1f5785", "#76afdf"]
- palette = ["#bbbbbb", "#bbbbbb", "#282828", "#bbbbbb"] + ["#cebeb1", "#cebeb1", "#675241", "#cebeb1"] + ["#cdc0d7", "#cdc0d7", "#511e79", "#cdc0d7"] + ["#b6d4ee", "#b6d4ee", "#1f5785", "#b6d4ee"]
- fig, axes = utils.plot_make()
- sns.boxplot(data = means_df , x = "tissue", y = "SFC", hue = "state", ax = axes, showfliers=False, order = ["Full Network", "GM", "GM-WM", "WM"])
- plt.setp(axes.lines, zorder=100); plt.setp(axes.collections, zorder=100, label="")
- #sns.stripplot(data= means_df, x = "tissue", y = "SFC", hue = "state", dodge=True, color = "#444444", ax = axes,s = 1, order = ["Full Network", "GM", "GM-WM", "WM"])
- axes.spines['top'].set_visible(False)
- axes.spines['right'].set_visible(False)
- axes.legend([],[], frameon=False)
- for a in range(len( axes.artists)):
- mybox = axes.artists[a]
- # Change the appearance of that box
- mybox.set_facecolor(palette[a])
- mybox.set_edgecolor(palette[a])
- #mybox.set_linewidth(3)
- count = 0
- a = 0
- for line in axes.get_lines():
- line.set_color(palette[a])
- count = count + 1
- if count % 5 ==0:
- a = a +1
- if count % 5 ==0: #set mean line
- line.set_color("#222222")
- #line.set_ls("-")
- #line.set_lw(2.5)
- axes.spines['top'].set_visible(False)
- axes.spines['right'].set_visible(False)
- utils.save_figure(join(paths.FIGURES, "GM_vs_WM", f"2SFC_bootstrap_10000.pdf"), save_figure=True)
- confidence_intervals = pd.DataFrame(columns = ["tissue", "state", "ci_lower", "ci_upper"])
- for t in range(len(params.TISSUE_TYPE_NAMES)):
- for s in range(len(STATE_NAMES)):
- df_ci = means_df.query(f'tissue == "{params.TISSUE_TYPE_NAMES2[t]}" and state == "{STATE_NAMES[s]}"')["SFC"]
- ci = stats.t.interval(alpha=0.95, df=len(df_ci)-1, loc=np.mean(df_ci), scale=stats.sem(df_ci))
- confidence_intervals = confidence_intervals.append(dict(tissue = params.TISSUE_TYPE_NAMES[t], state = STATE_NAMES[s], ci_lower = ci[0], ci_upper = ci[1] ),ignore_index=True)
- palette2 = ["#bbbbbb" , "#cebeb1" , "#b6d4ee", "#cdc0d7"]
- palette3 = ["#808080" , "#a08269" , "#76afdf", "#8a6ca1"]
- #reorder for plotting
- df = pd.DataFrame(means_delta_corr, columns =params.TISSUE_TYPE_NAMES )
- order = [params.TISSUE_TYPE_NAMES[i] for i in [3,1,2,0]]
- df = df[order]
- palette2_reorder = [palette2[i] for i in [3,1,2,0]]
- palette3_reorder = [palette3[i] for i in [0,2,1,3]] #idk why but seaborn and python are so stupid in their plotting. Makes no sense.
- fig, axes = utils.plot_make()
- sns.histplot(data = df, palette = palette2_reorder, ax = axes, binwidth = 0.01 , line_kws = dict(lw = 5), alpha=1 , edgecolor=None, kde = True)
- #sns.kdeplot(data = df, palette = palette3_reorder, ax = axes , lw = 5, bw_method = 0.1)
- axes.set_xlim([-0.025, 0.14])
- axes.spines['top'].set_visible(False)
- axes.spines['right'].set_visible(False)
- axes.legend([],[], frameon=False)
- for l in range(len(axes.lines)):
- axes.lines[l].set_color(palette3_reorder[l])
- utils.save_figure(join(paths.FIGURES, "GM_vs_WM", f"2SFC_bootstrap_delta_histogram_10000bootstrap.pdf"), save_figure=False)
- stats.t.interval(alpha=0.95, df=len(df)-1, loc=np.mean(df), scale=stats.sem(df))
- #%%#%%
- df_long, delta_corr = helper.get_tissue_SFC(patientsWithseizures, sfc_patient_list, paths,
- FC_TYPES, STATE_NAMES, FREQUENCY_NAMES, metadata_iEEG, SESSION, USERNAME, PASSWORD,FREQUENCY_DOWN_SAMPLE, MONTAGE,
- params.TISSUE_DEFINITION_PERCENT[0], params.TISSUE_DEFINITION_PERCENT[1], params.TISSUE_DEFINITION_PERCENT[2],
- ratio_patients = 5, max_seizures = 1,
- func = 2, freq = 0, print_pvalues = True)
- palette = ["#bbbbbb", "#808080", "#282828", "#808080"] + ["#cebeb1", "#a08269", "#675241", "#a08269"] + ["#cdc0d7", "#8a6ca1", "#511e79", "#8a6ca1"] + ["#b6d4ee", "#76afdf", "#1f5785", "#76afdf"]
- palette = ["#bbbbbb", "#bbbbbb", "#282828", "#bbbbbb"] + ["#cebeb1", "#cebeb1", "#675241", "#cebeb1"] + ["#cdc0d7", "#cdc0d7", "#511e79", "#cdc0d7"] + ["#b6d4ee", "#b6d4ee", "#1f5785", "#b6d4ee"]
- palette2 = ["#808080", "#808080", "#282828", "#808080"] + ["#a08269", "#a08269", "#675241", "#a08269"] + ["#8a6ca1", "#8a6ca1", "#511e79", "#8a6ca1"]+ ["#76afdf", "#76afdf", "#1f5785", "#76afdf"]
- #%%
- fig, axes = utils.plot_make(size_length = 5, size_height = 4)
- meanprops={"marker":"o", "markerfacecolor":"white", "markeredgecolor":"black", "markersize":"10"}
- sns.boxplot(data = df_long, x = "tissue", y = "FC", hue = "state", ax = axes , whis = 1,showmeans=True , meanline=True)
- axes.legend([],[], frameon=False)
- for a in range(len( axes.artists)):
- mybox = axes.artists[a]
- # Change the appearance of that box
- mybox.set_facecolor(palette[a])
- mybox.set_edgecolor(palette[a])
- #mybox.set_linewidth(3)
- axes.spines['top'].set_visible(False)
- axes.spines['right'].set_visible(False)
- count = 0
- a = 0
- for line in axes.get_lines():
- line.set_color(palette2[a])
- count = count + 1
- if count % 7 ==0:
- a = a +1
- if count % 7 ==5: #set median line
- line.set_color("white")
- line.set_ls("--")
- line.set_lw(1)
- if count % 7 ==6: #set mean line
- line.set_color("#970707")
- line.set_ls("-")
- line.set_lw(2.5)
- utils.save_figure(join(paths.FIGURES, "GM_vs_WM", f"SFC_{FC_type}_{FREQUENCY_NAMES[freq]}.pdf"), save_figure=SAVE_FIGURES, bbox_inches = "tight", pad_inches = 0)
- #%%
- fig, axes = utils.plot_make()
- binrange = [-0.3,0.3]
- binwidth = 0.01
- sns.histplot( delta_corr[:,1], ax = axes , binrange = binrange, binwidth = binwidth, kde = True, color = "red" )
- sns.histplot( delta_corr[:,2], ax = axes , binrange = binrange, binwidth = binwidth , kde = True, color = "blue" )
- sns.histplot( delta_corr[:,3], ax = axes , binrange = binrange, binwidth = binwidth , kde = True, color = "purple" )
- func = 2
- freq = 0
- i=83 #3, 21, 51, 54, 63, 75, 78, 103, 104, 105, 109, 110, 111, 112, 113, 116
- for s in range(STATE_NUMBER):
- SC_order, SC_order_gm, SC_order_wm, SC_order_gmwm, adj, adj_gm, adj_wm, adj_gmwm = helper.get_SC_and_FC_adj(patientsWithseizures,
- i, metadata_iEEG, SESSION, USERNAME, PASSWORD, paths,
- FREQUENCY_DOWN_SAMPLE, MONTAGE, FC_TYPES,
- TISSUE_DEFINITION_NAME,
- TISSUE_DEFINITION_GM,
- 0.5,
- func = func, freq = freq, state = s )
- if s == 0:
- interictal = [SC_order, SC_order_gm, SC_order_wm, SC_order_gmwm, adj, adj_gm, adj_wm, adj_gmwm]
- if s == 1:
- preictal = [SC_order, SC_order_gm, SC_order_wm, SC_order_gmwm, adj, adj_gm, adj_wm, adj_gmwm]
- if s == 2:
- ictal = [SC_order, SC_order_gm, SC_order_wm, SC_order_gmwm, adj, adj_gm, adj_wm, adj_gmwm]
- if s == 3:
- postictal = [SC_order, SC_order_gm, SC_order_wm, SC_order_gmwm, adj, adj_gm, adj_wm, adj_gmwm]
- #109 116, 111 104? 78
- def plot_adj_heatmap(adj, vmin = 0, vmax = 1, center = 0.5, cmap = "mako" ):
- fig, axes = plt.subplots(1, 1, figsize=(4, 4), dpi=300)
- sns.heatmap(adj, vmin = vmin, vmax =vmax, center = center, cmap = cmap , ax = axes, square=True , cbar = False, xticklabels = False, yticklabels = False )
- cmap_structural = sns.cubehelix_palette(start=2.8, rot=-0.1, dark=.2, light=0.95, hue = 1, gamma = 4, reverse=True, as_cmap=True)
- plot_adj_heatmap(SC_order, cmap = cmap_structural, center = 0.5)
- utils.save_figure(join(paths.FIGURES, "GM_vs_WM", f"adj_SC_FULL_{sub}_{FC_type}_{FREQUENCY_NAMES[freq]}.png"), save_figure=SAVE_FIGURES, bbox_inches = "tight", pad_inches = 0)
- plot_adj_heatmap(SC_order_gm, cmap = cmap_structural, center = 0.5)
- utils.save_figure(join(paths.FIGURES, "GM_vs_WM", f"adj_SC_GM_{sub}_{FC_type}_{FREQUENCY_NAMES[freq]}.png"), save_figure=SAVE_FIGURES, bbox_inches = "tight", pad_inches = 0)
- plot_adj_heatmap(SC_order_wm, cmap = cmap_structural, center = 0.5)
- utils.save_figure(join(paths.FIGURES, "GM_vs_WM", f"adj_SC_WM_{sub}_{FC_type}_{FREQUENCY_NAMES[freq]}.png"), save_figure=SAVE_FIGURES, bbox_inches = "tight", pad_inches = 0)
- plot_adj_heatmap(SC_order_gmwm, cmap = cmap_structural, center = 0.5)
- utils.save_figure(join(paths.FIGURES, "GM_vs_WM", f"adj_SC_GMWM_{sub}_{FC_type}_{FREQUENCY_NAMES[freq]}.png"), save_figure=SAVE_FIGURES, bbox_inches = "tight", pad_inches = 0)
- pad = 0.015
- cmap_functional = sns.cubehelix_palette(start=0.7, rot=-0.1, dark=0, light=0.95, hue = 0.8, gamma = 0.8, reverse=True, as_cmap=True)
- t = 4
- plot_adj_heatmap(interictal[t], cmap = cmap_functional, center = 0.5)
- utils.save_figure(join(paths.FIGURES, "GM_vs_WM", f"adj_FC_0_FULL_{sub}_{FC_type}_{FREQUENCY_NAMES[freq]}.png"), save_figure=SAVE_FIGURES, bbox_inches = "tight", pad_inches = pad)
- plot_adj_heatmap(preictal[t], cmap = cmap_functional, center = 0.5)
- utils.save_figure(join(paths.FIGURES, "GM_vs_WM", f"adj_FC_1_FULL_{sub}_{FC_type}_{FREQUENCY_NAMES[freq]}.png"), save_figure=SAVE_FIGURES, bbox_inches = "tight", pad_inches = pad)
- plot_adj_heatmap(ictal[t], cmap = cmap_functional, center = 0.5)
- utils.save_figure(join(paths.FIGURES, "GM_vs_WM", f"adj_FC_2_FULL_{sub}_{FC_type}_{FREQUENCY_NAMES[freq]}.png"), save_figure=SAVE_FIGURES, bbox_inches = "tight", pad_inches = pad)
- plot_adj_heatmap(postictal[t], cmap = cmap_functional, center = 0.5)
- utils.save_figure(join(paths.FIGURES, "GM_vs_WM", f"adj_FC_3_FULL_{sub}_{FC_type}_{FREQUENCY_NAMES[freq]}.png"), save_figure=SAVE_FIGURES, bbox_inches = "tight", pad_inches = pad)
- t = 5
- plot_adj_heatmap(interictal[t], cmap = cmap_functional, center = 0.5)
- utils.save_figure(join(paths.FIGURES, "GM_vs_WM", f"adj_FC_0_GM_{sub}_{FC_type}_{FREQUENCY_NAMES[freq]}.png"), save_figure=SAVE_FIGURES, bbox_inches = "tight", pad_inches = pad)
- plot_adj_heatmap(preictal[t], cmap = cmap_functional, center = 0.5)
- utils.save_figure(join(paths.FIGURES, "GM_vs_WM", f"adj_FC_1_GM_{sub}_{FC_type}_{FREQUENCY_NAMES[freq]}.png"), save_figure=SAVE_FIGURES, bbox_inches = "tight", pad_inches = pad)
- plot_adj_heatmap(ictal[t], cmap = cmap_functional, center = 0.5)
- utils.save_figure(join(paths.FIGURES, "GM_vs_WM", f"adj_FC_2_GM_{sub}_{FC_type}_{FREQUENCY_NAMES[freq]}.png"), save_figure=SAVE_FIGURES, bbox_inches = "tight", pad_inches = pad)
- plot_adj_heatmap(postictal[t], cmap = cmap_functional, center = 0.5)
- utils.save_figure(join(paths.FIGURES, "GM_vs_WM", f"adj_FC_3_GM_{sub}_{FC_type}_{FREQUENCY_NAMES[freq]}.png"), save_figure=SAVE_FIGURES, bbox_inches = "tight", pad_inches = pad)
- t = 6
- plot_adj_heatmap(interictal[t], cmap = cmap_functional, center = 0.5)
- utils.save_figure(join(paths.FIGURES, "GM_vs_WM", f"adj_FC_0_WM_{sub}_{FC_type}_{FREQUENCY_NAMES[freq]}.png"), save_figure=SAVE_FIGURES, bbox_inches = "tight", pad_inches = pad)
- plot_adj_heatmap(preictal[t], cmap = cmap_functional, center = 0.5)
- utils.save_figure(join(paths.FIGURES, "GM_vs_WM", f"adj_FC_1_WM_{sub}_{FC_type}_{FREQUENCY_NAMES[freq]}.png"), save_figure=SAVE_FIGURES, bbox_inches = "tight", pad_inches = pad)
- plot_adj_heatmap(ictal[t], cmap = cmap_functional, center = 0.5)
- utils.save_figure(join(paths.FIGURES, "GM_vs_WM", f"adj_FC_2_WM_{sub}_{FC_type}_{FREQUENCY_NAMES[freq]}.png"), save_figure=SAVE_FIGURES, bbox_inches = "tight", pad_inches = pad)
- plot_adj_heatmap(postictal[t], cmap = cmap_functional, center = 0.5)
- utils.save_figure(join(paths.FIGURES, "GM_vs_WM", f"adj_FC_3_WM_{sub}_{FC_type}_{FREQUENCY_NAMES[freq]}.png"), save_figure=SAVE_FIGURES, bbox_inches = "tight", pad_inches = pad)
- t = 7
- plot_adj_heatmap(interictal[t], cmap = cmap_functional, center = 0.5)
- utils.save_figure(join(paths.FIGURES, "GM_vs_WM", f"adj_FC_0_GMWM_{sub}_{FC_type}_{FREQUENCY_NAMES[freq]}.png"), save_figure=SAVE_FIGURES, bbox_inches = "tight", pad_inches = pad)
- plot_adj_heatmap(preictal[t], cmap = cmap_functional, center = 0.5)
- utils.save_figure(join(paths.FIGURES, "GM_vs_WM", f"adj_FC_1_GMWM_{sub}_{FC_type}_{FREQUENCY_NAMES[freq]}.png"), save_figure=SAVE_FIGURES, bbox_inches = "tight", pad_inches = pad)
- plot_adj_heatmap(ictal[t], cmap = cmap_functional, center = 0.5)
- utils.save_figure(join(paths.FIGURES, "GM_vs_WM", f"adj_FC_2_GMWM_{sub}_{FC_type}_{FREQUENCY_NAMES[freq]}.png"), save_figure=SAVE_FIGURES, bbox_inches = "tight", pad_inches = pad)
- plot_adj_heatmap(postictal[t], cmap = cmap_functional, center = 0.5)
- utils.save_figure(join(paths.FIGURES, "GM_vs_WM", f"adj_FC_3_GMWM_{sub}_{FC_type}_{FREQUENCY_NAMES[freq]}.png"), save_figure=SAVE_FIGURES, bbox_inches = "tight", pad_inches = pad)
- from sklearn import linear_model
- reg = linear_model.TweedieRegressor(power=1, alpha=0)
- #reg = linear_model.LinearRegression()
- states_SFC = [interictal, preictal, ictal, postictal]
- fig, axes = utils.plot_make(c =STATE_NUMBER, size_length = 16, size_height = 3, sharey = True)
- for s in range(STATE_NUMBER):
- matrix = states_SFC[s]
- x = utils.getUpperTriangle(SC_order)
- y = utils.getUpperTriangle(matrix[4])
- reg.fit(x.reshape(-1, 1), y)
- y_predict = reg.predict(x.reshape(-1, 1))
- sns.lineplot(x = x[1::10], y = y_predict[1::10], ax= axes[s], color = plot.COLORS_STATE4[1][s], lw = 5, alpha = 0.7);
- sns.scatterplot(x = x[1::2], y = y[1::2], ax= axes[s], s = 5, color = plot.COLORS_STATE4[1][s], linewidth=0, alpha = 0.3)
- axes[s].title.set_text( np.round( spearmanr(utils.getUpperTriangle(SC_order), utils.getUpperTriangle(matrix[4]))[0],2) )
- axes[s].set_ylim([0,1])
- axes[s].spines['top'].set_visible(False)
- axes[s].spines['right'].set_visible(False)
- utils.save_figure(join(paths.FIGURES, "GM_vs_WM", f"GLM_SFC_{sub}_{FC_type}_{FREQUENCY_NAMES[freq]}.pdf"), save_figure=SAVE_FIGURES, bbox_inches = "tight", pad_inches = pad)
- #%%
- #analysis of determining how good vs poor outcome have diff GM-GM activity
- patient_outcomes_good = ["RID0238", "RID0267", "RID0279", "RID0294", "RID0307", "RID0309", "RID0320", "RID0365", "RID0440", "RID0424"]
- patient_outcomes_poor = ["RID0274", "RID0278", "RID0371", "RID0382", "RID0405", "RID0442", "RID0322"]
- original_array_list = []
- test_statistic_array_list = []
- ratio_patients = 5
- cores = 12
- iterations = 12
- total = 200
- max_seizures= 2
- func = 2
- freq = 7
- for i in range(total):
- simulation = helper.mutilcore_permute_wrapper(cores, iterations, summaryStatsLong, FCtissueAll, seizure_number,
- patient_outcomes_good, patient_outcomes_poor,
- FC_TYPES, FREQUENCY_NAMES, STATE_NAMES,
- ratio_patients = ratio_patients, max_seizures = max_seizures, func = func, freq = freq)
- original_array_list.append([a_tuple[0] for a_tuple in simulation])
- original_array = [item for sublist in original_array_list for item in sublist]
- test_statistic_array_list.append([a_tuple[1] for a_tuple in simulation])
- test_statistic_array = [item for sublist in test_statistic_array_list for item in sublist]
- Tstat = np.array(original_array)
- permute = np.array(test_statistic_array)
- pvalue = len( np.where(permute >= Tstat.mean()) [0]) / len(Tstat)
- print(f"{i}/{total}: {pvalue}")
- is_abs = 0
- Tstat = np.array(original_array)
- permute = np.array(test_statistic_array)
- binrange = [ np.floor(np.min([Tstat, permute]) ), np.ceil(np.max([Tstat, permute]) ) ]
- if is_abs == 1:
- Tstat = abs(Tstat)
- permute = abs(permute)
- binrange = [0, 3]
- binwidth = 0.1
- fig, axes = utils.plot_make()
- sns.histplot(Tstat, kde = True, ax = axes, color = "#222222", binwidth = binwidth, binrange = binrange, edgecolor = None)
- sns.histplot(permute, kde = True, ax = axes, color = "#bbbbbb", binwidth = binwidth, binrange = binrange ,edgecolor = None)
- axes.axvline(x=abs(Tstat).mean(), color='k', linestyle='--')
- axes.set_xlim(binrange)
- axes.spines['top'].set_visible(False)
- axes.spines['right'].set_visible(False)
- pvalue = len( np.where(permute >= Tstat.mean()) [0]) / len(Tstat)
- axes.set_title(f"{Tstat.mean()} {pvalue}" )
- utils.save_figure(join(paths.FIGURES, "GM_vs_WM", f"good_vs_poor_FC_deltaT_PVALUES_PERMUTATION_morePatients3.pdf"), save_figure=False,
- bbox_inches = "tight", pad_inches = 0.1)
- ###############################################################
- ###############################################################
- ###############################################################
- ###############################################################
- original,summaryStatsLong_bootstrap_outcome = permute_resampling_pvalues(summaryStatsLong, patient_outcomes_good, patient_outcomes_poor, ratio_patients = ratio_patients, max_seizures = max_seizures)
- fig, axes = utils.plot_make(size_length = 4, size_height = 4)
- sns.boxplot(data = summaryStatsLong_bootstrap_outcome, x = "state", y = "FC_deltaT", hue = "outcome", ax = axes,showfliers=False , palette = plot.COLORS_GOOD_VS_POOR)
- sns.stripplot(data = summaryStatsLong_bootstrap_outcome, x = "state", y = "FC_deltaT", hue = "outcome", ax = axes, palette = plot.COLORS_GOOD_VS_POOR,
- dodge=True, size=3)
- axes.legend([],[], frameon=False)
- axes.spines['top'].set_visible(False)
- axes.spines['right'].set_visible(False)
- s = 2
- v1 = summaryStatsLong_bootstrap_outcome[(summaryStatsLong_bootstrap_outcome["state"]==STATE_NAMES[s])&(summaryStatsLong_bootstrap_outcome["outcome"]<="good")].dropna()["FC_deltaT"]
- v2 = summaryStatsLong_bootstrap_outcome[(summaryStatsLong_bootstrap_outcome["state"]==STATE_NAMES[s])&(summaryStatsLong_bootstrap_outcome["outcome"]<="poor")].dropna()["FC_deltaT"]
- stats.mannwhitneyu(v1, v2)[1]
- axes.set_title(f" {stats.mannwhitneyu(v1, v2)[1] }" )
- #axes.set_title(f" {stats.ttest_ind(v1, v2, equal_var=False)[1] }" )
- print(f" {stats.ttest_ind(v1, v2, equal_var=True)[1] }" )
- utils.save_figure(join(paths.FIGURES, "GM_vs_WM", f"good_vs_poor_FC_deltaT_morePatient2.pdf"), save_figure=False,
- bbox_inches = "tight", pad_inches = 0.1)
- ######################################################
- ######################################################
- ######################################################
- FCtissueAll_bootstrap_outcomes = [FCtissueAll_bootstrap_good, FCtissueAll_bootstrap_poor]
- tissue_distribution = [None] * 2
- for o in range(2):
- tissue_distribution[o] = [None] * 4
- for t in range(4):
- tissue_distribution[o][t] = [None] * 4
- OUTCOME_NAMES = ["good", "poor"]
- TISSUE_TYPE_NAMES = ["Full Network", "GM-only", "WM-only", "GM-WM"]
- for o in range(2):
- for t in range(4):
- for s in range(4):
- FCtissueAll_bootstrap_outcomes_single = FCtissueAll_bootstrap_outcomes[o]
- fc_patient = []
- for i in range(len(FCtissueAll_bootstrap_outcomes_single)):
- fc = utils.getUpperTriangle(FCtissueAll_bootstrap_outcomes_single[i][func][freq][t][s])
- fc_patient.append(fc)
- tissue_distribution[o][t][s] = np.array([item for sublist in fc_patient for item in sublist])
- ######################################################
- ######################################################
- ######################################################
- for s in [1,2]:
- fig, axes = utils.plot_make(c = 2, r = 2, size_height = 5)
- axes = axes.flatten()
- for t in range(4):
- sns.ecdfplot(data = tissue_distribution[0][t][s], ax = axes[t], color = plot.COLORS_GOOD_VS_POOR[0], lw = 6)
- sns.ecdfplot(data = tissue_distribution[1][t][s], ax = axes[t], color = plot.COLORS_GOOD_VS_POOR[1], lw = 6, ls = "-")
- axes[t].set_title(f"{TISSUE_TYPE_NAMES[t]}, {STATE_NAMES[s]} {stats.ks_2samp( tissue_distribution[0][t][s], tissue_distribution[1][t][s] )[1]*16 }" )
- axes[t].spines['top'].set_visible(False)
- axes[t].spines['right'].set_visible(False)
- utils.save_figure(join(paths.FIGURES, "GM_vs_WM", f"good_vs_poor_{STATE_NAMES[s]}.pdf"), save_figure=False,
- bbox_inches = "tight", pad_inches = 0.0)
- #good vs poor -- delta
- fig, axes = utils.plot_make()
- sns.ecdfplot(data = tissue_distribution[0][t][2] - tissue_distribution[0][t][1], ax = axes, color = "blue")
- sns.ecdfplot(data = tissue_distribution[1][t][2] - tissue_distribution[1][t][1], ax = axes, color = "red")
- #good vs poor -- ictal
- stats.ks_2samp( tissue_distribution[0][t][2], tissue_distribution[1][t][2])
- #good vs poor -- preictal
- stats.ks_2samp( tissue_distribution[0][t][1], tissue_distribution[0][t][1])
- #good vs poor -- delta
- stats.ks_2samp( tissue_distribution[0][t][2] - tissue_distribution[0][t][1], tissue_distribution[1][t][2] - tissue_distribution[1][t][1] )
- t = 1
- outcomes_good_tissue_preictal = []
- outcomes_good_tissue_ictal = []
- for i in range(len(FCtissueAll_bootstrap_good)):
- outcomes_good_tissue_preictal.append(utils.getUpperTriangle(FCtissueAll_bootstrap_good[i][func][freq][t][1]))
- outcomes_good_tissue_ictal.append( utils.getUpperTriangle(FCtissueAll_bootstrap_good[i][func][freq][t][2]))
- outcomes_good_tissue_preictal = np.array([item for sublist in outcomes_good_tissue_preictal for item in sublist])
- outcomes_good_tissue_ictal = np.array([item for sublist in outcomes_good_tissue_ictal for item in sublist])
- outcomes_poor_tissue_preictal = []
- outcomes_poor_tissue_ictal = []
- for i in range(len(FCtissueAll_bootstrap_poor)):
- outcomes_poor_tissue_preictal.append( utils.getUpperTriangle(FCtissueAll_bootstrap_poor[i][func][freq][t][1]))
- outcomes_poor_tissue_ictal.append( utils.getUpperTriangle(FCtissueAll_bootstrap_poor[i][func][freq][t][2]))
- outcomes_poor_tissue_preictal = np.array([item for sublist in outcomes_poor_tissue_preictal for item in sublist])
- outcomes_poor_tissue_ictal = np.array([item for sublist in outcomes_poor_tissue_ictal for item in sublist])
- fig, axes = utils.plot_make()
- sns.ecdfplot(data = outcomes_good_tissue_ictal, ax = axes, color = "blue")
- sns.ecdfplot(data = outcomes_poor_tissue_ictal, ax = axes, color = "red")
- fig, axes = utils.plot_make()
- sns.ecdfplot(data = outcomes_good_tissue_ictal - outcomes_good_tissue_preictal, ax = axes, color = "blue")
- sns.ecdfplot(data = outcomes_poor_tissue_ictal - outcomes_poor_tissue_preictal, ax = axes, color = "red")
- stats.ks_2samp( outcomes_good_tissue_ictal, outcomes_poor_tissue_ictal)
- stats.ks_2samp( outcomes_good_tissue_preictal, outcomes_poor_tissue_preictal)
- stats.ks_2samp( outcomes_good_tissue_ictal - outcomes_good_tissue_preictal, outcomes_poor_tissue_ictal - outcomes_poor_tissue_preictal)
- fig, axes = utils.plot_make()
- sns.ecdfplot(data = outcomes_good_tissue_preictal, ax = axes, color = "blue")
- sns.ecdfplot(data = outcomes_poor_tissue_preictal, ax = axes, color = "red")
- fig, axes = utils.plot_make()
- sns.ecdfplot(data = outcomes_good_tissue_preictal, ax = axes, color = "blue")
- sns.ecdfplot(data = outcomes_good_tissue_ictal, ax = axes, color = "red")
- #%%
- #patient outcomes good vs poor
- max_seizures=1
- func = 2
- freq = 7
- test_statistic_array_delta_list = []
- test_statistic_array_delta_permutation_list = []
- ratio_patients = 5
- cores = 10
- iterations = 10
- total = 6
- for i in range(total):
- simulation = helper.multicore_wm_good_vs_poor_wrapper(cores, iterations,
- summaryStatsLong, patient_outcomes_good, patient_outcomes_poor,
- patientsWithseizures, metadata_iEEG, SESSION, USERNAME, PASSWORD, paths,
- FREQUENCY_DOWN_SAMPLE, MONTAGE, FC_TYPES, TISSUE_DEFINITION_NAME, TISSUE_DEFINITION_GM, TISSUE_DEFINITION_WM, ratio_patients = ratio_patients, max_seizures = 1, func = 2, freq = 7,
- permute = False, closest_wm_threshold = 85, avg = 0)
- test_statistic_array_delta_list.append([a_tuple[0] for a_tuple in simulation])
- test_statistic_array_delta = [item for sublist in test_statistic_array_delta_list for item in sublist]
- test_statistic_array_delta_permutation_list.append([a_tuple[1] for a_tuple in simulation])
- test_statistic_array_delta_permutation = [item for sublist in test_statistic_array_delta_permutation_list for item in sublist]
- Tstat = np.array(test_statistic_array_delta)
- permute = np.array(test_statistic_array_delta_permutation)
- pvalue = len( np.where(permute >= Tstat.mean()) [0]) / len(Tstat)
- print(f"{i}/{total}: {pvalue}")
- is_abs = 0
- Tstat = np.array(test_statistic_array_delta)
- permute = np.array(test_statistic_array_delta_permutation)
- binrange = [ np.floor(np.min([Tstat, permute]) ), np.ceil(np.max([Tstat, permute]) ) ]
- if is_abs == 1:
- Tstat = abs(Tstat)
- permute = abs(permute)
- binrange = [0, 15]
- binwidth = 1#0.05
- fig, axes = utils.plot_make()
- sns.histplot(Tstat, kde = True, ax = axes, color = "#222222", binwidth = binwidth, binrange = binrange, edgecolor = None)
- sns.histplot(permute, kde = True, ax = axes, color = "#bbbbbb", binwidth = binwidth, binrange = binrange ,edgecolor = None)
- axes.axvline(x=abs(Tstat).mean(), color='k', linestyle='--')
- axes.set_xlim(binrange)
- axes.spines['top'].set_visible(False)
- axes.spines['right'].set_visible(False)
- pvalue = len( np.where(permute >= Tstat.mean()) [0]) / len(Tstat)
- axes.set_title(f"{Tstat.mean()} {pvalue}" )
- utils.save_figure(join(paths.FIGURES, "GM_vs_WM", f"good_vs_poor_PERMUTE_delta_morePatients5_19.pdf"), save_figure=False,
- bbox_inches = "tight", pad_inches = 0.0)
- binwidth = 0.005
- binrange = [-0.5,0.5]
- fig, axes = utils.plot_make()
- sns.histplot(abs(test_statistic_array_ablated), kde = True, ax = axes, color = "#222222", binwidth = binwidth, binrange = binrange)
- sns.histplot(abs(test_statistic_array_ablated_permutation), kde = True, ax = axes, color = "#bbbbbb", binwidth = binwidth, binrange = binrange)
- axes.axvline(x=abs(test_statistic_array_ablated.mean()), color='k', linestyle='--')
- axes.set_xlim([-0,0.3])
- axes.spines['top'].set_visible(False)
- axes.spines['right'].set_visible(False)
- pvalue = len( np.where(test_statistic_array_ablated_permutation <= np.mean(test_statistic_array_ablated ) )[0]) / iterations
- pvalue = len( np.where( abs(test_statistic_array_ablated_permutation ) >= np.mean(abs(test_statistic_array_ablated )) )[0]) / iterations
- axes.set_title(f" {np.mean(abs(test_statistic_array_ablated) )}, {pvalue}" )
- utils.save_figure(join(paths.FIGURES, "GM_vs_WM", f"good_vs_poor_FC_ABLATION_PVALUES_PERMUTATION2.pdf"), save_figure=False,
- bbox_inches = "tight", pad_inches = 0.1)
- #%%
- summaryStatsLong_bootstrap_good, summaryStatsLong_bootstrap_poor, seizure_number_bootstrap_good, seizure_number_bootstrap_poor, delta, gm_to_wm_all_ablated, gm_to_wm_all_ablated_closest_wm, gm_to_wm_all_ablated_closest_wm_gradient = helper.wm_vs_gm_good_vs_poor(summaryStatsLong, patient_outcomes_good, patient_outcomes_poor,
- patientsWithseizures, metadata_iEEG, SESSION, USERNAME, PASSWORD, paths,
- FREQUENCY_DOWN_SAMPLE, MONTAGE, FC_TYPES, TISSUE_DEFINITION_NAME, TISSUE_DEFINITION_GM, TISSUE_DEFINITION_WM,
- ratio_patients = 2, max_seizures = 2, func = func, freq = freq,
- closest_wm_threshold = 85)
- #delta is the change in FC of the ablated contacts to wm
- delta_mean = []
- delta_mean = np.zeros(len(delta))
- for x in range(len(delta)):
- #delta_mean.append(sum(x)/len(x))
- #delta_mean[x] = np.nanmedian(delta[x])
- delta_mean[x] = np.nanmean(delta[x])
- #good = np.concatenate(delta[:7])
- #poor = np.concatenate(delta[8:])
- good = delta[:len(seizure_number_bootstrap_good)]
- poor = delta[len(seizure_number_bootstrap_good):]
- #good = delta_mean[:len(patient_inds_good)]
- #poor = delta_mean[len(patient_inds_good):]
- #df_good = pd.DataFrame(dict(good = good))
- #df_poor = pd.DataFrame(dict(poor = poor))
- good = delta_mean[:len(seizure_number_bootstrap_good)]
- poor = delta_mean[len(seizure_number_bootstrap_good):]
- df_good = pd.DataFrame(dict(good = good))
- df_poor = pd.DataFrame(dict(poor = poor))
- #test_statistic_array2[it] = stats.ttest_ind(good,poor)[0]
- ##################################
- ##################################
- df_patient = pd.concat([pd.melt(df_good), pd.melt(df_poor)] )
- fig, axes = plt.subplots(1, 1, figsize=(4, 4), dpi=300)
- sns.boxplot(data = df_patient, x= "variable", y = "value", ax = axes, palette = plot.COLORS_GOOD_VS_POOR , showfliers = False)
- sns.swarmplot(data = df_patient, x= "variable", y = "value", ax = axes, palette = plot.COLORS_GOOD_VS_POOR,s = 3)
- axes.spines['top'].set_visible(False)
- axes.spines['right'].set_visible(False)
- utils.save_figure(join(paths.FIGURES, "GM_vs_WM", f"good_vs_poor_ABLATION_delta_morePatients3.pdf"), save_figure=False,
- bbox_inches = "tight", pad_inches = 0.0)
- print(stats.mannwhitneyu(poor,good))
- print(stats.ttest_ind(poor,good))
- stats.ttest_ind(good,poor)
- #shows the distributions of all the ablated channels and their connectivity to WM
- difference_gm_to_wm_ablated = []
- for l in range(len(gm_to_wm_all_ablated)):
- difference_gm_to_wm_ablated.append(np.array(gm_to_wm_all_ablated[l][1] )- np.array(gm_to_wm_all_ablated[l][0]))
- difference_gm_to_wm_good_ablated = difference_gm_to_wm_ablated[:len(seizure_number_bootstrap_good)]
- difference_gm_to_wm_poor_ablated = difference_gm_to_wm_ablated[len(seizure_number_bootstrap_good):]
- difference_gm_to_wm_good_ablated = [item for sublist in difference_gm_to_wm_good_ablated for item in sublist]
- difference_gm_to_wm_poor_ablated = [item for sublist in difference_gm_to_wm_poor_ablated for item in sublist]
- fig, axes = utils.plot_make()
- sns.ecdfplot(difference_gm_to_wm_good_ablated, ax = axes, color = plot.COLORS_GOOD_VS_POOR[0], lw = 5)
- sns.ecdfplot(difference_gm_to_wm_poor_ablated, ax = axes, color = plot.COLORS_GOOD_VS_POOR[1], lw = 5)
- axes.set_xlim([-0.1,0.5])
- axes.spines['top'].set_visible(False)
- axes.spines['right'].set_visible(False)
- utils.save_figure(join(paths.FIGURES, "GM_vs_WM", f"good_vs_poor_ABLATION_difference_all_connecions_morePatients3.pdf"), save_figure=False,
- bbox_inches = "tight", pad_inches = 0)
- #Closest gradient
- closest_wm_threshold_gradient = np.arange(15, 125,5 )
- difference_gm_to_wm_ablated_closest_gradient = []
- for l in range(len(gm_to_wm_all_ablated_closest_wm_gradient)):
- grad_tmp = []
- for gr in range(len(closest_wm_threshold_gradient)):
- grad_tmp.append(np.array(gm_to_wm_all_ablated_closest_wm_gradient[l][1][gr] )- np.array(gm_to_wm_all_ablated_closest_wm_gradient[l][0][gr]))
- difference_gm_to_wm_ablated_closest_gradient.append(grad_tmp)
- difference_gm_to_wm_good_ablated_closest_gradient = difference_gm_to_wm_ablated_closest_gradient[:len(seizure_number_bootstrap_good)]
- difference_gm_to_wm_poor_ablated_closest_gradient = difference_gm_to_wm_ablated_closest_gradient[len(seizure_number_bootstrap_good):]
- gradient_good = []
- for gr in range(len(closest_wm_threshold_gradient)):
- grad_tmp = []
- for l in range(len(difference_gm_to_wm_good_ablated_closest_gradient)):
- grad_tmp.append(difference_gm_to_wm_good_ablated_closest_gradient[l][gr])
- gradient_good.append( [item for sublist in grad_tmp for item in sublist])
- gradient_poor = []
- for gr in range(len(closest_wm_threshold_gradient)):
- grad_tmp = []
- for l in range(len(difference_gm_to_wm_poor_ablated_closest_gradient)):
- grad_tmp.append(difference_gm_to_wm_poor_ablated_closest_gradient[l][gr])
- gradient_poor.append( [item for sublist in grad_tmp for item in sublist])
- #[np.nanmean(i) for i in gradient_good]
- #[np.nanmean(i) for i in gradient_poor]
- df_good_gradient = pd.DataFrame(gradient_good).transpose()
- df_poor_gradient = pd.DataFrame(gradient_poor).transpose()
- df_good_gradient.columns = closest_wm_threshold_gradient
- df_poor_gradient.columns = closest_wm_threshold_gradient
- df_good_gradient_long = pd.melt(df_good_gradient, var_name = "distance", value_name = "FC")
- df_poor_gradient_long = pd.melt(df_poor_gradient, var_name = "distance", value_name = "FC")
- #fig, axes = utils.plot_make()
- #sns.regplot(data = df_good_gradient_long, x= "distance", y = "FC", ax = axes, color = "blue", ci=95,x_estimator=np.mean, scatter_kws={"s": 10})
- #sns.regplot(data = df_poor_gradient_long, x= "distance", y = "FC", ax = axes, color = "red", ci=95,x_estimator=np.mean, scatter_kws={"s": 10})
- fig, axes = utils.plot_make(size_length = 10)
- sns.lineplot(data = df_good_gradient_long, x= "distance", y = "FC", ax = axes, color = plot.COLORS_GOOD_VS_POOR[0], ci=None, err_style="bars")
- sns.lineplot(data = df_poor_gradient_long, x= "distance", y = "FC", ax = axes, color = plot.COLORS_GOOD_VS_POOR[1], ci=None, err_style="bars")
- sns.lineplot(data = df_good_gradient_long, x= "distance", y = "FC", ax = axes, color = plot.COLORS_GOOD_VS_POOR[0], ci=95)
- sns.lineplot(data = df_poor_gradient_long, x= "distance", y = "FC", ax = axes, color = plot.COLORS_GOOD_VS_POOR[1], ci=95)
- axes.spines['top'].set_visible(False)
- axes.spines['right'].set_visible(False)
- utils.save_figure(join(paths.FIGURES, "GM_vs_WM", f"good_vs_poor_ABLATION_gradient_morePatient18.pdf"), save_figure=False,
- bbox_inches = "tight", pad_inches = 0)
- #%%
- #REDONE
- pt = 0
- func = 2
- freq = 7
- summaryStatsLong_mean = summaryStatsLong.groupby(by=["patient", 'state', "frequency", "FC_type", "outcome", "seizure_number"]).mean().reset_index()
- summaryStatsLong_outcome = summaryStatsLong_mean.query(f'outcome != "NA" and FC_type == "{FC_TYPES[func]}" and frequency == "{FREQUENCY_NAMES[freq]}" ')
- summaryStatsLong_outcome_seizures_not_combined = copy.deepcopy(summaryStatsLong_outcome)
- summaryStatsLong_outcome = summaryStatsLong_outcome.groupby(by=["patient", 'state', "frequency", "FC_type", "outcome"]).mean().reset_index()
- fig, axes = utils.plot_make( size_length = 4, size_height = 6.5)
- sns.pointplot(data=summaryStatsLong_outcome, x="state", y="FC_deltaT", hue = "outcome",
- ax = axes, palette = plot.COLORS_GOOD_VS_POOR4, order = STATE_NAMES,join=False, dodge=0.4, errwidth = 7,capsize = 0.3, linestyles = ["-","--"], scale = 1.1)
- plt.setp(axes.lines, zorder=100); plt.setp(axes.collections, zorder=100, label="")
- sns.stripplot(data=summaryStatsLong_outcome, x="state", y="FC_deltaT", hue = "outcome", ax = axes, palette = plot.COLORS_GOOD_VS_POOR2, dodge=True,
- size=7, order = STATE_NAMES, zorder=1, jitter = 0.25)
- axes.spines['top'].set_visible(False)
- axes.spines['right'].set_visible(False)
- axes.legend([],[], frameon=False)
- T = helper.compute_T(summaryStatsLong_outcome, group = False, i =0)
- print(T)
- print(p_val := helper.compute_T(summaryStatsLong_outcome, group = False, i =1, alternative = "two-sided"))
- axes.set_title(f" {p_val}" )
- utils.save_figure(join(paths.FIGURES, "GM_vs_WM", f"good_vs_poor_ABLATION_delta_by_seizure.pdf"), save_figure=False,
- bbox_inches = "tight", pad_inches = 0)
- T_star_list = []
- cores = 16
- iterations = 16
- total = 1
- print(iterations*total)
- for i in range(total):
- simulation = helper.mutilcore_permute_deltaT_wrapper(cores, iterations, summaryStatsLong_outcome)
- T_star_list.extend(simulation)
- utils.printProgressBar(i+1, total)
- T_star = np.array(T_star_list)
- binrange = [-8,10]
- binwidth = 0.25
- fig, axes = utils.plot_make()
- axes.axvline(x=T, color='black', linestyle='--', lw = 5)
- sns.histplot(T_star, kde = True, ax = axes, color = "#bbbbbbbb", binwidth = binwidth, binrange = binrange, edgecolor = None, line_kws=dict(linewidth = 10))
- for line in axes.get_lines():
- line.set_color("#333333")
- axes.set_xlim([-3,3])
- print(T_nonabs := len(np.where(T_star > T)[0]) / len(T_star))
- print(T_abs := len(np.where(abs(T_star) > T)[0]) / len(T_star))
- print(len(T_star))
- axes.spines['top'].set_visible(False)
- axes.spines['right'].set_visible(False)
- axes.set_title(f" {T_nonabs}, {T_abs}" )
- utils.save_figure(join(paths.FIGURES, "GM_vs_WM", f"2_good_vs_poor_delta_perm_by_patient.pdf"), save_figure=False,
- bbox_inches = "tight", pad_inches = 0)
- ##############################################
- df = pd.DataFrame(columns = ["iteration", "state", "outcome", "FC_deltaT"])
- cores = 17
- iterations = 17
- total = 1
- for i in range(total):
- simulation = helper.mutilcore_deltaT_wrapper(cores, iterations, summaryStatsLong_outcome)
- df = df.append(simulation)
- utils.printProgressBar(i+1, total)
- df = df.query( f"state == 'ictal'")
- fig, axes = utils.plot_make()
- sns.histplot(data = df, x = "FC_deltaT", hue = "outcome", binrange = [-0.005,0.05], binwidth = 0.001, kde = True, palette = plot.COLORS_GOOD_VS_POOR, line_kws=dict(linewidth = 10), edgecolor = None)
- axes.axvline(x=df.query(f"outcome == 'good' and state == 'ictal' ")["FC_deltaT"].mean(), color='k', linestyle='--')
- axes.axvline(x=df.query(f"outcome == 'poor' and state == 'ictal' ")["FC_deltaT"].mean(), color='k', linestyle='--')
- print(len(df)/2)
- print(helper.compute_T(df, state = "ictal", i = 0, equal_var=True, group = False))
- print(helper.compute_T(df, state = "ictal", i = 1, equal_var=True, group = False))
- axes.spines['top'].set_visible(False)
- axes.spines['right'].set_visible(False)
- axes.legend([],[], frameon=False)
- utils.save_figure(join(paths.FIGURES, "GM_vs_WM", f"2_good_vs_poor_delta_boot_by_patient.pdf"), save_figure=False,
- bbox_inches = "tight", pad_inches = 0)
- #%%
- #ablation
- delta, gm_to_wm_all , gm_to_wm_all_ablated, gm_to_wm_all_ablated_closest_wm, gm_to_wm_all_ablated_closest_wm_gradient= helper.wm_vs_gm_good_vs_poor_redone(summaryStatsLong,
- patientsWithseizures, metadata_iEEG, SESSION, USERNAME, PASSWORD, paths,
- FREQUENCY_DOWN_SAMPLE, MONTAGE, FC_TYPES, TISSUE_DEFINITION_NAME, TISSUE_DEFINITION_GM, TISSUE_DEFINITION_WM , func = 2, freq = 7,
- closest_wm_threshold = 40)
- #get the median ablated-wm connectivity for all ablated channels in a patient, then take the avg of those
- delta_mean = pd.DataFrame(columns = delta.columns)
- for x in range(len(delta)):
- delta_mean = delta_mean.append(copy.deepcopy(delta.iloc[x]))
- chans = delta.iloc[x]["delta"]
- chans_means = np.nanmean(np.nanmedian(chans, axis = 1)) #take median FC values, and then take means of those channels
- delta_mean.loc[ (delta_mean["patient"] == delta_mean.iloc[x]["patient"]) & (delta_mean["seizure_number"] == delta_mean.iloc[x]["seizure_number"] ) , "delta"]= chans_means
- delta_mean.delta = delta_mean.delta.astype(float)
- delta_means_patients = delta_mean.groupby(by=["patient", "outcome"]).mean().reset_index()
- fig, axes = plt.subplots(1, 1, figsize=(4, 4.2), dpi=300)
- sns.pointplot(data = delta_mean, x= "outcome", y = "delta", ax = axes, palette = plot.COLORS_GOOD_VS_POOR4,
- join=False, dodge=0.4, errwidth = 7,capsize = 0.3, linestyles = ["-","--"], scale = 1.3)
- plt.setp(axes.lines, zorder=100); plt.setp(axes.collections, zorder=100, label="")
- sns.stripplot(data = delta_mean, x= "outcome", y = "delta",ax = axes, palette = plot.COLORS_GOOD_VS_POOR2,s = 8, zorder=1, jitter = 0.3)
- axes.spines['top'].set_visible(False)
- axes.spines['right'].set_visible(False)
- pval = helper.compute_T_no_state(delta_mean, group = False, i = 1, var = "delta", alternative = "two-sided")
- axes.set_title(f"{pval}" )
- utils.save_figure(join(paths.FIGURES, "GM_vs_WM", f"2_good_vs_poor_ABLATION_delta_by_patient.pdf"), save_figure=False,
- bbox_inches = "tight", pad_inches = 0.0)
- ###########################3
- good = []
- poor = []
- for x in range(len(gm_to_wm_all_ablated)):
- outcome = gm_to_wm_all_ablated["outcome"][x]
- if outcome == "good":
- good.extend(list(np.array(gm_to_wm_all_ablated["gm_to_wm_all_ablated"][x][1]) - np.array(gm_to_wm_all_ablated["gm_to_wm_all_ablated"][x][0])))
- if outcome == "poor":
- poor.extend(list(np.array(gm_to_wm_all_ablated["gm_to_wm_all_ablated"][x][1]) - np.array(gm_to_wm_all_ablated["gm_to_wm_all_ablated"][x][0])))
- if x+1 == len(gm_to_wm_all_ablated):
- good = np.array(good)
- poor = np.array(poor)
- fig, axes = utils.plot_make()
- sns.ecdfplot(good, ax = axes, color = plot.COLORS_GOOD_VS_POOR[0], lw = 5)
- sns.ecdfplot(poor, ax = axes, color = plot.COLORS_GOOD_VS_POOR[1], lw = 5)
- axes.set_xlim([-0.1,0.8])
- axes.spines['top'].set_visible(False)
- axes.spines['right'].set_visible(False)
- utils.save_figure(join(paths.FIGURES, "GM_vs_WM", f"2_good_vs_poor_ABLATION_difference_all_connecions_morePatients.pdf"), save_figure=False,
- bbox_inches = "tight", pad_inches = 0)
- #% permute delta
- delta_mean
- T = helper.compute_T_no_state(delta_mean, group = True, i = 0, var = "delta")
- print(T)
- print(helper.compute_T_no_state(delta_mean, group = True, i = 1, var = "delta"))
- T_star_list = []
- cores = 16
- iterations = 16
- total = 1
- print(iterations*total)
- for i in range(total):
- simulation = helper.mutilcore_permute_deltaT_wrapper(cores, iterations, delta_mean, state_bool = False, group = True, var = "FC_deltaT")
- T_star_list.extend(simulation)
- utils.printProgressBar(i+1, total)
- T_star = np.array(T_star_list)
- binrange = [-8,10]
- binwidth = 0.25
- fig, axes = utils.plot_make()
- axes.axvline(x=T, color='black', linestyle='--', lw = 5)
- sns.histplot(T_star, kde = True, ax = axes, color = "#bbbbbbbb", binwidth = binwidth, binrange = binrange, edgecolor = None, line_kws=dict(linewidth = 10))
- for line in axes.get_lines():
- line.set_color("#333333")
- axes.set_xlim([-5,6])
- print(T_nonabs := len(np.where(T_star > T)[0]) / len(T_star))
- print(T_abs := len(np.where(abs(T_star) > T)[0]) / len(T_star))
- print(len(T_star))
- axes.spines['top'].set_visible(False)
- axes.spines['right'].set_visible(False)
- axes.set_title(f" {T_nonabs}, {T_abs}" )
- utils.save_figure(join(paths.FIGURES, "GM_vs_WM", f"2_good_vs_poor_ABLATION_perm_by_patient.pdf"), save_figure=False,
- bbox_inches = "tight", pad_inches = 0)
- ##############################################
- #boostrap delta
- df = pd.DataFrame(columns = ["iteration","outcome", "delta"])
- cores = 16
- iterations = 16
- total = 1
- for i in range(total):
- simulation = helper.mutilcore_delta_mean_wrapper(cores, iterations, delta_mean)
- df = df.append(simulation)
- utils.printProgressBar(i+1, total)
- binrange = [-0.005,1]
- binwidth = 0.01
- fig, axes = utils.plot_make()
- sns.histplot(data = df, x = "delta", hue = "outcome", binrange =binrange, binwidth =binwidth, kde = True, palette = plot.COLORS_GOOD_VS_POOR, line_kws=dict(linewidth = 10), edgecolor = None)
- axes.axvline(x=df.query(f"outcome == 'good' ")["delta"].mean(), color='k', linestyle='--')
- axes.axvline(x=df.query(f"outcome == 'poor' ")["delta"].mean(), color='k', linestyle='--')
- axes.set_xlim([-0.0005, 0.25])
- print(len(df)/2)
- print(helper.compute_T_no_state(df, i = 0, equal_var=True, group = False, var = "delta"))
- print(helper.compute_T_no_state(df, i = 1, equal_var=True, group = False, var = "delta"))
- axes.spines['top'].set_visible(False)
- axes.spines['right'].set_visible(False)
- axes.legend([],[], frameon=False)
- utils.save_figure(join(paths.FIGURES, "GM_vs_WM", f"2_good_vs_poor_ABLATION_boot_by_patient.pdf"), save_figure=False,
- bbox_inches = "tight", pad_inches = 0)
- ######################################################
- ######################################################
- ######################################################
- seizure_number_good = summaryStatsLong.query(f"outcome == 'good' ")["seizure_number"].unique()
- seizure_number_poor = summaryStatsLong.query(f"outcome == 'poor' ")["seizure_number"].unique()
- FCtissueAll_ind_good = np.intersect1d(seizure_number_good, seizure_number, return_indices=True )[2]
- FCtissueAll_ind_poor = np.intersect1d(seizure_number_poor, seizure_number, return_indices=True )[2]
- FCtissueAll_good = [FCtissueAll[i] for i in FCtissueAll_ind_good]
- FCtissueAll_poor = [FCtissueAll[i] for i in FCtissueAll_ind_poor]
- FCtissueAll_outcomes = [FCtissueAll_good, FCtissueAll_poor]
- tissue_distribution = [None] * 2
- for o in range(2):
- tissue_distribution[o] = [None] * 4
- for t in range(4):
- tissue_distribution[o][t] = [None] * 4
- OUTCOME_NAMES = ["good", "poor"]
- TISSUE_TYPE_NAMES = ["Full Network", "GM-only", "WM-only", "GM-WM"]
- for o in range(2):
- for t in range(4):
- for s in range(4):
- FCtissueAll_outcomes_single = FCtissueAll_outcomes[o]
- fc_patient = []
- for i in range(len(FCtissueAll_outcomes_single)):
- fc = utils.getUpperTriangle(FCtissueAll_outcomes_single[i][func][freq][t][s])
- fc_patient.append(fc)
- tissue_distribution[o][t][s] = np.array([item for sublist in fc_patient for item in sublist])
- for s in [1,2]:
- fig, axes = utils.plot_make(c = 2, r = 2, size_height = 5)
- axes = axes.flatten()
- for t in range(4):
- sns.ecdfplot(data = tissue_distribution[0][t][s], ax = axes[t], color = plot.COLORS_GOOD_VS_POOR[0], lw = 6)
- sns.ecdfplot(data = tissue_distribution[1][t][s], ax = axes[t], color = plot.COLORS_GOOD_VS_POOR[1], lw = 6, ls = "-")
- axes[t].set_title(f"{TISSUE_TYPE_NAMES[t]}, {STATE_NAMES[s]} {stats.ks_2samp( tissue_distribution[0][t][s], tissue_distribution[1][t][s] )[1]*16 }" )
- axes[t].spines['top'].set_visible(False)
- axes[t].spines['right'].set_visible(False)
- axes[t].set_xlim([0,1])
- utils.save_figure(join(paths.FIGURES, "GM_vs_WM", f"good_vs_poor_{STATE_NAMES[s]}.pdf"), save_figure=False,
- bbox_inches = "tight", pad_inches = 0.0)
- #good vs poor -- delta
REVELL_MDPHD_THESIS_WORK.py at commit 942cd91, no license · at the source
Overview
- Department of Neuroscience, Perelman School of Medicine, University of Pennsylvania, Philadelphia, PA, USA
- Department of Radiology, Brigham and Women's Hospital, Harvard University, Boston, MA, USA
- Center for Neuroengineering and Therapeutics, University of Pennsylvania, Philadelphia, PA, USA
- Department of Bioengineering, School of Engineering and Applied Science, University of Pennsylvania, Philadelphia, PA, USA
- Department of Neurology, Perelman School of Medicine, University of Pennsylvania, Philadelphia, PA, USA
- Department of Neuroscience, The Warren Alpert Medical School, Brown University, Providence, RI, USA
- Department of Radiology, Perelman School of Medicine, University of Pennsylvania, Philadelphia, PA, USA
Abstract
Objective: The focus of epilepsy research has largely been on seizure onset; however, physicians typically examine the patterns of seizure spread past seizure onset as well. This study aims to align automated seizure analysis with clinical practice, leverage deep learning to standardize seizure annotations that varies among physicians, and understand common seizure spread patterns across patients.
Methods: We developed deep learning algorithms on a small subset of patients to detect seizure activity and deployed these algorithms across 275 seizures in 71 patients to analyze the patterns of seizure spread (extent, timing, surgical outcomes, and common patterns) along with incorporating diffusion‐weighted imaging to understand how these patterns relate to the structural connections of the brain.
Results: Deep learning algorithms outperform single features (line length, absolute slope, and power) in ranking seizure onset contacts using physician annotations as a benchmark. We also find that poor outcome patients have more extensive brain regions involved in their seizures while also having more rapid spread between temporal lobes. Incorporating diffusion‐weighted imaging, we find that an increase in structural connectivity between temporal lobes is associated with quicker seizure spread. Finally, we identify clusters of spread patterns common across patients based on spread timing, location, and extent.
Interpretation: Analyzing seizure spread can reveal new insights into seizure evolution and its relationship with surgical outcomes in patients with epilepsy. The findings also suggest that focusing beyond seizure onset is crucial for understanding and treating epilepsy. ANN NEUROL 2026;100:59–73
Reproduced under the paper's license (CC BY-NC), from the paper cited above.
Repositories
Its files are read in the Code ↔ Paper reader above, with 7 matches between paragraphs and lines of code.
andrewyrevell/revellLab
942cd9101906388fe38ea4f4c0373b2f496f3897, 15 July 2022Availability: 1 check, the latest on 28 September 2026: the link answers
- 28 September 2026: the link answers
199 files
- __init__.py, Python, 1 line
- packages/
__init__.py , Python, 1 line - packages/
atlasLocalization/ , Python, 1 line__init__.py - packages/
atlasLocalization/ , Python, 336 linesatlasLocalization.py - packages/
atlasLocalization/ , Python, 924 linesatlasLocalizationFunctio ns.py - packages/
atlasLocalization/ , Python, 564 linesatlasLocalization_DoNotU seDEPRICATED.py - packages/
dataclass/ , Python, 1 line__init__.py - packages/
dataclass/ , Python, 271 linesdataclass_SFC.py - packages/
dataclass/ , Python, 82 linesdataclass_atlases.py - packages/
dataclass/ , Python, 98 linesdataclass_cohorts_brain_ atlas.py - packages/
dataclass/ , Python, 568 lines, 1 matchdataclass_iEEG_metadata. py - packages/
deep_learning_playground , Python, 145 lines.py - packages/
diffusionModels/ , Python, 1 line__init__.py - packages/
diffusionModels/ , Python, 552 linesdiffusionModels.py - packages/
eeg/ , Python, 1 line__init__.py - packages/
eeg/ , Python, 1 lineechobase/ __init__.py - packages/
eeg/ , Python, 1,905 linesechobase/ echobase.py - packages/
eeg/ , Python, 59 linesechobase/ echoimage.py - packages/
eeg/ , Python, 1 lineieegOrg/ __init__.py - packages/
eeg/ , Python, 198 linesieegOrg/ downloadiEEGorg.py - packages/
eeg/ , Python, 1 lineieegOrg/ ieegpy/ __init__.py - packages/
eeg/ , Python, 234 linesieegOrg/ ieegpy/ examples/ annotations.py - packages/
eeg/ , Python, 56 linesieegOrg/ ieegpy/ examples/ dataset_start_time.py - packages/
eeg/ , Python, 51 linesieegOrg/ ieegpy/ examples/ get_data.py - packages/
eeg/ , Python, 84 linesieegOrg/ ieegpy/ examples/ montages.py - packages/
eeg/ , Python, 142 linesieegOrg/ ieegpy/ examples/ mprov_example.py - packages/
eeg/ , Python, 1 lineieegOrg/ ieegpy/ ieeg/ __init__.py - packages/
eeg/ , Python, 105 linesieegOrg/ ieegpy/ ieeg/ annotation_processing.py - packages/
eeg/ , Python, 113 linesieegOrg/ ieegpy/ ieeg/ auth.py - packages/
eeg/ , Python, 581 linesieegOrg/ ieegpy/ ieeg/ dataset.py - packages/
eeg/ , Python, 315 linesieegOrg/ ieegpy/ ieeg/ ieeg_api.py - packages/
eeg/ , Python, 76 linesieegOrg/ ieegpy/ ieeg/ ieeg_auth.py - packages/
eeg/ , Python, 520 linesieegOrg/ ieegpy/ ieeg/ mprov_listener.py - packages/
eeg/ , Python, 154 linesieegOrg/ ieegpy/ ieeg/ processing.py - packages/
eeg/ , Python, 74 linesieegOrg/ ieegpy/ read_sample.py - packages/
eeg/ , Python, 35 linesieegOrg/ ieegpy/ setup.py - packages/
imaging/ , Python, 724 linesBIDS/ BIDSorganization.py - packages/
imaging/ , Python, 185 linesBIDS/ tabulationOfPatients.py - packages/
imaging/ , Python, 493 linesbrainTemplate/ brainTemplate.py - packages/
imaging/ , Python, 98 lineselectrodeLocalization/ blender_compress_mesh.py - packages/
imaging/ , Python, 149 lineselectrodeLocalization/ convertCoordinates.py - packages/
imaging/ , Python, 210 lineselectrodeLocalization/ electrodeLocalization.py - packages/
imaging/ , Python, 315 lineselectrodeLocalization/ electrodeLocalizationFun ctions.py - packages/
imaging/ , Python, 95 linesfreesurferReconAll/ freesurferReconAll.py - packages/
imaging/ , Python, 57 linesmakeSphericalRegions/ make_spherical_regions.p y - packages/
imaging/ , Python, 206 linesrandomAtlas/ randomAtlasGeneration.py - packages/
imaging/ , Python, 141 linesregionMorphology/ regionMophology.py - packages/
imaging/ , Python, 239 linestractography/ pipeline_create_structur al_connectivity.py - packages/
imaging/ , Python, 287 linestractography/ tractography.py - packages/
seizureSpread/ , Python, 1 line__init__.py - packages/
seizureSpread/ , Python, 607 linesechomodel.py - packages/
statistics/ , Python, 51 linesHoff_A_First_Course_In_B ayesian_Statistical_Meth ods.py - packages/
utilities/ , Python, 36 linescopy_structure_to_becker le.py - packages/
utilities/ , Python, 175 linesmove_BIDS_cornblath.py - packages/
utilities/ , Python, 76 linessync_LINUX.py - packages/
utilities/ , Python, 44 linessync_MAC.py - packages/
utilities/ , Python, 965 linesutils.py - papers/
brainAtlas/ , Python, 59 linesScript_00_random_atlas_g eneration.py - papers/
brainAtlas/ , Python, 51 linesScript_01_imaging_01_qsi prep.py - papers/
brainAtlas/ , Python, 102 linesScript_01_imaging_02_atl as_registration_to_preop 3T.py - papers/
brainAtlas/ , Python, 222 linesScript_01_imaging_03_tra ctography.py - papers/
brainAtlas/ , Python, 163 linesScript_01_volumes_vs_sph ericity.py - papers/
brainAtlas/ , Python, 106 linesScript_02_download_iEEG_ data.py - papers/
brainAtlas/ , Python, 108 linesScript_02_electrodeLocal ization_01_tissue_segmen tation.py - papers/
brainAtlas/ , Python, 97 linesScript_02_electrodeLocal ization_02_atlas_registr ation_to_T00.py - papers/
brainAtlas/ , Python, 158 linesScript_02_electrodeLocal ization_03_electrode_loc alization.py - papers/
brainAtlas/ , Python, 190 linesScript_02_electrodeLocal ization_03_electrode_neu roanatomical_distributio n.py - papers/
brainAtlas/ , Python, 118 linesScript_03_EEG_01_downloa d_iEEG_data.py - papers/
brainAtlas/ , Python, 559 linesScript_03_EEG_02_preproc essEEG.py - papers/
brainAtlas/ , Python, 124 linesScript_03_electrode_loca lization.py - papers/
brainAtlas/ , Python, 155 linesScript_04_atlas_01_volum es_vs_sphericity.py - papers/
brainAtlas/ , R, 609 linesScript_04_atlas_02_plotM orphology.R - papers/
brainAtlas/ , Python, 104 linesScript_04_functional_con nectivity.py - papers/
brainAtlas/ , Python, 87 linesScript_05_HARDI_correcti on.py - papers/
brainAtlas/ , Python, 130 linesScript_05_structure_02_n etwork_measures.py - papers/
brainAtlas/ , R, 366 linesScript_05_structure_02_n etwork_plot.R - papers/
brainAtlas/ , Python, 1,231 linesScript_06.3_FunctionalCo nnectivity.py - papers/
brainAtlas/ , Python, 1,141 linesScript_06_data_01_SFC.py - papers/
brainAtlas/ , Python, 169 linesScript_06_data_01_aggreg ate.py - papers/
brainAtlas/ , Python, 120 linesScript_06_tractography.p y - papers/
brainAtlas/ , Python, 101 linesScript_07_structural_con nectivity.py - papers/
brainAtlas/ , Python, 120 linesScript_08_network_measur es.py - papers/
brainAtlas/ , Python, 145 linesScript_09_SFC.py - papers/
brainAtlas/ , Python, 363 linesScript_10_SFC_post_proce ssing.py - papers/
brainAtlas/ , Python, 1,532 linesScript_11_SFC_plot.py - papers/
brainAtlas/ , Python, 37 linesScript_template.py - papers/
brainAtlas/ , Python, 270 lines, 1 matchbrainAtlasAnalysis.py - papers/
brainAtlas/ , Python, 149 linesconvert_atlases_to_MNI15 2_1mm_resolution.py - papers/
brainAtlas/ , Shell, 71 linesgenerate_atlas_images_sc reenshots.sh - papers/
brainAtlas/ , Python, 790 linesget_structure_function_c orrelation.py - papers/
brainAtlas/ , Python, 114 linesharvard_Oxford_edit.py - papers/
brainAtlas/ , R, 366 linesnetwork_measures.R - papers/
brainAtlas/ , Python, 141 linesnetwork_measures.py - papers/
brainAtlas/ , Python, 77 linesnull_model.py - papers/
brainAtlas/ , Python, 117 linesoverlap_HO_Hammersmith.p y - papers/
brainAtlas/ , Python, 241 lines, 1 matchstructure_function_corre lation.py - papers/
brainAtlas/ , Python, 324 linesstructure_function_corre lation_post_processing.p y - papers/
brainAtlas/ , R, 573 linesvolumes_vs_sphericity.R - papers/
old/ , Python, 51 linesseeg_GMvsWM/ old/ Script_01_imaging_01_qsi prep.py - papers/
old/ , Python, 102 linesseeg_GMvsWM/ old/ Script_01_imaging_02_atl as_registration_to_preop 3T.py - papers/
old/ , Python, 222 linesseeg_GMvsWM/ old/ Script_01_imaging_03_tra ctography.py - papers/
old/ , Python, 108 linesseeg_GMvsWM/ old/ Script_02_electrodeLocal ization_01_tissue_segmen tation.py - papers/
old/ , Python, 97 linesseeg_GMvsWM/ old/ Script_02_electrodeLocal ization_02_atlas_registr ation_to_T00.py - papers/
old/ , Python, 158 linesseeg_GMvsWM/ old/ Script_02_electrodeLocal ization_03_electrode_loc alization.py - papers/
old/ , Python, 190 linesseeg_GMvsWM/ old/ Script_02_electrodeLocal ization_03_electrode_neu roanatomical_distributio n.py - papers/
old/ , Python, 118 linesseeg_GMvsWM/ old/ Script_03_EEG_01_downloa d_iEEG_data.py - papers/
old/ , Python, 559 linesseeg_GMvsWM/ old/ Script_03_EEG_02_preproc essEEG.py - papers/
old/ , Python, 155 linesseeg_GMvsWM/ old/ Script_04_atlas_01_volum es_vs_sphericity.py - papers/
old/ , R, 609 linesseeg_GMvsWM/ old/ Script_04_atlas_02_plotM orphology.R - papers/
old/ , Python, 130 linesseeg_GMvsWM/ old/ Script_05_structure_02_n etwork_measures.py - papers/
old/ , R, 366 linesseeg_GMvsWM/ old/ Script_05_structure_02_n etwork_plot.R - papers/
old/ , Python, 2,268 linesseeg_GMvsWM/ old/ Script_06.1_FunctionalCo nnectivity.py - papers/
old/ , Python, 973 linesseeg_GMvsWM/ old/ Script_06.2_FunctionalCo nnectivity.py - papers/
old/ , Python, 1,231 linesseeg_GMvsWM/ old/ Script_06.3_FunctionalCo nnectivity.py - papers/
old/ , Python, 1,141 linesseeg_GMvsWM/ old/ Script_06_data_01_SFC.py - papers/
old/ , Python, 169 linesseeg_GMvsWM/ old/ Script_06_data_01_aggreg ate.py - papers/
old/ , Python, 172 linesseeg_GMvsWM/ old/ Script_10_spectrogram_av eraging.py - papers/
old/ , Python, 108 linesseeg_GMvsWM/ old/ Script_10_spectrogram_in terpolation.py - papers/
old/ , Python, 127 linesseeg_GMvsWM/ old/ Script_11_PSDvsDistance. py - papers/
old/ , Python, 113 linesseeg_GMvsWM/ old/ Script_11_PSDvsDistance_ averaging.py - papers/
old/ , Python, 156 linesseeg_GMvsWM/ old/ Script_11_SNR.py - papers/
old/ , Python, 132 linesseeg_GMvsWM/ old/ Script_11_SNR_averaging. py - papers/
old/ , Python, 104 linesseeg_GMvsWM/ old/ Script_11_functional_con nectivity.py - papers/
old/ , Python, 258 linesseeg_GMvsWM/ old/ Script_11_make_electrode _sphere_ROIs.py - papers/
old/ , Python, 226 linesseeg_GMvsWM/ tools/ atlas_edits_HarvardOxfor d_AALJHU_MNI2009cNlin.py - papers/
old/ , Python, 71 linesseeg_GMvsWM/ tools/ combine_FIRST_and_FAST_i mages.py - papers/
old/ , Python, 93 linesseeg_GMvsWM/ tools/ convert_atlas_to_2.py - papers/
old/ , Python, 149 linesseeg_GMvsWM/ tools/ convert_atlases_to_MNI15 2_1mm_resolution.py - papers/
old/ , Python, 115 linesseeg_GMvsWM/ tools/ download_iEEG_data.py - papers/
old/ , Python, 1,534 linesseeg_GMvsWM/ tools/ echobase.py - papers/
old/ , Python, 283 linesseeg_GMvsWM/ tools/ electrode_localization.p y - papers/
old/ , Python, 147 linesseeg_GMvsWM/ tools/ functional_connectivity. py - papers/
old/ , Python, 156 linesseeg_GMvsWM/ tools/ get_Functional_connectiv ity.py - papers/
old/ , Python, 86 linesseeg_GMvsWM/ tools/ get_iEEG_data.py - papers/
old/ , Python, 839 linesseeg_GMvsWM/ tools/ get_network_measures.py - papers/
old/ , Python, 131 linesseeg_GMvsWM/ tools/ get_patient_PSD.py - papers/
old/ , Python, 53 linesseeg_GMvsWM/ tools/ get_power_spectra_densit y.py - papers/
old/ , Python, 96 linesseeg_GMvsWM/ tools/ imagingToolsRevell.py - papers/
old/ , Python, 141 linesseeg_GMvsWM/ tools/ network_measures.py - papers/
old/ , Python, 89 linesseeg_GMvsWM/ tools/ preprocessEEG.py - papers/
old/ , Python, 111 linesseeg_GMvsWM/ tools/ register_atlases_to_pati ent.py - papers/
old/ , Python, 72 linesseeg_GMvsWM/ tools/ resample_network_measure s_0278.py - papers/
old/ , Python, 209 linesseeg_GMvsWM/ tools/ signal_processing_pipeli ne.py - papers/
old/ , Python, 192 linesseeg_GMvsWM/ tools/ tissue_segmentation_atla s_registration.py - papers/
old/ , Python, 153 linesseeg_GMvsWM/ tools/ volumes_sphericity_surfa ce_area.py - papers/
predictSFC/ , Python, 1 line__init__.py - papers/
predictSFC/ , Python, 263 linescreate_feature_matrix.py - papers/
predictSFC/ , Python, 462 linesgraph_feature_distributi ons.py - papers/
predictSFC/ , Python, 81 linesrandom_forest.py - papers/
predictSFC/ , Python, 97 linesrandom_forest_script.py - papers/
predictSFC/ , Python, 99 linesrf_script2.py - papers/
seizureSpread/ , Python, 244 linesAkash/ 05-schindler_recruited_c hannels.py - papers/
seizureSpread/ , Python, 92 linesAkash/ incorporate_SOZ_json.py - papers/
seizureSpread/ , Python, 186 linesAkash/ incorporate_json.py - papers/
seizureSpread/ , Python, 20 linesAkash/ pull_patient_localizatio n.py - papers/
seizureSpread/ , Python, 1,169 linesScript02_seizurePattern. py - papers/
seizureSpread/ , Python, 848 linesScript_01_trainModel.py - papers/
seizureSpread/ , Python, 1,212 linesScript_02_seizurePattern _seizure_severity.py - papers/
seizureSpread/ , Python, 660 linesScript_03_seizure_spread _many_patients.py - papers/
seizureSpread/ , Python, 1,413 lines, 1 matchScript_04_seizure_spread _vs_SOZ.py - papers/
seizureSpread/ , Python, 1,363 linesScript_05_seizure_spread _clustering.py - papers/
seizureSpread/ , Python, 656 linesScript_06_seizure_spread _by_coordinates.py - papers/
seizureSpread/ , Python, 159 linesScript_07_seizure_spread _by_regions.py - papers/
seizureSpread/ , Python, 1,006 lines, 1 matchScript_08_seizure_model_ comparisons.py - papers/
seizureSpread/ , Python, 633 linesScript_09_spread_associa ted_with_connectivity.py - papers/
seizureSpread/ , Python, 686 linesScript_10_spread_associa ted_with_connectivity_al l_regions.py - papers/
seizureSpread/ , Python, 71 linesScript_11_combine_jsons. py - papers/
seizureSpread/ , Python, 1,013 linesScript_11_hipp_spread_as sociated_with_connectivi ty_updated.py - papers/
seizureSpread/ , Python, 13 linesdiffusion_model.py - papers/
seizureSpread/ , Python, 108 linesepileptogenicity_index.p y - papers/
seizureSpread/ , Python, 445 linesold_Script02_seizurePatt ern.py - papers/
seizureSpread/ , Python, 837 linesplotting/ seizure_patterns_plots.p y - papers/
seizureSpread/ , Python, 565 linesseizurePattern.py - papers/
seizureSpread/ , Python, 500 linesseizurePattern_seizure_s everity.py - papers/
white_matter_iEEG/ , Python, 1,423 lines, 1 matchREVELL_MDPHD_THESIS_WORK .py - papers/
white_matter_iEEG/ , Python, 485 linesbootstrap_permutation_si mulation.py - papers/
white_matter_iEEG/ , Python, 37 linesconstants_parameters.py - papers/
white_matter_iEEG/ , Python, 35 linesconstants_plotting.py - papers/
white_matter_iEEG/ , Python, 138 linescount_contacts.py - papers/
white_matter_iEEG/ , Python, 1,994 lineshelpers/ thesis_helpers.py - papers/
white_matter_iEEG/ , Python, 1,531 linesplotting/ plot_GMvsWM.py - papers/
white_matter_iEEG/ , Python, 60 linesplotting/ plot_seizure_distributio ns.py - papers/
white_matter_iEEG/ , Python, 1,462 lines, 1 matchwhite_matter_iEEG.py - paths/
__init__.py , Python, 1 line - paths/
constants_paths.py , Python, 100 lines - tools/
templates/ , C/C++, not shown hereMNI/ freesurfer/ surf/ lh.inflated.H - tools/
templates/ , C/C++, not shown hereMNI/ freesurfer/ surf/ lh.white.H - tools/
templates/ , C/C++, not shown hereMNI/ freesurfer/ surf/ lh.white.preaparc.H - tools/
templates/ , C/C++, not shown hereMNI/ freesurfer/ surf/ rh.inflated.H - tools/
templates/ , C/C++, not shown hereMNI/ freesurfer/ surf/ rh.white.H - tools/
templates/ , C/C++, not shown hereMNI/ freesurfer/ surf/ rh.white.preaparc.H - tools/
threejs/ , JavaScript, 1,227 linesexamples/ jsm/ controls/ OrbitControls.js - tools/
threejs/ , JavaScript, 749 linesexamples/ jsm/ controls/ TrackballControls.js - tools/
threejs/ , JavaScript, 3,575 linesexamples/ jsm/ libs/ dat.gui.module.js - tools/
threejs/ , JavaScript, 167 linesexamples/ jsm/ libs/ stats.module.js - tools/
threejs/ , JavaScript, 3,923 linesexamples/ jsm/ loaders/ GLTFLoader.js - tools/
threejs/ , JavaScript, 402 linesexamples/ jsm/ loaders/ STLLoader.js - tools/
threejs/ , JavaScript, 205 linesexamples/ jsm/ renderers/ CSS2DRenderer.js - README.md, Text, 7 lines
andyrevell/revellLab
942cd9101906388fe38ea4f4c0373b2f496f3897, 15 July 2022Availability: 1 check, the latest on 28 September 2026: the link answers
- 28 September 2026: the link answers
199 files
- __init__.py, Python, 1 line
- packages/
__init__.py , Python, 1 line - packages/
atlasLocalization/ , Python, 1 line__init__.py - packages/
atlasLocalization/ , Python, 336 linesatlasLocalization.py - packages/
atlasLocalization/ , Python, 924 linesatlasLocalizationFunctio ns.py - packages/
atlasLocalization/ , Python, 564 linesatlasLocalization_DoNotU seDEPRICATED.py - packages/
dataclass/ , Python, 1 line__init__.py - packages/
dataclass/ , Python, 271 linesdataclass_SFC.py - packages/
dataclass/ , Python, 82 linesdataclass_atlases.py - packages/
dataclass/ , Python, 98 linesdataclass_cohorts_brain_ atlas.py - packages/
dataclass/ , Python, 568 linesdataclass_iEEG_metadata. py - packages/
deep_learning_playground , Python, 145 lines.py - packages/
diffusionModels/ , Python, 1 line__init__.py - packages/
diffusionModels/ , Python, 552 linesdiffusionModels.py - packages/
eeg/ , Python, 1 line__init__.py - packages/
eeg/ , Python, 1 lineechobase/ __init__.py - packages/
eeg/ , Python, 1,905 linesechobase/ echobase.py - packages/
eeg/ , Python, 59 linesechobase/ echoimage.py - packages/
eeg/ , Python, 1 lineieegOrg/ __init__.py - packages/
eeg/ , Python, 198 linesieegOrg/ downloadiEEGorg.py - packages/
eeg/ , Python, 1 lineieegOrg/ ieegpy/ __init__.py - packages/
eeg/ , Python, 234 linesieegOrg/ ieegpy/ examples/ annotations.py - packages/
eeg/ , Python, 56 linesieegOrg/ ieegpy/ examples/ dataset_start_time.py - packages/
eeg/ , Python, 51 linesieegOrg/ ieegpy/ examples/ get_data.py - packages/
eeg/ , Python, 84 linesieegOrg/ ieegpy/ examples/ montages.py - packages/
eeg/ , Python, 142 linesieegOrg/ ieegpy/ examples/ mprov_example.py - packages/
eeg/ , Python, 1 lineieegOrg/ ieegpy/ ieeg/ __init__.py - packages/
eeg/ , Python, 105 linesieegOrg/ ieegpy/ ieeg/ annotation_processing.py - packages/
eeg/ , Python, 113 linesieegOrg/ ieegpy/ ieeg/ auth.py - packages/
eeg/ , Python, 581 linesieegOrg/ ieegpy/ ieeg/ dataset.py - packages/
eeg/ , Python, 315 linesieegOrg/ ieegpy/ ieeg/ ieeg_api.py - packages/
eeg/ , Python, 76 linesieegOrg/ ieegpy/ ieeg/ ieeg_auth.py - packages/
eeg/ , Python, 520 linesieegOrg/ ieegpy/ ieeg/ mprov_listener.py - packages/
eeg/ , Python, 154 linesieegOrg/ ieegpy/ ieeg/ processing.py - packages/
eeg/ , Python, 74 linesieegOrg/ ieegpy/ read_sample.py - packages/
eeg/ , Python, 35 linesieegOrg/ ieegpy/ setup.py - packages/
imaging/ , Python, 724 linesBIDS/ BIDSorganization.py - packages/
imaging/ , Python, 185 linesBIDS/ tabulationOfPatients.py - packages/
imaging/ , Python, 493 linesbrainTemplate/ brainTemplate.py - packages/
imaging/ , Python, 98 lineselectrodeLocalization/ blender_compress_mesh.py - packages/
imaging/ , Python, 149 lineselectrodeLocalization/ convertCoordinates.py - packages/
imaging/ , Python, 210 lineselectrodeLocalization/ electrodeLocalization.py - packages/
imaging/ , Python, 315 lineselectrodeLocalization/ electrodeLocalizationFun ctions.py - packages/
imaging/ , Python, 95 linesfreesurferReconAll/ freesurferReconAll.py - packages/
imaging/ , Python, 57 linesmakeSphericalRegions/ make_spherical_regions.p y - packages/
imaging/ , Python, 206 linesrandomAtlas/ randomAtlasGeneration.py - packages/
imaging/ , Python, 141 linesregionMorphology/ regionMophology.py - packages/
imaging/ , Python, 239 linestractography/ pipeline_create_structur al_connectivity.py - packages/
imaging/ , Python, 287 linestractography/ tractography.py - packages/
seizureSpread/ , Python, 1 line__init__.py - packages/
seizureSpread/ , Python, 607 linesechomodel.py - packages/
statistics/ , Python, 51 linesHoff_A_First_Course_In_B ayesian_Statistical_Meth ods.py - packages/
utilities/ , Python, 36 linescopy_structure_to_becker le.py - packages/
utilities/ , Python, 175 linesmove_BIDS_cornblath.py - packages/
utilities/ , Python, 76 linessync_LINUX.py - packages/
utilities/ , Python, 44 linessync_MAC.py - packages/
utilities/ , Python, 965 linesutils.py - papers/
brainAtlas/ , Python, 59 linesScript_00_random_atlas_g eneration.py - papers/
brainAtlas/ , Python, 51 linesScript_01_imaging_01_qsi prep.py - papers/
brainAtlas/ , Python, 102 linesScript_01_imaging_02_atl as_registration_to_preop 3T.py - papers/
brainAtlas/ , Python, 222 linesScript_01_imaging_03_tra ctography.py - papers/
brainAtlas/ , Python, 163 linesScript_01_volumes_vs_sph ericity.py - papers/
brainAtlas/ , Python, 106 linesScript_02_download_iEEG_ data.py - papers/
brainAtlas/ , Python, 108 linesScript_02_electrodeLocal ization_01_tissue_segmen tation.py - papers/
brainAtlas/ , Python, 97 linesScript_02_electrodeLocal ization_02_atlas_registr ation_to_T00.py - papers/
brainAtlas/ , Python, 158 linesScript_02_electrodeLocal ization_03_electrode_loc alization.py - papers/
brainAtlas/ , Python, 190 linesScript_02_electrodeLocal ization_03_electrode_neu roanatomical_distributio n.py - papers/
brainAtlas/ , Python, 118 linesScript_03_EEG_01_downloa d_iEEG_data.py - papers/
brainAtlas/ , Python, 559 linesScript_03_EEG_02_preproc essEEG.py - papers/
brainAtlas/ , Python, 124 linesScript_03_electrode_loca lization.py - papers/
brainAtlas/ , Python, 155 linesScript_04_atlas_01_volum es_vs_sphericity.py - papers/
brainAtlas/ , R, 609 linesScript_04_atlas_02_plotM orphology.R - papers/
brainAtlas/ , Python, 104 linesScript_04_functional_con nectivity.py - papers/
brainAtlas/ , Python, 87 linesScript_05_HARDI_correcti on.py - papers/
brainAtlas/ , Python, 130 linesScript_05_structure_02_n etwork_measures.py - papers/
brainAtlas/ , R, 366 linesScript_05_structure_02_n etwork_plot.R - papers/
brainAtlas/ , Python, 1,231 linesScript_06.3_FunctionalCo nnectivity.py - papers/
brainAtlas/ , Python, 1,141 linesScript_06_data_01_SFC.py - papers/
brainAtlas/ , Python, 169 linesScript_06_data_01_aggreg ate.py - papers/
brainAtlas/ , Python, 120 linesScript_06_tractography.p y - papers/
brainAtlas/ , Python, 101 linesScript_07_structural_con nectivity.py - papers/
brainAtlas/ , Python, 120 linesScript_08_network_measur es.py - papers/
brainAtlas/ , Python, 145 linesScript_09_SFC.py - papers/
brainAtlas/ , Python, 363 linesScript_10_SFC_post_proce ssing.py - papers/
brainAtlas/ , Python, 1,532 linesScript_11_SFC_plot.py - papers/
brainAtlas/ , Python, 37 linesScript_template.py - papers/
brainAtlas/ , Python, 270 linesbrainAtlasAnalysis.py - papers/
brainAtlas/ , Python, 149 linesconvert_atlases_to_MNI15 2_1mm_resolution.py - papers/
brainAtlas/ , Shell, 71 linesgenerate_atlas_images_sc reenshots.sh - papers/
brainAtlas/ , Python, 790 linesget_structure_function_c orrelation.py - papers/
brainAtlas/ , Python, 114 linesharvard_Oxford_edit.py - papers/
brainAtlas/ , R, 366 linesnetwork_measures.R - papers/
brainAtlas/ , Python, 141 linesnetwork_measures.py - papers/
brainAtlas/ , Python, 77 linesnull_model.py - papers/
brainAtlas/ , Python, 117 linesoverlap_HO_Hammersmith.p y - papers/
brainAtlas/ , Python, 241 linesstructure_function_corre lation.py - papers/
brainAtlas/ , Python, 324 linesstructure_function_corre lation_post_processing.p y - papers/
brainAtlas/ , R, 573 linesvolumes_vs_sphericity.R - papers/
old/ , Python, 51 linesseeg_GMvsWM/ old/ Script_01_imaging_01_qsi prep.py - papers/
old/ , Python, 102 linesseeg_GMvsWM/ old/ Script_01_imaging_02_atl as_registration_to_preop 3T.py - papers/
old/ , Python, 222 linesseeg_GMvsWM/ old/ Script_01_imaging_03_tra ctography.py - papers/
old/ , Python, 108 linesseeg_GMvsWM/ old/ Script_02_electrodeLocal ization_01_tissue_segmen tation.py - papers/
old/ , Python, 97 linesseeg_GMvsWM/ old/ Script_02_electrodeLocal ization_02_atlas_registr ation_to_T00.py - papers/
old/ , Python, 158 linesseeg_GMvsWM/ old/ Script_02_electrodeLocal ization_03_electrode_loc alization.py - papers/
old/ , Python, 190 linesseeg_GMvsWM/ old/ Script_02_electrodeLocal ization_03_electrode_neu roanatomical_distributio n.py - papers/
old/ , Python, 118 linesseeg_GMvsWM/ old/ Script_03_EEG_01_downloa d_iEEG_data.py - papers/
old/ , Python, 559 linesseeg_GMvsWM/ old/ Script_03_EEG_02_preproc essEEG.py - papers/
old/ , Python, 155 linesseeg_GMvsWM/ old/ Script_04_atlas_01_volum es_vs_sphericity.py - papers/
old/ , R, 609 linesseeg_GMvsWM/ old/ Script_04_atlas_02_plotM orphology.R - papers/
old/ , Python, 130 linesseeg_GMvsWM/ old/ Script_05_structure_02_n etwork_measures.py - papers/
old/ , R, 366 linesseeg_GMvsWM/ old/ Script_05_structure_02_n etwork_plot.R - papers/
old/ , Python, 2,268 linesseeg_GMvsWM/ old/ Script_06.1_FunctionalCo nnectivity.py - papers/
old/ , Python, 973 linesseeg_GMvsWM/ old/ Script_06.2_FunctionalCo nnectivity.py - papers/
old/ , Python, 1,231 linesseeg_GMvsWM/ old/ Script_06.3_FunctionalCo nnectivity.py - papers/
old/ , Python, 1,141 linesseeg_GMvsWM/ old/ Script_06_data_01_SFC.py - papers/
old/ , Python, 169 linesseeg_GMvsWM/ old/ Script_06_data_01_aggreg ate.py - papers/
old/ , Python, 172 linesseeg_GMvsWM/ old/ Script_10_spectrogram_av eraging.py - papers/
old/ , Python, 108 linesseeg_GMvsWM/ old/ Script_10_spectrogram_in terpolation.py - papers/
old/ , Python, 127 linesseeg_GMvsWM/ old/ Script_11_PSDvsDistance. py - papers/
old/ , Python, 113 linesseeg_GMvsWM/ old/ Script_11_PSDvsDistance_ averaging.py - papers/
old/ , Python, 156 linesseeg_GMvsWM/ old/ Script_11_SNR.py - papers/
old/ , Python, 132 linesseeg_GMvsWM/ old/ Script_11_SNR_averaging. py - papers/
old/ , Python, 104 linesseeg_GMvsWM/ old/ Script_11_functional_con nectivity.py - papers/
old/ , Python, 258 linesseeg_GMvsWM/ old/ Script_11_make_electrode _sphere_ROIs.py - papers/
old/ , Python, 226 linesseeg_GMvsWM/ tools/ atlas_edits_HarvardOxfor d_AALJHU_MNI2009cNlin.py - papers/
old/ , Python, 71 linesseeg_GMvsWM/ tools/ combine_FIRST_and_FAST_i mages.py - papers/
old/ , Python, 93 linesseeg_GMvsWM/ tools/ convert_atlas_to_2.py - papers/
old/ , Python, 149 linesseeg_GMvsWM/ tools/ convert_atlases_to_MNI15 2_1mm_resolution.py - papers/
old/ , Python, 115 linesseeg_GMvsWM/ tools/ download_iEEG_data.py - papers/
old/ , Python, 1,534 linesseeg_GMvsWM/ tools/ echobase.py - papers/
old/ , Python, 283 linesseeg_GMvsWM/ tools/ electrode_localization.p y - papers/
old/ , Python, 147 linesseeg_GMvsWM/ tools/ functional_connectivity. py - papers/
old/ , Python, 156 linesseeg_GMvsWM/ tools/ get_Functional_connectiv ity.py - papers/
old/ , Python, 86 linesseeg_GMvsWM/ tools/ get_iEEG_data.py - papers/
old/ , Python, 839 linesseeg_GMvsWM/ tools/ get_network_measures.py - papers/
old/ , Python, 131 linesseeg_GMvsWM/ tools/ get_patient_PSD.py - papers/
old/ , Python, 53 linesseeg_GMvsWM/ tools/ get_power_spectra_densit y.py - papers/
old/ , Python, 96 linesseeg_GMvsWM/ tools/ imagingToolsRevell.py - papers/
old/ , Python, 141 linesseeg_GMvsWM/ tools/ network_measures.py - papers/
old/ , Python, 89 linesseeg_GMvsWM/ tools/ preprocessEEG.py - papers/
old/ , Python, 111 linesseeg_GMvsWM/ tools/ register_atlases_to_pati ent.py - papers/
old/ , Python, 72 linesseeg_GMvsWM/ tools/ resample_network_measure s_0278.py - papers/
old/ , Python, 209 linesseeg_GMvsWM/ tools/ signal_processing_pipeli ne.py - papers/
old/ , Python, 192 linesseeg_GMvsWM/ tools/ tissue_segmentation_atla s_registration.py - papers/
old/ , Python, 153 linesseeg_GMvsWM/ tools/ volumes_sphericity_surfa ce_area.py - papers/
predictSFC/ , Python, 1 line__init__.py - papers/
predictSFC/ , Python, 263 linescreate_feature_matrix.py - papers/
predictSFC/ , Python, 462 linesgraph_feature_distributi ons.py - papers/
predictSFC/ , Python, 81 linesrandom_forest.py - papers/
predictSFC/ , Python, 97 linesrandom_forest_script.py - papers/
predictSFC/ , Python, 99 linesrf_script2.py - papers/
seizureSpread/ , Python, 244 linesAkash/ 05-schindler_recruited_c hannels.py - papers/
seizureSpread/ , Python, 92 linesAkash/ incorporate_SOZ_json.py - papers/
seizureSpread/ , Python, 186 linesAkash/ incorporate_json.py - papers/
seizureSpread/ , Python, 20 linesAkash/ pull_patient_localizatio n.py - papers/
seizureSpread/ , Python, 1,169 linesScript02_seizurePattern. py - papers/
seizureSpread/ , Python, 848 linesScript_01_trainModel.py - papers/
seizureSpread/ , Python, 1,212 linesScript_02_seizurePattern _seizure_severity.py - papers/
seizureSpread/ , Python, 660 linesScript_03_seizure_spread _many_patients.py - papers/
seizureSpread/ , Python, 1,413 linesScript_04_seizure_spread _vs_SOZ.py - papers/
seizureSpread/ , Python, 1,363 linesScript_05_seizure_spread _clustering.py - papers/
seizureSpread/ , Python, 656 linesScript_06_seizure_spread _by_coordinates.py - papers/
seizureSpread/ , Python, 159 linesScript_07_seizure_spread _by_regions.py - papers/
seizureSpread/ , Python, 1,006 linesScript_08_seizure_model_ comparisons.py - papers/
seizureSpread/ , Python, 633 linesScript_09_spread_associa ted_with_connectivity.py - papers/
seizureSpread/ , Python, 686 linesScript_10_spread_associa ted_with_connectivity_al l_regions.py - papers/
seizureSpread/ , Python, 71 linesScript_11_combine_jsons. py - papers/
seizureSpread/ , Python, 1,013 linesScript_11_hipp_spread_as sociated_with_connectivi ty_updated.py - papers/
seizureSpread/ , Python, 13 linesdiffusion_model.py - papers/
seizureSpread/ , Python, 108 linesepileptogenicity_index.p y - papers/
seizureSpread/ , Python, 445 linesold_Script02_seizurePatt ern.py - papers/
seizureSpread/ , Python, 837 linesplotting/ seizure_patterns_plots.p y - papers/
seizureSpread/ , Python, 565 linesseizurePattern.py - papers/
seizureSpread/ , Python, 500 linesseizurePattern_seizure_s everity.py - papers/
white_matter_iEEG/ , Python, 1,423 linesREVELL_MDPHD_THESIS_WORK .py - papers/
white_matter_iEEG/ , Python, 485 linesbootstrap_permutation_si mulation.py - papers/
white_matter_iEEG/ , Python, 37 linesconstants_parameters.py - papers/
white_matter_iEEG/ , Python, 35 linesconstants_plotting.py - papers/
white_matter_iEEG/ , Python, 138 linescount_contacts.py - papers/
white_matter_iEEG/ , Python, 1,994 lineshelpers/ thesis_helpers.py - papers/
white_matter_iEEG/ , Python, 1,531 linesplotting/ plot_GMvsWM.py - papers/
white_matter_iEEG/ , Python, 60 linesplotting/ plot_seizure_distributio ns.py - papers/
white_matter_iEEG/ , Python, 1,462 lineswhite_matter_iEEG.py - paths/
__init__.py , Python, 1 line - paths/
constants_paths.py , Python, 100 lines - tools/
templates/ , C/C++, not shown hereMNI/ freesurfer/ surf/ lh.inflated.H - tools/
templates/ , C/C++, not shown hereMNI/ freesurfer/ surf/ lh.white.H - tools/
templates/ , C/C++, not shown hereMNI/ freesurfer/ surf/ lh.white.preaparc.H - tools/
templates/ , C/C++, not shown hereMNI/ freesurfer/ surf/ rh.inflated.H - tools/
templates/ , C/C++, not shown hereMNI/ freesurfer/ surf/ rh.white.H - tools/
templates/ , C/C++, not shown hereMNI/ freesurfer/ surf/ rh.white.preaparc.H - tools/
threejs/ , JavaScript, 1,227 linesexamples/ jsm/ controls/ OrbitControls.js - tools/
threejs/ , JavaScript, 749 linesexamples/ jsm/ controls/ TrackballControls.js - tools/
threejs/ , JavaScript, 3,575 linesexamples/ jsm/ libs/ dat.gui.module.js - tools/
threejs/ , JavaScript, 167 linesexamples/ jsm/ libs/ stats.module.js - tools/
threejs/ , JavaScript, 3,923 linesexamples/ jsm/ loaders/ GLTFLoader.js - tools/
threejs/ , JavaScript, 402 linesexamples/ jsm/ loaders/ STLLoader.js - tools/
threejs/ , JavaScript, 205 linesexamples/ jsm/ renderers/ CSS2DRenderer.js - README.md, Text, 7 lines
The paper's code and data availability statement is in the Data section.
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:
- 2 repositories of the authors' code, each at its verified commit, with its license and how the link was found in the paper;
- 396 scripts, each with its path and the digest of its content;
- 7 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
All analysis code used in this study is publicly available at the repository cited in the manuscript. The underlying intracranial EEG and structural/
Reproduced under the paper's license (CC BY-NC), 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 2, 28 September 2026
- Publisher: n/a → Wiley
Version 1, 28 September 2026: the first record
Recorded: type, language, journal, volume, issue, pages, dates, 14 authors, 12 MeSH terms, 11 funders, 45 references.
Cite
This paper
Revell, A. Y., Jaskir, M., Pattnaik, A. R., Ojemann, W. K. S., Conrad, E., Sinha, N., Scheid, B. H., Lucas, A., Bernabei, J. M., Beckerle, J., Stein, J. M., Das, S. R., Litt, B., & Davis, K. A. (2026). AI-Driven Mapping of Seizure Spread Patterns. Annals of neurology, 100(1), 59-73. https://
BibTeX
@article{revell2026ai,
author = {Revell, Andrew Y and Jaskir, Marc and Pattnaik, Akash R and Ojemann, William K S and Conrad, Erin and Sinha, Nishant and Scheid, Brittany H and Lucas, Alfredo and Bernabei, John M and Beckerle, John and Stein, Joel M and Das, Sandhitsu R and Litt, Brian and Davis, Kathryn A},
title = {{AI-Driven Mapping of Seizure Spread Patterns}},
journal = {Annals of neurology},
year = {2026},
month = may,
volume = {100},
number = {1},
pages = {59--73},
publisher = {Wiley},
issn = {0364-5134},
doi = {10.1002/
url = {https://
pmid = {42101065},
pmcid = {PMC13327593}
}
RIS
TY - JOUR
AU - Revell, Andrew Y
AU - Jaskir, Marc
AU - Pattnaik, Akash R
AU - Ojemann, William K S
AU - Conrad, Erin
AU - Sinha, Nishant
AU - Scheid, Brittany H
AU - Lucas, Alfredo
AU - Bernabei, John M
AU - Beckerle, John
AU - Stein, Joel M
AU - Das, Sandhitsu R
AU - Litt, Brian
AU - Davis, Kathryn A
TI - AI-Driven Mapping of Seizure Spread Patterns
T2 - Annals of neurology
J2 - Ann Neurol
PY - 2026
DA - 2026/
VL - 100
IS - 1
SP - 59
EP - 73
SN - 0364-5134
PB - Wiley
DO - 10.1002/
UR - https://
LA - en
ER -
CSL-JSON
{
"id": "10.1002/
"type": "article-journal",
"title": "AI-Driven Mapping of Seizure Spread Patterns",
"container-title": "Annals of neurology",
"author": [
{
"family": "Revell",
"given": "Andrew Y"
},
{
"family": "Jaskir",
"given": "Marc"
},
{
"family": "Pattnaik",
"given": "Akash R"
},
{
"family": "Ojemann",
"given": "William K S"
},
{
"family": "Conrad",
"given": "Erin"
},
{
"family": "Sinha",
"given": "Nishant"
},
{
"family": "Scheid",
"given": "Brittany H"
},
{
"family": "Lucas",
"given": "Alfredo"
},
{
"family": "Bernabei",
"given": "John M"
},
{
"family": "Beckerle",
"given": "John"
},
{
"family": "Stein",
"given": "Joel M"
},
{
"family": "Das",
"given": "Sandhitsu R"
},
{
"family": "Litt",
"given": "Brian"
},
{
"family": "Davis",
"given": "Kathryn A"
}
],
"container-title-short":
"volume": "100",
"issue": "1",
"page": "59-73",
"DOI": "10.1002/
"PMID": "42101065",
"PMCID": "PMC13327593",
"ISSN": "0364-5134",
"publisher": "Wiley",
"URL": "https://
"language": "en",
"issued": {
"date-parts": [
[
2026,
5,
8
]
]
}
}
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.1093/nc/niag029 [code]
- A data-driven approach to identifying and evaluating connectivity-based neural correlates of conscious visual perception.Journal: Neuroscience of consciousnessIn common: Pingouin, FSL, NetworkX, 12 other tools, 1 reference
- [2] doi:10.1371/journal.pcbi.1014571 [code]
- SynAPSeg: A novel dataset and image analysis framework for deep learning-based synapse detection and quantification.Journal: PLoS computational biologyIn common: Pingouin, Keras, TensorFlow, 11 other tools, 1 reference
- [3] doi:10.1038/s42003-026-10957-8 [code]
- Brain defence by the extracellular matrix protein Cochlin.Journal: Communications biologyIn common: Keras, TensorFlow, NetworkX, 12 other tools
- [4] doi:10.1016/j.xcrm.2026.102766 [code]
- A longitudinal single-cell and spatial multiomic atlas of pediatric high-grade glioma.Journal: Cell reports. MedicineIn common: Keras, TensorFlow, NetworkX, 11 other tools
- [5] doi:10.1038/s41398-026-04081-8 [code]
- Functional system-specific brain aging across the Alzheimer's disease continuum.Journal: Translational psychiatryIn common: QSIPrep, Pingouin, Keras, 9 other tools, structural MRI / diffusion
- [6] doi:10.1016/j.nicl.2026.104012 [code]
- Structural-functional multilayer brain network properties and outcome of combined repetitive transcranial magnetic stimulation and psychotherapy for obsessive-compulsive disorder.Journal: NeuroImage. ClinicalIn common: Brain Connectivity Toolbox, Pingouin, NetworkX, 10 other tools, structural MRI / diffusion
- [7] doi:10.1162/imag.a.1164 [code]
- Bias and generalizability of brain age prediction models: A multi-cohort evaluation with anatomical and interpretability insights.Journal: Imaging neuroscience (Cambridge, Mass.)In common: Keras, TensorFlow, FSL, 10 other tools, structural MRI / diffusion
- [8] doi:10.7554/elife.103097 [code]
- Canonical neurodevelopmental trajectories of structural and functional manifolds.Journal: eLifeIn common: Brain Connectivity Toolbox, Pingouin, cowplot, 8 other tools, structural MRI / diffusion, 1 reference
- [9] doi:10.1002/alz.71649 [code]
- Postmortem brain MRI reveals differential associations of subcortical and limbic volumes with cortical thinning and neurodegenerative pathologies.Journal: Alzheimer's & dementia : the journal of the Alzheimer's AssociationIn common: Pingouin, FSL, scikit-image, 10 other tools, structural MRI / diffusion
- [10] doi:10.3389/fnsys.2026.1822122 [code]
- Convergence-divergence circuits for multimodal integration of innate and learned opponent valences.Journal: Frontiers in systems neuroscienceIn common: Keras, TensorFlow, NetworkX, 10 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.
Claim this paper
Correct its record
Say what each link of this record is, remove the ones that are not the paper's, add the ones that are missing. The correction becomes a new version of the record, in its Versions section.
Validate its tracing map
You validate the map as this page shows it: 2 repositories of the authors' code, each at its verified commit and with its license, 396 scripts, and 7 matches between paragraphs and code (see the Code and Map sections). It then receives a DOI on Zenodo, with you (your ORCID iD) and OSCR as its creators; the code itself is not deposited.
The map's fingerprint: sha256:b8b4114863f86b3b…
Add the badge to its README
The badge links the code to this page. Copy one of these into the README of the paper's code: only you decide where it goes, and nothing is changed for you.
Markdown
[, paste the snippet at the top, then “Commit changes…” and, to review it first, “Create a new branch and start a pull request”. You open the pull request; OSCR asks for no permission.
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.
