SPINDILOMETER: a model describing sleep spindles on EEG signals for polysomnography

This paper aims to present a model called SPINDILOMETER, which we propose to be integrated into polysomnography (PSG) devices for researchers focused on electrophysiological signals in PSG, physicians, and technicians practicing sleep in clinics, by examining the methods of the sleep electroencephalogram (EEG) signal analysis in recent years. For this purpose, an assist diagnostic model for PSG has been developed that measures the number and density of sleep spindles by analyzing EEG signals in PSG. EEG signals of 72 volunteers, 51 males and 21 females (age; 51.7 ± 3.42 years and body mass index; 37.6 ± 4.21) diagnosed with sleep-disordered breathing by PSG were analyzed by machine learning methods. The number and density of sleep spindles were compared between the classical method (EEG monitoring with the naked eye in PSG) (‘method with naked eye’) and the model (SPINDILOMETER). A strong positive correlation was found between ‘method with naked eye’ and SPINDILOMETER results (correlation coefficient: 0.987), and this correlation was statistically significant (p = 0.000). Confusion matrix (accuracy (94.61%), sensitivity (94.61%), specificity (96.60%)), and ROC analysis (AUC: 0.95) were performed to prove the adequacy of SPINDILOMETER (p = 0.000). In conclusion SPINDILOMETER can be included in PSG analysis performed in sleep laboratories. At the same time, this model provides diagnostic convenience to the physician in understanding the neurological events associated with sleep spindles and sheds light on research for thalamocortical regions in the fields of neurophysiology and electrophysiology.


