Introduction

There are over 50 million people with epilepsy worldwide1. Anti-seizure medications cannot adequately control the disorder in about 30% of cases2. If the epilepsy is considered focal (i.e., seizures arising from part of one hemisphere3), those with drug-resistant focal epilepsy may undergo presurgical evaluation to detect areas involved in the generation of seizure activity, which may require intracranial electroencephalography (EEG) in some. These areas can be collectively referred to as the epileptogenic zone (EZ), a term that was conceptually developed from stereo-electroencephalography (SEEG)4, a method of intracerebral recording based on multiple depth electrodes. The EZ is considered as the region of primary seizure organization5. After localisation, if the clinical riskā€“benefit ratio is deemed favourable for a specific patient, the EZ can be removed and/or disconnected through surgical resection or laser-based ablation. Despite great progress in use of multimodal approaches (e.g., magnetic resonance imaging (MRI), electroencephalography (EEG), positron emission tomography (PET) scans, etc.) and wealth of clinical expertise, precise localisation of the EZ often remains difficult and may lead to failure to achieve seizure freedom6,7.

Quantification methods have shown great promise in localising the EZ through quantification of intracranial EEG signals8,9,10 (see11 for a review). These methods generally investigate either the interictal or the ictal time window (see Supplementary Table 1 for an overview). In the ictal window, low voltage fast activity (LVFA), baseline shift, rhythmic spikes/spike-waves and preictal low frequency spiking, were found to be the most prevalent epileptiform activities12. These characteristics were successfully extracted from signals and used for EZ localisation in several studies13,14,15,16,17,18,19. In the interictal window, the traditional epileptiform characteristics include interictal spikes/discharges20 and high-frequency oscillations (HFOs21) with a debate on more efficacy of one over the other, and ultimately possible increased predictive EZ by measuring their co-occurrence22. Modelling approaches based on patient-specific imaging data can predict spatial extent of epileptogenicity23.

The relation between electrical seizure onset and electrical disturbances detectable between seizures is of great clinical and neuroscientific importance and yet remains incompletely known20. Interictal spiking is a heterogeneous phenomenon that reflects the involvement of different neuronal networks and mechanisms (e.g., synaptic conductance) in different regions of an epileptic brain24 and has shown predictive value in differentiating underlying neuropathological substrates25. In fact, the original concept of ā€œepileptic focusā€ arose not from seizure recordings, but from observations of interictal spiking during ECoG5. Basing surgical excision extent on the zone of interictal spiking measured peri-operatively by ECoG was thought to help improve likelihood of surgical outcome, albeit with variable accuracy26. In pioneering SEEG work27, the regions involved by interictal spiking typically showed (partial) overlap with the zone of primary seizure organization. Observations from clinical data of this type as well as animal models suggest that interictal and ictal signal features may reflect some similar neuronal mechanisms24. Apart from spikes and HFOs, many other linear and nonlinear signal features including randomness, power and entropy have shown success in localising EZ in the interictal window28,29,30,31,32,33,34,35. While many of the classical methods for EZ localisation relied on univariate/single-channel signal activity, there has been a shift to multivariate/network-based localisation10,35,36,37,38,39,40,41,42, which aligns with the conceptualisation of epilepsy as a network disorder43,44,45 and has shown better performance than univariate methods10,38,42,46,47,48.

Despite the large literature on EZ localisation, using various signal analysis approaches applied to both interictal and ictal windows (Supplementary Table 1), the correspondence between the two windows has remained unclear. This might be because of the distinct, pre-defined sets of features which were looked for in the two windows and which appear visually different (e.g., interictal spikes and ictal LVFA). Nonetheless, if there are signal features which are shared between the two windows, interictal activity, which represents most of the patientā€™s brain state and is generally easier to record, could potentially be sufficient to predict EZ. As a first step to explore this, we looked at a heterogeneous group of epilepsies studied with intracranial EEG, available in an open-access dataset46,48. We compared a large battery of explainable signal characteristics, ranging from simple single-channel to computationally complex network-based features, from both interictal and ictal time windows, to see which features generalise across the two time-windows using the data from each individual patient (i.e., within-individual across-time generalisation (The word generalisation in this manuscript refers to testing machine learning classifiers on time-wise/patient-wise new data rather than the conventional sense epilepsy referring to seizure propagation across the brain.)). Moreover, to see if there are features which are shared between individuals, we also evaluated the generalisability of features across patients within each individual time window (i.e., across-individual within-time generalisation). Finally, we evaluated the effect of surgical outcome (seizure-free/not seizure-free), EZ, pathology of epilepsy (lesional/non-lesional) and type of recording (SEEG/ECoG) on the EZ localisation performances.

Materials and methods

Dataset

