# Short Time Fourier Transform and Automatic Visual Scoring for the Detection of Sleep Spindles

João Da Costa, Manuel Duarte Ortigueira, Arnaldo Batista

► To cite this version:

João Da Costa, Manuel Duarte Ortigueira, Arnaldo Batista. Short Time Fourier Transform and Automatic Visual Scoring for the Detection of Sleep Spindles. 3rd Doctoral Conference on Computing, Electrical and Industrial Systems (DoCEIS), Feb 2012, Costa de Caparica, Portugal. pp.267-272, 10.1007/978-3-642-28255-3_29 . hal-01365594

HAL Id: hal-01365594

https://inria.hal.science/hal-01365594

Submitted on 13 Sep 2016

**HAL** is a multi-disciplinary open access
archive for the deposit and dissemination of sci-
entific research documents, whether they are pub-
lished or not. The documents may come from
teaching and research institutions in France or
abroad, or from public or private research centers.

L'archive ouverte pluridisciplinaire HAL, est
destinée au dépôt et à la diffusion de documents
scientifiques de niveau recherche, publiés ou non,
émanant des établissements d'enseignement et de
recherche français ou étrangers, des laboratoires
publics ou privés.

<figure><img src="image_1.png" /></figure>

Distributed under a Creative Commons Attribution 4.0 International License
# Short Time Fourier Transform and Automatic Visual Scoring for the detection of Sleep Spindles

João Caldas da Costa¹, Manuel Duarte Ortigueira², Arnaldo Batista²

¹,² Department of Systems and Informatics, EST, IPS, Setubal, Portugal
joao.costa@estsetubal.ips.pt

² CTS – UNINOVA, Dep. de Eng. Electrotécnica, Faculdade de Ciências e Tecnologia, Universidade Nova de Lisboa, 2829-516 Caparica, Portugal
{mdo, agb}@fct.unl.pt

**Abstract.** Sleep spindles are the most interesting hallmark of stage 2 sleep EEG. Their accurate identification in a polysomnographic signal is essential for sleep professionals to help them mark Stage 2 sleep. Visual spindle scoring however is a tedious workload. In this paper two different approaches are used for the automatic detection of sleep spindles: Short Time Fourier Transform and Automatic Visual Scoring. The results obtained using both methods are compared with human expert scorers.

**Keywords:** Sleep Spindles, EEG, Short Time Fourier Transform, Automatic Visual Scoring.

## 1 Introduction

Sleep spindles (SS) are particular EEG patterns which occur during the sleep cycle with center frequency in the band 11 to 15 Hz. They are used as one of the features to classify the sleep stages [1]. Sleep spindles are promising objective indicators in neurodegenerative disorders [2]. In this work, two methods are used to find SS, Short Time Fourier Transform (STFT) and Automatic Visual Scoring (AVS), with the aim to improve the detection mechanisms.

## 2 Contribution to Value Creation

Society-valued technologies can leverage economic transformation, create value in the society and ultimately improve individuals' lives. The correct detection of human sleep spindles and posterior characterization can lead to early detection of changes in brain and prevent or, at least, mitigate the influence of certain diseases [4].
## 3 Sleep Spindles

It is commonly referred in literature that sleep spindles are the most interesting hallmark of stage 2 sleep electroencephalograms (EEG) [1]. A sleep spindle is a burst of brain activity visible on an EEG and it consists of 11-15 Hz waves with duration between 0.5s and 2s in healthy adults, they are bilateral and synchronous in their appearance, with amplitude up to 30 µV (Fig.1).

The spindle is characterized by progressively increasing, then gradually decreasing amplitude, which gives the waveform its characteristic name [3]. It is now reliable that sleep spindles are originated in the thalamus and can be recorded as potential changes at the cortical surface [5].

<figure><img src="image_2.png" /><figcaption>Fig. 1. EEG signal showing a SS</figcaption></figure>

