{'fraction_non_alphanumeric': 0.02787472238589494, 'fraction_numerical': 0.013053528531931287, 'mean_word_length': 4.797162375197058, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Designing an Intelligent System to Detect Stress Levels During Driving

: In addition to the devastating effects of anxiety and stress on the development and exacerbation of the cardiovascular disease, lack of stress control increases drivers' risk of accidents. This paper aims to identify the stress of drivers in various driving situations to warn the driver to control the tense conditions during driving. In order to detect stress while driving, we used the heart signals in the Physionet database. To analyze the conditions of the electrocardiogram (ECG) under various driving situations, linear and non-linear features were used. The characteristics of the RRIs are the only able to identify driver stress in different driving modes relative to rest periods, while the return mapping features, in addition to identifying driver stress while resting, have the ability to identify stress between different driving positions also brought. The results showed that driver's stress level during driving in city 1 and highway 1 with a P-value of 0.028 and also in city 3 and highway 2 with a P-value of 0.041 can be distinguished. The accuracy obtained from the proposed detection method is 98±2% for 100 iterations. The result indicated an efficiency of our proposed method and enhanced the reliability.


Introduction
In addition to the significant risk factors for heart disease, including cholesterol and high blood pressure, lack of physical activity, smoking, and diabetes, stress (nervous tension) is also the main factor associated with cardiovascular disease. When a person gets stress, the body secretes hormones called epinephrine, norepinephrine, which increases blood pressure and, over time, damages to the lining of the arteries. The amount of plaque deposition increases with the restoration of the arteries and thicken them. The heart rate and blood pressure can be increased with stressful conditions, and in this case, the heart's need for oxygen is greater than before [5]. In some people with heart disease, increasing the heart's need for oxygen can lead to chest pain (angina). Stress also increases the clotting factors in the blood, which increases the likelihood of clot formation and blockage of the arteries, especially in cases where it has been somewhat obstructed by a plaque [12].
Driving accidents are responsible for more than 50% of deaths worldwide between the ages of 15 to 44 and about 1.35 million deaths are due to road traffic crashes [28]. In Iran, driving accidents are the second leading cause of death [11]. Driving is a skillful work that requires a full focus and a critical balance between consciousness and a calm situation [15]. The result of public vehicle transportation in urban centers is among the most stressful and unhealthy modern jobs. People with this mental disorder should not be placed in drivers of personal or public vehicles to jeopardize their health and others [13].
High-stress can cause a lot of social damage and, if not properly and timely controlled, costs including the provision of health services for people who suffer from the disease due to high levels of stress as well as the high cost of driving disability caused by severe stress, are imposed on individuals and the community [15,21]. Moreover, stress makes people cranky and negatively affects the overall life quality of individuals. Therefore, controlling and reducing stress leads to a healthier and happier society and plays a significant role in developing that community [22].

Background and Related Works
Many studies have been carried out to determine the stress of a driver during driving. In the following, some research conducted on the methods of driver stress detection and structural categories will be discussed. By reviewing the background related to this topic, it is possible to improve the previous methods and techniques and use new and more precise methods.
Jeong et al. [10] investigated the detection of drivers' stress using the electrocardiogram (ECG) signal in Turkey. The experiment was conducted on 6 people, including 5 men and one woman, aged 26 to 33 years, with an average age of 27.2 years who learned driving. None of these people had pathological changes and physical defects. This study measured the driver's stress level using the ECG signal and analysis of Heart Rate Variability (HRV) and other signals during driving. The results indicated that this system provides more comfort for the driver by placing electrodes on the steering wheel, gear, and rest position of the arm on the driver's side door. Therefore, it is very useful for driving because it records body signals without affecting the performance of the steering wheel and other parts.
Another study was conducted in 2012 by Singh et al. [26]. Their research focused on identifying drivers' stress levels while driving, using biological signals. Data is collected in 5 modes of driving (primary driving mode for 10 minutes and relax (pr-dr), relax driving for 8 to 9 minutes (rx-dr), driving in busy and traffic for 8 to 9 minutes in the city (by-dr), rest driving after busy for 3 to 4 minutes (rt-dr), secondary driving mode for 5 minutes (po-dr) and 20 drivers have been used to form the statistical population. The data obtained in (pr-dr) and (po-dr) modes are in the lowstress group, and the data of (rx-dr) and (rt-dr) modes are in the moderate stress group and the data of (by-dr) mode are classified in the high-stress group. They selected the Self-Organizing Map (SOM) method for clustering the data into distinct topographic clusters from low, moderate and severe stress states, which were able to classify three different categories of driver stress with a predictive power of 81.6%. As a result, drivers were classified into three categories based on susceptibility to stress [27].
Similarly, in another paper conducted by Shiwu et al. [25] of this paper in 2011 in China, a total of 15 people, including 12 men and 3 women, were randomly selected, with an average age of 6 ± 38 years, and all of them had at least 3 years of driving experience. They provided a system that regularly controls the driver's fatigue in real-time to prevent accidents. To do so, they used the support vector machine technique to detect driver fatigue based on recorded EEG and ECG signals. Driver fatigue levels were used as output variables of the SVM model and resulted in a model that can detect driver fatigue levels.
Another study entitled "Detecting the driver's stress in the real world when driving with physiological signals" was conducted by Healey and Picard [7]. Out of the 27 cases recorded in this study, only 16 of these data were completed and could be used. They used four types of physiological sensors during their test, which were connected to an analog-to-digital converter. The converter was also connected to a computer inside the tested vehicle. The ECG electrodes are placed so that the Lead 2 covers the heart and minimize the unwanted signals (artifacts) and maximize the R-wave amplitude. In their research, in addition to using the mean filter, the ECG sampling frequency, 496 Hz and the sampling frequency of skin conductance and respiration signals, 31 Hz and the sampling frequency of the electromyogram (EMG) signal was 15.5 Hz. This study showed that, with the advancement of computer vision algorithms and automotive sensors in the future, it is possible to automatically create a stress measure similar to video analysis that can calculate the driver's stress level [2].

Introduction of The Database
In this study, the Physionet database was used [7]. This dataset has been collected through experiments conducted by Helay and Picard [7]. The data consist of 17 healthy drivers, with six types of data in a driving route, including two highways and three cities in the Boston area and two rest modes recorded. The drivers selected for data recording did not have any specific cardiovascular disease, nor did they use any alcoholic and tobacco products. People enjoyed relative calm at the start of the recording time. Recorded data included ECG, EMG, foot Galvanic Skin Response (GSR), hand galvanic skin response, Intermittent Heart Rate (IHR), and respiration rate. All data has been recorded using wearable sensors. The data were categorized into three levels of stress, including low-stress (rest time), moderate stress (driving on the highway) and highstress (driving in the city). The times recorded for rest and driving in cities and highways were distinguished by Akba [1] for each section. In the case of 7 data recorded about the drivers, no information was not reported for rest and driving times by Akba [1]. Therefore, only 10 data are used in this paper to identify the stress levels of drivers. The duration of data recording lasted at least 65 minutes and up to 93 minutes. Therefore, a method was provided to identify the driver's stress level with the help of a heart signal, aimed at warning in stressful times, could help the driver maintain calm and prevent potential risks during driving.

Proposed Method
Given that the effect of stress during driving is on heart rate, an ECG signal is used in this paper to detect the driver's stress level. According to the block diagram of Figure 1, the target data is firstly selected from the database presented in the previous section, and then, to extract useful information for better detection, the city power noise and field lines contained in the ECG signal were deleted in the preprocessing stage using the method mentioned in reference [16]. Then, the R wave was detected, and the Heart Rate Variability (HRV) signal was formed using Pan and Tompkins algorithm [18]. In the next step, according to the database information, the ECG signal was divided into seven different prescribed routes during driving, including initial rest (IR), driving in city 1 (C1), driving on highway 1 (H1), driving in city 2 (C2), driving on highway 2 (H2), driving in city 3 (C3) and Final Rest (FR)). Then, conversion and extraction of features from different sections (various situations during driving) were discussed in the next step. In order to extract better information to more accurately determine the driver's stress level in different situations, the non-linear features of return map were used, in addition to the time characteristics, such as Mean Heart Rate (Mean HR), Standard Deviation Heart Rate (STD HR), RR interval and RR standard deviation which was assessed using the source code available in GitHub [9]. Figures 2 and 3 illustrate the electrode's installation, how to record and analyze data in different situations.  This map graphic depicts the relationship between two consecutive heart rate intervals that examines the short-term and long-term variations. In this mapping, the horizontal axis represents the n-th RR interval (RRn), and the vertical axis represents the n+1-th RR interval (RRn+1) [19]. If the heart rate variability is completely the same, the points that include the return map all places on a point on the 45-degree line. This occurs when the patient has a brain death. If the interval between these heart rates is different, the points are scattered on the map so that the distribution will look like an ellipse. The standard deviation created in a small ellipse radius that represents short-term HRV changes is defined as Standard Deviation1 (SD1). Short-term changes are generally in line with the effect of the respiratory cycle on heart rate, and because respiratory effects are applied to heart rate variability through the vagus nerve [29], any dysfunction of the vagus may reduce heart rate variability in the short term. In addition, the standard deviation in the large elliptical radius is an index of long-term heart rate variability and indicates conditions that affect the heart rate variability in the long-term, including sympathetic fluctuations, compression reflexes, and hormonal changes [14]. Therefore, longterm HRV changes are defined as SD2. Figure 4 shows the driver's heart rate signal for 13.15 minutes in the initial rest mode (above image), as well as the return map (below image). a) Driver's heart rate in initial rest period. b) Poincare initial rest period.