This study uses a well-structured open-access intracranial dataset which brings together data from multiple centres46,48. The dataset includes 57 patients who had been implanted with either subdural grid/strip (termed ā€œelectrocorticographyā€ (ECoG)47) or SEEG as their presurgical workup, and subsequently treated with surgical resection or laser ablation. Two patientsā€™ data were excluded from our analyses as one had no interictal and the other no ictal recordings. Among the 55 patients analysed, 27 patientsā€™ pathology was lesional (28 non-lesional) and 35 patients were implanted with SEEG (20 ECoG). 34 patients had Engel I, 6 Engel II, 11 Engel III and 2 had Engel IV outcomes. Resections/ablations targeted frontal areas in 10 patients, temporal in 24, mesiotemporal in 15, insular in 2, frontoparietal in 1, parietal in 1 and mesiofrontal areas in 2 patients. Clinically determined seizure onset channels were provided, as well as marking of channels which overlap with the resection/ablation zone, which was rigorously determined by segmenting the resection cavity. Each patient had 2 interictal recordings and between 1 and 5 (meanā€‰=ā€‰3.7) ictal recordings/seizures (110 interictal and 204 ictal recordings over all patients). The interictal data was selected from awake brain activities determined both by the selection of day-time epochs (8 am ā€“ 8 pm) and the use of a custom non-REM sleep detector (explained in detail in Bernabei et al.48). The interictal data were at least 2Ā h before the beginning of a seizure and at least 2Ā h after a subclinical seizure, 6Ā h after a focal seizure and 12Ā h after a generalised seizure, free of spikes if possible and not within the first 72Ā h of recording to minimize immediate implant and anaesthesia effects. The details of the patients included in the analyses are provided in Supplementary Table 2. Epileptogenic zones/resected areas ranged from frontal, frontoparietal, mesiofrontal, temporal, mesiotemporal, parietal and insular areas.

Pre-processing

We used a 5-min signal from each interictal recording (10 min per patient) and a 58-s signal from each ictal recording (āˆ’ā€‰30 to +ā€‰28 s around the time of seizure onset). These windows were selected based on previous studies which analysed (20Ā s to 15Ā min of) interictal30,32,39 or (20ā€“60Ā s of) ictal10,38,42 data. Bad channels, as marked in the dataset, were excluded from analyses. An average of 105.6 contacts (stdā€‰=ā€‰38.04) per patient remained for analysis after bad channels were removed from the dataset. There was an average of 114.2 (stdā€‰=ā€‰41.2) and 88.8 (stdā€‰=ā€‰25.3) channels recorded in patients implanted with SEEG and ECoG, respectively. Among these, an average of 12.87% (stdā€‰=ā€‰11.1%) of channels were in the EZ/resected area in each patient. The sampling frequencies of the signals varied across patients and ranged from 256 to 1024Ā Hz. We adjusted the sampling rate of all datasets to 256Ā Hz across patients. We applied no filtering or artefact removal on the dataset. As the low- and high-frequency noise is shared across both groups of contacts, and as classifiers rely on the differences between classes rather than similarities49, we did not apply filters. Moreover, by not applying any filters, we allowed easier replication of results in future studies as any choice of filters can potentially affect the results in some way50.

Feature extraction

We quantified the signal patterns by extracting 34 mathematically distinct features. Features were extracted in 2s non-overlapping sliding windows along the interictal and ictal signals as in previous studies51,52,53,54. This led to 14 pre- and 14 post-seizure onset time windows in the ictal period excluding the last window. To quantify changes to neural activities upon seizure onset, we normalised the extracted post-seizure onset data by the pre-seizure onset data using:

$$Post\left( {window} \right) = \frac{{Post\left( {window} \right) - mean\left( {Pre} \right)}}{{mean\left( {Post} \right) + mean\left( {Pre} \right)}}$$
(1)

where \(Pre\) and \(Post\) refer to the arrays of 14 feature values extracted from neural data. This led to 14 normalised ictal feature values which were used for analysis. In interictal data, we down sampled the number of extracted feature samples (nā€‰~ā€‰150) to 28 samples using the Matlab ā€œresampleā€ function. This led to approximately equal number of data points in interictal and ictal windows, from 110 interictal and 204 ictal recordings. A range of simple to complex signal features were extracted. All these features have been previously used to quantify EEG patterns55,56,57 and the reader is referred to Supplementary Text 1 and the mentioned publications for details. Briefly, we extracted four categories of signal features to obtain a relatively comprehensive view of signal characteristics. These include the signal moment features, nonlinear complexity features, frequency-domain features and network-based features.

Multivariate pattern classification

We used a standard multivariate pattern classification procedure to localise EZ (i.e., to discriminate epileptogenic/resected and non-epileptogenic/non-resected contacts). We use the term ā€œepileptiformā€ patterns/activities in a general sense to refer to any patterns which discriminated epileptogenic and non-epileptogenic contacts. Accordingly, the classification performance indicates how discriminable were the signal patterns across these two sets of contacts. We quantified the classification performance by area-under-the-curve (AUC) to provide a comprehensive, threshold-free classification performance49. As in recent studies48,58, we used decision tree (DT) classifiers, and each contact was treated like an observation in classification. Our DT classifiers used a random forest algorithm with 50 bags of feature combinations. DT classifiers are well suited for nonlinear feature classifications and provide insights into feature contributions. This method also provides a ā€œfeature contributionā€ metric by permuting the observation/contact labels in each feature separately and quantifying its effect on performanceā€”contribution is in inverse proportion to performance drop. We performed three distinct types of classificationsā€”one within patient and time (non-generalisation) and two which involved generalisation either across time or patients. In all three analyses, we classified epileptogenic and non-epileptogenic contacts (i.e., EZ localisation). In the non-generalisation classification (Fig.Ā 1A), we performed the classification within the interictal and ictal time window separately for each patient using a tenfold cross-validation procedure. In the cross-time generalisation (Fig.Ā 2A), in each patient, we trained the classifier using the data from the two interictal recordings and tested the classifier using all the ictal recordings (meanā€‰=ā€‰3.7). In the cross-patient generalisation (Fig.Ā 3A), in each time window (interictal/ictal), we trained the classifier using the data from all patients minus one and tested the classifier using the data from the left-out patient and repeated this procedure until every patient was used once for testing the classifier.

