Method of automated epileptiform seizures and sleep spindles detection in the wavelet spectrogram of rats' EEG I.A. Kershner1, Yu.V. Obukhov1, I.G. Komoltsev2 1 Kotel'nikov Institute of Radio Engineering and Electronics of RAS, Mokhovaya 11-7, 125009, Moscow, Russia 2 Institute of Higher Nervous Activity and Neurophysiology of RAS, Butlerova 5A, 117485,Moscow, Russia Abstract A method and algorithm for automatic detection of epileptiform seizures, sleep spindles, and other high voltage rhythmic activity were developed. They based on the analysis of the ridges of EEG wavelet-transformation. The uninformative points of the ridge are removed adaptively on the basis of power spectral density histograms analysis. Keywords: Traumatic brain injury; EEG; Wavelet; Spectrogram; Ridges; Epileptiform seizures; Sleep spindles; Event detection 1. Introduction The study of long-term electroencephalographic (EEG) signals of patients who have suffered from traumatic brain injury (TBI) to detect markers of posttraumatic epilepsy (PE) [1] is an unsolved issue. Immediate and early seizures within the first week after PTI are important risk factors for appearance of late convulsive seizures, which are a manifestation of PE. Early seizures are associated with brain damage, while late ones are associated with the processes of restructuring the neuronal connections and many other changes called epileptogenesis. Late convulsive seizures can develop months or even years after TBI, as epileptogenesis proceeds extremely slowly and asymptomatically. At the moment there are no clear EEG criteria for this pathological process. Therefore, the detection of biomarkers of PE in the acute period of TBI is of great importance for timely diagnosis, as well as researches of new methods of preventing epilepsy. In the study of neurobiological mechanisms of epileptogenesis, animal models (rats) are widely used. The most adequate of these is the model of posttraumatic epilepsy caused by injury, resulting from lateral fluid percussion (LFP) [2,3]. The first unprovoked seizures in rats occur months after the injury. The appearance of epileptiform activity in the EEG signals in the early post-traumatic period (first week) can serve as a predictor of the PE development. For the detailed characterization of the early post-traumatic period, it becomes necessary to automatically detect epileptiform discharges (ED) in long-term (day, week) EEG records. In recent years, much attention has been paid to the automatic detection of epileptiform discharges in patients with confirmed diagnosis of epilepsy. This is due to several reasons. Among them: the need to predict the emergence of seizures in order to prevent them by use electrostimulation, difficulties in processing long-term EEG recordings, the need to classify the forms of epilepsy, and a number of other reasons [4]. A review of the works on automatic epileptic seizures detection is presented in [5, 6]. In [5], the EEG signal is decomposed into empirical modes, for which the standard deviation, the asymmetry coefficients and the kurtosis are calculated. These parameters were entered in the learning machine. Then the part of the signal is classified as a seizure activity or background activity. This method does not give knowledge about the threshold criteria by which epileptic discharges differ both from background activity and from other high-amplitude activity in the EEG signal (hereinafter we will call such activity an event). In [6], the parameters for the seizure classification are skewness and kurtosis coefficients, the Fourier peak frequency of the spectrum, the median of the frequency, entropy, correlation dimension, and variance of the EEG signals. However, as in [5], epileptic discharge is distinguished from the background activity, but other high-amplitude events present in the signal were not considered. In [7] studied sleep spindles (SS). To detect them, a method based on the analysis of the wavelet transform was used. The calculation of the mean value over the time-frequency rectangles of the instantaneous energy of the wavelet transform was carried out. After that, in comparison with the parameters inherent in EEG signal background activity, the conclusion was made whether this event is a sleep spindle or not. This method does not consider the presence in the EEG signals of such high-energy activity as epileptiform discharges. Although in works [8-10] it is said about the possibility of transformation the sleep spindle into the peak wave’s discharge. In long-term EEG records (day, week), in addition to epileptiform discharges, there are other high-energy activities that differ from the background EEG signal, such as sleep spindles. SS, as well as ED, belong to the group of high-amplitude brain rhythmic electrical activity. In humans and animals with absence epilepsy, the frequency range of SS and ED ranges from one to fifteen Hz [7,11-16]. 3rd International conference β€œInformation Technology and Nanotechnology 2017” 104 Image Processing, Geoinformation Technology and Information Security / I.A. Kershner, Yu.V. Obukhov, I.G. Komoltsev Automatic detection of sleep spindles and epileptiform discharges in the early post-traumatic period, in which the mechanisms of the occurrence of epileptiform activity differ from those that occur in epilepsy, is an unresolved task. As in [13-16], in order to investigate the time-frequency dynamics of the EEG, we use the ridges of the Morlet wavelet transform. However, in contrast to these works, when the beginning of epileptiform discharges was set by the expert manually, in this article we describe the method of automatically finding the beginning and end of high-amplitude activity, and calculating its parameters. 2. The method of automatic detection of events containing high-amplitude rhythmic activity Long-term EEG records represent a large array of ~ 10 8 numeric data. Typically, the EEG is measured at a sampling rate of 250 Hz. EEG signals were divided into 10-minute intervals, as there is a limit to the amount of data that can be processed in the Matlab. To remove linear trends, power supply noise and low-frequency noise, daily fragments of EEG records were filtered by a 16th-order Butterworth discrete filter with a bandwidth ranging from 2 Hz to 30 Hz. The bandwidth of the filter exceeds the frequency range typical for ED and SS. The signal is filtered in two stages. At the first stage, synthesis of 8th order discrete bandpass filter with a bandwidth ranging from 2 Hz to 30 Hz was realized by using function "butter". As a result, the transfer function H in decreasing order of powers of the variable z was obtained: βˆ‘π‘›+1 𝑖=1 𝑏(𝑖)βˆ—π‘§ 1βˆ’π‘– 𝐻(𝑧) = (1) 1+βˆ‘π‘›+1 𝑖=2 βˆ—π‘§ 1βˆ’π‘– Where n = 8 is the order of the filter. In the second stage, the phase shift was compensated. By means of the "filtfilt" function, discrete filtering using the Fast Fourier Transform (FFT) is implemented in conjunction with the division of the signal into blocks. The signal is filtered from the beginning of record to its end, then obtained signal is filtered a second time - from the end to the beginning. Thus, the phase shifts were compensated, and the resulting filter order was doubled: n = 16. The result of filtration of 10-minute signal fragment is shown in Fig. 1. Fig. 1. 10 minute signal fragment after filtration. The sampling frequency is 250 Hz. The automatic detection method of high-amplitude brain rhythmic electrical activity is based on the analysis of wavelet spectrogram ridges [17]. To calculate the wavelet spectrograms, a complex Morlet wavelet transform was used (2): 1 π‘‘βˆ’πœ π‘Š(𝜏, 𝑓) = ∫ π‘₯(𝑑) βˆ— πœ“( )𝑑𝑑 (2) βˆšπ‘“ 𝑓 In the formula (2) x(t) refers to the source signal, and ψ(Ξ·) refers to the Morlet mother function: πœ‚2 1 βˆ’ πœ“(πœ‚) = 𝑒 2π‘–πœ‹πΉπ‘ πœ‚ 𝑒 𝐹𝑏 (3) βˆšπœ‹πΉπ‘ The coefficients Fb = Fc = 1. The power spectrum density (PSD) of a time-frequency signal is calculated according to function (4): 𝑆π‘₯ = |π‘Š(𝜏, 𝑓)|2 (4) The ridge consists of the points y(i) with the maximum values of the power spectral density in each time count of the wavelet- spectrogram: 𝑦(𝑖) = π‘šπ‘Žπ‘₯π‘“βˆˆ(2βˆ’20 𝐻𝑧) (𝑆π‘₯ (πœπ‘– , 𝑓)) (5) Usually, the neurophysiologist examines long-term EEG recordings, in which he extracts fragments with high-amplitude activity and, in his experience, classifies them into sleep spindles or epileptiform discharges. Fig. 2 shows examples of wavelet spectrograms of rat EEG signals the day after TBI with ED and SS and their ridges y(i). The entire 10-minute time interval has both interesting events for us and background activity. Therefore, to extract the points of ridges corresponding to SS or ED, it is necessary to delete the ridge points corresponding to the background. Fig. 3 shows wavelet-spectrogram ridge of a 10-minute rat EEG signal. 3rd International conference β€œInformation Technology and Nanotechnology 2017” 105 Image Processing, Geoinformation Technology and Information Security / I.A. Kershner, Yu.V. Obukhov, I.G. Komoltsev Fig. 2. Wavelet spectrograms and their ridges of rat EEG signal the day after the traumatic brain injury. To the left is ED and to the right is SS. Fig. 3. Wavelet-spectrogram ridge of a 10-minute rat EEG signal. SS and ED are characterized by an increased value of the spectral power density (PSD) as compared to the background. To select a positive ridge background clipping threshold Tr > 0, a histogram of the PSD at the points of the ridge is analyzed (Fig. 4). In the histogram, the PSD values are divided into 100 equal intervals. Fig. 4. One hundred interval PSD histogram at the ridge points of wavelet-spectrogram (10-minute record). To calculate the histogram, the function "hist" was used. One of the output arguments of this function is an array of 100 PSD values. Each PSD value from this array was considered as a threshold Tr. The ridge points y(i) y(k), then the point k is considered the beginning of the event, otherwise the left shift along the ridge of the wavelet spectrogram continues until a local minimum is reached. A similar operation was done to calculate the end of the event, only the advance along the ridge was made to the right. Fig. 6 shows a 10-minute fragment of a filtered rat EEG signal with isolated high-amplitude events on it, and on wavelet- spectrogram ridge of this signal. Fig. 6. Top image is 10 minute fragment of the filtered rat EEG signal with highlighted high-amplitude events (black lines). The middle figure is the ridge of the wavelet-spectrogram of this signal in the projection on the axis of the PSD-time with the selected events. The bottom figure is the events highlighted by the expert. Fragments of a signal with epileptiform discharges are of immense importance in the study of PE. But they may not have such high amplitude, as, for example, in the time interval from 0 seconds to 200 seconds or from 440 seconds to 600 seconds (Fig.6.). Consider the minute section of the current 10-minute recording, at which the expert detected a discharge with smaller amplitude than the other events (Fig. 7). The presence of such events makes the detection process more difficult. Fig. 7. Top image is minute fragment of the filtered rat EEG signal with highlighted high-amplitude events (black lines). The middle figure is the ridge of the wavelet-spectrogram of this signal in the projection on the axis of the PSD-time with the selected events. The bottom figure is the events highlighted by the expert. The epileptiform discharge is in the time interval from 390 seconds to 395 seconds. As can be seen from Fig. 7, this method allows identifying regions with epileptiform discharges, but also other events are detected. Additional conditions for the selection of high-amplitude events were given by expert-neurophysiologist. If there is a time delay between two events of not more than 1/7 second, then these two events are considered as one. Also, events longer than 0.5 3rd International conference β€œInformation Technology and Nanotechnology 2017” 107 Image Processing, Geoinformation Technology and Information Security / I.A. Kershner, Yu.V. Obukhov, I.G. Komoltsev seconds were considered uninformative and were removed from consideration. In Fig. 8 shows the result of reliable events, taking into account the conditions set by the expert. Fig. 8. Top image is minute fragment of the filtered rat EEG signal with highlighted high-amplitude events (black lines). The middle figure is the ridge of the wavelet-spectrogram of this signal in the projection on the axis of the PSD-time with the selected events. The bottom figure is the events highlighted by the expert. The calculated areas are different from the background, but need further classification. They can contain both carotid spindles, epileptiform discharges, and other high-amplitude activity, which neurophysiologists have not detected. Beginning, end, duration, minimum, maximum and average value of frequencies, maximum PSD value were calculated for each event. After analyzing these parameters, events will be classified as epileptiform discharges, or as high-amplitude activity that are not ED. 3. Conclusion The paper describes a method for automatic detection of high-amplitude rhythmic activity, based on the analysis of wavelet- spectrogram ridges. As a result of algorithm work, areas with high amplitude rhythmic activity on the electroencephalogram were allocated. Also, the parameters of the allocated parts of signal were calculated. With the help of this method, all epileptiform activity found by the expert, as well as sleep spindles and other high-amplitude activity. This method allows collecting a large group of events that will permit the classification of epileptiform discharges not only with background activity, but also with other events. Acknowledgements This research was done at the expense of the grant of the Russian Science Foundation (project 16-11-10258). References [1] Annegers JF, Hauser WA, Coan SP, Rocca WA. A population-based study of seizures after traumatic brain injuries. NEJM 1998; 338: 20–24. [2] Pitkanen A, Immonen RJ, Grohn OHJ, Kharatishvili I. From traumatic brain injury to posttraumatic epilepsy: what animal models tell us about the process and treatment options. Epilepsia 2009; 50: 21–29. [3] Kabadi SV, Hilton GD, Stoica BA, Zapple DN, Faden AI. Fluid-percussion-induced traumatic brain injury model in rats. Nature Protocols 2010; 5(9): 1552– 1563. [4] Hopfengartner R, Kasper BS, Graf W. Automatic seizure detection in long-term scalp EEG using an adaptive thresholding technique: a validation study for clinical routine. Clinical Neurophysiology 2014; 125(7): 1346–1352. [5] Divya S, Priyadharsini SS. Classification of EEG Signal for Epileptic Seizure Detectionusing EMD and ELM. International journal for trends in engineering & technology 2015; 3(2): 68–74. [6] Fergus P, Hignett D, Hussain A, Al-Jumeily D, Abdel-Aziz K. Automatic Epileptic Seizure Detection Using Scalp EEG and Advanced Artificial Intelligence Techniques. BioMed research international, 2015. [7] Sitnikova EY, Grubov VV, Khramov AE, Koronovskii AA. Developmental changes in the frequency-time structure of sleep spindles on the EEG in rats with a genetic predisposition to absence epilepsy (WAG/Rij). Neuroscience and Behavioral Physiology 2014; 44(3): 301–309. [8] Gloor P. Generalized cortico-reticular epilepsies: some considerations on the pathophysiology of generalized bilaterally synchronous spike and wave discharge. Epilepsia 1968; 9(3): 249–263. [9] Gloor P. Generalized epilepsy with bilateral synchronous spike and wave discharge. New findings concerning its physiological mechanisms. Electroencephalography and Clinical Neurophysiology. Supplement 1978; 34: 245–249. [10] Kostopoulos GK. Spike-and-wave discharges of absence seizures as a transformation of sleep spindles: the continuing development of a hypothesis. Clinical Neurophysiology 2000; 111: 27–38. [11] Jankel WR, Niedermeyer E. Sleep spindles. Journal of clinical neurophysiology 1985; 2(1): 1–36. [12] Jobert M. Topographical analysis of sleep spindle activity. Neuropsy-chobiology 1992; 26(4): 210–217. 3rd International conference β€œInformation Technology and Nanotechnology 2017” 108 Image Processing, Geoinformation Technology and Information Security / I.A. Kershner, Yu.V. Obukhov, I.G. Komoltsev [13] Gabova AV, Bosnyakova DY, Bosnyakov MS, Shatskova AB, Kuznetsova GD. The Time–Frequency Structure of the Spike–Wave Discharges in Genetic Absence Epilepsy. Doklady Biological Sciences. Kluwer Academic Publishers-Plenum Publishers 2004; 396(1-6): 194–197. [14] Bosnyakova DYu, Obukhov YuV. Extraction of dominant feature in biomedical signals. Pattern Recognition and Image Analysis 2005; 15(3): 513–515. [15] Bosnyakova D, Gabova A, Kuznetsova G. Time–frequency analysis of spike-wave discharges using a modified wavelet transform. Journal of neuroscience methods 2006; 154(1): 80–88. [16] Bosnyakova D, Gabova A, Zharikova A. Some peculiarities of time-frequency dynamics of spike-wave discharges in human and rat. Clinical Neurophysiology 2007; 118(8): 1736–1743. [17] Malla S. Wavelets in Signal Processing. Moscow: Mir, 2005; 671 p. (in Russian) 3rd International conference β€œInformation Technology and Nanotechnology 2017” 109