# The SWEC-ETHZ iEEG Database and Algorithms

## Long-term Dataset and Algorithms

### Dataset

In this study we included 116 seizures in 2656 hours of anonymized and continuous intracranial electroencephalography (iEEG) of 18 patients with pharmaco-resistant epilepsies who were evaluated for epilepsy surgery at the Sleep-Wake-Epilepsy-Center (SWEC) of the University Department of Neurology at the Inselspital Bern. All the patients gave written informed consent that their iEEG data might be used for research and teaching purposes. The decision on the necessity for iEEG recordings, the electrode implantation scheme, and the decision about surgical therapy was made entirely on clinical grounds. These decisions were taken prior to and completely independently from the compilation of this dataset.

#### iEEG Acquisition

The iEEG signals were recorded intracranially by strip, grid, and depth electrodes. After 16-bit analog-to-digital conversion, the iEEG signals were median-referenced and digitally band-pass filtered between 0.5 and 120 Hz using a fourth-order Butterworth filter prior to analysis and written onto disk at a rate of 512 or 1024 Hz. Forward and backward filtering was applied to minimize phase distortions. All the iEEG recordings were visually inspected by an EEG board-certified and experienced epileptologist (K.S.) for identification of seizure onsets and endings and exclusion of channels continuously corrupted by artifacts.

#### Data Format

The dataset is provided in 18 folders, named with the ID of the 18 patients (e.g., ID1). The continuous recoding of each patient is segmented to a set of .mat files, each of which contains exactly one hour of recording (e.g., ID01_1h.mat, ID01_2h.mat,…,ID01_294h.mat). Every file is less than 1 GB. In each .mat file, the recording is stored in a variable called EEG as a TxM array where T is the number of iEEG electrodes and M is the number of sampling points for one hour. The folder also contains an additional file (e.g., ID01_info.mat) defining the sampling frequency, beginning and end of the seizures (beginning and end of the seizures are computed in seconds).

### Algorithm

The main idea of our algorithm is to combine local binary patterns (LBP) with hyperdimensional (HD) computing followed by a patient-specific postprocessing. We called it Laelaps.

Main features of our algorithm:

• Fast learning from one or two seizure examples
• No false alarms over 1357 hours of testing
• Lower number of undetected seizures, false alarms (to zero), execution time, and energy consumption for classification on a TX2 embedded device compared to support vector machine (SVM), convolutional neural network (CNN), and long short-term memory recurrent neural network (LSTM).
• Scalable to all patients having 24 to 128 electrodes implanted

We provide the Python implementation of our algorithm. We used the Pytorch library with Python 2.7.12 to parallelize the code on a single Nvidia GeForce GTX 1080. For the baseline SVM, CNN, and LSTM algorithms we used the Scikilt-learn and Keras libraries.

Running a test : We run a sequence of scripts to obtain the results reported in our DATE 2019 paper.
Using Laelaps:

1. iEEG_HD_analysis_prediction.py file trains the HD classifier and performs the test on the non-trained part of the recording. You should set the GPU index (0 if the workstation has only one) and the patient ID in this file. Execution of this .py file generates a result file Total_period_randomiM in which different metrics are saved for all the duration of the recording. The intermediate result is also saved in the Laelaps folder (e.g., Laelaps/intermediate_results/Pat01/Total_period_randomiM)

2. smoothing.py file applies an average pooling to the results with kernel size=10x1 and stride=1. The intermediate result is saved in the Laelaps folder (e.g., Laelaps/intermediate_results/Pat01/Pred_rel_mean)

3. postprocess.py file applies the tc and the tr thresholds described in the paper to obtain the final classification. This script reports on the terminal the mean latency, the total number of errors and the sensitivity for the target patient.

Using baselines (LBP+SVM, STFT+CNN, LSTM):

1. SeizureDetectionSVM.py file trains the classifier and performs the test on all the seizures and on 20 hours randomly chosen from recording of all the patient. Execution of this .py file generates a result file where the predictions are saved.

2. PostprocessingSVM.py file applies an average pooling to the results with kernel size=10x1 and stride=1 and the tc thresholds described in the paper to obtain the final classification. This script plots the final classification for each window of the ictal/interictal segments.

#### Source Codes

• Our algorithm (Laelaps)
• Python code
• CUDA code
• OpenMP code
• Verilog code coming soon!
• Baseline algorithms (LBP+SVM, STFT+CNN, LSTM)

#### Dataset

• linux and mac users: wget -i longterm-files.txt
• windows users: e.g. using ‘uGet’ or a similar download manager and copy/pasting the list of files into it.

### Related Paper