Sleep spindles are affected by brain pathology, as well as by normal and pathological aging (e.g., dementia) [1]. With normal aging, sleep spindles are less numerous and less well formed. In dementia, the sleep EEG patterns suggest accelerated aging [6].

Sleep EEG measures seem promising as objective indicators in neurodegenerative disorders, including dementia, where sleep changes appear to be an exaggeration of changes that come normally with aging.

## 4 Detection methods

### 4.1 Short Time Fourier Transform (STFT)

The concept of Short Time Fourier Transform (STFT), also called windowed Fourier or is the localization of the Fourier transform using an appropriate window function centered on a location of interest. STFT is an expansion along two parameters, frequency and time shift. It consists of a separate Fourier transform for
each instant in time. In particular, for each instant, the Fourier transform of the signal in the neighborhood of that instant is associated. The STFT of a signal is the Fourier transform of the short-time sections of that signal, obtained by multiplying the signal with the window function. [7]

The STFT of a discrete signal is:

$$ \text{STFT}\{x[n]\} = X(m, \omega) = \sum_{n=-\infty}^{\infty} x[n]\omega[n-m]e^{-j\omega n} \quad (1) $$

The magnitude squared of the STFT yields the spectrogram of the function:

$$ \text{spectrogram}\{x[n]\} = |X(\tau, \omega)|^2. \quad (2) $$

An example of detection of SS using STFT and corresponding spectrogram can be seen in (Fig. 2). It is clear the presence of peak in the spectrogram (t=0.5s and f=15Hz), corresponding to a SS.

<figure><img src="image_3.png" /><figcaption>Fig. 2. Example of SS detection using STFT</figcaption></figure>

## 4.2 Automatic Visual Scoring (AVS)

The Automatic Visual Scorer (AVS) proposed in this paper is based on the definition of Sleep Spindle by Rechtschaffen and Kales [3] which states:
"The presence of a sleep spindle should not be defined unless it is of at least 0.5sec duration, i.e., one should be able to count 6 or 7 distinct waves within the half-second period. Because the term "sleep spindle" has been widely used in sleep research, this term will be retained. The term should be used only to describe activity between 12 and 14 cps."

The AVS implemented algorithm consists of:

1. Detections of peaks in the signal, based on a defined threshold, thus, eliminating small peaks;

2. Determination of peaks time distance and conversion to frequency in order to find if it is in the SS range;

3. If there are more than 6 peaks in the SS frequency a spindle is marked.

An example of a SS detected using this algorithm can be seen in Fig 3, where the SS is marked between t=1.1s and t=1.6s. The peaks above the threshold limit are marked with a '.' , the ones which also satisfy the frequency criteria are marked with a '+' and the SS beginning is marked by the '*' .

<figure><img src="image_4.png" /><figcaption>Fig. 3. Example of SS detection using AVS</figcaption></figure>

5 Experimental Results

This study makes use of a sample representative of human sleep, obtained from healthy male volunteers. It is a set of 18 sets from 3 different subjects, comprising 3 minutes each. Briefly, all polysomnograms were performed in an 18-channel analog NIHON-KOHDEN polygraph with 12 bit digital conversion (STELLATEs RHYTHM V10.0), recorded with 128Hz resolution, with manufacturers 0.5Hz high-pass filter, 0.3s time constant and -3dB IIR32 digital filter conditions applied to the signal.
Sleep was visually scored according to RK [3]. From a screen display of C3-A2 channel, two specialists scored all concordant spindles, using the RK68 spindle definition.

In order to test the validity of results, both algorithms were applied to the data and measures were taken, namely TP, FP, TN and FN events.

In Table 1, Sensitivity = TP/( TP+FN ) and Specificity = TN/( TN+FP ) for STFT and AVS is presented to several values of threshold.