Figure 1
figure 1

Classification of contacts with and without epileptogenic activities in each patient. (A) The classification scheme, which was performed separately for interictal and ictal data and repeated until the whole dataset (all contacts) were used in testing the classifiers. (B) Area Under Curve (AUC) of classification performance for interictal and ictal classifications. Box plots show the distribution of data, its quartiles and median and whiskers indicate the maximum and minimum of the data over patients. Each dot indicates the data from one patient. Numbers below the bars indicate Bayesian evidence for the difference between true and null classification performances. Horizontal dashed line refers to theoretical chance-level classification (0.5). Bayes factor reflecting evidence for the difference between interictal and ictal classifications are also shown. BFā€‰>>ā€‰10 indicates BFā€‰>ā€‰100. (C) Contribution of each feature to the classification performance shown in B, calculated using random permutation. Yellow, pink, green and purple dots indicate moment, complexity, frequency and network-based features. (D) Pearson correlation between interictal and ictal classification performances across patients with each dot showing one patient. (E) Pearson correlation between interictal and ictal feature contributions across features with each dot showing one feature. Correlation and the corresponding p values are shown on top of panel D and E with the slant line showing the best linear fit to the data.

Figure 2
figure 2

Classification of contacts with and without epileptogenic activities for each patient across time windows. (A) The classification scheme, which was performed separately for each patient. (B) AUC of cross-time generalisation performance for interictal-to-ictal and ictal-to-interictal generalisations. Box plots show the distribution of data, its quartiles and median and whiskers indicate the maximum and minimum of the data over patients. Each dot indicates the data from one patient. Numbers below the bars indicate Bayesian evidence for the difference between true and null generalisation performances. Horizontal dashed line refers to theoretical chance-level generalisation (0.5). Bayes factor reflecting evidence for the difference between interictal-to-ictal and ictal-to-interictal generalisations are shown. BFā€‰>>ā€‰10 indicates BFā€‰>ā€‰100. (C) Contribution of each feature to the generalisation performance shown in B, calculated using random permutation. Yellow, pink, green and purple dots indicate moment, complexity, frequency and network-based features. (D) Pearson linear correlation between interictal-to-ictal and ictal-to-interictal generalisation performances across patients with each dot showing one patient. (E) Pearson linear correlation between interictal-to-ictal and ictal-to-interictal feature contributions across features with each dot showing one feature. Correlation and the corresponding p values are shown on top of panel D and E with the slant line showing the best linear fit to the data.

Figure 3
figure 3

Classification of contacts with and without epileptogenic activities across patients. (A) The classification scheme, which was performed separately for interictal and ictal data and repeated until all patients were used for testing the classifiers. (B) AUC of cross-patient generalisation performance for interictal and ictal generalisations. Box plots show the distribution of data, its quartiles and median and whiskers indicate the maximum and minimum of the data over patients. Each dot indicates the data from one patient. Numbers below the bars indicate Bayesian evidence for the difference between true and null generalisation performances. Horizontal dashed line refers to theoretical chance-level generalisation (0.5). Bayes factor reflecting evidence for the difference between interictal and ictal generalisations are shown. BFā€‰>ā€‰ā€‰>ā€‰10 indicates BFā€‰>ā€‰100. (C) Contribution of each feature to the generalisation performance shown in B, calculated using random permutation. Yellow, pink, green and purple dots indicate moment, complexity, frequency and network-based features. (D) Pearson linear correlation between interictal and ictal generalisation performances across patients with each dot showing one patient. (E) Pearson linear correlation between interictal-to-ictal and ictal-to-interictal feature contributions across features with each dot showing one feature. Correlation and the corresponding p values are shown on top of panel D and E with the slant line showing the best linear fit to the data.

To equalise the number of epileptogenic to non-epileptogenic contacts (12.87% vs. 77.13% on average, respectively) which is essential for avoiding bias toward one class in classification49, we used a down-sampling procedure in our analyses and repeated every classification of data 1000 times before averaging the results.

To generate chance-level performances, against which we could evaluate the validity of our true classification performances, we shuffled (epileptogenic/non-epileptogenic) contact labels 1000 times and recalculated the classification performance leading to 1000 chance-level classification results.

Statistical analysis

We used a Bayes Factor analysis for statistical inference59. We compared the levels of AUCs against chance-level AUCs as well as evaluated main effects on classifications. We used standard rules of thumb for interpreting levels of evidence60,61: Bayes factors between 3 and 10 and between 1/10 and 1/3 were interpreted as evidence for the alternative and null hypotheses, respectively. Bayes factorsā€‰>ā€‰10 and <ā€‰1/10 were interpreted as significant evidence for the alternative and null hypotheses, respectively. We considered the Bayes factors which fell between 1/3 and 3 as insufficient evidence either way. Insufficient evidence means that no conclusions can be made about difference between a pair of variables.