A. Burrello, L. Cavigelli, K. Schindler, L. Benini, A. Rahimi, ‘‘Laelaps: An Energy-Efficient Seizure Detection Algorithm from Long-term Human iEEG Recordings without False Alarms’’ in proceedings of the ACM/IEEE Design, Automation, and Test in Europe Conference (DATE), Florence, Italy, March 25-29, 2019. Received Best Paper Nomination. [OpenAccess]

## Short-term Dataset and Algorithms

### Dataset

In this study, we included a total of 100 anonymized intracranially recorded electroencephalographic (iEEG) datasets of 16 patients with pharmaco-resistant epilepsy who were evaluated for epilepsy surgery at the Sleep-Wake-Epilepsy-Center (SWEC) of the University Department of Neurology at the Inselspital Bern. All the patients gave written informed consent that their iEEG data might be used for research purposes. The decision on the necessity for iEEG recordings, the electrode implantation scheme, and the decision about surgical therapy was made entirely on clinical grounds. These decisions were taken prior to and independently from the compilation of this dataset.

#### iEEG Acquisition

The iEEG signals were recorded intracranially by strip, grid, and depth electrodes. After 16-bit analog-to-digital conversion, the data were digitally band-pass filtered between 0.5 and 150 Hz using a fourth-order Butterworth filter prior to analysis and written onto disk at a rate of 512 Hz. Forward and backward filtering was applied to minimize phase distortions. All the iEEG recordings were visually inspected by an EEG board-certified experienced epileptologist (K.S.) for identification of seizure onsets and endings and exclusion of channels continuously corrupted by artifacts. Each recording consists of 3 minutes of preictal segments (i.e., immediately before the seizure onset), the ictal segment (ranging from 10 s to 1002 s), and 3 minutes of postictal time (i.e., immediately after seizure ending).

#### Data Format

The dataset is provided in 19 zipped folders (each file is less than 1 GB), named with the ID of the 16 patients (e.g., ID1.zip). Each unzipped folder contains a number of .mat files as recorded seizures (e.g., Sz1.mat, Sz2.mat, …) for the target patient. In each .mat file, the recording is stored in a variable called EEG as a TxM array where T is the number of sampling points and M is the number of iEEG electrodes. Seizure always starts at 3 minutes from the beginning of recording (i.e., the sampling point of 512*3*60=92160), and ends 3 minutes before the end of recording (i.e., sampling point of T-92160).

### Algorithm

The main idea of our algorithm is to combine local binary patterns (LBP) with hyperdimensional (HD) computing. We called it LBP+HD.

Main features of our algorithm:

• Fast learning from one or few seizure examples
• Superior sensitivity and specificity compared to feedforward multilayer perceptron (MLP) and support vector machine (SVM)
• End-to-end binary operations during both learning and classification (up to 13X lower memory)
• Scalable to all patients having 36 to 100 electrodes implanted

We provided the Python implementation of our algorithm. We used Pytorch library with Python 2.7.12 to parallelize the code on a single Nvidia GeForce GTX 1080. For the baseline SVM and MLP algorithms we used the Scikilt-learn library.

Running a test : We run a sequence of two scripts to obtain the results reported in our BioCAS 2018 paper. Using LBP+HD algorithm as an example:

1. iEEGClassifierLBP+HD.py file trains the HD classifier and performs the test on the non-trained recordings. You should set the GPU index (0 if the workstation has only one) and the patient ID in this file. Execution of this .py file generates different files for each combination of train-test seizure. For example, for a patient with 2 seizures, it produces 4 files as Train1Test1, Train1Test2, Train2Test1, Train2Test2.

2. HD_Postprocessing.py file applies the threshold to obtain the final classification. The value of the threshold and the patient ID should be set. The patient ID has to be equal for both scripts. This script reports on the terminal the mean latency, the specificity and the sensitivity for the target patient.

#### Source Codes

• Our algorithm (LBP+HD)
• Baseline algorithms (LBP+SVM, LGP+MLP)

### Related Paper

Alessio Burrello, Kaspar Schindler, Luca Benini, Abbas Rahimi, “One-shot Learning for iEEG Seizure Detection Using End-to-end Binary Operations: Local Binary Patterns with Hyperdimensional Computing,” in proceedings of the IEEE Biomedical Circuits and Systems Conference (BioCAS), Cleveland, OH, October 17-19, 2018. Received Best Paper Award. [OpenAccess]

## Legal Agreement

The source codes, datasets, and results on these sites are free of charge for research and education purposes only. Any commercial or military use is prohibited. All resources are provided without any expressed or implied warranty. In no event the authors of the article or any of their host institutions are liable for any damages arising from the use of the software, data or results.