{'fraction_non_alphanumeric': 0.026440757460280236, 'fraction_numerical': 0.011608137421586446, 'mean_word_length': 4.558162267839688, 'pattern_counts': {'":': 0, '<': 1, '<?xml version=': 0, '>': 1, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
EEG – based study on sleep quality improvement by usingmusic

Use your smartphone to scan this QR code and download this article ABSTRACT Napping is essential for human to reduce drowsiness, contribute to improving cognitive function, reflex, short-term memory, and state. Some studies have shown that a certain amount of time for a nap can boost the body's immunity and reduce the danger of cardiovascular disease. Using music for relaxation and enjoyment to fall asleep is an effective solution that earlier studies have shown. There are many genres of music that have been used for stimulation, such as binaural beats or melodic sounds. The aim of the study was to confirm the positive effect of music on sleep quality by analyzing electroencephalography signal. There were four types of music is being used in this study: instrumental music, Ballad music, K-pop music, and Jazz. The study applied the pre-processing include filtering block, features extraction, and clustering steps to analyze raw data. This research calculated the power spectrum of Alpha wave and Theta wave, to detect the transition of wake sleep stages by K-means clustering algorithm. Sleep latency is one of the factors that determine the quality of sleep. The sleep onset is detected based on the phase shift of the Alpha and Theta waves. The exact timing of the sleep onset was important in this study. The user interface was developed in this study to compute sleep latency in normal andmusical experiment. As a result, music is an intervention in helping people fall asleep easier (mean of sleep latency in normal and musical experiment was 9.0714 min and 5.6423 min, respectively) but the standard deviation of this result was rather high due to the little number of experiments. However, the study concludes that listening to music before naptime can improve sleep latency in some participants.


INTRODUCTION
Sleep quality plays a vital role in the quality of life. A healthy nap can gain benefits such as reducing fatigue and stress, enhancing productivity, memory, creativity and concentration 1 . Music is a wide tool to improve sleep. In a survey of 515 patients with sleep disorders, almost half of them reported to use music as a sleep aid 2 . From 2004 -2018, there are a number of studies have focused on the positive effects of music on the quality of sleep in human. Jesperson and colleagues' research based on six included studies in a total of 314 patients reported that insomnia patients improve subjective sleep quality by using music 3 . Similarly, sedative music was also helped to improve subjectively in patients with sleep complaints 4 . The advantages of music on subjectively evaluated sleep were found in elementary school children 5 and students 6 when listening 45 minutes at naptime or bedtime for 3 consecutive weeks. Another finding provided evidence for the use of soothing music as an intervention for sleep in older adults. In 20 included trials, a metaanalysis showed positive of music measured by PSQI scores, sleep onset latency and sleep efficiency in primary insomnia patients 7 . In conclusion, the benefits of music can be proved subjectively on sleep quality in different age groups.
However, several of these studies use subjective self -report measurements as a primary outcome index and empirical findings measured sleep quality are scared and inconsistent such as Pittsburgh Sleep Quality Index (PSQI) 4-8 , Epworth Sleepiness Scale (ESS) 5 , (Montgomery Samberg Depression Rating Scale (MADRS) 6 , Beck Depression Inventory (BDI) 8 , Personality Assessment Inventory (PAI) 7 . For instance, Lai H.-L and Good M. just used the PSQI questionnaire as an outcome index while the score was not better for some participants after 3 weeks of experiments 9 .
Therefore, there are some researchers used the combination of self-report measurement and empirical research. Lazic and Ogilvie used quantitative analysis of the electroencephalogram and the PSQI questionnaire but the study did not find the differences in polysomnographic measures when subjects either listened to music, tones, or neither tones nor music 10 .
Different kinds of intervention are used such as classical music 11 , sedative music MAR (music -assisted relaxation) 12 , binaural beats 8,10 , music from paid-app (Brain.fm) 13 , music and audiobook 6 , music depending on cultural 12 .
This study examined the effects of music on sleep quality using self -assessment survey and analysis of the electroencephalogram (EEG) and showed evidence for the use of favorite music of each subject to shorten their sleep latency. This study focuses on measuring the SL value instead of others sleep parameters. The K-means clustering algorithm was used to determine the sleep onset and calculate sleep latency value. Experiments with and without music intervention will be compared the sleep latency value and assessed the positive results of music for sleep.

MATERIALS AND METHODS
This research applies the Declaration of Helsinki principles in human studies.

Subjects
Seven 22-year-old students took part in this study with no neurology medical record. They were recommended not to use caffeine or alcohol drink one day before their experiments, they were also asked to sleep enough the previous night. Subjects were invited to the Biomedical Laboratory, Ho Chi Minh City University of Technology -VNU HCMC in 30 minutes before measuring to fill out the survey and get used to the environment in Faraday cage which minimizes noisy signal.
There are two experiments -one had no intervention and the other had music intervention. The survey in this study was based on the Pittsburgh Sleep Quality Index (PSQI) 14 and some questions about the state of the subject before measuring. The PSQI is a 19item questionnaire that assesses sleep quality for the preceding month and it was used to obtain descriptive information about sleep, and this research just takes some questions related to the naptime sleep in the PSQI questionnaire including the time falls into sleep (under 15 minutes, from 16 to 30 minutes, from 31 to 60 minutes, and over 60 minutes), frequency of above phenomenon (not during the past month, less than once a week, once or twice a week, three or more times a week), etc.
When the subjects were in bed, they were attached the electrode. Once lights were out, the data were collected and the music began playing (on musical experiment) to measure the value of sleep latency (SL) correctly.

Data collection
The data signal, including electroencephalogram (EEG), electrooculogram (EOG) and electromyogram (EMG) were utilized to score sleep stages as recommended by the American Academy of Sleep Medicine (AASM) 15 and collected by NicoletOnea clinical device from Natus Medical Incorporated 16 . Three EEG electrodes were attached to positions of F4, C4 and O2 due to the international 10/20 system for EEG electrode placement. These positions were practically recommended for sleep stage scoring by the AASM standard. For EOG, an electrode was attached to the left and right sides, 1 cm below the eyelid. Two electrodes for chin EMG were placed 2 cm to the right and left of the midline and at the position 1 cm above the inferior edge of the mandible. A ground electrode was placed at the right mastoid process (M2 position), while a reference EEG electrode was placed at the left mastoid process (M1 position).

Auditory stimuli
The music was used to stimulate at first is music from the paid-app Brain.fm 11 . This online app has many genres of music depending on the purpose of the audience, such as focus, relax, meditate, nap and sleep. The music begins to be effective when it is listened for about 15 minutes. Santostasi, 2015 demonstrated the applicability of Brain.fm effectively in improving sleep, increasing concentration and relaxation 13 . However, after using the music of this software, based on the survey obtained, most subjects complained that the music made them difficult to fell asleep. From that effect, the use of available music is impossible due to the physiology and preferences of each subject. In order to overcome the above situation, the use of favorite music may is proposed. Music, as a culturally specific phenomenon, is influenced strongly by the social environment and cultural traditions 12 . Reference 17 shows that depending on their cultural background, individuals differ in their preference for music. Subjects were asked to fill out the survey about favorite music that can help them sleep easier. They were also recommended to mention from 5 to 6 songs that belong to that music genre. The required songs were combined into a complete 30-minute song and listened to by the subjects with a custom volume level. Based on the US-UK music classification standard and the result of the survey, there were four types of music: instrumental music (14%), Ballad music (28%), K-pop music (29%), Jazz (29%). These kinds of music have a gentle rhythm, smooth melody that help subjects easy to fall asleep.

Power ratio
After the signal had been filtered, a quantity calculated the power of each brainwave on the total power at the same time. The power ratio R between brainwaves was computed by applying the following formula: Whereas x is the power of each brainwave: Delta, Theta, Alpha and Beta.
P(µV 2 ) is the power of four brainwaves in one channel at the same time.

Classification
Besides the filtered data was plotted on the graph by visualization and estimation so it was impossible to determine the exact value of SL. Therefore, it was necessary to develop a model of predictive result, using the K-means clustering algorithm. This algorithm was to classify the time of Sleep -onset and determine exactly when the subjects fell asleep (SL). It is known that K-means clustering is the algorithm of unsupervised learning so the training data did not have the label. The accuracy of K-means is evaluated by comparing the two data sets: the data set of the Kmeans algorithm categorized and the data set classified by identifiable characteristics 18 as shown in Figure 1.
As shown in Figure 1, after EEG signal was denoised and filtered. Two parameters were calculated as R α and R θ . If R α was higher than 50% at one epoch, Alpha was dominated and the subject was Wake state. And if the power ratio of Theta was higher than Alpha, sometimes that value was higher than 50% at one epoch, the subject began to sleep, at stage N1.
K-means algorithm would randomly classify training data into two clusters, respectively creating two centroids of each cluster. After the data have been clustered, it is necessary to find a boundary line between the two clusters. This line is based on the definition of K-means, which is a perpendicular bisector of two centroids. Perpendicular bisector equation: Whereas: A(x 1 , y 1 ) and B(x 2 , y 2 ) were the centroid of "Wake" and "Sleep" cluster, respectively.

M = (midX, midY ): midpoint of A and B.
Set the variable test: Using (3) and assign (x,y) to test. If test<0, that point belonged to cluster "Wake" and was assigned the value "1". And vice versa, if test>0, that point belonged to cluster "Sleep" and the value was "0". As shown in Figure 2, the blue line was the perpendicular bisector that divided training data into two clusters. A green point stood for one epoch in the analysis data.
The matrix result "0" and "1" showed the transition between "1" and "0" is the epoch number. The SL value was computed by applying the following formula:

Filtered data
There were totally of 14 samples, including 7 samples with no intervention and 7 samples with music intervention. The sampling frequency of the collected data was 2000 Hz.
It can be seen from Figure 3 that the data were removed the 50 Hz noise and fixed baseline drift problem by Wavelet transform. The signal was filtered in the range from 0.5 Hz to 35 Hz, and converted from time domain to frequency domain by Fourier transform. Mother Wavelet Transform was "db7" because its waveform matches the waveform of the occipital region 19 . So, the O2 channel was used to investigate the result.

Sleep latency (SL)
Sleep onset is defined as the start of the first epoch when the subject starts falling asleep. Sleep latency is the time lights out to the first epoch of any sleep measured in min 15 . The shorter the sleep latency, the better the sleep quality. And the aim of this study is to use music to shorten the sleep latency value.
In this study, we decided to focus on Theta wave and Alpha wave, which characterize for sleep study. Alpha wave characterizes human physiological alertness, while Theta wave appears when people feel sleepy. If there is a state change between these two waves (power ratio of Alpha decreases and power ratio of Theta increases), the subject goes to sleep -sleep onset. From the moment of turning off the light and starting to measure until the subject falls asleep, that is the value of SL, in minute. It can be also seen from Figure 4 each symbol in was stood for one epoch which was 30-second long. The power ratio of Alpha and Theta were marked '*' and ' O ' , respectively. The horizontal axis was time axis (minute) and the vertical one was the power ratio R. The power ratio of Alpha reached over 0.8 at about the first 20 minutes while the power ratio of Theta was just around 0.1 at the same time. The intersection of two waves was the time subject fell to sleep. The other intersection was not investigated because the study had just focused on the fall to sleep time of the subject. The SL at the experiment without music intervention was estimated in range 21 -23 minutes. Figure 5 shows the sleep late cy at the musical experiment on the same subject. The SL value was guessed in range 13.5 -14 minutes.

Classification
The above results were evaluated by visualization and estimation so that it was necessary to develop a model of predictive result, using the K-means clustering algorithm. The classification was classified based on the flowchart in Figure 1. Table 1 shows the accuracy of the K-means clustering algorithm. The accuracy was quite high (the lowest was 93.75%) and three data sets with 100% accuracy were three training data sets. This study investigated in naptime, therefore the subjects woke up randomly. So, the length of each experiment was different, which caused incorrect accuracy.

Statistical analysis
To test for differences between with and without music intervention, paired -samples for means t-test model was used. Statistical analysis impact of music to shorten the value of SL.  Figure 6 shows the sleep latency value of each subject in two experiments: with and without music intervention. There are many different sleep latency values because each SL value depends on each person. To illustrate this, subject 1 reported in the survey that he did not have a habit of napping, and music helped him to fall asleep easier. Besides, subject 3 usually had a break in the afternoon, for this reason, SL value was not much different between the two experiments. In sum, this research measures the change of sleep latency by using their favorite music and shows the result that music can improve sleep in people who cannot sleep in naptime.
It can clearly be seen that music helps to shorten SL value of each subject, which makes people fall asleep easier. But the SD value was high due to some reasons below: • The number of samples was limited.
• The SL value difference between subjects was highly depended on the habit of having nap sleep. • The laboratory environment is not suitable for some subjects owing to the enclosed space of Faraday cage and noise.

User interface
To develop user interface by using GUIDE in MAT-LAB that helps the data were analyzed more convenient. Figure 7 shows the GUIDE developed in MAT-LAB with some main button to analyze data: -PLOT: the data were filtered and analyzed by using Options. Then analyzed data were plotted on three graphs to evaluate the results.
-Sleep latency: plot the power ratio of Theta and Alpha and export a dialog box of SL value as shown in Figure 8.

CONCLUSION
The present study had built an interface user to analyze EEG signal using FFT, Wavelet, power ratio and K-means clustering algorithm. Instead of measuring SL by visualization or available self-reported questionnaire, this study is empirical research that combines both the above methods. A new point of the research is Machine learning in analyzing data to calculate the SL value.
The main aim of this study was to confirm that music affected to shorten the SL value -one factor in improving sleep quality, which helped the subject fall asleep easier and faster by using favorite music of each subject. However, there were some shortcomings that needed to be improved. The number of subjects and experiments was limited so that the result was not accurate. In the near future, this research can be measured more samples and limited the noise. Besides investigating each person's response to certain types of music.