To evaluate the evidence for the null and alternative hypotheses of at-chance and above-chance classification, respectively, we compared the classification rates in each analysis and the classification rates obtained from the chance-level classification results (e.g., panel A in Figs.Ā 1, 2, 3). For that, we performed an unpaired Bayes factor t-test for alternative (i.e., difference from chance; H1) and the null (i.e., no difference from chance; H0) hypotheses. To evaluate the evidence for the null and alternative hypotheses of difference between classification levels across analyses (e.g., Interictal vs. Ictal), we compared the classification rates obtained from each of those analyses using paired Bayes factor t-test. To evaluate the main effects of resection outcome, EZ, pathology (lesional/non-lesional) and type of recording (SEEG/ECoG), we used a Bayes factor ANOVA, with these four factors as independent variables and classification/generalisation AUC as the dependent variable. For statistical power in ANOVA, we excluded patients with insular, frontoparietal, parietal and mesiofrontal resection which were under-sampled (nā€‰<ā€‰3). The priors for all Bayes factor analyses were determined based on Jeffreyā€“Zellnerā€“Siow priors62,63 which are from the Cauchy distribution based on the effect size that is initially calculated in the algorithm using t-test59.

Results

We used a multivariate pattern analysis approach on features extracted from intracranial SEEG/ECoG data in patients with epilepsy to address two main questions. First, we wondered if there were similarities between the epileptiform patterns which discriminated epileptogenic from non-epileptogenic areas in interictal and ictal time windows. Second, we wondered how generalisable epileptiform patterns were across patients.

How discriminable are epileptogenic and non-epileptogenic contacts?

As an initial step in our analyses, we quantified the discriminability of epileptogenic and non-epileptogenic contacts. This was done for each patient and time window (interictal and ictal) separately (Fig.Ā 1A). There was significant evidence (BFā€‰>>ā€‰10) for above-chance AUC which averaged to 0.97 (stdā€‰=ā€‰0.03) in the interictal and 0.91 (stdā€‰=ā€‰0.07) in ictal time windows, respectively (Fig.Ā 1B). These showed that our multi-feature classification pipeline could robustly differentiate epileptogenic from non-epileptogenic contacts.

Interestingly, there was significant evidence (BFā€‰>>ā€‰10) for higher classification in the interictal than ictal time window (Fig.Ā 1B). While the classification performances were high across all patients (AUCā€‰>ā€‰0.8), there was no correlation (rā€‰=ā€‰āˆ’ā€‰0.17, pā€‰=ā€‰0.24; Pearson) between the level of AUCs in interictal and ictal time windows across patients (Fig.Ā 1D). This suggests that patients with the clearest separation between epileptogenic and non-epileptogenic contacts in interictal window did not necessarily show the clearest separation between those contacts in the ictal window and vice versa.

We then evaluated the contribution of each feature to the performance (Fig.Ā 1C). In interictal data, variance from the moment features, Hjorth mobility from the complexity features, beta-band power from the frequency features, and gamma-band coherence from the network features were among the most contributory features. In ictal data, variance from the moment features, approximate entropy from the complexity features, gamma-band power from the frequency features, and beta-band coherence from the network features were among the most contributory features. There was significant correlation between the featuresā€™ contributions across the two windows (rā€‰=ā€‰0.73, pā€‰<ā€‰0.01; Pearson; Fig.Ā 1E) suggesting that similar sets of features dominantly contributed to the EZ localisation across interictal and ictal time windows.

Next, we evaluated the effect of outcome, region of resection (EZ), pathology and recording type on the classification results in each window (Supplementary Fig.Ā 1). In the interictal data, there was evidence (1/10ā€‰<ā€‰BFā€‰<ā€‰1/3) against any effect of outcome, region of resection, pathology and recording type on classification results. In the ictal data, there was significant evidence (BFā€‰<ā€‰1/10) against any effect of outcome, evidence (3ā€‰<ā€‰BFā€‰<ā€‰10) for an effect of region of resection, insufficient evidence (1/3ā€‰<ā€‰BFā€‰<ā€‰3) for an effect of pathology and evidence (1/10ā€‰<ā€‰BFā€‰<ā€‰1/3) against any effect of recording type on classification results (Supplementary Fig.Ā 1). To check the direction of region of resection effect, we used Bayes-factor t-test which showed insufficient evidence (1ā€‰<ā€‰BFā€‰<ā€‰3) for higher classification in patients where the epileptogenic zone/resection was in temporal than frontal and mesiotemporal area (Supplementary Fig.Ā 1).

Our classifications used all signal features simultaneously. To check if any individual feature could predict the resection outcome, we performed a direct comparison (unpaired Bayes factor t-test) between feature contributions in patients who became seizure-free (Engel I) vs. not seizure-free (Engel II-IV) outcomes (Supplementary Fig.Ā 2). In interictal data, there was evidence (3ā€‰<ā€‰BFā€‰<ā€‰10) that signal median contributed to better EZ localisation in patients who became seizure-free vs. those who did not. However, as median was among the least contributory features overall (c.f., Fig.Ā 1C), we prefer not to put too much weight on this result. In ictal data, there was insufficient evidence (1/3ā€‰<ā€‰BFā€‰<ā€‰3) for any feature to predict resection outcome.