<table><caption>**Table 1.** Sensitivity and Specificity obtained with the STFT and AVS algorithm</caption><thead><tr><th colspan="3">STFT</th><th colspan="3">AVS</th></tr><tr><th>Threshold</th><th>Sensitivity (%)</th><th>Specificity (%)</th><th>Threshold</th><th>Sensitivity (%)</th><th>Specificity (%)</th></tr></thead><tbody><tr><td>30</td><td>97.4</td><td>70.3</td><td>7.5</td><td>98.6</td><td>61.3</td></tr><tr><td>40</td><td>95.2</td><td>84.8</td><td>10</td><td>97.9</td><td>74.9</td></tr><tr><td>50</td><td>90.9</td><td>90.9</td><td>12.5</td><td>96.2</td><td>84</td></tr><tr><td>60</td><td>85.2</td><td>94.2</td><td>15</td><td>93.4</td><td>89.6</td></tr><tr><td>70</td><td>79.5</td><td>96</td><td>17.5</td><td>87.7</td><td>93.7</td></tr><tr><td>80</td><td>71.3</td><td>97.6</td><td>20</td><td>80.6</td><td>96</td></tr><tr><td>90</td><td>61.3</td><td>98.5</td><td>22.5</td><td>71.1</td><td>97.5</td></tr></tbody></table>

In the STFT case, the threshold value corresponds to the cumulative value of peaks in the spectrogram. Lower thresholds, mean more SS (TP and/or FP) are found.

In the AVS algorithm, a point is considered a maximum peak if it has the maximal value, and was preceded (to the left) by a value lower than the threshold defined.

<figure><img src="image_5.png" /><figcaption>**Fig. 4.** Sensitivity x Specificity curve for the STFT algorithm</figcaption></figure>

In Figs. 4 and 5 Sensitivity x Specificity curves are shown for both the STFT and AVS algorithms.
<figure><img src="image_6.png" /><figcaption>Fig. 5. Sensitivity x Specificity curve for the AVS algorithm</figcaption></figure>

**6 Conclusions**

The overall performance of both methods is similar, changing the thresholds can lead to sensitivity next to 100%. However, high values of sensitivity lead to a decrease in specificity. This low value in specificity is due to higher values in False Positives. The conjunction of both methods can lead to better results, eliminating some False Positives, not compromising the True Positives, thus improving specificity with minor changes in sensitivity. This conjunction will be explored in future work.

**Acknowledgements.** The authors would like to acknowledge sleep laboratory from HCPA, G. Gerhardt, M. P. Hidalgo and S. Schonwald for providing the data used for this work.

**References**

1. De Gennaro, L., Ferrara, M. Sleep spindles: an overview. Sleep Medicine Reviews; 7:423-40 (2003)

2. Ktonas, P.Y., Golemati, S., Xanthopoulos, P., Sakkalis, V., Ortigueira, M.D., et al. Time-varying analysis methods to quantify the time-varying microstructure of sleep EEG spindles: Possibility for dementia biomarkers? J. of Neuroscience Methods, Vol. 185-1, 133-142 (2009)

3. Rechtschaffen, A., Kales, A., Eds. A Manual of Standardized Terminology, Techniques and Scoring System for Sleep Stages of Human Subject. US Government Printing Office, National Institute of Health Publication, Washington DC (1968)

4. Costa, J.C., Ortigueira, M.D., Batista, A. ARMA Modelling of Sleep Spindles, Proceedings of the Doctoral Conference on Computing, Electrical and Industrial Systems, DoCEIS'11 - IFIP AICT 349, pp 341-348 (2011)

5. Steriade, M., Jones, E.G., Llinas, R. Thalamic Oscillations and Signaling. Neuroscience Institute Publications. New York: John Wiley & Sons (1990).

6. Petit, D., Gagnon, J.F., Fantini, M.L., Ferini-Strambi, L., Montplaisir, J. Sleep and quantitative EEG in neurodegenerative disorders. J. Psychosomatic Research; 56:487-96 (2004)

7. Görür, D. Automated Detection of Sleep Spindles. s.l.: MSc thesis, Middle East Technical University (2003).