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)