As our features relied on signal patterns which were relatively sustained, compared to transient patterns such as interictal spikes or HFOs, we wondered whether accurate classification was possible using even shorter time windows. To test this, we repeated the classifications using the earliest, the middle and the latest 2-s time window of data in interictal and ictal data separately. Interestingly, we found significant evidence (BFā€‰>>ā€‰10) for above-chance AUC in both interictal and ictal time, with significant evidence (BFā€‰>>ā€‰10) for higher classification in ictal than interictal data (Supplementary Fig.Ā 3). This repeated the pattern observed when using all windows of data in interictal and ictal periods (c.f., Fig.Ā 1B).

Do epileptiform patterns generalise across time windows?

We showed that a correlated set of features contributed to EZ localisation in both interictal and ictal windows (Fig.Ā 1E), which might point to shared neural mechanisms underlying signal patterns in both time windows. We wondered if we could localise the EZ in the ictal window based on patterns of interictal activities. To test this, we trained our classifiers on interictal data and tested them on ictal data for each patient separately (Fig.Ā 2A). We observed that, while the performance was lower (mean AUCā€‰=ā€‰0.60, stdā€‰=ā€‰0.1; Fig.Ā 2B) than those obtained by training and testing the classifiers within each time window separately (c.f., Fig.Ā 1B), there was still significant evidence for above-chance cross-time generalisation (interictal to ictal; BFā€‰>>ā€‰10).

Feature contribution results showed an advantage for variance from the moment features, Higuchi fractal dimension from the complexity features, delta-band power from the frequency features, and gamma-band coherence from network features (Fig.Ā 2C). There was evidence (1/10ā€‰<ā€‰BFā€‰<ā€‰1/3) against any effect of outcome, region of resection, pathology and insufficient evidence (1/3ā€‰<ā€‰BFā€‰<ā€‰3) for an effect of recording type on the cross-time generalisation results (Supplementary Fig.Ā 4).

Note that we only used two 5-min windows of interictal recording to train the classifiers, which is relatively short given usual large clinical datasets of interictal activities recorded over several days. The generalisation performance is predicted to improve with higher volumes and more varied sets of training data. To check if increasing the diversity of the training data could improve the generalisation performance, we trained the classifiers using the ictal data and tested them using the interictal data. This would provide the classifiers with a more diverse training set as ictal data were obtained from more recordings than interictal recordings (3.7 vs. 2). Numbers of observations were equalised between interictal and ictal time windows.

While there was significant evidence (BFā€‰>>ā€‰10) for above-chance generalisation performance when training on the ictal data, there was insufficient evidence (BFā€‰=ā€‰0.91) for higher cross-time generalisation when the training data was from the ictal than interictal time windows. Therefore, while a more diverse dataset seems to have improved the classification (shifted the mean AUC from 0.6 up to 0.63), more data is needed to establish an improvement effect. There was significant correlation (rā€‰=ā€‰0.60, pā€‰<ā€‰0.01, Pearson; Fig.Ā 2D) between the level of performance in interictal-to-ictal and ictal-to-interictal generalisations across patients. This shows that patients who showed the best generalisation from interictal to ictal windows also showed the highest generalisation in the opposite direction. This suggests that each patient has a certain level of similarity between interictal and ictal epileptiform patterns. There was significant correlation between the featuresā€™ contributions across the interictal-to-ictal and ictal-to-interictal generalisations (rā€‰=ā€‰0.56, pā€‰<ā€‰0.01; Pearson; Fig.Ā 2E) suggesting that generalisable epileptiform patterns were reflected in similar sets of features no matter if generalising from interictal to ictal or vice versa.

In interictal-to-ictal generalisation data, there was evidence or significant evidence (BFā€‰>ā€‰3) that features of Katz fractal dimension, energy ratio, theta-band power led to poorer EZ localisation in patients with seizure-free vs. not seizure-free outcome (Supplementary Fig.Ā 5). In ictal-to-interictal generalisation, this pattern was repeated for features of energy ratio and delta-band power. These suggest that specific features such as energy ratio might be more informative for EZ localisation when they show differences between their interictal and ictal patterns (i.e., as reflected in lower cross-time generalisability; Fig.Ā 2B). This might mean that, patients whose signalsā€™ energy ratio changes from interictal to ictal windows (e.g., through a significant increase) have a higher chance for their EZ to be localised; energy ratio change was indeed the basis for the original Epileptogenicity Index method13.

Do epileptiform patterns generalise across patients?

So far, our analyses focused on within-time classification of contacts and cross-time generalisation of classifications both done within each patient. A clinically important aspect is to ascertain the generalisability of epileptiform patterns across patients, and test the feasibility of using the data from previous patients to help localise the EZ in new out-of-sample patients. To test this, we trained classifiers on the data from all patients minus one and tested the classifiers on the data from the left-out patient (Fig.Ā 3A). This was done separately for interictal and ictal windows.

In interictal data, there was significant evidence (BFā€‰>ā€‰ā€‰>ā€‰10) for above chance cross-patient generalisation (Fig.Ā 3B), which suggests that there were interictal epileptiform patterns which had similarities across patients. We evaluated the featuresā€™ contribution to the generalisation (Fig.Ā 3C). Results showed an advantage for kurtosis from the moment features, Higuchi fractal dimension from the complexity features, beta-band power from the frequency features, and gamma-band coherence from the network features. There was significant evidence (BFā€‰<ā€‰1/10) against any effect of outcome, evidence (1/10ā€‰<ā€‰BFā€‰<ā€‰1/3) against any effect of region of resection, insufficient evidence (1/3ā€‰<ā€‰BFā€‰<ā€‰3) for an effect of pathology and significant evidence (BFā€‰>ā€‰10) for an effect of recording type on the cross-patient generalisation results (Supplementary Fig.Ā 6). There was significant evidence (BFā€‰=ā€‰12) for higher generalisation to test patients with resection in mesiotemporal than temporal and significant evidence (BFā€‰>>ā€‰10) for higher generalisation to test patients with SEEG than ECoG recording (Supplementary Fig.Ā 6).

