The Application of Visual Organization Principle in the Detection of Sleep Spindles

In order to detect the sleep spindles simply and efficiently, a novel time-domain approach to detect sleep spindles based on the principles of visual organization is proposed. The code idea of the visual organization is to organize the primary visual elements according to some rules of organization, and to form a more meaningful object of visual processing, as the input of next process. After the collected EEG is processed with the merging algorithm based on the principle of visual organization, it can extract the time-domain feature frequency and duration time better. Use these features with a simple algorithm to detect spindles achieving sensitivity of 92.5% and specificity of 98.1%, which verifies the validity of this method to detect the sleep spindles.


Introduction
Sleep spindles (SS) generated from complex interactions between thalamic, limbic and cortical areas are the hallmarks of the non-REM stage 2 sleep (N2).They are sinusoidal spindle-like waveforms which have the characteristic of progressively increasing, then gradually decreasing lasting 0.5~3s with a frequency profile at 11 -16 Hz.The figure characteristic of the waveforms is obvious [1].
Apart from being the characteristic wave of the sleep stage, sleep spindles also have great relationships with human activities.Studies [2] have founded that during sleep, the more sleep spindles exist, noises can be more tolerated and the deep sleep can be more easily kept.Moreover, they are known to play a fundamental role in memory consolidation during sleep [3], as well as being related to the secretion of melatonin that helps in maintaining the body's circadian rhythms [4].
Therefore, detecting the sleep spindles rapidly and efficiently has a great value in physiological, pathological and pharmacological studies during sleep.
Detecting sleep spindles by man is a time-consuming and laborious work with many uncertainty factors and prone to human error.The study [5] has indicated the inter-rater variability in scoring them to be around 80%.
Since the EEG was first detected, scholars have applied various signal analysis methods to the EEG analysis.Time-domain method is one of the earliest methods to study EEG, which has the irreplaceable advantages.With the continuous development of the EEG study, analysis method has turned from the time-domain into the time of frequency-domain, time and frequency-domain and other nonlinear method.Gorur [6] used Short time Fourier transform for feature extraction.Both multilayer perceptron and support vector machine are utilized in detection of the spindles achieving a sensitivity of 88.7% and 95.4%.
[7] used amplitude-frequency normal modelling and reported a sensitivity of 75.1%.[8] used bandpass filtering with thresholding, relative power and autoregressive modelling to achieve sensitivity and specificity values of 84.6% and 95.3%.
In this paper, the merging algorithm based on the principle of the visual organization was applied to process the rare sleep EEG and then according to the time-domain feature of sleep spindles to detect the sleep spindles, which can be automatically marked.The rest of paper is organized as follows: Section 2 and section 3 introduce the detection method and result, Section 4 shows the conclusion.

Merging Algorithm Based on the Principle of the Visual Organization
The concept of visual organization originates from cognitive psychology.The main research contents include: Gestalt perceptual organization principles [9] [10] [11], visual closure [12] and non-contingency principle [13] et al. visual organization algorithm is the method to make the basic image elements form an overall subject according to the quantitative model of Gestalt principle in a narrow sense.In a broad sense, algorithms that can achieve segmentation and clustering can be classified as the visual organization algorithm [14].Visual organization method can solve the computer visual problem such as: contour extraction, image segmentation and object detection et al.
The merging algorithm based on the visual organization consists two parts.
One of them is to merger the clutter waves.The amplitude of EEG for an adult is 10 uv -50 uv.The merging clutters algorithm is to remove the EEG with amplitude below 10uv is meaningless.The other part of the merging algorithm is to merger incomplete waves.After merging, the render shape of EEG becomes more in line with the standards of human vision.According to the study of [15], 11 kinds of merging situation are presented in the Figure 1.   is incomplete, the right is complete, and they can't be merged; (e) the left is complete, the right is incomplete, and they can't be merged; (f) the left and right are both incomplete, and they can't be merged; (g) the left and right both are complete, and they can't be merged; (h) the left is complete, the right is incomplete, when , they can be merged; (i) the left and right are both complete, when , they can't be merged; (j) the left is incomplete, the right is complete, when, they can be merged; (k) the left and right are both completes, when , they can't be merged.(c) It can be seen that r impacts the merging result directly.Zhang [15] [16] have compared the results when r was changed from 0.2 to 0.7, and found that r = 0.5 can be more adaptive to waves of different rhythm and different amplitude.So r = 0.5 is chosen in this experiment.
The Figure 4 shows the single wave merger and the picture below presents a sample merger.The blue represents the rare EEG and the green represents the EEG after merger.

