# Drowsiness Transitions Detection Using a Wearable Device
## 3 Materials and Methods
### Analysis Procedure  
In order to analyze the data collected from the simulations, the heart rate variability was computed using the data from Empatica E4 device. First, the R-R Intervals, which are the time between consecutive heartbeats [34], were extracted. Then, a resampling of the data into equal intervals was needed. The next step was the cleaning of the signal, where  
Figure 1: Driving Simulation Procedure. the outliers and ectopic beats were removed, and the cubic interpolation was considered to replace these values. Last, the time, frequency, and nonlinear domains from the heart variability metrics were extracted, every two minutes. In theory, the time domain is the quantification of the heart rate variability over a period of time. Conversely, the frequency domain is the absolute or relative signal power, and the nonlinear domain is the unpredictability and complexity [11]. After gathering the heart rate variability dataset, the PCA was conducted, where three principal components were considered, taking the heart rate variability domains into account. For each principal component, the Hotelling \(T^{2}\) and SPE statistics and the given upper limit control were computed to identify the out-of-control points. Future work in [21] defined the inclusion of one additional principal component with the accelerometer data as requiring more investigation. When the arm is moved, for example, this sensor gathers vital information about the movement of that action. The Empatica E4 was 3-axis (X, Y, and Z) accelerometer that collects continuously gravitational force, every second [35]. In order to analyze this information it is necessary to organize the collected data to be in accordance with heart rate variability metrics. Thus, the coefficient of variation (cv), Equation (8), was computed every two minutes. \[cv=\frac{s}{\pi}\times 100 \tag{8}\]  
where \(s\) and \(\pi\) represent respectively the standard deviation and the mean of a given sample. This value is a well-known statistical measure used to compute the percentage of variation of the mean value. The sample can be considered consistent if the coefficient of variation is less than 33 [36]. When such happens, every two minutes, the mean value is used for each feature X, Y, and Z. Otherwise, the median value is considered. After the preparation of the dataset, the multivariate statistical process control was considered to identify the out-of-control points in the accelerometer information, using only one principal component. Note that these points can represent signal noise. Finally, the drowsiness phases classification, by videoing the participant's face, was performed considering [PERSON]'s drowsiness scale [16]. The drowsiness was classified into five levels: not drowsy (S1), slightly (S2), moderately (S3), significantly (S4), and extremely drowsy (S5). For this classification, it is necessary to look at the eye movement, the time between blinks and the number of blinks, mouth movements, unnecessary motions, yawns, deep breathing, eye closure, and head movements. Note that only two experts labeled the drowsiness phases so that each one rated half of the participants. One disadvantage of this approach is the great amount of time required to visualize and label all the videos, meaning that this method is not automated. For a better understanding of what has been explained above, a flowchart was created with all the steps performed, both for the classification of the drowsiness phases as well as the construction of the dataset and methodology implemented (Figure 2). The main goal of this analysis was to compare the out-of-control points using the heart rate variability and verify if there are points that occurred due to signal noise at the same time. Furthermore, it is important to conclude if the noise is influencing the out-of-control points in the heart rate variability and, consequently, reducing the number of points that are not a drowsiness transition.