In ictal data, there was significant evidence (BFā€‰>>ā€‰10) for above-chance cross-patient generalisation (Fig.Ā 3B) which suggests that there were ictal epileptiform patterns which had similarities across patients. Results showed the highest contribution to generalisation by skewness from the moment features (however very low compared to other features), Hjorth mobility from the complexity features, mean frequency from the frequency features, and gamma-band coherence from the network features. There was evidence (1/10ā€‰<ā€‰BFā€‰<ā€‰1/3) against any effect of outcome, insufficient evidence (1/3ā€‰<ā€‰BFā€‰<ā€‰3) for an effect of region of resection and pathology and significant evidence (BFā€‰>ā€‰10) for an effect of recording type on the cross-patient generalisation. There was significant evidence (BFā€‰>>ā€‰10) for higher generalisation to test patients with resection in mesiotemporal than temporal and significant evidence (BFā€‰>>ā€‰10) for higher generalisation to test patients with SEEG than ECoG recording (Supplementary Fig.Ā 6). In this cross-patient generalisation analysis, data from different modalities were included in the training and testing sets, which can obscure the pure effect of recording modality on cross-patient localisation performance. To address this, we re-ran the cross-patient generalisation analysis separately for SEEG (nā€‰=ā€‰35) and ECoG (nā€‰=ā€‰20) data. We observed similar results to Fig.Ā 3 showing a higher generalisability using ictal than interictal data, similar sets of informative features and no evidence for any effect of outcome, region of resection and pathology for either ECoG and SEEG modality (Supplementary Fig.Ā 7; there was evidence for an effect (BFā€‰=ā€‰3.4) of pathology on generalisation performance in interictal ECoG data which we could not do t-test for because of low sample size).

There was significant correlation (rā€‰=ā€‰0.73, pā€‰<ā€‰0.01; Pearson) between the level of generalisation in interictal and ictal time windows across patients (Fig.Ā 3D). This suggests that if a patientā€™s data (i.e., testing set) has similarities to the pool of other patientsā€™ data (i.e., training set), this will reflect in both interictal and ictal generalisations. On the other hand, patients with very distinct epileptiform activity patterns show this distinction across both interictal and ictal time windows. There was no correlation (rā€‰=ā€‰āˆ’ā€‰0.23, pā€‰=ā€‰0.19; Pearson) between informative features in the interictal and ictal time windows. This suggests that distinct sets of features contributed to cross-patient generalisation in interictal and ictal time windows.

In interictal data, there was significant evidence (BFā€‰>>ā€‰10; Bayes factor t-test) that approximate entropy led to better EZ localisation in patients who became seizure-free vs. those who did not (Supplementary Fig.Ā 8). In ictal data, there was evidence or significant evidence (BFā€‰>ā€‰3) that mean and median led to better EZ localisation in patients who became seizure-free vs. those who did not and median frequency led to the opposite pattern. As these were all among the least contributory features to the overall cross-patient generalisation performance we avoid over-interpreting them.

There was no correlation between the featuresā€™ contributions across the interictal and ictal generalisations (rā€‰=ā€‰āˆ’ā€‰0.23, pā€‰=ā€‰0.19; Pearson; Fig.Ā 3E) suggesting that generalisable epileptiform patterns were reflected in different sets of features when generalising interictal and ictal patterns.

Discussion

Precise localisation of epileptogenic zone has remained a challenging problem. It has recently been highlighted that data and code sharing are fundamental to moving computational epilepsy studies towards clinical translation11. The current work uses one of the few open-access SEEG/ECoG datasets which provides epochs of interictal and ictal activities with meticulous labelling of electrode contacts, resection volume and clinical information including surgical outcome46,48. Using a rigorous ML-based pipeline, our study shows the feasibility of establishing generalisability of patterns within individuals from interictal to ictal periods, and across individuals during both interictal and ictal time windows. These results make several contributions to EZ localisation, explained below.

First, to establish that our ML-based method could discriminate areas with and without epileptiform activities, we classified epileptogenic and non-epileptogenic areas (EZ localisation, based on clinician labelling of the dataset) within each patient and found significant differences between the two classes of areas. At the individual patient level, we observed a remarkable EZ localisation performance in the interictal time window, which counter-intuitively surpassed that obtained in the ictal time window. Therefore, while majority of available studies have been developed to localise EZ during the ictal time window13,14,15,16,17,18,19, this study finds significant information within the interictal signal that can be utilised for EZ localisation. It is important to note that our approach did not pre-select any specific feature (such as spikes, HFO) as biomarkers a priori, but rather analysed the ensemble of the neural signal over time, which appears to contain predictive information beyond these well-known features, even when analysing time-windows as short as 2 s (c.f., Supplementary Fig.Ā 3). This agrees with reports showing that interictal patterns are relatively stable over time36,40,64 (but also see65,66). We believe that the two factors of ā€œa large feature setā€ and the use of ā€œmultiple time windowsā€ in both interictal and ictal epochs contributed to achieving the observed remarkable localisation accuracy in both epochs. Specifically, because our pipeline used a large battery of features, it was able to use many distinct informative patterns within each 2-s time window even if the most informative and time-invariant pattern was not available in every given window. That is probably the reason behind not having a single feature dominating other features (Fig.Ā 1C). Also, by combining many time windows of data in analysis, we made our pipeline less sensitive to any specific time window, which is important specially in the ictal time window where patterns change rapidly.

