1 Introduction

Social and economic changes have contributed to changes in sleep habits, effectively reducing sleep quantity and quality. Long-term sleep deprivation can lead to dysphoria, irritability, lack of self-control, and other emotional instability. It can also contribute to a decline in cognitive ability, alertness, and judgment while increasing susceptibility to immune function disorders. Over time, poor sleep quality is not only harmful to health, but also affects work and learning performance (Passarella and Duong 2008). This issue has been exacerbated by the popularity of Internet-enabled mobile devices, with users frequently sleeping later and less because of frequent online or media-consumption activity.

Sleep quality is difficult to assess objectively. The past studies have primarily relied on subjective assessment methods such as questionnaires and scales, with clinicians seeking to diagnose sleep disorders through inquiring into subjects’ sleep conditions, lifestyles, and mental stress. Results are necessarily subjective and dependent on individual experience, leaving them prone to error. Polysomnography (PSG) is currently the most accurate sleep quality detection method, using data from multiple physiological signals for sophisticated analysis to diagnose sleep disorders. However, PSG implementation is time and labor intensive, and frequently requires several months to arrange. Moreover, the recording process is complicated and requires assessment of a large number of indicators, making it difficult to implement and disseminate. Therefore, clinicians require a sleep quality assessment tool which provides the objective accuracy provided by the physiological signal detection of PSG without its implementation drawbacks.

Many studies have confirmed a correlation between brainwave activity and sleep quality (Sugi et al. 2009; Trojan et al. 2012; Koley and Dey 2012; Bajaj and Pachori 2013). This study combines fast Fourier transform (FFT) and fuzzy Petri nets (FPNs) to develop a sleep quality detection model. Through analyzing EEG results, key brainwave features are identified for the accurate measurement of sleep quality, providing suggestions for clinicians and their sleep disorder patients.

Many studies have shown that bedtime behaviors or food consumed before going to bed have an impact on sleep quality (Wang et al. 2014; Ko and Lee 2014). However, few studies have examined the impact of the use of mobile devices on sleep quality. This study thus designs three different mobile devices using behaviors (internet surfing, watching videos, and playing games) prior to sleep. Changes of brainwave features are observed, and through brainwave analysis and sleep quality questionnaires, we explore the possible impact of these three behaviors on sleep quality.

2 Related works

2.1 Sleep quality and detection

Sleep is a crucial human activity, and the therapeutic effectiveness of sleep depends on sleep quality. Sleep quality determines the extent to which the body and mind are resting during sleep, and thus sleep’s restorative effect. Over time, poor sleep quality can lead to irritability, fatigue, and low productivity, among other issues. Sleep quality is determined by a range of complex, interrelated physiological, psychological, and environmental factors. Therefore, assessing sleep quality can be rather difficult.

Sleep quality refers to a comprehensive qualitative and quantitative self-assessment of sleep effectiveness in meeting individual sleep needs (Buysse et al. 1989). Good sleep quality should include less than 30 min of sleep latency (the length of time takes from lying down to sleep), one or fewer instances of wakefulness during the night with a total of less than 20 min of sleep interruption, and sleep efficiency over 85% [calculated by Total Sleep Time (TST)/Time in Bed (TIB)] (Morin et al. 2006). Lerner (1982) suggested that characteristics of poor sleep quality include: (1) poor sleep efficiency; (2) long awakening time; and (3) declining deep sleep. Cohen et al. (1983) argued that poor sleep quality was indicated by (1) sleep time less than 6 h, (2) sleep latency exceeding 30 min, and (3) more than three instances of wakefulness during the night.

Methods for sleep quality detection can be divided into three categories: (1) self-subjective assessment; (2) objective instrument measurement; and (3) sleep activity observation.

  1. 1.

    Self-subjective assessment: a post-experiment questionnaire is used to investigate subjects’ subjective perception towards sleep, covering the relevant attributes of the assessment of sleep quality, such as total sleep time, number of instances of wakefulness at night, and other sleep disturbances. Different assessment questionnaires have been developed for different research purposes.

  2. 2.

    Objective instrument measurement: objective scientific instruments are used to monitor physiological changes in sleep as a basis for sleep quality assessment and sleep disorder diagnosis.

  3. 3.

    Sleep activity observation: healthcare providers directly observation subjects’ sleeping behavior or activity to understand subjects’ sleep condition. This approach is time and labor intensive and is relatively inefficient.

