Skip to main content

Enhanced automatic sleep spindle detection: a sliding window-based wavelet analysis and comparison using a proposal assessment method

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 window-based 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 SWPE-E 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 non-rapid 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).

Fig. 1
figure 1

Illustration of the EEG signal segment and sleep spindle. A sleep spindle is the fuchsia curve with duration of 0.8 s

Sleep spindles play an important role in clinical research. Sleep spindles are believed to be associated with synaptic plasticity, memory consolidation, and long-term 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 time-consuming 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 Short-Time 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 low-pass filters and obtained individual envelopes. Though these approaches achieved a high level of performance, they only work on NREM data or require signals from multi-channels, 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 fixed-length 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 window-based 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 whole-night 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 non-stationary if its statistics (including mean, variance, and higher-order statistics) changed with time, so the EEG signals used in this study are non-stationary 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. Short-Time Fourier Transform (STFT) can be applied for non-stationary signal processing, but it uses an equal sized window for all ranges of frequency. This is a weakness when analyzing signals in multi-resolution. In this paper, the Mexican hat wavelet transform was used to perform a time–frequency analysis, as shown in Fig. 2.

Fig. 2
figure 2

Time–frequency analysis based on the Mexican hat wavelet

Mathematically, the Mexican hat wavelet is defined as the negative normalized second derivative of a Gaussian function,

$$\begin{aligned} \psi (t) = -c(e^{-t^2/2})^{''} = c(1-t^2)e^{-t^2/2} \end{aligned}$$
(1)

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 low-frequency 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 window-based 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.

Fig. 3
figure 3

Illustration of estimation of EEG signals using a sliding window. A value in the table is the simplified form of five values corresponding to five adjacent scales because the frequency resolution is 0.2 Hz

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

$$\begin{aligned} \begin{array}{lll} p(b_i) = \sum \limits _{k=i-nf}^{i+nf} b_{k}&\,&i\in [1+nf,N-nf] \end{array} \end{aligned}$$
(2)

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.

$$b_{i} = \left\{ {\begin{array}{*{20}c} {{\text{spindle point}}} & {p{\text{(}}b_{i} {\text{) > 0}}{\text{.5}}} \\ {{\text{non - spindle point}}} & {p{\text{(}}b_{i} {\text{)}} \le {\text{0}}{\text{.5}}} \\ \end{array} } \right.$$
(3)

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:

$$\begin{aligned} \begin{array}{lll} y(n) = x(n)*h_{11-16}(n)&\,&n = 1,\ldots ,N \end{array} \end{aligned}$$
(4)

where x(n) is the raw EEG signal and \(h_{11-16}(n)\) is the impulse response of the filter. Then, we used a low-pass filter with a cutoff frequency of 2 Hz to obtain the envelope of the rectified signal, which is expressed as follows:

$$\begin{aligned} \begin{array}{lll} e(n) = |y(n)|*h_{\mathrm{lowpass}}(n)&\,&n = 1,\ldots ,N \end{array} \end{aligned}$$
(5)

where e(n) is the envelope of the rectified signal and \(h_{\mathrm{lowpass}}\) is the impulse response of the low-pass 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.

$$\begin{aligned} \begin{array}{lll} r(c_{i}) =\frac{1}{d_{i}}{\sum\limits_{k=o_{i}}^{o_{i}+d_{i}} e_{k}}&\,&i = 1,\ldots ,C \end{array} \end{aligned}$$
(6)

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.

Fig. 4
figure 4

Relationship between the envelope and the spindle candidates. The red curve in the top graph is the envelope of the rectified signal, and the purple curve in the bottom graph shows the candidates

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. 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. 2.

    Specificity: This metric measures the proportion of non-spindles 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. 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. 4.

    F1-score: The F1-score 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.

Table 1 Sensitivity (%) of the six methods
Table 2 Specificity (%) of the six methods
Table 3 FDR (%) of the six methods
Table 4 Precision (%) of the six methods

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.

Table 5 F1-score (%) of the six methods

The F1-score 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 F1-score was employed to measure the overall performance of an algorithm in this paper. We can see that the F1-score of our approach, SWPE-E, was significantly higher than the other approaches, as shown in Fig. 5.

Fig. 5
figure 5

Comparison of the F1-scores of the six methods

When comparing the approach SWPE and the enhanced method SWPE-E, we can see that SWPE-E 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 data-driven 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

    Google Scholar 

  • Causa L, Held CM, Causa J, Estévez PA, Perez CA, Chamorro R, Garrido M, Algarín C, Peirano P (2010) Automated sleep-spindle detection in healthy children polysomnograms. IEEE Trans Biomed Eng 57(9):2135–2146

    Article  Google Scholar 

  • De Gennaro L, Ferrara M (2003) Sleep spindles: an overview. Sleep Med Rev 7(5):423–440

    Article  Google Scholar 

  • Devuyst S, Dutoit T, Stenuit P, Kerkhofs M (2011) Automatic sleep spindles detection-overview 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

    Google Scholar 

  • 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

    Article  Google Scholar 

  • 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

    Article  Google Scholar 

  • 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

    Article  Google Scholar 

  • 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

    Article  Google Scholar 

  • 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

    Article  Google Scholar 

  • Tsanas A, Clifford GD (2015) Stage-independent, single lead eeg sleep spindle detection using the continuous wavelet transform and local weighted smoothing. Front Hum Neurosci 9:181

    Article  Google Scholar 

  • Warby SC, Wendt SL, Welinder P, Munk EG, Carrillo O, Sorensen HB, Jennum P, Peppard PE, Perona P, Mignot E (2014) Sleep-spindle detection: crowdsourcing and evaluating performance of experts, non-experts and automated methods. Nat Methods 11(4):385–392

    Article  Google Scholar 

  • 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

Download references

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

Authors

Corresponding author

Correspondence to Yuanqing Li.

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.

Reprints and permissions

About this article

Check for updates. Verify currency and authenticity via CrossMark

Cite this article

Zhuang, X., Li, Y. & Peng, N. Enhanced automatic sleep spindle detection: a sliding window-based wavelet analysis and comparison using a proposal assessment method. Appl Inform 3, 11 (2016). https://doi.org/10.1186/s40535-016-0027-9

Download citation

  • Received:

  • Accepted:

  • Published:

  • DOI: https://doi.org/10.1186/s40535-016-0027-9

Keywords