Introductıon
The synaptic electrical activity and voltage changes [non rapid eye movement (NREM) sleep, characterized by high amplitude, low-frequency brain waves, and rapid eye movement (REM) sleep, defined by low amplitude, higher frequency EEG activity, with mixtures of these occurring during transitional phases] that occur in the brain during sleep each night enable the reintegration of sensory and motor networks throughout the body [1][2][3][4][5][6].Sleep is a physiological process organized in stages (NREM1, NREM2, REM, NREM3).The K-complex and sleep spindle are the cornerstones of the sleep-EEG microstructural architecture.These electrophysiological microelements play an important role in understanding sleep's neurophysiological and functional aspects [2,7].Sleep spindles are EEG rhythms especially prominent during NREM 2 [6].They are oscillatory EEG activities in the sigma frequency band (∼11-16 Hz) of fusiform morphology that last around 0.5-3 s [8][9][10].Two types of sleep spindles have been recognized; fast spindles at 14-15 Hz maximal in centroparietal regions and slow spindles at 12-13 Hz predominant in frontal areas [7,11,12].Sleep spindles are thalamocortical oscillations [13,14] with the physiological potential to facilitate neuroplasticity [15][16][17].Sleep spindle characteristics such as spindle density, frequency or amplitude are trait-like individual characteristics with genetic and anatomical underpinnings [18][19][20][21].Sleep spindles are electrophysiological characteristics with a function very closely related to cognition [22] and intelligence [23], with normal aging processes [24,25].Changes in the number and intensity of sleep spindles observed in EEG may indicate a malfunction in the thalamocortical circuit (e.g., schizophrenia, epileptic seizures, Parkinson's, Alzheimer, mental retardation, abnormal maturation but also with recovery processes as in post brain stroke) [8,[26][27][28][29].In recent years, the pace of sleep EEG studies that associate electrophysiological activity to cognition and disease has increased [30].Computers detect sleep spindles automatically, but the results must be evaluated by visual-scoring experts and sleep physicians.Accurate recognition of microelements in EEG, understanding their electrophysiological properties, and interpreting their number and intensity provide important information for brain health.Although a limited number of automatic sleep spindle counters have been designed in the literature [31][32][33][34][35], they have not yet taken their place as a basic analysis tool in interpreting PSG reports.In sleep analysis laboratories, PSG is the gold standard diagnostic method for recognizing sleep physiology and disorders.This article aims to present a model called SPIN-DILOMETER, which we propose to be integrated into PSG devices for researchers focusing on electrophysiological signals in PSG as well as, physicians, and technicians practicing sleep in clinics, by examining the methods of the sleep EEG signal analysis in recent years.

Materials and methods
This study was carried out in the Sleep Disorders Center, Electrophysiology Laboratory in Erzurum Regional Train

Study participants
The study was planned according to Helsinki Declaration.EEG signals of 72 volunteers, 51 males and 21 females (age; 51.7 ± 3.42 years and body mass index; 37.6 ± 4.21) diagnosed with sleep-disordered breathing by PSG were analyzed.The mean total sleep time of the volunteers during one night's sleep was 6 ± 2.37 h.

Experimental recordings
All patients underwent a full-night laboratory PSG using the Grass Technologies PSG system (TWin 4.5.3,USA).During sleep, polysomnography consists of recording different physiological and pathophysiological parameters for period of 6 h or longer throughout the night: these are reported after evaluations by a clinical physiologist whose field of study is sleep medicine and neurophysiology (M.D.).

Experimental protocol
While sleep breathing disorders diagnoses of the volunteers were established according to AASM together with the physiology specialist (M.D.) responsible from the laboratory, the electrophysiological properties, number and density of sleep spindles in the EEG were examined and counted at least 3 times for each of the 6 channels with the naked eye (EEG monitoring with naked eye in PSG), ('method with naked eye').EEG signal waves (sleep spindles) with fusiform morphology in each of six different EEG channels (F4-M1, C4-M1 and O2-M1, F3-M2, C3-M2, and O1-M2) lasting approximately 0.5-3 s at 11-16 Hz were analyzed by machine learning methods (SPINDILOMETER) (Fig. 1).The number and density of sleep spindles were compared between the classical method ('method with naked eye') and the model (SPINDILOMETER).

Experimental setting
The idea of using machine learning methods to analyze sleep spindles and reveal clues about basic and clinical events related to thalamocortical activity in the brain is the main inspiration for the development of SPINDILOM-ETER.SPINDILOMETER contains units that analyze the frequency and amplitude values of EEG signals in PSG.SPINDILOMETER stores these values, uses them, and decides whether a sleep spindle exists [sigma frequency band (~ 11-16 Hz)] (Fig. 1).Care was given to use the latest machine learning methods in developing this model.Table 1 describes the algorithm for the model: first, the missing data were normalized by replacing it with the mean value.Next, four different feature extraction algorithms were applied to this data: "Power Spectral Density, Continuous Wavelet Transform, Non-gaussianity Score and Bispectrum Score Features (X d )."Then, appropriate features were determined by the feature selection process.In the final stage, the number and characteristics of sleep spindles were revealed by using classification algorithms.

A general technical approach to sleep spindle extraction methods in EEG signals
On each of the channel signals were analyzed by using computer-based electrophysiological signal analysis methods.The process consisted of "Pre-processing, Feature extraction, Feature selection, and Classification".We applied highly reliable signal analysis methods used in computer science to sleep medicine.For this reason, we used a wide spectrum of multiple (9 specifics) signal analysis methods for the analysis of EEG signal waves in PSG.The EEG wave signals of a sample PSG recording from the study (Fig. 2) and the relationship between the methods applied to these signals and the EEG signals are explained below.

Pre-processing of EEG signals for SPINDILOMETER
Six-channel EEG wave signals were obtained from the electrophysiological signal recordings obtained from PSG, and were accepted as a data set.EEG wave signals were analyzed for each PSG epoch (30 s periods) during at least 6 h of sleep   If a spindle is found, increase the spindle number 15: end if 16: end for 17: Stop the collection of recordings from 6 EEG channels for each volunteer.We tried to see the details by dividing each age into 10-s segments to better understand the EEG waves.Seventy percent of the data set was split into two as training and 30% as test phase.Sleep spindles detected by the researcher (M.D.) who reported the PSG were estimated in the testing phase.The technical procedure in the data preprocessing phase was as follows: (1) Missing data were identified and filled with mean values.(2) Outlier data were identified and subjected to normalization.Minimum-Maximum Normalization: one of the most common methods used to reduce the differences between the data and to normalize the data.(a) the minimum value of the amplitude and frequency values of the EEG waves was set as '0' and the maximum value as '1', (b) all values between the minimum and maximum values were converted to 'decimal numbers.'

Power spectral density (PSD)
Frequency is a characteristic of EEG signals.PSD measures the power content of a signal versus frequency or the energy density of a signal at different frequencies.In the time domain, it is difficult to find distinctive features of EEG signals, but in the frequency domain, PSD finds similarities and differences as the maximum values are known [37].Since PSD is the energy of the signal per frequency, it is defined as the Fourier transform of an EEG signal's autocorrelation function (A(ξ)).Its formula is as follows (ξ is the spatial shift, Ω is the number of waves) [38]:

Continuous wavelet transform (CWT)
EEG waves are chaotic bio-signals.CWT allows provisioning an over-complete signal representation by allowing the translation of wavelets and scale parameters to change continuously.Thus, it generates a large number of wavelet coefficients.These coefficients can be used as features.The scaling of a wavelet is expressed as its compression or expansion.Unlike the Fourier transforms, the time-frequency window of the CWT is adjustable.Its formula is as follows (b is the shift factor, α is the scale factor, t is the time, and f(t) is the signal vector of interest) [39]:

Non-Gaussianity score (NGS)
This score was used to understand the distribution of EEG signal characteristics (amplitude, frequency).NGS indicates the non-Gaussianity of a given data segment.This method made it easy to measure the deviation of the EEG signals in each epoch of the PSG from the Gaussian model.The formula is as follows (p and q are the normal probability plots of the reference and analyzed data, respectively) [40]:

Bispectrum score (BGS)
The BGS, the 3rd order spectrum of the signal, is known as the bispectrum.Unlike the autocorrelation-based power spectrum (2nd order statistics), the bispectrum preserves Fourier phase information.It allows in-depth analysis of the EEG wave signals at each epoch in PSG.Its formula is as follows (ω1 = ω2 = ω; through the defined diagonal slice P(ω), the information available in the bispectrum is captured) [41]:

Feature selection for SPINDILOMETER
This process aims to simplify the number of attributes.Attribute selection focuses on finding an optimal subset of attributes (defining which attribute is more important).In our study, filtering methods were used in the attribute selection phase.The filtering method examines each attribute's susceptibility in the dataset to each classification [42][43][44].

Classification
Classification is the process of determining to which class an unknown pattern belongs with the help of a classifier that uses the features of that pattern as input.This study classified EEG signals using the most appropriate machine learning methods to identify sleep spindles among the EEG signals during PSG [45,46].
KNN is a learning algorithm and its goal is to perform a classification on the existing training data when a new sample is received [47].KNN was preferred in this study due to the simplicity of the method and its high accuracy when used on EEG data.KNN method is a simple and effective method.

Support vector machine (SVM)
Support vector machines are a highly effective, simple machine-learning method for classification problems in data sets where the patterns between variables are unknown.It minimizes the classification error by selecting the line with the highest margin (necessary for discriminating sleep spindle wave signals).Therefore, SVM has facilitated the rapid and reliable extraction of the characteristic wave signals of the sleep spindle for the SPINDILOMETER model [48,49].

Decision trees (DT)
Decision trees are one of the supervised machine learning algorithms [50].The purpose of using the decision tree algorithm in this study is to learn decision rules extracted from the features of EEG wave signals and then develop a model that can predict the value of the target variable (sleep spindles).

Naive Bayes
The Naive Bayes algorithm helped us to classify the features of EEG wave signals as it is easy to apply and understand in large data sets: this method works by assuming that the presence of an attribute in a given class is not related to the presence of any other attribute [51].This method provided us with important data on the probability of discovering specific sleep spindle wave signals that we tried to find among the EEG wave signals from 6 channels, which is the dataset of our study.

Extra tree classifier (ETC)
The ETC differs from other tree-based ensemble methods for two main reasons: (1) it separates nodes by choosing breakpoints completely randomly, and (2) it uses all learning samples to grow the trees [52].With the ETC ensemble implementation, the entire sample of EEG wave signals was used and classified.

Confusion matrix tables comparing sleep spindles numbers calculated by both methods
In the model developed in this study, the EEG waves of PSG recordings collected from all volunteers were divided into 10-s time slices to prove that each sleep spindle accurately identifies the electrophysiological wave signal.The confusion matrix was used to measure the success of the model.In order to see the effectiveness of a classifier, the prediction accuracy of the classifier should be measured after the training phase is completed.In this study, after the confusion matrix was created, the performance of the prediction models were compared using the criteria of accuracy, sensitivity, precision and F1 score.The confusion matrix is a table used to show how much of the predicted value of the classification model created as a result of machine learning algorithms matches the actual class value.It summarizes and visualizes the performance of the classification algorithm.We tried to understand the success of the SPINDILOMETER algorithm in identifying sleep spindles by means of performance measures for results obtained from each volunteer.Performance measures applied to SPINDILOMETER are the following: (a) Accuracy is calculated as the number of all correct predictions divided by the total number of the dataset.(b) Sensitivity and Recall are calculated as the number of true positive predictions divided by the total number of true positive classes.(c) Precision is the number of true positive predictions divided by the total number of positive predictions.(d) F1-score is the harmonic mean of Precision and Recall.

Comparison of 'method with naked eye' and SPINDILOMETER methods with ROC analysis
One of the statistical techniques commonly used to evaluate the performance of a classifier is the receiver operating characteristics (ROC) curve.ROC curves provide a visual approach to judge the efficiency of a classifier.In this study, in addition to the performance measures obtained from the confusion matrix, the area under the ROC curve (ROC-AUC) value was also calculated and evaluated.The ROC-AUC score was chosen as an evaluation criterion to determine the degree of separability.It measures the classification performance of the model at all possible thresholds.With this metric, we evaluate how well the model works when discriminating between sleep spindle and non-sleep spindle electrophysiological wave signals.If the ROC-AUC value is high, we can say that the model is successful.

Statistical analysis
The number and density of sleep spindles were determined from the EEG recordings of the physician who examined the real-time PSG during sleep with the naked eye (classical method, 'method with naked eye') and SPINDILOM-ETER and compared using the 'SPSS 22 for Windows program.The Intra-class Correlation Coefficient test was used to analyze the results.In this comparison, p < 0.001 was considered statistically significant.The accuracy of our algorithm was analyzed with confusion matrix tables.Finally, two methods ('method with naked eye' and SPIN-DILOMETER) were compared by ROC analysis to prove that our algorithm can successfully identify each sleep spindle count in the shortest time interval (10 s).

Results of the classifiers used for the development of the SPINDILOMETER
The highest values belong to the KNN algorithm.The KNN algorithm achieved 94.61% accuracy, 92.47% sensitivity, and 96.60% specificity (Table 2).

Comparison of 'method with naked eye' and our model in terms of sleep spindle detection
The number of sleep spindles for each volunteer was determined separately for both models.A strong positive correlation (correlation coefficient: 0.987) was found between 'method with naked eye' and SPINDILOMETER results, and this correlation was statistically significant (Intraclass Correlation Coefficient Test: p = 0.000) (Tables 3,  4, Figs. 3, 4).

Findings of confusion matrix tables comparing sleep spindle numbers calculated by both methods
Numerical values pertaining to the methods were accepted as actual for 'method with naked eye' and predicted for SPINDILOMETER.If sleep spindles are identified in a 10 s time frame it is marked as 1; not as 0 (Fig. 5: demonstrates the confusion matrix for all of the volunteers).Table 5 demonstrates that the performance score for each volunteer is statistically significantly high.

Findings of both methods compared with ROC analysis
In our study, ROC curves were drawn to make a statistical comparison of the performances of the two methods and to delineate the relationship between the sensitivity and specificity of the two methods in detail.Furthermore, by showing the size of AUC, high discriminative performance of sleep spindle definitions pertaining to our method was demonstrated (Fig. 6).
The blue curve is a ROC curve with which we compare SPINDILOMETER and 'method with naked eye' for sensitivity and specificity; having a high slope and having an area under the curve (AUC) of 0.5-1 proves us that our method that is the subject matter of our study has a high sensitivity, high specificity and high precision (Fig. 6).

Discussions
This study calculates the number and density of sleep spindles in PSG, an important diagnostic tool in medicine used in the fields of sleep neurophysiology and neuroscience, using optimal machine-learning methods with high success rates, and proposes a model called SPINDILOMETER to be integrated into PSG (PSG + ).During the study, electrophysiological signals of the sleep spindle, one of the cornerstones of the sleep-EEG microstructural architecture, were analyzed to understand the connections between sleep spindles and the neurophysiological and functional aspects of sleep.In addition, this study provides a perspective on the recent scientific studies on sleep spindle and EEG signal analysis.

Sleep spindles analysis for physiological studies and brain pathophysiology
Sleep spindle waveforms are named "spindles" and are inspired by wool spinning tools.They are 10-15 Hz sinusoidal cycles that appear as burst-like sequences in NREM 2 in EEG [53].Their generation takes place between the thalamoreticular nucleus (TRN) and thalamocortical (ThCx) generator-neuronal circuits, which are closely interconnected.As deep sleep progresses, inhibitory neurons in the TRN begin to fire in bursts, causing massive generation of inhibitory postsynaptic electrical potentials in ThCx neurons.The precise physiological mechanisms in these regions (TRN-ThCx), referred to as neuronal generator circuits, are considered to be a critical line between deep sleep and wakefulness modes of the brain (under the control of the reticular activating system in the brainstem) [8,[25][26][27][28].The model SPINDILOMETER, which we intend to make more and more functional, is a physiological detector of this critical region.In recent studies, the sleep spindles that appear in the EEG, which seem to originate from these sensitive generator circuits (TRN-ThCx), has been found to cause the following physiological mechanisms: (1) They facilitate neuroplasticity [13,14].(2) Since TRN-ThCx oscillations significantly change the activity in the gray matter of the cortex (a large number of neuronal circuits in the white matter that process incoming information and release new information), they play a decisive role in the control of movement, memory, and emotion [15][16][17].(3) Sleep spindles show a characteristic profile throughout life (from the early postnatal period to adolescence and aging) in parallel with the cortical maturation of the individual, and therefore, like genes, they have an important role in the fate of the individual (normal aging process) [24,25].(4) Spindle density, frequency, or amplitude in EEG is closely related to cognition [22] and intelligence [23].Considering the relationship of sleep spindles with critical concepts in human neurophysiology, such as understanding neuroplasticity, movement, memory and emotion control, cortical maturation, aging, cognition, and intelligence [26][27][28], the importance of SPINDILOMETER and the idea of developing new algorithms on it becomes more important.Recent studies have emphasized the importance of NREM 2 sleep and the deepening of sleep.Higher sleep spindle densities correlate with longer N2 sleep duration and greater resilience to external perturbation.Sleep spindles cluster on an infraslow time scale of ~ 50 s, thought to be correlated with periods of NREMS fragility.In some sleeprelated movement disorders, involuntary limb movements occur periodically on this time scale [8,36,53].Changes in the number and intensity of sleep spikes in the EEG may indicate a malfunction in the TRN-ThCx circuit."Mood disorders, sleep movement disorders, cognitive deficits, attention and hyperactivity disorders, schizophrenia, epileptic Fig. 6 ROC curve-demonstrates the relationship between the sensitivity and specificity of 'method with naked eye' and SPINDILOM-ETER test results.Red dashed line represents a test that does not have correct discriminative features; the area under the curve is 0.5.For the best test performance, this needs to be 1.As we go upwards from the red dashed line, the increasing slopes of the appearing curves show us that the discriminative capacity of the diagnostic test under consideration has increased.Therefore, in order to talk about a high sensitivity and high specificity for a diagnostic test we anticipate that the area under the ROC curve should be 0.5-1.0seizures, Parkinson's, Alzheimer's, mental retardation, abnormal cortical maturation and recovery processes after brain stroke (neuroplasticity)" are the examples of TRN-ThCx circuit failures [8,[26][27][28][29].SPINDILOMETER and its upgraded versions, which we are developing, may be pathognomonic in the diagnosis of these complex diseases in pediatric and adult patients and may become a good marker for following the treatment and progression of these patients.
The relationship between EEG signal analysis and sleep spindle "a brief overview of recent literature"  mechanisms in the TRN-ThCx neuronal circuits in the brain and the disorders that occur when these circuits malfunction.SPINDILOMETER is an algorithm compatible with this important EEG waveform.For us, the reason for creating and further developing a SPINDILOMETER is that (a) physicians dealing with neurological sciences tend towards accurate diagnoses, and (b) brain researchers like using an algorithm that has reached high diagnostic accuracy values in their articles.

Why PSG + SPINDILOMETER?
PSG systems in the hospital sleep laboratories provide physicians and researchers important information regarding sleep physiology and diseases.Sleep spindles, as the building blocks of the microstructural architecture of EEG, are routinely monitored for PSG systems.However, when we look at the content of PSG reports created for physicians, no data are available on sleep spindles.We would like to see our algorithm included in PSG systems, and we believe that PSG + SPINDILOMETER is necessary for both patients and physicians and scientific research.In our opinion, while PSG applications and the resulting reports, through the criteria determined by the AASM, provide us information about the brain and bodily functions after a night's sleep (at least 6 h), they leave the interpretation of very important information incomplete.This information is, of course, related to the physiology and diseases of the TRN-ThCx region.This lack of information in PSG reports can be eliminated by means of SPINDILOMETER by AASM criteria.Moreover, this information can be improved over time, and its scope can be expanded because, based on their number and density SPINDILOMETER algorithms are expected to predict the physiological mechanisms that are disrupted while detecting sleep spindles and making comments about sleep physiology and disorders, as well as cognitive, emotional, and movement disorders.

Limitations of the study and future work for improving SPINDILOMETER
Our main goal in this study was not solely to develop an algorithm that successfully calculates the number and density of sleep spindles.We also took into account the microstructures (sleep spindles, K-complexes) that form the architecture of sleep EEG and the arousals that occur during sleep; we wanted to create sleep maps of individuals that allow us to interpret their interactions with one another.From this point of view, the current study is incomplete; we can even in our opinion that we are in the preliminary stages of our studies to reach the sleep maps we want.The strength of our study is having more subjects compared to the literature.However, our limitation is that these subjects were individuals diagnosed with sleep-disordered breathing.
Computer analysis of the micro-elementary electrophysiological signals of sleep EEG in undiagnosed children, young individuals, and healthy adults will provide us with more information about normal functioning.Finally, we know and wish that the idea of combining signal processing methods with new neuroimaging techniques to monitor the effects of sleep spindles on TRN-ThCx and cortex will lead us to algorithmic versions of "SPINDILOMETER + Neuroimaging" in the future.

Conclusion
SPINDILOMETER can be incorporated into PSG analysis conducted in sleep laboratories.Thus, this model provides diagnostic convenience to the physician in understanding the neurological events associated with sleep spindles and sheds light on thalamocortical region research in the fields of neurophysiology and electrophysiology.
Open Access This article is licensed under a Creative Commons Attribution 4.0 International License, which permits use, sharing, adaptation, distribution and reproduction in any medium or format, as long as you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons licence, and indicate if changes were made.The images or other third party material in this article are included in the article's Creative Commons licence, unless indicated otherwise in a credit line to the material.If material is not included in the article's Creative Commons licence and your intended use is not permitted by statutory regulation or exceeds the permitted use, you will need to obtain permission directly from the copyright holder.To view a copy of this licence, visit http://creativecommons.org/licenses/by/4.0/.

1 :
EEG wave signals for every 10 seconds time slot in PSG 2: Start the collection of recordings from 6 EEG channels (Xn) 3: Missing data removal 4: Normalize Xn 5: for all n 6: Calculated Power Spectral Density Features (Xa) 7: Calculated Continuous Wavelet Transform Features (Xb) 8: Calculated Non-gaussianity Score Features (Xc) 9: Calculated Bispectrum Score Features (Xd) 10: end for 11: Perform feature selection from the obtained features 12: for all N 13: Classify spindle from data 14:

Fig. 4 Fig. 5
Fig.4 The comparison of the number of sleep spindles calculated by 'method with naked eye' and SPINDILOMETER methods as a histogram

Table 1
Algorithm for SPINDILOMETER

Table 2
Results of the classifiers (algorithms) used for the development of the SPINDILOMETER KNN K-nearest neighborhood, SVM support vector machine, DT decision trees, NB Naive Bayes, ETC extra tree classifier

Table 3
There was a strong positive correlation between 'method with naked eye' (correlation coefficient: 0.987) and SPINDILOMETER results, and this relationship was statistically significant (intraclass correlation coefficient test: p < 0.001)

Table 5
Performance measures for all the volunteers in the data set were obtained by taking 10 s time frames into consideration