Simulation Results
Descriptive analysis (mean and standard deviation) related to the heart rate variability features at different driving stages is presented in Table 1. The Mean HR and Mean RR features when driving in C1, C2, and C3 are respectively higher and lower than when the driver was driving at H1 and H2, much less than when he was in the initial and the final rest modes. A comparison of the results obtained from STD RR and STD HR features represents an increase of standard deviation in situations where a driver is driving in a busy and voluminous environment. Figure 5 displays the driver's heart rate during driving and rest times. As shown in this figure, the cities' heart rate is much higher than the highway and much more than the rest mode. In Figure 6, the driver's stress is shown by the feature of RR intervals. When the feature has less value, the driver is in more stressful situations. Figures 7, and 8 also represent changes in the non-linear properties of the return map. The SD1 feature has less value when complexity is less, and its value increases at high-stress times. The SD2 has also reduced when the driver is driving in high traffic and a busy environment.  Figure 5. Impact of driver's stress on heart rate.   This increase and decrease in mean and standard deviation were analyzed by statistical analysis. It was found that there is a significant difference in the number of extracted features from different driving situations, according to Table 2. The places shown in this table with the green and red colors mean differentiation and non-differentiation of data in two different driving situations. For example, the heart rate feature could differentiate the driver's stress during driving in City 2 with P-value equal to 0.001 compared to when it was at the initial rest position. In the case of the other features mentioned in Table 1, although the level of some features has increased or decreased in different driving situations, the test's execution showed no significant difference in some features when comparing other driving conditions.
Using the RR interval feature, this feature could create a good distinction between the driving distance between city 1 and highway 1 with a P-value of 0.031 and the differentiation of all time intervals with rest mode. The use of the SD1 feature produced far better results than the previous two features, which made it a good distinction between driver stress during driving in city 1 and highway 1 with a P-value of 0.011 and city 3 and highway 2 with a P-value of 0.044. Using the SD2 feature also has a slightly better performance than the SD1 feature with more acceptable differentiation values. This feature indicated that the driver's stress level during the driving in the city 1 and highway 1 with a P-value of 0.028 and the city 3 and highway 2 with a P-value of 0.041 can be distinguished and identified.
This feature showed that the proposed algorithm can create a significant difference between driver stress levels during driving in city 1 and highway 1 with Pvalue of 0.028 and in city 3 and highway 2 with a Pvalue of 0.041. Using extracted features from the return map shows that when a person is driving in cities, the SD1 and SD2 rates have increased and decreased, respectively, reflecting the driver's higher stress when driving in heavy traffic and crowded route. Due to the increasing number of vehicles and their collisions' fear and anxiety, the number of accidents in crowded routes is high, which the driver stress naturally increases due to the lack of collision with other vehicles [17]. Figure 9 shows the heart rate variability and RR intervals. As shown in this figure, City 3 has the highest heart rate and more standard deviation than other driving positions, and this point has the lowest mean in the RR intervals graph. This figure's results represent increased driver stress in crowded situations in cities compared to times when the driver needs to focus less on ideal driving. Figure 10 also indicates an increase in SD1 and a decrease in the SD2 value when the driver needs more attention and brainpower to make low-risk driving. Changing the features of the return map mentioned above indicates the system's complexity and disorder while driving in stressful situations than the situations where the driver is less stressed because of reduced traffic volume and driving route openness.

