# Use Electroencephalogram Entropy as an Indicator to Detect Stress-Induced Sleep Alteration
## 2 Materials and Methods
### Data Analysis
#### 2.5.2 EEG Parameter Investigation  
Spectrum  
The spectrogram was computed using the multitaper method from the open-source MATLAB toolbox Chronux (version 2.10) [26]. The time-bandwidth product parameter was set at 3, and the number of tapers was set at 5. The power for each frequency was subsequently z-scored, to minimize the difference of absolute power between different subjects. Before analyzing the entropies of amplitude, frequency, and phase, the instantaneous amplitude, frequency, and phase of every sampling point were calculated first. To be specific, the raw EEGs were converted by Hilbert transformation. This transformation gave complex numbers for every sampling point. The instantaneous amplitudes were obtained by calculating the absolute values of the complex numbers [27]. Similarly, the instantaneous phases were obtained by calculating the angles of the complex numbers. For the instantaneous frequencies, the raw EEG data were filtered between 0.5 to 30 Hz from a Hamming window and, then, converted by Hilbert transformation. Subsequently, the differences in the phases between sampling points were then computed, by measuring the angles of complex numbers. By determining the differences of the phases within the delta time (in our setup, the sampling rate was 128 Hz), the instantaneous frequencies can be acquired [11]. For instance, a difference of pi/128 gives an instance frequency of 2 Hz. The Shannon entropy was used to compare the differences of EEG waveforms after being exposed to the footh shock. The Shannon entropy equation is as follows [25]. \[\mathrm{H}(X)=-\sum_{i=1}^{n}\mathbf{P}(\boldsymbol{x_{i}})\ \mathbf{log_{2}} \mathbf{P}(\boldsymbol{x_{i}})\]  
The entropy \(\mathrm{H}(X)\) is the summation of \(\mathrm{P}(x_{i})^{*}\mathrm{log_{2}}\mathrm{P}(x_{i})\), and the \(\mathrm{P}(x_{i})\) is the probability of occurrence of event \(x\) under \(i\) circumstance. In our study, we applied the equation to measuring the entropies of amplitude, frequency, and phase. We, firstly, sorted the variables (i.e., amplitude, frequency, or phase) into n levels (nAmplitude = 15, nFrequency = 25, nPhase = 12). For amplitude entropy, the z-scored amplitudes between \(-\)0.4 and 1.4 were sorted into 15 levels, as we noticed most amplitudes were within this range. For frequency entropy, frequencies between 0.5 and 30 Hz (the range of predominant frequencies for sleep and wakefulness) were sorted into 25 levels. For phase entropy, the phases between 0 and 2*pi were sorted into 12 levels. The numbers or levels were related to data distribution and the number of data points, so we used the Freedman-Diaconis rule to determine them [28]. \[nlevels=\frac{\max(x)-\min(x)}{2Q_{x}n^{\frac{1}{2}}}\]  
\(Q_{x}\) is the 25 th and the 75 th percentiles of the data \(X\), \(n\) is the total number of data points, and \(\max(x)\) and \(\  
especially during the first 2 h. The spectrograms (Figure 2G,H) and panel of significance test (Figure 2I) depicted an enhancement of high frequencies (25-30 Hz) during the first 2 h after the footh shock stimuli (the black-dashed-line area of Figure 2I). From the result of the spectrogram analysis, we postulated that the distinct EEG profiles would be clearer if we measured entropies of the EEG features because we noticed the consistent alterations of EEGs between the control and footh shock groups. For instance, the control group had a wider theta band than those in the footh shock group (Figure 2D vs. Figure 2E, the arrow area demonstrated the power intensity). Since entropy is only related to the probabilities and distributions of the data, it can detect both linear and non-linear changes. Moreover, entropy is insensitive to the effect of the power law (i.e., higher frequency shows lower power), so it may reveal some underlying changes of EEGs. Figure 1: Comparison of the duration between distinct vigilance stages. (**A**) NREM sleep duration. The solid line and light gray shadow represent the values of means \(\pm\) SEMs, for every 15 min during the light period in the control group.