While systematic comparison between interictal and ictal epileptiform patterns are rare in the literature, our result aligns with a surface EEG study in children with MRI-visible lesions which found better predictive value of interictal rather than ictal data67. We observed that the most informative features in interictal data included variance, beta-band power, correlation and gamma-band coherence, which in order support previous studies finding information in multiscale entropy in the gamma band28,30 (a complexity measure) and relative entropy34(a network measure). Interictal network studies have shown a gradient of within-area connectivity decreasing progressively from epileptogenic regions to propagation regions to non-involved zones39,41,54, providing a proxy for EZ localisation. The prominence of network measures in all of our analyses also aligns with a recent study showing greater information in network measures compared to univariate power-based measures in EZ localisation48. While we cannot perfectly equalise the interictal and ictal data for fair comparison, as there are systematic differences in their collection time, number of epochs and potential artefacts in ictal signals, these results provide valuable insights into the richness of interictal activity patterns for EZ localisation.

The remarkable classification performance observed especially in the interictal window (>ā€‰0.90; Fig.Ā 1B) supports the value of ML-based interictal localisation methods, which here used multiple features. While these features could have overlapped in their selectivity, they worked in synergy to detect as much non-overlapping information as possible. DT classifiers are good at combining distinct combinations of features to generate representational spaces in which classes can be separated. We also tested Support Vector Machine and Linear Discriminant Analysis classifiers, but both provided poorer classification. Our approach of using a range of simple-to-complex features is different from older localisation methods which used one main feature such as high-to-low frequency energy ratio13,16, and aligns with later studies which have combined several features for EZ localisation17,31,68,69, temporal detection of seizures70 and quantification of seizure severity71.

Second, we found predictive power in activity patterns of interictal data to localise EZ in the ictal period. While previous studies have localised EZ in interictal and ictal windows, the interictal-ictal correspondence has not been systematically investigated. In eleven patients with epilepsy who had been implanted with ECoG, one study found that the template of connectivity-based ictal epileptogenic areas could be helpful in informing the localisation of EZ interictally72. One recent study investigated the fine-grained timing and direction of interictal and ictal discharges using microelectrode grids, and suggested that interictal discharges are traveling waves that traverse the same path as seizure discharges73. After confirming a consistent temporal ordering of discharges in interictal and ictal windows, another study developed a novel source localisation method based on wave propagation, which successfully localised the EZ74. Our work evaluates the generalisability of a large battery of epileptiform features from interictal to ictal time windows and vice versa. The drop in cross-time generalisation performances (Fig.Ā 2B) compared to the non-generalisation analysis (c.f., Fig.Ā 1B) is supported by known differences in visualisable epileptogenic patterns from the interictal to the ictal time window75,76. In our study, the observed above-chance cross-time generalisation had not been necessarily predictable. It could be the case that epileptogenic areas would show higher value of a particular feature (e.g., power) than non-epileptogenic areas in the interictal window with this pattern flipping in the ictal window. This would have been detectable by our machine learning pipeline and would have been reflected in below-chance (AUCā€‰<ā€‰0.5) generalisation performance. The potential of using interictal recording to predict EZ localisation is significant because many patients have insufficient or sometimes no seizures during their one/two-week hospitalisation for EZ localisation. This is an important limitation for visual localisation of EZ based on electrical patterns during seizures and for training ML algorithms, which, like humans, need enough samples to learn and localise epileptiform patterns from the data.

The third contribution of this work is showing that, despite clear inter-subject differences, there were patterns of epileptiform activities which were shared across patients. Machine learning allowed us to train the classifiers using data from one set of patients and test the generalisability of patterns to the data from a new out-of-sample patient. While these performances were expectedly lower in the cross-patient generalisation than within-patient classification (Fig.Ā 3B vs. Fig.Ā 1B), this result is promising and informative. The decrease in performance can be explained by large differences across patientsā€™ data including epilepsy characteristics as well as distinct sampling of the brain, recording type, etc. Moreover, significant inter-subject differences may be present in terms of patient-specific epileptogenic ā€œsignaturesā€, the features of which are detectable across both interictal and ictal time windows for that individual77. On the other hand, a few studies showed that specific patterns can be generalised across patients, but only evaluated it in either interictal or ictal time window (Supplementary Table 1). A universal repertoire of seizure patterns across species has previously been observed, which suggests that some invariant properties characterise seizures under different physiological and pathological conditions78. Here, we showed that ictal epileptogenic patterns, especially those captured by complexity features, were more generalisable across subjects than interictal patterns. It is of note that as we only had enough patients with resection/ablation targets in frontal, mesiotemporal and temporal areas, the generalisability of epileptogenic patterns observed in other areas remains unclear and a question for future studies. The present results also showed that SEEG recordings provided advantageous generalisability compared to ECoG (Supplementary Fig.Ā 6). While the interpretation of this result needs further systematic investigations, potentially on larger datasets, one explanation for SEEGā€™s higher generalisation performance might be a more complete sampling of the brain in SEEG than ECoG 79 (average number of contacts is 115.2 (stdā€‰=ā€‰40.9) in SEEG vs. 88.8 (stdā€‰=ā€‰25.3) in ECoG) allowing for sampling of a wider range of brain structures with increasing chance of overlap across patients. These cross-patient generalisable patterns make it possible and desirable to use them on new out-of-sample data, to potentially build on these results by testing larger datasets. To facilitate future testing in novel datasets, we have shared our Matlab scripts.