Thresholding Criteria
The online thresholding method was used to determine the efficiency of the proposed algorithm.
In this method, the characteristics extracted from the heart signal in the periods mentioned above are compared. If the value of the desired feature approaches the selected threshold for driver stress in that feature, the alarm of the driver's position in the stress state would sound. The accuracy of this method for 100 iteration reported 98±2%. The results show that the extracted features of the return mapping are capable of identifying driver stress in various driving situations more than the introduced linear features.
Physiological parameters derived from the activity of the autonomic nervous system can be used to identify individuals' mental states.

Discussion
This paper aimed to evaluate an appropriate and practical method for identifying stress during driving. To this end, firstly, the investigations of researchers in these years and the various methods used and the causes of failure and the advantages of these methods have been discussed. Noting the advantages of the method of this paper, how the data were recorded and its recording conditions were then described.
So far, research on the driver's stress detection has been carried out using other methods, including the recording of brain signals, jaw muscle signal recording and hand sweating, and so on. By reviewing these articles, it can be found that the recording methods of some of these signals, such as the electrical signal of the brain, are relatively complex and difficult, and the varying conditions of a person during driving (fatigue, head movements, etc.) can have negative effects on the correct recording of the signal. On the other hand, some studies have been able to detect driver stress by recording and using more data than this paper. In contrast, the authors of this paper were only able to detect the driver's stress level by recording the ECG signal and processing it (ECG recording is far more straightforward and more comfortable for drivers) at different stages of driving.
As expected, the heart rate response was different during the initial and final rest periods than other driving conditions.
A comparison of the results obtained in this paper with other research in this field shows that this paper's results show a significant advantage in identifying drivers' stress. In 2014, a study by Liu et al. [13] published a review of the ECG and GSR signals, which achieved only 85% accuracy in diagnosing stress. Similarly, El-Haouij et al. [4] achieved 81% accuracy in stress diagnosis using the Random Forest classifier. Munla et al. [20] also achieved 83% accuracy in diagnosing driver stress using the SVM-RBF method. Another study by Corcoba-Magaña et al. [3] based on deep learning found stress with an accuracy of 88%. Another study was conducted in 2008 by Patil and Hansen [23]. to detect stress using a contact sensor, which achieved an accuracy of 86.52%. According to the mentioned articles, we find that using the method proposed in this paper is still a useful way to diagnose driver stress.
The obtained results of a research about stress detection showed that the use of the EMG signal and the statistical features with a support vector machine classifier with a cubic kernel were effective for detecting stress events where an Area Under Curve (AUC) of %97 is produced [30]. In other research, Rastgoo et al. [24] presented a method based on Convolutional Neural Network (CNN) is used to fuse the information obtained from ECG, vehicle, and environmental data. The result of this paper showed that the average accuracy: 92.8%, sensitivity: 94.13%, specificity: 97.37% and precision: 95.00%. In result, improvements should also be made based on explainable machine learning methods to assess stress levels, as it can personalize the severity of the warning that a re-system can reduce the personal and economic effects that a car accident can have [9].

Conclusions
This paper indicated that the activity of the autonomic nervous system changes while driving and being on times that require more attention and focus. By identifying the stress caused by changes in different driving conditions, biorhythm, environmental conditions, fatigue, and illness, the proposed system prevents the driver from getting into a false situation and makes driving much safer. Through this information and careful monitoring of the driver's state during the event of an unfavorable condition, the driver is asked to stop and rest, resulting in safe driving. Therefore, the HRV signal can easily be extracted with the aid of a Photo Plethysmography (PPG) signal in real and practical mode, which will reduce the problems associated with the electrodes-induced fault with the skin and the body's sweating. According to the studies, the following suggestions are provided to improve the work and solve the limitations to achieve better results and increase diagnosis speed.
Other methods that may be considered in this paper include selecting the superior feature rank using optimization methods.
A deep qualitative understanding of which trait is most important to us can help us find more features and better understand the sympathetic nervous system's biological processes. Other time-frequency algorithms (such as waveletviolet conversion) may also differentiate ECG data.