looking for epileptic seizures

Example of different sections of the EEG signal before and after wavelet transformation (seizure)

Example of different sections of the EEG signal before and after wavelet transformation (seizure)

To apply the transformation, it is necessary to select a function on the basis of which the transformation itself will be built. The choice is made from a limited class of functions called wavelets. In the literature related to the analysis of the EEG signal and epileptic seizures, the main one chosen for use is the Complex Morlet wavelet . Having decided on the function to be used, we began to look for the best frequency range and function parameters: the central frequency (hereinafter C) and the bandwidth (hereinafter B).

Experiments

The same dataset was used to conduct the experiments. TUH EEG Security Corpus v2.0.0 and the same uniform sampling of 6 classes during training as in the article that was the reference in the first part of the article. Before talking about the results, it is worth talking about the preprocessing of the data.

Data processing

At the output of the wavelet transform, we get 20 matrices, since the EEG signal has 20 channels. Each matrix consists of complex numbers (due to our complex-valued wavelet). An example of what a matrix might look like is shown in the image below:

An example of the output from applying the wavelet transform to the EEG signal from the used dataset

An example of the output from applying the wavelet transform to the EEG signal from the used dataset

To use this data for classification, we concatenate all 20 matrices as follows: each matrix has size N \times Mand we concatenate them along the frequency axis, obtaining a final matrix of size (20 N) \times M. Then we break each complex number in this matrix into amplitude and phase, resulting in two new matrices – one with amplitudes and one with phases.

If we want the model to use only amplitudes, then we take the amplitude matrix. If we need to use both amplitudes and phases, then we concatenate both matrices, obtaining a new matrix of size (40N) \times M. A sequence of column vectors from this obtained matrix is ​​fed to the input of the model.

Also, due to the different magnitude of the response (the higher the frequency, the smaller the amplitude of the response in the matrix), we could apply standardization along the time axis of the matrix or logarithm to the amplitude.

It is also necessary to clarify the change in the frequency of the output signal. Signals with a frequency of 200 Hz are fed to the input of the wavelet transform. However, due to the large weight of the data obtained after the transformation, we are limited in using a high-frequency signal. Therefore, the output signal from the wavelet transform, which has the same frequency of 200 Hz, we transformed into a signal with a frequency of 10 Hz. The transformation occurred by averaging segments of 20 values ​​long.

Tests

Having explained how the vectors fed to the model input are formed, we can move on to the results. During the entire testing period, restrictions were imposed on all the required parameters:

  • Parameter C could be \pi, 2\pi And 4\pi;

  • Parameter B was selected 2;

  • The lower frequency range was chosen to be 1 Hz;

  • The upper frequency range was moved from 10 Hz to 100 Hz in 10 Hz steps;

  • The frequency resolution was chosen to be 32;

  • The frequencies were evenly distributed across the entire range.

Parameter C was chosen precisely within these limits, based on specialized literature, according to which C=2\pi — the most suitable frequency on average for EEG signal analysis. Due to the large number of tests, only those that gave the best result will be given.

At first, we took a simple model as a model, which consists of sequential blocks: Batch Norm, LSTM, Linear. Only amplitudes of complex numbers, to which standardization was applied, were fed into the model. The best result:

WITH

IN

High frequency

PR-AUC

ROC-AUC

Precision

Recall

\pi

2

80

0.18

0.72

0.16

0.42

Then came the idea to replace standardization with a logarithm. The best result:

WITH

IN

High frequency

PR-AUC

ROC-AUC

Precision

Recall

2\pi

2

80

0.25

0.86

0.18

0.74

Next we added the phase, but we did not use arctg in the calculation. The best result:

WITH

IN

High frequency

PR-AUC

ROC-AUC

Precision

Recall

\pi

2

50

0.33

0.88

0.29

0.59

As you can see, the “main” PR-AUC metric is steadily growing, but it is still fundamentally lower than what we achieved with the old approach. Therefore, we decided to try other RNNs: S4 and the new xLSTM.

S4 — is not a new model, but it represents a new trend in DL. S4 belongs to a family of linear RNNs, the most productive and popular representative of which is Mamba, and it was she who started the trend for this family of RNNs. S4 gave the best gain, but it can probably be even better, since we used an unofficial implementation and could not have chosen the hyperparameters optimally. The best result:

WITH

IN

High frequency

PR-AUC

ROC-AUC

Precision

Recall

2\pi

2

70

0.50

0.91

0.31

0.66

xLSTM — is the freshest and largest model we have tested. The model develops the idea of ​​the original LSTM and introduces transformer-like blocks into the architecture. With this model, we were able to obtain similar metrics, and this is probably not the limit, since the hyperparameters chosen are not the most optimal. The best result:

WITH

IN

High frequency

PR-AUC

ROC-AUC

Precision

Recall

\pi

2

50

0.46

0.90

0.34

0.63

However, even with the naked eye it is clear that any of these models lag behind even the results we obtained following the approach not based on wavelet transforms. It is quite possible that the difference between the results can be reduced, for example, if we try to add an encoder, which will also allow us to conduct tests at a higher frequency. However, the difference may remain, for example, if we use xLSTM instead of LSTM or improve the encoder, which clearly suffers from information loss, in the first approach described.

3. Conclusion

In conclusion, it can be noted that the study of the proposed approach is an interesting and important task. The use of various transformation methods and their adaptation to deep learning models opens up new opportunities for more accurate classification and analysis of signals. This area of ​​research is not only interesting, but also extremely relevant, since its development can lead to significant improvements in the diagnosis and monitoring of various neurophysiological conditions.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *