The Convolutional Kernel Density Estimation (CKDE) is a method that transforms EEG signals into images and applies a convolution filter to improve the visualization and automatic detection of pathological events such as interictal epileptic spikes (IESs). More details can be found in published scientific paper [L. Gardy et al., 2019] and in [doctoral thesis of L. Gardy].
With a time series as input, the algorithm performs the following steps:
- Transforms the timeseries into an image
- Convolves the non-null pixels of the image image, which represent the time series portion baiscally
- [Optional] Filters the convolved image to isolate epileptic spikes. Not included here because any basic filtering method will work like a low-pass filter, to isolate low density events, such as IEDs.
- Python 3.11
- Python libraries
pip install -r requirements.txt
### For the example, select the 5th event in the dataset
event_num = 5
### Get a timeseries filepath (look in the folder you have downloaded)
timeseries_folderpath = r"input_data\events_signal_data"
timeserie_filename = f"event_{event_num}.txt"
### Load a timeseries from the sample data provided with this program (1D)
signal = load_timeseries(timeseries_folderpath, timeserie_filename) # or,
#signal = random_signal_simulation()
### Get the timeseries info
meta_data = json.load(open(r"input_data\events_info.json"))
sfreq = meta_data["events_info"][event_num]["sampling_frequency"]
### Convert it to a 2D signal
image_2D = from_1D_to_2D(signal, bandwidth = 1)
### Convolve the 2D signal
image_2D_convolved = convolve_2D_image(image_2D, convolution = "gaussian custom")
### Plot summary
fig_name = "Epileptic spike (signal duration: 400 ms) \n\n[1] raw [2] imaged [3] convoluted"
plot_summary(signal, image_2D, image_2D_convolved, fig_name)
We propose some simulated data to validate our procedure with a known frequency, duration and position. This database is structured as shown in Figure 1. User can either use these data, use his own, or simulate some. A signal simulation function is also provided in the program.
Figure 2 shows how the convolved image (2D) is drawn from the raw signal (1D). A: Convolution process. B: Full process.
Figure 1. Input Data | Figure 2. CKDE workflow |
Figure 3 below, shows the result of the full process. The timeseries used as input is an IED called "event_5" in the data sample we provide with this program.
Gardy, L., Barbeau, E., and Hurter, C. (2020). Automatic detection of epileptic spikes in intracerebral eeg with convolutional kernel density estimation. In 4th International Conference on Human Computer Interaction Theory and Applications, pages 101–109. SCITEPRESS-Science and Technology Publications. https://doi.org/10.5220/0008877601010109
- LinkedIn: Ludovic Gardy
- Doctoral thesis: PDF