Advances in sensing technology and wearable devices have allowed researchers to objectively evaluate sleep quality via the collection and quantification of physiological data, rather than through subjective questionnaires and observation. Key considerations include using physiological sensing technology to capture the physiological signals during sleep, the development of sleep detection models, and perform sleep quality detection without influencing sleep.

Most previous studies analyzing brainwaves as indicators of sleep quality have used EEG with data mining, neural networks, and statistical analysis. Sugi et al. (2009) developed a sleep apnea syndrome detection model by capturing the frequency band of EEG and electromyography (EMG) and calculating the amplitude of each frequency band. Leistedt et al. (2007) used detrended fluctuation analysis to analyze the sleep quality of male patients with acute depression, using the EEG characteristics of SWS and rapid eye movement (REM) sleep to assess sleep quality. Based on changes to EEG and heart rate of participants with restless legs syndrome (RLS), Ferri et al. (2007) used ANOVA analysis to find significant changes in the waveform of β and δ waves for participants with poor sleep quality. Saletu-Zyhlarz et al. (2002) examined whether use of drugs impacts participant sleep quality and used the Wilcoxon test to identify significant changes in EEG signals. The result shows that drug use can have a negative impact on sleep quality.

2.2 Effects of bedtime behavior on sleep quality

Many studies have examined the effect of bedtime behavior on sleep quality. Kenney et al. (2012) studied 261 college students and found that drinking alcohol resulted in cases of poor sleep quality, but the impact was not significant. However, alcohol consumption has been found to have a significant negative impact on sleep quality, and affects daily behavior the following day. Other studies have found that listening to light rhythmic music as one goes to sleep relaxes the brain and produces better sleep quality (Shum et al. 2014; Wang et al. 2014). In addition, warmer body temperatures whether through climate control or by bathing prior to sleep, are known to improve sleep quality (Liao et al. 2005, 2013; Raymann et al. 2007). Massage has been found to stimulate nerves, relax muscles, and promote blood circulation, thus reducing sleep latency and the frequency of overnight awakening, thereby improving sleep quality (Ejindu 2007; Ko and Lee 2014).

2.3 Fuzzy reasoning technologies

In the past few years, fuzzy logic has been widely applied in a wide range of fields including intelligent controls, fault diagnosis, industrial systems, and decision support systems (Chen and Chung 2006; Wang and Chen 2008). Traditional logic assesses objective facts to seek a result which is entirely correct or entirely incorrect. However, things aren’t always so clear cut in the real world. Fuzzy logic concepts can assist in making determinations that allow for a degree of correctness along a continuum from 0 to 1. Applying fuzzy logic approaches to solve problems is a process referred to as fuzzy inference. Fuzzy inference systems are based on the theory of fuzzy sets, which consist of fuzzifiers, membership function, fuzzy rules bases, inference engines and defuzzifiers (Chen 1996; Pedrycz and Chen 2015a, b). The fuzzifier maps observe real-world values to fuzzy sets. After establishing a fuzzy rule base, the fuzzy inference system can map relationships between input and output values. The degree of correctness of a given proposition is determined based on the membership function, after which the fuzzy inference is used to obtain appropriate inference results (Chen and Hsiao 2000; Horng et al. 2005).

3 Methods

3.1 Fast Fourier transform

Real-time signal processing systems require accelerating the computing speed of the discrete Fourier transform (DFT). Thus the fast Fourier transform was developed to reduce the computational complexity of the Fourier transform by processing the original value N of the DFT as two sub-numbers N 1 and N 2, and letting N = N 1 N 2, thus accelerating the Fourier transform estimation process. The equation of DFT is expressed as following:

$${X_k}=\sum\limits_{{n=0}}^{{N - 1}} {{x_n}{{\text{e}}^{ - j\frac{{2\pi }}{N}kn}}} ,\;k=0,1,2,3, \ldots ,N - 1,\;{{\text{e}}^{ - j\frac{{2\pi }}{N}kn}},$$
(1)

where N is the sequence number; x n is the original signal, and X k is a complex number (spectrum).