One of the main concerns when using artificial intelligence in applications such as EZ localisation is the explainability of algorithms. Lack of knowledge about how a ML algorithm decides why a contact is classified as ā€œepileptogenicā€ makes the algorithm less trustworthy for clinicians80, who may not be able to validate if a specific feature of a signal is indicative of epileptogenicity or whether the algorithm is simply wrong. Methodologies incorporating explainable features can mitigate the explainability issue and provide complementary insights into the growing body of work in EZ localisation and seizure prediction, which tend to adopt unexplainable ML algorithms such as deep neural networks81,82. Every individual feature used in our work has clear mathematical definition and has been validated in previous quantification analysis of neural data55,56,83,84. We also quantified the contribution of each feature in our analyses, thus avoiding the ā€œblack boxā€ effect encountered when using algorithms such as deep neural networks. Accordingly, our proposed pipeline can be added as a primary feature extractor to prediction pipelines to make them more explainable to humans. It is of note that, while the mathematical definition of each of our features are clear, the neurophysiological correlates of these features needs to be sought for in the future.

There are several future directions which can facilitate the translation of this work to clinical practice. One can come through the improvement of the classification and generalisation performance. We used relatively short time windows of interictal (5-min windows) and ictal (1-min windows) data, both of which can be lengthened to potentially improve the classification performance. We did not apply any filtering or artefact removal, as ML classification algorithms are mainly sensitive to distinct patterns between classes (i.e., contacts with and without epileptiform patterns) rather than patterns which are common between classes (e.g., line noise). Nonetheless, one future direction would be to test if application of filters or artefact removal algorithms in the pre-processing stage can improve classification performance. It is of note that, like other supervised ML algorithms, our proposed method still relies on clinicianā€™s labelling of contacts (i.e., epileptogenic vs. non-epileptogenic). It is hoped that upon the collection of enough clinician-labelled datasets and training of machines, these supervised algorithms can make reliable predictions to help clinician decision-making around epilepsy surgery in the future. Rather than an optimised work, the current study was only a feasibility effort to establish the generalisability of patterns of activities across time within patients and within time across patients. Another future direction would be to test the generalisability of the classification pipeline to datasets from other centres, which have undergone meticulous clinical evaluation and labelling. Finally, it would be interesting to evaluate the generalisability of the proposed pipeline to non-invasive modalities such as scalp EEG and magnetoencephalography (MEG). As the features extracted here are not modality-specific and rely on characteristics of time series, these methods can be applied to sensor- or source-space E/MEG data. The generalisability of these methods to non-invasive modalities is significant because current gold-standard invasive methods of SEEG and ECoG suffer from incomplete or sub-optimal sampling of the brain, and in addition these invasive methods are only indicated in a subset of patients. Delineation of likely spatial extent of epileptogenic zones could in theory be optimised using rigorous localisation methods developed here in conjunction with non-invasive E/MEG recording modalities, especially in the interictal time window. This will provide a more objective and fully automatic method for the localisation of EZ than current methods which often rely on visual detection, manual annotation and operator-dependent analysis of epileptiform patterns85,86 which are prone to error87.

In conclusion, we showed that powerful classification patterns were embedded within the EEG signal, which could reliably differentiate epileptogenic from non-epileptogenic contacts in every individual. Such patterns could be identified in both interictal and ictal recordings through features such as signal variance, Hjorth mobility and complexity as well as high-frequency power and network features, without taking account of any predetermined figures such as spikes, HFO or known ictal patterns. There were also features that could correctly predict EZ in ictal recordings from interictal recordings. Again, high-frequency power and network features were the most contributory features here. Finally, we showed that, while there were differences between epileptiform patterns across patients suggesting subject-specific effects, we could localise the EZ with well above chance precision using interictal and more dominantly ictal activities. The proposed methods and results provide new evidence for generalisability of epileptiform patterns across time and patients and open new avenues for future methods developed for epileptogenic zone localisation. Clues from neural signal changes could also provide new directions for investigating the biological correlates of interictal88 and ictal89 epileptiform activity. Their explainable nature is important for further investigation of pathophysiologic underpinnings of these signal changes. This could help contribute to efforts to develop paradigm-shifting therapeutic possibilities in epilepsy including disease-modifying treatments90, as well as further refining network-based surgical treatments91, seizure forecasting92 and seizure detection93.

Data availability

The dataset used in this study was from previous studies and is available at https://openneuro.org/datasets/ds004100/versions/1.1.3. The code developed for this project is available at https://github.com/HamidKarimi-Rouzbahani/Intracranial_EEG_generalisation.