Detection of Sleep Spindles
The core idea of this paper is to merger the rare EEG using the merger algorithm based on the principle of visual organization so that the time-domain feature of the waves can be more obvious.According to these features, the waves which meet the period condition of sleep spindles can be marked, and then combine these waves with same features, and last judge whether the duration time of the marked waves is meet the duration feature of sleep spindles.
(1) Detect the single wave that meets the period condition The frequency range of sleep spindle is 11 -16 Hz, so the period of the single wave is 0.07 -0.085 s.In this paper, we take the period of 0.06 -0.10 s as the period condition to detect sleep spindles.The wave that meets the condition is marked in red in the dashed box.
In the Figure 4, a represents the location of the merger point in the waveform.The period (T) of the single wave after merger is calculated following the equation below: In the Equation ( 1), fs represents sample frequency.Here the value of fs is 100 Hz or 200 Hz.The wave with period in the range of 0.06 0.1 T < < was marked in red.Shown in the Figure 4, " 1 T " is not in the range of period, so it  T " meets the period condition and the wave was marked in red.
(2) Merge the marked waves After the filter of the period, the single waves meet condition would be marked in red.If the interval distance between two adjacent marked waves meets the threshold conditions, the two adjacent marked waves can be combined, which means the waves between two adjacent marked waves would be marked in red in the dashed box.
Shown as the Figure 5, the waves in red in dashed box represent the waves that meet the period condition, 1 L and 2 L represent the interval distance between the marked waves.Set L as the interval distance, new sequence 1( ) t i to record the location of the end point in an unmarked waveform and ( ) t i to record the location of the front point in the unmarked waveform, and i represents the i th unmarked wave: In the Equation ( 2), fs represents sample frequency.Here the value of fs is 100 Hz or 200 Hz. the location of the front point in the marked waveform, and j represents the j th unmarked wave: In the Equation ( 3), fs represents sample frequency.Here the value of fs is 100 Hz or 200 Hz.> , the marked wave is not sleep spindle, and it should be removed the mark.Through calculation, 3 L keeps it was and 4 L remove the mark.

Results
The data used in this experiment is from 6 subjects' whole-nights recording.Two of them are collected from the laboratory, the sampling frequency of which is 200 Hz and the other four is downloaded from MIT [17], the frequency of which is 100 Hz.A segment of 30 minutes was extracted from each night from the central EEG channel for spindles scoring.And set a sample length of 20 sec.In Figure 7, the fragment of the detection result is shown in the dashed box: Among these: The blue is the rare EEG signal, the green is the wave after merger and the red is the marked sleep spindles.
According to the assessment method of detecting sleep spindle proposed by [18], the number of false positive (FP), true positive (TP) and false negative (FN) is recorded.Taking the duration time of sleep spindles 2sec, we calculate the sensitivity and specificity according to the equations below and the results are shown in the Table 1:   Seen from Table 1, the FP and FN exist.The main cause for FP is that the interval length between the marked waves whose duration time is less than 0.5secis lower than the threshold.They can't form a wave whose duration time longer than 0.5 sec.In addition, the period of sleep spindle is about 0.06~0.10sec,so 0.06 0.1 T < < is the detection condition of sleep spindles.Some FPs' period is just 0.06sec or 0.10sec.When the period condition changes into 0.06 0.1 T ≤ ≤ , the FP can be changed into TP.However, if to do so, the FNs would become more.Finally, we take the condition: 0.06 0.1 T < < . The main cause for FN is that some waves whose period is not in the range 0.06~0.1 would be meet the period condition because of the process of merger algorithm.Meanwhile, the interval duration time is less than the set threshold, and they would become a waveform longer than 0.5sec.We can't remove them using duration time condition.

Concluding Remarks
This paper mainly introduces that the sleep spindles are detected by the time-domain feature in the EEG processed by the merger algorithm based on the principle of visual organization.Experiment results show that after the introduction of merging algorithm, it is feasible to combine the single wave into a spindle through the organizational rules, and are close to the visual result.To detect the spindles using time-domain features is simple, efficient and very intuitive.The detection result is also good.Of course, this method also has some limitations.
When the experimental object is the patient, there will be more leakage.By analysis, the threshold for the experiments is fixed value for the training set of normal sleep data.When the data is from patients' night sleep, the threshold is not the optimal value, and the waveform cannot be combined into the waveform with the duration of more than 0.5 sec.It does not meet the conditions of duration time.Therefore, the next stage of work is the optimization of the threshold parameters, so that the detection method can be used in different subjects.
the order of the remaining points.In this case local maximum nor the local minimum point.So the local maximum point should be recalculated, and if the new sequence containing alternating local maximum and minimum points is formed.The results before and after merger are shown in Figure 2. (b) Merging incomplete waves The definition of complete waves and incomplete waves were proposed by Zhang [15] [16].Set If these points satisfy one or more following conditions, start the merging procedure in Section 2.2.1.

Figure 1 .
Figure 1.Merger result: (a) the left and right waves both are incomplete, and they are merged; (b) the left and right waves both are incomplete, and they are merged; (c) the left and right waves both are incomplete, and they are merged;(d) the left is incomplete, the right is complete, and they can't be merged; (e) the left is complete, the right is incomplete, and they can't be merged; (f) the left and right are both incomplete, and they can't be merged; (g) the left and right both are complete, and they can't be merged; (h) the left is complete, the right is incomplete, when , they can be merged; (i) the left and right are both complete, when , they can't be merged; (j) the left is incomplete, the right is complete, when, they can be merged; (k) the left and right are both completes, when , they can't be merged.

Figure 2 .
Figure 2. Merger examples, the left is the wave before, the right is after.

Figure 4 .
Figure 4. Wave meets the period condition
point and front point of the marked waves in the sample waveform.When L meets the condition:

Figure 6 .
Figure 6.Waves meet the duration time condition.

Table 1 .
Detection result of sleep spindle.