3.2 Fuzzy Petri nets

A Petri net (PN) is a mathematical tool useful for describing and analyzing the behavior of modeled systems. In recent years, it has also been used to express the meaning of knowledge and logical relationships between knowledge constructs, and has been applied in areas such as knowledge management and decision making. However, PNs cannot analyze systems with complex, ambiguous, or uncertain information. To deal with data ambiguity, Looney (1988) proposed fuzzy Petri nets (FPNs) which integrate the fuzzy set concept in to a Petri net framework to represent uncertain information or complex rules in modeled systems.

FPN is a kind of graph framework with two types of nodes: places and transitions. In addition, FPN circles indicate the places and bars which reflect transition status. A places token is a real value in the range from 0 to 1. Every transition is then connected with a certainty factor (CF) value. If the condition of input tokens connected to a transition node is satisfied, the transition can be fired. The tokens are moved from input places to the output places. Directed arcs represent the relationships between two places. Figure 1 illustrates an FPN framework (Chen et al. 1990).

Fig. 1
figure 1

Definition of FPN (Chen et al. 1990)

3.2.1 Fuzzy production rules

Fuzzy theory has been widely applied in the field of decision-making and expert systems. FPRs are sets of fuzzy IF-THEN rules that are suitable for dealing with particular classification or decision problems. FPRs can be produced manually by experts, through knowledge extraction, or through automated learning based on data characteristics. FPRs are usually presented as fuzzy IF-THEN rules. The antecedent portion is described as a fuzzy set, so input values must be fuzzified based on their associated membership functions. The consequent portion obtains the result through fuzzy logic inference and is also expressed in the form of fuzzy set. The composition of fuzzy relations can be used to combine different fuzzy correlations. In FPR rule types, the certainty factor function is used to describe the relationship between place p i and place p j . The truth degree of the propositions for all input places is matched with facts by membership functions. The certainty factors (CF) are calculated by (2), (3) and (4). Then, the Fuzzy reasoning can draw the approximate values based on a set of FPRs.

3.2.2 Certainty factors’ theory

In this paper, the certainty factor model is used as the CF function of the transition node in a FPN. The use of certainty factors to deal with uncertain knowledge was originally developed for the expert systems MYCIN and EMYCIN (Buchanan and Shortliffe 1984). This certainty factor reflects the degree of uncertainty that is the total strength of belief or disbelief in a hypothesis. Two measures of uncertainty, MB[h, e] and MD[h, e], are used to measure the degree of belief or disbelief that evidence e affects hypothesis h (in a range between 0 and 1). The degree of belief and disbelief in hypothesis h is based on evidence e. Some evidence e will increase the degree of belief, and some evidence e will increase the degree of uncertainty. Therefore, the certainty factor CF[h, e] is defined as the difference between the measures of belief and disbelief, as shown in Eq. (2) (Buchanan and Shortliffe 1984; Shih et al. 2010):

$${\text{CF}}[h,e]={\text{MB}}[h,e] - {\text{MD}}[h,e],$$
(2)

CF is the certainty factor for hypothesis h when evidence e appears; MB reflects an increase in the measure of belief in hypothesis h due to the existence of evidence e; and MD reflects an increase in the measure of the disbelief in hypothesis h due to the existence of evidence e. The measures of belief MB[h, e] and disbelief MD[h, e] are defined based on following probability theory (Buchanan and Shortliffe 1984; Shih et al. 2010):

