 Research
 Open access
 Published:
Enhanced automatic sleep spindle detection: a sliding windowbased wavelet analysis and comparison using a proposal assessment method
Applied Informatics volumeÂ 3, ArticleÂ number:Â 11 (2016)
Abstract
Sleep spindles are thought to be related to some sleep diseases and play an important role in memory consolidation. They were traditionally identified by physiology experts based on rules and recently detected by automatic algorithms. However, many automatic approaches were validated on the different electroencephalogram (EEG) using various assessment methods, making it difficult to appraised a method objectively and fairly. In this paper, we proposed a sliding windowbased probability estimation (SWPE) method for sleep spindle detection. We performed a continuous wavelet transform with Mexican hat wavelet function, following by a sliding window to find out the candidate spindle points corresponding to the large wavelet coefficients at the frequencies of spindles and estimated their probabilities. To enhance the results, we used the envelope of the rectified signal to reject some false sleep spindle candidates. This was an enhanced method and we called it SWPEE in this paper. Finally, we compared our approaches with four approaches on the same public available EEG database, and the result showed the significative improvement of our proposed approaches.
Background
Sleep spindles are characteristic electroencephalogram (EEG) waves mainly observed during stage 2 nonrapid eye movement (NREM), but occasionally appearing in sleep stages 3 and 4 as well, as shown in Fig.Â 1. The sleep spindle is one of the few transient EEG events and is composed of a group of rhythmic waves with progressively increasing amplitude followed by a gradual decrease (De Gennaro and Ferrara 2003). Strictly speaking, a sleep spindle is a train of distinct waves with a frequency of 11â€“16Â Hz (most commonly 12â€“14Â Hz) (Berry etÂ al. 2012). Interestingly, the characteristics of sleep spindles, such as density, amplitude, or duration, vary substantially between individuals but are reasonably stable for each individual (Warby etÂ al. 2014; Tsanas and Clifford 2015).
Sleep spindles play an important role in clinical research. Sleep spindles are believed to be associated with synaptic plasticity, memory consolidation, and longterm storage of memory representations (Warby etÂ al. 2014). In clinical practice, several disorders, such as schizophrenia, autism, and sleep disorders, have been found to accompany a change in spindle density (Diekelmann and Born 2010). Thus, spindle detection is significant and may provide further guidance for clinical practice.
Traditionally, sleep spindles are identified by physiology experts, who rely on their experience to visually identify them. This approach is a very timeconsuming and difficult task; furthermore, different experts agree on only approximately 70% of the identifications of sleep spindles (Wendt etÂ al. 2012). In recent years, many researchers have proposed different approaches for detecting spindles. Generally, previous researchers either considered the raw signal as isolated sample points or epochs. SchÃ¶nwald etÂ al. (2003) applied a Gabor transforms to analyze EEG signals. Duman etÂ al. (2009) introduced a technology combining ShortTime Fourier Transform, Multiple Signal Classification, and the Teager Energy Operator to locate spindles. In addition, Wendt etÂ al. (2012) processed the signals from two channels with two equiripple lowpass filters and obtained individual envelopes. Though these approaches achieved a high level of performance, they only work on NREM data or require signals from multichannels, which is not flexible enough for practical application. Pattern recognition methods, such as neural network (Shimada etÂ al. 2000) and Bayesian classification (Babadi etÂ al. 2012), were also applied to develop automatic sleep spindle detection methods (Kabir etÂ al. 2015). However, the downside to these approaches is the required use of training data to generate a classifier for the analysis of subjects. Tsanas and Clifford (2015) developed two similar approaches based on the Morlet wavelet transforms and combined spindles with appropriate duration. However, to some extent, dividing the signal into fixedlength epochs or focusing on a sample point in isolation is not suitable for spindle detection.
Based on this point of view, we employed a sliding windowbased probability estimation (SWPE) method for sleep spindle detection, aiming to improve the performance of the spindle detection method. In our work, sample points were estimated in relation to their neighboring points. Moreover, we presented a novel assessment method to evaluate and compare the performance of the different approaches for detecting sleep spindles.
Materials and methods
In this section, we summarize the database we used in this work and then introduce our approach in two steps. Step 3 was the enhancement of our approach, using the envelope of the rectified signal. A suggested assessment method is also discussed at the end of this section.
Materials
The database in this work was obtained from the DREAM project (Devuyst etÂ al. 2011). The full database consisted of wholenight polysomnogram (PSG) recordings collected from eight subjects with different pathologies. PSG recordings usually included several bioelectricity signals but only the EEG signals were analyzed in our study. These recordings were sampled at different frequencies, namely 50, 100, or 200Â Hz. As described, a segment of 30Â min from the central EEG channel of each subject was extracted for spindles scoring, rather than analyzing the recording from the whole night. Two experts independently annotated the onset of sleep spindles in an effort order to make the annotations more reliable. However, one expert scored eight segments and provided the exact duration of spindles, while the other expert scored only six segments and set all of the durations to 1 second. The database can be accessed from http://www.tcts.fpms.ac.be/Â devuyst/Databases/DatabaseSpindles.
Methods
Step 1: Continuous wavelet transform with Mexican hat wavelet function
A signal is defined as nonstationary if its statistics (including mean, variance, and higherorder statistics) changed with time, so the EEG signals used in this study are nonstationary according to this definition. Many classical frequency analysis methods, such as the Fourier transform, will fail to capture the dynamics of the underlying events and are not appropriate for sleep spindle detection. ShortTime Fourier Transform (STFT) can be applied for nonstationary signal processing, but it uses an equal sized window for all ranges of frequency. This is a weakness when analyzing signals in multiresolution. In this paper, the Mexican hat wavelet transform was used to perform a timeâ€“frequency analysis, as shown in Fig.Â 2.
Mathematically, the Mexican hat wavelet is defined as the negative normalized second derivative of a Gaussian function,
where c is a constant for normalization and \(c=2\pi ^{1/4}/\sqrt{3}\).
Before analyzing the timeâ€“frequency characteristics, we calculated the power spectral density of the raw sleep EEG signals. The results showed that the amplitude of the signals generally decreased as the frequency increased, roughly fitting a negative power equation. Moreover, the most concentrated frequency band of the sleep EEG signal was below 10Â Hz. However, it has been introduced that the frequency band of a sleep spindle is predominantly between frequencies of 11â€“16Â Hz. Thus, the spindle would be submerged by the lowfrequency components, making spindle detection difficult. Based on this point of view, we focused on frequencies from 8â€“25Â Hz with a resolution of 0.2Â Hz in this paper. As a result, the signals were analyzed at 86 adjacent scales and a wavelet coefficient matrix with 86 rows was ultimately obtained.
Step 2: Sleep spindles identification with a sliding window
After obtaining the wavelet coefficient matrix, we employed a sliding windowbased method to estimate the sample points. To find out the candidate spindle points corresponding to large wavelet coefficients at the frequencies, we sorted the wavelet coefficients of each sample point in descending order and set the top 10% of the coefficients to 1 and the rest to 0. Here, 10% is an empirical value in our study.
A sliding window was then placed on the matrix, as shown by the red rectangle in Fig.Â 3. We denoted the width and height of the sliding window by row and col, separately. For a signal sampled at a frequency of f, the row will be \(0.1\times f\), while the col will be a constant value of 25 (representing a frequency band from 11 to 16Â Hz with a resolution of 0.2Â Hz). For instance, for signals sampled at 100Â Hz, the width of the sliding window will be 10 (10 = \(0.1\times 100\) ) and the height of the sliding window will be a constant value of 25. Additionally, a sample point was set to 1 only when the sum of its binary coefficients in the sliding window was in the top 10%. As a result, 90% of sample points will be set to 0 according to this rule. The raw EEG signal was represented by a binary signal.
In our study, the binary signal was used to generate sleep spindle candidates. For a binary signal b with a length of N, the probability that the sample point belongs to a spindle is estimated by
where \(b_i\) is a sample point of a binary signal b, f is the frequency of the raw signal, N is the length of the binary signal, and n is an empirical value equated to 0.1 in this paper.
Then, we used a threshold of 0.5 to determine sleep spindle points. A sleep spindle point can be regarded as a sample point from the whole sleep spindle in this paper.
Finally, the successive sleep spindle points were combined to generate the spindle candidates, with the constraint condition that the length of a spindle is between 0.4 and 1.6Â s.
Step 3: Enhancement with the envelope of the rectified signal
After generating the spindle candidates, we used the envelope of the rectified signal to remove the false spindle candidates. First, we used a filter with a pass band between 11 and 16Â Hz (the frequency band of sleep spindles) to obtain a rectified signal y(n), which can be expressed as follows:
where x(n) is the raw EEG signal and \(h_{1116}(n)\) is the impulse response of the filter. Then, we used a lowpass filter with a cutoff frequency of 2Â Hz to obtain the envelope of the rectified signal, which is expressed as follows:
where e(n) is the envelope of the rectified signal and \(h_{\mathrm{lowpass}}\) is the impulse response of the lowpass filter mentioned above.
The relationship between the envelope and the spindle candidates is illustrated in Fig.Â 4. It shows that most of the candidates are located at positions corresponding to the local maximums of the envelope. Therefore, we applied (6) to estimate the reliability of each sleep spindle candidate \(c_i\) and removed 10% of candidates with the lowest reliabilities.
where C is the number of candidates, \(c_i\) represents a single candidate, \(d_i\) and \(o_i\) are the duration and the onset of \(c_i\), respectively.
A suggested assessment method for evaluating the detection method
As discussed above, the first expert defined both the onsets and exact durations of the eight recordings, while the second expert only gave the onsets of the six recordings. Additionally, these annotations are not consistent, which caused researchers to have divergent views. For example, some researchers only considered the annotations from the first expert. Moreover, the criteria to evaluate the detection capabilities were quite different. Only considering the absolute difference between the detected spindle onset and the spindle onset determined by the experts (Tsanas and Clifford 2015) or only considering the overlap of the spindles (Causa etÂ al. 2010) are both inappropriate in fact. In this study, we suggested comparing the center offset between the detected spindle and the spindle determined by the experts. We regarded the detected spindle as correct if the absolute difference between these two centers is <0.5Â s.
To evaluate the performance of an algorithm, the precision (also known as positive predictive value) and the recall (also known as sensitivity) are usually used. However, the sensitivityâ€“specificity metric was commonly used in the previous researches, so we cautiously include them in this paper. The metrics involved in our study are defined as follows:

1.
Sensitivity: This metric is also known as recall, and it measures the proportion of sleep spindles correctly identified by an automatic method. We want the sensitivity (or recall) to be high or even equal to 100%:
$$\begin{aligned} \begin{array}{lll} {\text {sensitivity}} = \frac{{\text {TP}}}{{\text {TP}}+{\text {FN}}} \end{array} \end{aligned}.$$(7) 
2.
Specificity: This metric measures the proportion of nonspindles correctly identified by an automatic method. We want the specificity to be high or even equal to 100%:
$$\begin{aligned} \begin{array}{lll} {\text {specificity}} = \frac{{\text {TN}}}{{\text {TN}}+{\text {FP}}} \end{array} \end{aligned}.$$(8) 
3.
False Discovery Rate (FDR): This metric measures the proportion of wrong detection results. Ideally, we want FDR to be 0:
$$\begin{aligned} \begin{array}{lll} {\text {FDR}} = \frac{{\text {TP}}}{{\text {TN}}+{\text {FP}}} \end{array} \end{aligned}$$(9)$$\begin{aligned} \begin{array}{lll} {\text {precision}} = \frac{{\text {TP}}}{{\text {TN}}+{\text {FP}}} = 1{\text {FDR}} \end{array} \end{aligned}.$$(10) 
4.
F1score: The F1score can be used as a single measure of the performance of an algorithm. It is the harmonic mean of precision and recall that introduced to measure the overall performance of an approach:
$$\begin{aligned} \begin{array}{lll} {\text {score}}= 2 \times \frac{{\text {precision}} \times {\text {recall}}}{{\text {precision}} + {\text {recall}}} \end{array} \end{aligned}.$$(11)
Results and discussion
In our study, we compared our approach with four different approaches denoted by A1, A2, A3, and A4. A1 was proposed by Ferrarelli etÂ al. (2007), A2 was proposed by Wendt etÂ al. (2012), and A3 and A4 were successively proposed by Tsanas and Clifford (2015). The results are shown in TablesÂ 1, 2, 3, 4, and 5, with the best performing approach for each case highlighted in italic.
When comparing these six methods, we can see that none of these methods has absolute superiority in sensitivity, specificity, and FDR. Although the forth approach (A4) performed best in relation to sensitivity, its specificity was much lower than our proposed approach SWPE. The first approach (A1) has a high value on specificity but its performance in sensitivity is very poor. Among these methods, our approach SWPE has distinct advantages in FDR.
The F1score is a harmonic mean of precision and recall, which is usually applied as a single measure of a detector, especially in retrieval work. Therefore, the F1score was employed to measure the overall performance of an algorithm in this paper. We can see that the F1score of our approach, SWPEE, was significantly higher than the other approaches, as shown in Fig.Â 5.
When comparing the approach SWPE and the enhanced method SWPEE, we can see that SWPEE has a lower FDR because it rejected some false candidates.
Conclusions
This paper proposes a novel approach for automatic detection of sleep spindles and introduced a method for comparing the performance of different detection methods. Our approach relied on only one single EEG channel and does not need the specified NREM stage signals for detection. We performed a continuous wavelet transform following by a sliding window to find out the candidate spindle points corresponding to the large wavelet coefficients at the frequencies of spindles. We estimated their probabilities with neighboring sample points. Finally, we compared our detection method with four other approaches using a novel assessment method based on the center offset, and the results showed that our detection method performed significantly better than the other methods.
References
Babadi B, McKinney S, Tarokh V, Ellenbogen J (2012) A datadriven Bayesian algorithm for sleep spindle detection. In: SLEEP, vol. 35, pp. 134â€“134 (2012). AMER ACAD SLEEP MEDICINE ONE WESTBROOK CORPORATE CTR, STE 920, WESTCHESTER, IL 60154 USA
Berry RB, Brooks R, Gamaldo CE, Harding SM, Marcus C, Vaughn B (2012) The AASM manual for the scoring of sleep and associated events: rules terminology and technical specifications. American Academy of Sleep Medicine, Darien
Causa L, Held CM, Causa J, EstÃ©vez PA, Perez CA, Chamorro R, Garrido M, AlgarÃn C, Peirano P (2010) Automated sleepspindle detection in healthy children polysomnograms. IEEE Trans Biomed Eng 57(9):2135â€“2146
De Gennaro L, Ferrara M (2003) Sleep spindles: an overview. Sleep Med Rev 7(5):423â€“440
Devuyst S, Dutoit T, Stenuit P, Kerkhofs M (2011) Automatic sleep spindles detectionoverview and development of a standard proposal assessment method. In: 2011 Annual international conference of the IEEE engineering in medicine and biology society, pp. 1713â€“1716. IEEE
Diekelmann S, Born J (2010) The memory function of sleep. Nat Rev Neurosci 11(2):114â€“126
Duman F, Erdamar A, Erogul O, Telatar Z, Yetkin S (2009) Efficient sleep spindle detection algorithm with decision tree. Expert Syst Appl 36(6):9980â€“9985
Ferrarelli F, Huber R, Peterson MJ, Massimini M, Murphy M, Riedner BA, Watson A, Bria P, Tononi G (2007) Reduced sleep spindle activity in schizophrenia patients. Am J Psychiatry 164(3):483â€“492
Kabir MM, Tafreshi R, Boivin DB, Haddad N (2015) Enhanced automated sleep spindle detection algorithm based on synchrosqueezing. Med Biol Eng Comput 53(7):635â€“644
SchÃ¶nwald SV, Gerhardt GJ, Emerson L, Chaves ML (2003) Characteristics of human EEG sleep spindles assessed by gabor transform. Phys A Stat Mech Appl 327(1):180â€“184
Shimada T, Shiina T, Saito Y (2000) Detection of characteristic waves of sleep eeg by neural network analysis. IEEE Trans Biomed Eng 47(3):369â€“379
Tsanas A, Clifford GD (2015) Stageindependent, single lead eeg sleep spindle detection using the continuous wavelet transform and local weighted smoothing. Front Hum Neurosci 9:181
Warby SC, Wendt SL, Welinder P, Munk EG, Carrillo O, Sorensen HB, Jennum P, Peppard PE, Perona P, Mignot E (2014) Sleepspindle detection: crowdsourcing and evaluating performance of experts, nonexperts and automated methods. Nat Methods 11(4):385â€“392
Wendt SL, Christensen JA, Kempfner J, Leonthin HL, Jennum P, Sorensen HB (2012) Validation of a novel automatic sleep spindle detector with high performance during sleep in middle aged subjects. In: 2012 Annual international conference of the IEEE engineering in medicine and biology society, pp. 4250â€“4253. IEEE
Authorsâ€™ contributions
XZ, NP and YL participated in the design of the study, performed in the data analysis, and drafted the manuscript. All authors read and approved the final manuscript.
Acknowledgements
This work was supported by the National Key Basic Research Program of China (973 Program) under Grant 2015CB351703, the National Natural Science Foundation of China under Grants 61633010, 91420302, and 61573150, and Guangdong Natural Science Foundation under Grant 2014A030312005.
Competing interests
The authors declare that they have no competing interests.
Author information
Authors and Affiliations
Corresponding author
Rights and permissions
Open Access This article is distributed under the terms of the Creative Commons Attribution 4.0 International License (http://creativecommons.org/licenses/by/4.0/), which permits unrestricted use, distribution, and reproduction in any medium, provided you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons license, and indicate if changes were made.
About this article
Cite this article
Zhuang, X., Li, Y. & Peng, N. Enhanced automatic sleep spindle detection: a sliding windowbased wavelet analysis and comparison using a proposal assessment method. Appl Inform 3, 11 (2016). https://doi.org/10.1186/s4053501600279
Received:
Accepted:
Published:
DOI: https://doi.org/10.1186/s4053501600279