$${\text{MB}}[h,e]=\left\{ {\begin{array}{*{20}{l}} 1&{{\text{if}}\;P(h)=1} \\ {\frac{{\hbox{max} \left[ {P(h|e),P(h)} \right] - P(h)}}{{\hbox{max} \left[ {1,0} \right] - P(h)}}}&{{\text{otherwise}}} \end{array}} \right.,$$
(3)
$${\text{MD}}[h,e]=\left\{ {\begin{array}{*{20}{l}} 1&{{\text{if}}\;P(h)=0} \\ {\frac{{\hbox{min} \left[ {P(h|e),P(h)} \right] - P(h)}}{{\hbox{min} \left[ {1,0} \right] - P(h)}}}&{{\text{otherwise}}} \end{array}} \right.,$$
(4)

where P(h|e) is the conditional probability, P(h) represents a priori probability. It is impossible for the same evidence e to increase both the belief and disbelief a single hypothesis h. Therefore, MB and MD must satisfy mutually exclusive rules.

4 Experiment

4.1 Participants and materials

In this study, brainwave data are used as training and test samples. Training data are collected from 36 healthy participants (23 males and 13 females) aged 20–25 years. All subjects did not currently suffer from any sleep disorders and provided formal consent. Subjective perceptions were measured using the Verran and Snyder–Halpen Sleep Scale (VSHSS) (1987). The scale type is a 10 cm horizontal line of visual analogue scales which contains a total of 15 questions. Each subject completed the questions in terms of his/her perception of sleep from the previous night. Scores for each question ranged from 0 to 100, for a total score of 1500. Sleeping brainwave data were collected using wearable MindWave Mobile EEG headsets (NeroSky) with electrodes positioned on the prefrontal cortex and a sampling frequency of 512 Hz.

During the experiment, subjects entered a dedicated sleep room 2 h prior to going to bed. After adapting to the environment, subjects followed their regular bedtime routine while wearing the brainwave headsets. Sleeping brainwave data were collected throughout the night. The following morning, subjects were asked to complete the VSHSS as the basis for marking the corresponding brainwave data as indicative of good or poor sleep quality. After eliminating disrupted and excessively noisy signal brainwave data, we had collected 168 days of full night brainwave data and corresponding questionnaire results, with a poor/good sleep quality ratio of 63/105.

4.2 Sleep quality detection

The sleep quality assessment model consists of three stages: EEG filtering, feature extraction, and model construction.

4.2.1 EEG filtering

Brainwave signal collection is easily disrupted by subject blinking, head movement, and other actions. This study uses the MindWave instrument’s built-in noise filtering function to reduce signal interference by eliminating unwanted frequency bands through high-pass and low-pass filtering.

4.2.2 Feature extraction

The power spectral density (PSD) is obtained by transforming time-domain signals into the amplitude of multiple frequency bands via a fast Fourier transform (FFT) algorithm. Four frequency bands β(13–30 Hz), α(8–13 Hz), θ(4–8 Hz), and δ(0.1–3 Hz) are selected from the overall frequency band O(0.5–30 Hz). The percentage of four frequency bands power on the overall frequency band power are calculated as the frequency features, respectively, β ratio, α ratio, θ ratio, and δ ratio.

Furthermore, this study divides overnight sleeping brainwave data into 1000 time segments and calculates the intermediate value of maximum difference value between the brainwave power of good and poor sleep quality for each segment t i , i = 1,2…1000 as the threshold value. Next, we calculate the total time of good sleep quality divided by total overall time to obtain the proportion of subjects’ brainwave in the overall frequency band and four frequency bands as characteristics for sleep quality assessment, expressed as O pow, α pow, β pow, θ pow, and δ pow.

4.2.3 Membership function

This research decides the reasonable threshold line with minimize entropy principle approach to build the appropriate membership functions (Christensen 1980), and then use the triangular and trapezoidal fuzzy number to start the fuzzification process (Ross 2009). Figure 2 illustrates the β ratio values with different fuzzy membership functions and detail calculation was introduced by Chiang and Wu 2017.

Fig. 2
figure 2

Fuzzy membership function of β ratio

4.2.4 Model building

To construct the sleep quality assessment model, this study randomly selected training data and testing data in a 7:3 ratio from the 168 objective field observations, for a total of 117 training samples (71 good and 46 poor) and 51 testing samples (34 good and 17 poor). In this study, nine brainwave feature variables are used as FPN input parameters to train samples to verify whether the data can be individually focused according to objective class.

We first use the fuzzy membership function to calculate the truth degree of proposition of each feature variables based on changes in brainwave. Next, use the CF theory to calculate the CF value between antecedent and the consequent based on different types of FPRs. Then, we can gain the FPRs by integrating the propositions and certainty factors, and Fig. 3 shows the FPN reasoning model. Finally, fuzzy reasoning is applied to compare the degree of membership of one EEG signal record in both the good and poor sleep quality clusters (Chen et al. 1992; Chen 2002). We speculate that the EEG signal is more likely to belong to the cluster with the higher degree of membership.

Fig. 3
figure 3

FPN reasoning model

4.3 Evaluations of FPN

To evaluate the proposed FPN sleep quality assessment method, the results are compared using WEKA v3.9.1 against several well-known classification algorithms including support vector machine–sequential minimal optimization (SVM–SMO), adaboostM1, logistic, decision tree (C4.5), Naïve Bayes (NB), and Bayes Net (BN). The evaluation indicators are as follows:

  1. 1.

    True positive rate (TP), the test result is good sleep quality and the actual situation is good sleep quality;

  2. 2.

    True negative rate (TN), the test result is poor sleep quality and the actual situation is poor sleep quality;

  3. 3.

    False positive rate (FP), the test result is good sleep quality, but the actual situation is poor sleep quality;

  4. 4.

    False negative rate (FN), the test result is poor sleep quality, but the actual situation is good sleep quality.

  5. 5.

    TP/(TP + FP), showing the ability to identify sleep quality (the accuracy of the test result).

  6. 6.

    TP/(TP + FN), showing the ratio of all detected good sleep quality instances.

  7. 7.

    F-measure: 2 × TP/(2 × TP + FP + FN), evaluating the comprehensive testing accuracy of the classification method.

  8. 8.

    AUC: the area under ROC curve. Greater AUC value indicates better classification performance.

  9. 9.

    Accuracy: number of accurate classification of good and poor sleepy quality/total number of samples.

Table 1 shows the results of all classification methods. Our proposed FPN outperforms the other methods for most of the indicators. Therefore, FPN provides the best overall performance, indicating its suitability for sleep quality assessment.

Table 1 Performance measure of different approaches

5 Impact of bedtime behavior on sleep quality

Experiments were conducted using various mobile device behavioral scenarios (Internet browsing, watching videos, and playing games) to understand their impact on sleep quality.

5.1 Subjects

This study screened 36 physically and mentally healthy participants for analysis. The participants included 23 (63.9%) males and 13 (27.1%) females aged 20–25 years with an average age of 22.4. None suffered from hearing impairments or had a history of serious illness including sleep disorders, cardiovascular disease, mental illness, or psychological trauma. No participants had taken any medication for the 2 weeks preceding the experimental period, and each had at least 7 h of daily sleep for each of the three consecutive days prior to testing. All participants abstained from stimulants (tea, coffee, etc.) and alcohol beginning on the first test day.

Four different scenarios were constructed, with six participants forming the control group, and ten participants in each of three experimental groups, respectively, using smart phones for 30 min before sleep to conduct the following activities: (1) Internet browsing; (2) video watching; and (3) game playing. Testing proceeded over five continuous nights. The control group went to bed without using mobile devices. When participants reported feeling sleepy, the electrodes were attached and they were permitted to fall asleep, with the EEG apparatus recording continuous brainwave signals overnight. The next morning, upon waking, participants were asked to complete a VSH sleep scale questionnaire to assess sleep quality (Fig. 4).

Fig. 4
figure 4

Experimental process

5.2 Impact of bedtime behavior on sleep quality

  1. 1.

    VHS sleep scale

Table 2 shows that video watching has a significantly negative effect on sleep quality, followed by Internet browsing. In the video watching group, two participants showed signs of fatigue prior to the experiment on the fifth day (D 5) and leading to higher scores for subjective sleep perception, and resulting in lower but insignificant D 2 vs D 5 averages. Playing mobile games was found to have a less severe impact than the other two activities.

Table 2 Paired-samples t test (VHSSS)

We used the daily average score from D 2 to D 5 for the three experimental groups to obtain a sleep quality trend line. Figure 5 shows that the scores of the VHS sleep scale of the three groups show a downward trend, indicating that using mobile devices before going to bed leads to poor sleep quality. The average score of the video watching group is lower than the other two groups and shows a steeper decline, indicating a greater impact on sleep quality, while game playing shows a more gentle decline.

Fig. 5
figure 5

Sleep quality trends for various bedtime activities

  1. 2.

    EEG characteristics analysis

To understand the images of different brainwave features for different bedtime activities, we subjected the D 2 vs D 5 brainwave data to a paired-samples t test. In Table 3, β amp (t = −2.342, p < 0.05) shows that the Internet browsing group exhibits significant differences in the β pow feature. For the video watching group, the features β ratio (t = 3.301, p < 0.05), β pow (t = 2.317, p < 0.05) and δ pow (t = −2.560, p < 0.05) show significant differences. There are no significant differences in any brainwave features in game playing group.

Table 3 Paired-samples t test (EEG signal)

The β band exhibits stronger activity mostly when people are awake and processing received external signals. β ratio refers to the activity of the β band. β pow refers to the proportion trend towards good sleep quality; although it rising, it is still a very low proportion, suggesting that the Internet browsing group is mainly occupied with social media which requires immediate signal processing and response, resulting in a rise in β ratio during sleep and explaining the significant change in β pow. The video watching group primarily watched YouTube videos and APP-based dramas. Both the β ratio and β pow declined, but δ pow increased along with O pow, indicating good quality sleep, in contrast to the conclusions of the VHSSS scale. This may be because two participants noted feeling particularly tired on D 5, resulting in improved sleep quality. This may also explain the lack of significance for D 2 vs D 5 in the video watching group. Game playing before going to bed was found to have no significant impact on sleeping brainwaves.

5.3 Gender impact on sleep quality

To understand the impact of gender as a mitigating factor in the effect of different bedtime activities on sleep quality, independent-samples t test using VHSSS sleep quality scores were performed for the three different experimental groups, with the results summarized in Table 4 showing gender had no significant impact in any of the three groups. The VHSSS mean scores of female subjects show a downward trend in D 3D 5, while the mean scores of male subjects show an initial upward trend which is later reversed. The results show that all three tested bedtime activities have a negative impact on the sleep quality of female subjects. Watching videos had a greater impact on sleep quality for both men and women, leading to relatively poor sleep quality.

Table 4 Independent-samples t test for gender (VHSSS)

5.4 Comparison of different bedtime activities

To understand the impact of different bedtime mobile device activities on sleep quality, we designed an experiment with control group (which did not use mobile devices prior to sleep) and three different experimental groups (Internet browsing, video watching, and game playing), and observe the results of the VHS sleep scale and changes of brainwave on the fifth day. One-way ANOVA was used to analyze differences between the groups.

Table 5 shows a significant difference between the control and experimental groups. Although Internet browsing and game playing exhibited no short-term negative impact on sleep quality, negative impacts emerged over long-term observation. Video watching was found to have a more significant negative impact on sleep quality than the other two activities.

Table 5 ANOVA test of different bedtime behaviors (VHSSS)

Changes in the brainwave features for the different groups show a significant difference between the control group and Internet group, where β ratio(p < 0.05) and β pow(p < 0.05). For the control group and video group, O pow(p < 0.05), α pow(p < 0.05) and θ pow(p < 0.05). Moreover, a significant difference is found between the control and game groups, O pow(p < 0.05) and θ pow(p < 0.05). The above results indicate that the β and θ bands may be the main bands that affect sleep quality. Furthermore, the proposed new brainwave feature variables O pow, α pow, β pow, and θ pow may serve as important references for assessing sleep quality (Table 6).

Table 6 ANOVA test of different bedtime activities (EEG signal)

6 Conclusion

An FPN-based sleep quality assessment method is proposed. By analyzing overnight EEG data, we develop new brainwave variables O pow, α pow, β pow, θ pow, and δ pow to assess sleep quality. Experimental results indicate that these variables are effective for assessing the impact of different bedtime activities on sleep quality. Moreover, most indicators of the proposed assessment model outperform other data mining methods, and can provide objective and efficient sleep quality assessments to doctors and their patients.

We also experimentally explore the impact of bedtime use of mobile devices on sleep quality and brainwave activity. Results show that Internet browsing and video watching on mobile devices prior to sleep both have a negative impact on sleep quality, with video watching having the greatest impact. Such activities have a negative impact on sleep quality for both males and females, but the impact is more severe for women. Brainwave feature analysis shows that β ratio and β pow have more significant brainwave feature response for Internet browsing, while O pow, α pow, β pow, and θ pow are more significant for video watching, and O pow and θ pow for game playing. The β and θ bands have a crucial impact on sleep quality.