Design of a Fatigue Detection System for High-Speed Trains Based on Driver Vigilance Using a Wireless Wearable EEG

The vigilance of the driver is important for railway safety, despite not being included in the safety management system (SMS) for high-speed train safety. In this paper, a novel fatigue detection system for high-speed train safety based on monitoring train driver vigilance using a wireless wearable electroencephalograph (EEG) is presented. This system is designed to detect whether the driver is drowsiness. The proposed system consists of three main parts: (1) a wireless wearable EEG collection; (2) train driver vigilance detection; and (3) early warning device for train driver. In the first part, an 8-channel wireless wearable brain-computer interface (BCI) device acquires the locomotive driver’s brain EEG signal comfortably under high-speed train-driving conditions. The recorded data are transmitted to a personal computer (PC) via Bluetooth. In the second step, a support vector machine (SVM) classification algorithm is implemented to determine the vigilance level using the Fast Fourier transform (FFT) to extract the EEG power spectrum density (PSD). In addition, an early warning device begins to work if fatigue is detected. The simulation and test results demonstrate the feasibility of the proposed fatigue detection system for high-speed train safety.


Introduction
From 1 April 1997 to 18 April 2007, the railway transportation in China experienced six great "improvements" in train speed. The speed of Chinese high-speed trains has been raised to 200 km/h, and accordingly, the Chinese high-speed train technology is the worldwide leader. Since the "7.23" Yong-Tai-Wen railway accident (which occurred on 23 July 2011), the most serious railway accident in Chinese railway history, high-speed train accident prevention in China has been changed from passive control modes to active ones [1]. According to the accident investigation report, the causes of the accident were associated with the design, approval, and use of the TCC (the Train Control Centre). Little attention is paid to the important part of the high-speed train Safety Management

Driver Vigilance Detection Technologies
Studies of train driver fatigue have shown that critical incidents are more likely to occur at certain times of the day and at certain periods within a duty [7][8][9]. Fatigue and vigilance, the first two of the highest-ranking topics, were found to be critical problems of railroad operational safety in 2006 [10]. Especially for high-speed train safety, the vigilance of the driver is a major factor in maintaining basic awareness of oncoming traffic [11].
The Chinese traditional train driver alarm system requires the driver to pedal at least once every 30 s [12]. Otherwise, the control system of the train assumes he is not alert and sends an alarm to the driver. If the driver still fails to step on the pedal after 7 s, the train will automatically brake to a stop for the safety of the passengers. Although it is a safe strategy guarding against the declination of driver vigilance, an undesired braking action will result in time loss and disruption to railway schedules. Moreover, to improve the efficiency of railway operation and personnel utilization. Most countries have adopted a single-driver operating system [13]. If the driver is drowsy, no second driver can operate the train. After the train brakes, no other vigilant driver can restart the train. Therefore, it is necessary to detect and relieve the fatigue of drivers for high-speed train safety in the course of trains running on schedule.
Technologies to detect the vehicle driver's vigilance have been rapidly developed by various vehicle manufacturers, for example, in the applications of a drowsy-driver-detection system for Volvo trucks [14]. In the literature [15], authors have evaluated the use of fatigue detection technologies in a fatigue risk management system for the transport industry. They proposed a set of evaluative and operational criteria for organizations and regulators to contemplate the use of these technologies. However, in the railway transportation field, most studies focus only on the management of driver shift system procedures, policies, and regulations of related companies or the railroad administration to avoid incidents [16,17]. In high-speed trains, the driver's vigilance can be the main factor that affects the railway system in terms of safety, especially in the case of emergency.
The driver's vigilance detection technology can be divided into three main categories: (1) vehicle-behaviour-based technology; (2) driver-behaviour-based systems; and (3) driverphysiological-signal-based algorithms [18][19][20][21][22]. The first category is not suitable for trains because they use a track [23]. The second category analyses the changes of driver behaviour, such as eye tracking, yawning, percent eye closure (PERCLOS), blink frequency, nodding frequency, facial position, and inclination of the driver's head [24][25][26][27][28]. Recent progress in machine vision research and advances in computer hardware technologies have made it possible to measure eyelid movement, face expression and head pose using video cameras. Usually, a recorded video is used to analyse and classify the vigilance level of the driver. The quality of video images is susceptible to or dependent on environmental and driver conditions, such as light conditions, the glass of driver, etc. Furthermore, false estimation can also be caused by the variability of the driver's behaviours, such as sleeping with open eyes.
The last category is the driver-physiological-signal-based algorithms for driver vigilance detection, using electrocardiosignal (ECG), electrooculography (EOG), electroencephalographic (EEG), or Heart Rate Variability (HRV) [29][30][31][32][33]. These systems are more reliable because physiological signs of drowsiness are well known and rather similar. The EEG signal is always regarded as a "gold standard" of vigilance detection. Proven techniques of signals processing, such as date compressing, de-noising, feature extraction and classification, make it be possible to cope with the EEG single. Principal Component Analysis (PCA), independent component analysis (ICA), sparse representation and compressed sensing and so on are widely applied to EEG detection [2,[34][35][36][37][38]. The literature shows that a typical sleep stage can be divided into non-rapid-eye-movement (NREM) sleep and rapid-eye-movement (REM) sleep based on the EEG signal [39]. NREM sleep is further subdivided into stages 1 to 3. The first stage, which is the transition period from alertness to sleep, is considered to be the drowsy stage in this paper. In this stage, the increasing power of theta (4-8 Hz) and alpha (8)(9)(10)(11)(12)(13)(14) waves is observed by Parikh [40], as well as the decreasing power of beta  waves at the area of occipital sites (O1 and O2). The difficulties of the driver-physiological-signal-based measures lie in how to obtain EEG signal recordings comfortably under driving conditions and classify the driver vigilance with so many EEG signals. Nevertheless, the physiological signal measures are believed to be accurate, valid, and objective in determining driver vigilance. Currently, there are two front-ends for EEG signal collection: dry electrodes and wet electrodes. A wet electrode tests with a smearing conducting solution. Thus, it can be used only under special circumstances. Compared with the wet electrode, there is no limit of dielectric or environment for the dry electrode [41][42][43][44][45]. Table 4 shows a survey and comparison of the existing systems used for driver vigilance monitoring.
Despite the success of the existing approaches/systems for driver vigilance detection of active vehicle safety, until now, few researchers have investigated high-speed train safety deeply and systematically based on train driver's vigilance detection. In this paper, a fatigue warning system for high-speed train safety is introduced based on train driver vigilance detection using wireless wearable EEG collection technology. An 8-channel wireless wearable brain-computer interface (BCI) hardware system is designed to collect the train driver's EEG signal comfortably. A support vector machine (SVM) classification algorithm with the Fast Fourier transform (FFT) for extraction of the EEG power spectrum density (PSD) is implemented for the high-speed train driver's EEG signal to determine the vigilance level. The proposed system is the first scheme to design a novel fatigue detection system for high-speed train safety.
The rest of this paper is organized as follows: in Section 2, the general system architecture of the proposed fatigue detection system is presented. Section 3 focuses on the wireless wearable EEG collection system for the train driver. Train Driver vigilance detection is developed in Section 4, and the early warning system is described in Section 5. The experiments and analysis are reported in Section 6. Finally, some conclusions are provided in Section 7. These systems are more reliable because physiological drowsiness signs are well known and rather similar from one driver to another. The EEG signal is regarded as a "gold standard" of vigilance detection. In this paper, a wireless wearable EEG signal collection system for high-speed train drivers is presented The difficulties of the driver-physiological-signal-based measures are in how to obtain EEG signal recordings comfortably under driving conditions and classify the driver vigilance with so many EEG signals. At the same time, the wearable comfortable EEG collection system is very important for train drivers

System Architecture
The general architecture of the fatigue detection system, as illustrated in Figure 1, has three major steps: (1) the wireless wearable EEG collection system; (2) the train driver vigilance detection system; and (3) the early warning device.

System Architecture
The general architecture of the fatigue detection system, as illustrated in Figure 1, has three major steps: (1) the wireless wearable EEG collection system; (2) the train driver vigilance detection system; and (3) the early warning device. In the first step, an eight-channel wireless wearable BCI system collects the driver's EEG signal and transmits the recorded data to a PC/FPGA/DSP via a Bluetooth interface. As shown on the left of Figure 1, a wireless wearable EEG collection system embedded in the driver's cap is designed. The BCI system consists of eight stainless steel dry electrodes. It incorporates the use of a wireless and wearable EEG device to conveniently record EEG signals from the head regions of the train driver.
The second step is train driver vigilance detection using SVM with the FFT to extract the PSD of the EEG signal. As shown in the middle block of Figure 1, after the original EEG signal is collected from the train driver's head, a wavelet de-noising algorithm is implemented to remove interference, such as blinking (<5 Hz) and electromyography (>30 Hz). Then, the PSD is extracted as the feature of each state (alert/drowsy) using the FFT. Finally, an SVM algorithm is proposed to establish a vigilance detection model based on the training data. In this paper, two vigilance levels are defined: alert and drowsy. In the experiment and simulation, a personal computer is used to process the simulation data. The improved versions will be completed in the experiment using DSP or FPGA.
In the last step, as shown in the right part of Figure 1, an early warning system is designed. When fatigue is detected, a massage chair begins to work to warn the high-speed train driver. At the same time, the early warning system messages about the high-speed train driver's situation is sent to the TCC.

Wireless Wearable EEG System for High-Speed Train Drivers
EEG data are highly important to our train driver vigilance detection. To collect the EEG signal of the driver, an eight-channel wireless wearable BCI system is designed as shown in Figure 2. The electrodes, which are a type of sensor for EEG acquisition, are placed on the pre-frontal (Fp1, Fp2), temporal (T3, T4), posterior occipital (O1, O2), and central (C3, C4) regions of the cerebrum according to the 10-20 electrode system in Figure 3. The signal process model stores the collected signal. The In the first step, an eight-channel wireless wearable BCI system collects the driver's EEG signal and transmits the recorded data to a PC/FPGA/DSP via a Bluetooth interface. As shown on the left of Figure 1, a wireless wearable EEG collection system embedded in the driver's cap is designed. The BCI system consists of eight stainless steel dry electrodes. It incorporates the use of a wireless and wearable EEG device to conveniently record EEG signals from the head regions of the train driver.
The second step is train driver vigilance detection using SVM with the FFT to extract the PSD of the EEG signal. As shown in the middle block of Figure 1, after the original EEG signal is collected from the train driver's head, a wavelet de-noising algorithm is implemented to remove interference, such as blinking (<5 Hz) and electromyography (>30 Hz). Then, the PSD is extracted as the feature of each state (alert/drowsy) using the FFT. Finally, an SVM algorithm is proposed to establish a vigilance detection model based on the training data. In this paper, two vigilance levels are defined: alert and drowsy. In the experiment and simulation, a personal computer is used to process the simulation data. The improved versions will be completed in the experiment using DSP or FPGA.
In the last step, as shown in the right part of Figure 1, an early warning system is designed. When fatigue is detected, a massage chair begins to work to warn the high-speed train driver. At the same time, the early warning system messages about the high-speed train driver's situation is sent to the TCC.

Wireless Wearable EEG System for High-Speed Train Drivers
EEG data are highly important to our train driver vigilance detection. To collect the EEG signal of the driver, an eight-channel wireless wearable BCI system is designed as shown in Figure 2. The electrodes, which are a type of sensor for EEG acquisition, are placed on the pre-frontal (Fp1, Fp2), temporal (T3, T4), posterior occipital (O1, O2), and central (C3, C4) regions of the cerebrum according to the 10-20 electrode system in Figure 3. The signal process model stores the collected signal. The Bluetooth in front of the signal-processing model transmits the data to a PC. The power display outside the signal-processing model informs the user of how much power remains. Figure 4 shows usage of the BCI system. By referencing the appearance of the train driver's hat, the driver vigilance detection device can be easily embedded into the cap, and it hardly affects the driver's operation. Bluetooth in front of the signal-processing model transmits the data to a PC. The power display outside the signal-processing model informs the user of how much power remains. Figure 4 shows usage of the BCI system. By referencing the appearance of the train driver's hat, the driver vigilance detection device can be easily embedded into the cap, and it hardly affects the driver's operation.   Bluetooth in front of the signal-processing model transmits the data to a PC. The power display outside the signal-processing model informs the user of how much power remains. Figure 4 shows usage of the BCI system. By referencing the appearance of the train driver's hat, the driver vigilance detection device can be easily embedded into the cap, and it hardly affects the driver's operation.     A set of high-comfort wireless wearable BCI equipment for testing and simulation in the lab has been made. The basic scheme of our homemade EEG-based BCI system is as proposed in Figure 5. The BCI system consists of an EEG collection cap, reference electrodes, and processing model (see Figure 5a). In Figure 5b, the positions of eight dry electrodes installed in the EEG collection cap correspond to the cerebrum areas. The installation positions have close relationships with driver vigilance levels detection. In the homemade wireless wearable BCI system, the EEG collection cap is able to comfortably collect the train driver's brain signal data for testing and simulation in the lab. There are eight single-channel EEG collection models. As shown in Figure 5c, for a single model, the structure has a five-part structure: (1) a stainless steel dry electrode; (2) a TGAM model (the chip used to process the EEG signal); (3) a Bluetooth model; (4) a reference electrode; and (5) a battery model. The EEG signal is obtained by the stainless steel dry electrodes first and then amplified and filtered by the think gear basic module (TGAM) model with hardware filtering of 3 Hz to 100 Hz and a sampling rate of 512 Hz. Next, the EEG signal is transmitted to the PC via Bluetooth. The reference electrode provides the reference potential for the stainless steel dry electrode. The system is powered by eight 3-V DC batteries. Figure 5d shows the processing model, including the TGMA, Bluetooth, and batteries installed into some boxes, which were designed by SolidWorks software and manufactured by a 3D printer. Finally, all chips of the TGAM, Bluetooth and batteries are arranged into a bag, as shown in Figure 5a, to make the equipment more wearable for train driver experiments. A set of high-comfort wireless wearable BCI equipment for testing and simulation in the lab has been made. The basic scheme of our homemade EEG-based BCI system is as proposed in Figure 5. The BCI system consists of an EEG collection cap, reference electrodes, and processing model (see Figure 5a). In Figure 5b, the positions of eight dry electrodes installed in the EEG collection cap correspond to the cerebrum areas. The installation positions have close relationships with driver vigilance levels detection. In the homemade wireless wearable BCI system, the EEG collection cap is able to comfortably collect the train driver's brain signal data for testing and simulation in the lab. There are eight single-channel EEG collection models. As shown in Figure 5c, for a single model, the structure has a five-part structure: (1) a stainless steel dry electrode; (2) a TGAM model (the chip used to process the EEG signal); (3) a Bluetooth model; (4) a reference electrode; and (5) a battery model. The EEG signal is obtained by the stainless steel dry electrodes first and then amplified and filtered by the think gear basic module (TGAM) model with hardware filtering of 3 Hz to 100 Hz and a sampling rate of 512 Hz. Next, the EEG signal is transmitted to the PC via Bluetooth. The reference electrode provides the reference potential for the stainless steel dry electrode. The system is powered by eight 3-V DC batteries. Figure 5d shows the processing model, including the TGMA, Bluetooth, and batteries installed into some boxes, which were designed by SolidWorks software and manufactured by a 3D printer. Finally, all chips of the TGAM, Bluetooth and batteries are arranged into a bag, as shown in Figure 5a, to make the equipment more wearable for train driver experiments. To validate the efficiency of our homemade wearable BCI system in data acquisition accuracy, a 64-channel EEG provided by Brain Products (BP, Gilching, Germany) was used. To validate the efficiency of our homemade wearable BCI system in data acquisition accuracy, a 64-channel EEG provided by Brain Products (BP, Gilching, Germany) was used.
As shown in Figure 6, the commercial BP system consists of a Brain Cap, a Brain Amp, and the Recorder Analysis Software. As shown in Figure 6, the commercial BP system consists of a Brain Cap, a Brain Amp, and the Recorder Analysis Software.

Train Driver Vigilance Detection
After a high-speed train driver's EEG signal is obtained, data processing begins in the next steps, described as follows:

Data Preprocessing
The purpose of this step is to extract the features of alert and drowsy EEG signals of train drivers by removing various interference. In this paper, a wavelet de-noising method is introduced because of its multi-resolution capability, which is appropriate for the non-stationary EEG signal. A six-layer decomposition of the db5 wavelet is implemented for the original EEG signal to extract theta, alpha and beta rhythms. The 6-layer decomposition is implemented to get the sub-band wavelet detail coefficients (Di, i = 1, 2, 3, 4, 5, 6) and approximation coefficients (Ai, i = 1, 2, 3, 4, 5, 6). The decomposition space tree and frequency range are shown in Figure 7. By reconstructing the decomposition coefficients of D3, D4, D5, and D6, the useful EEG signal is extracted, and various lowfrequency and high-frequency interferences are removed. Then, the PSD is adopted as the train driver's EEG feature to distinguish two states. The significant differences of the power scalp topographies of various frequency components in the states of (a) alert and (b) drowsy are shown in Figure 8.

Train Driver Vigilance Detection
After a high-speed train driver's EEG signal is obtained, data processing begins in the next steps, described as follows:

Data Preprocessing
The purpose of this step is to extract the features of alert and drowsy EEG signals of train drivers by removing various interference. In this paper, a wavelet de-noising method is introduced because of its multi-resolution capability, which is appropriate for the non-stationary EEG signal. A six-layer decomposition of the db5 wavelet is implemented for the original EEG signal to extract theta, alpha and beta rhythms. The 6-layer decomposition is implemented to get the sub-band wavelet detail coefficients (D i , i = 1, 2, 3, 4, 5, 6) and approximation coefficients (A i , i = 1, 2, 3, 4, 5, 6). The decomposition space tree and frequency range are shown in Figure 7. By reconstructing the decomposition coefficients of D 3 , D 4 , D 5 , and D 6 , the useful EEG signal is extracted, and various low-frequency and high-frequency interferences are removed. Then, the PSD is adopted as the train driver's EEG feature to distinguish two states. The significant differences of the power scalp topographies of various frequency components in the states of (a) alert and (b) drowsy are shown in Figure 8. As shown in Figure 6, the commercial BP system consists of a Brain Cap, a Brain Amp, and the Recorder Analysis Software.

Train Driver Vigilance Detection
After a high-speed train driver's EEG signal is obtained, data processing begins in the next steps, described as follows:

Data Preprocessing
The purpose of this step is to extract the features of alert and drowsy EEG signals of train drivers by removing various interference. In this paper, a wavelet de-noising method is introduced because of its multi-resolution capability, which is appropriate for the non-stationary EEG signal. A six-layer decomposition of the db5 wavelet is implemented for the original EEG signal to extract theta, alpha and beta rhythms. The 6-layer decomposition is implemented to get the sub-band wavelet detail coefficients (Di, i = 1, 2, 3, 4, 5, 6) and approximation coefficients (Ai, i = 1, 2, 3, 4, 5, 6). The decomposition space tree and frequency range are shown in Figure 7. By reconstructing the decomposition coefficients of D3, D4, D5, and D6, the useful EEG signal is extracted, and various lowfrequency and high-frequency interferences are removed. Then, the PSD is adopted as the train driver's EEG feature to distinguish two states. The significant differences of the power scalp topographies of various frequency components in the states of (a) alert and (b) drowsy are shown in Figure 8.   In the alert case, the lower-frequency components are found in the area of the forehead, and the higher-frequency components are distributed in the occipital area. In the case of drowsiness, lowfrequency components and high-frequency components in the forehead and occipital areas are approximately uniform. Different states between the occipital and forehead areas are distinguished by using the PSD of different frequency components. Under the assumption that the driver's state at time t remains identical to that within the previous r seconds, the feature of the EEG signal at time t is calculated as the average PSD of the previous s seconds and t seconds. The PSD of each second is calculated using FFT and is subsequently converted into a logarithmic scale. Next, a Hanning Window is used to extract the PSD of theta, alpha, beta rhythms as the feature of drowsiness and alertness.

Vigilance Detection Based on SVM Classification
Developed from statistical learning theory (SLT), the SVM maps the input data to a high-dimensional feature space and constructs a linear optimal classification hyperplane. It addresses a nonlinear EEG data classification problem. The theoretical analyses of linear and nonlinear SVMs are described as follows.
As shown in Figure 9, the linear SVM separates two classes of sample points, denoted by '*' and '+,' using the optimal hyperplane H and maximizes the margin, which is the distance between H1 and H2 (the lines pass through the nearest point away from H). Assume that the training data set is T = {(x1, y1), (x2, y2), …, (xm, ym)} (xi∈R n , yi∈{1, −1}), where xi is the training driver's EEG data, yi is the label of the data class, m is the number of training data, and n is the dimension of xi. In this paper, yi = 1 represents the class of xi that is alert, and yi = −1 represents the class of xi that is drowsy. For the linear classification case, the training data can be separated by the hyperplane H in (1): where w is the weight vector and b is the bias vector. Therefore, H1 and H2 can be represented by (2): Thus, the margin in Figure 5 is represented as 2 w and calculated using (1) and (2). In the alert case, the lower-frequency components are found in the area of the forehead, and the higher-frequency components are distributed in the occipital area. In the case of drowsiness, low-frequency components and high-frequency components in the forehead and occipital areas are approximately uniform. Different states between the occipital and forehead areas are distinguished by using the PSD of different frequency components. Under the assumption that the driver's state at time t remains identical to that within the previous r seconds, the feature of the EEG signal at time t is calculated as the average PSD of the previous s seconds and t seconds. The PSD of each second is calculated using FFT and is subsequently converted into a logarithmic scale. Next, a Hanning Window is used to extract the PSD of theta, alpha, beta rhythms as the feature of drowsiness and alertness.

Vigilance Detection Based on SVM Classification
Developed from statistical learning theory (SLT), the SVM maps the input data to a high-dimensional feature space and constructs a linear optimal classification hyperplane. It addresses a nonlinear EEG data classification problem. The theoretical analyses of linear and nonlinear SVMs are described as follows.
As shown in Figure 9, the linear SVM separates two classes of sample points, denoted by '*' and '+,' using the optimal hyperplane H and maximizes the margin, which is the distance between H 1 and H 2 (the lines pass through the nearest point away from H). Assume that the training data set is T = {(x 1 , y 1 ), (x 2 , y 2 ), . . . , (x m , y m )} (x i ∈R n , y i ∈{1, −1}), where x i is the training driver's EEG data, y i is the label of the data class, m is the number of training data, and n is the dimension of x i . In this paper, y i = 1 represents the class of x i that is alert, and y i = −1 represents the class of x i that is drowsy. For the linear classification case, the training data can be separated by the hyperplane H in (1): where w is the weight vector and b is the bias vector. Therefore, H 1 and H 2 can be represented by (2): Thus, the margin in Figure 5 is represented as 2 w and calculated using (1) and (2). Ideally, all sample points can be separated by H and are located outside the margin. In reality, because of the noise or the complexity of the training data, some sample points are inside the margin, which makes the linearly separable SVM invalid. Therefore, a positive slack variable ξ is introduced to transform it to a linearly separable approximate situation, which is defined as (3): where ξi is introduced to measure the deviation between yi and w·xi = b. If 0 < ξi < 1, xi is inside the margin and is correctly classified. If ξi > 1, xi is inside the margin but falsely classified. Finally, (3) can be simplified as (4): The classification hyperplane is represented as w * ·x = b * = 0, and the optimal classification function is calculated using (5): To approximate the nonlinear separable situation, the input x is first mapped to a higherdimensional space via a nonlinear mapping ( ) x φ . Thus, the approximate nonlinear separable SVM classification function can be rewritten as (6): where ( is called a kernel function. Any function that satisfies the Mercer theorem can be used as a kernel function. Some common kernel functions are as follows: After determining the vigilance level using (6), the train driver's vigilance level is sent to the designed massage chair via Bluetooth. Then, the massage chair begins to work. At the same time, the train driver's vigilance system sends an alarm signal to the train driver, and the alarm signal will be uploaded to the management operation centre. Ideally, all sample points can be separated by H and are located outside the margin. In reality, because of the noise or the complexity of the training data, some sample points are inside the margin, which makes the linearly separable SVM invalid. Therefore, a positive slack variable ξ is introduced to transform it to a linearly separable approximate situation, which is defined as (3): where ξ i is introduced to measure the deviation between y i and w·x i = b. If 0 < ξ i < 1, x i is inside the margin and is correctly classified. If ξ i > 1, x i is inside the margin but falsely classified. Finally, (3) can be simplified as (4): The classification hyperplane is represented as w * ·x = b * = 0, and the optimal classification function is calculated using (5): To approximate the nonlinear separable situation, the input x is first mapped to a higher-dimensional space via a nonlinear mapping φ(x). Thus, the approximate nonlinear separable SVM classification function can be rewritten as (6): is called a kernel function. Any function that satisfies the Mercer theorem can be used as a kernel function. Some common kernel functions are as follows: After determining the vigilance level using (6), the train driver's vigilance level is sent to the designed massage chair via Bluetooth. Then, the massage chair begins to work. At the same time, the train driver's vigilance system sends an alarm signal to the train driver, and the alarm signal will be uploaded to the management operation centre.

Early Warning System
In this paper, an early warning system is designed. If fatigue is detected, a massage chair can be used to continuously warn the high-speed train driver. As shown in Figure 10, considering the existing massage chair in the market and the appearance of the train driver's chair, a fatigue-warning device was designed and modelled using SolidWorks.

Early Warning System
In this paper, an early warning system is designed. If fatigue is detected, a massage chair can be used to continuously warn the high-speed train driver. As shown in Figure 10, considering the existing massage chair in the market and the appearance of the train driver's chair, a fatigue-warning device was designed and modelled using SolidWorks. Eight massage heads with high mechanical vibrational frequency, which are evenly distributed on the chair back, can rotate to massage the back of the driver. The Bluetooth located lateral of the chair is used to receive the information about the driver's vigilance level (drowsy or alert). If the driver is detected drowsy, the massage chair begins to work. At the same time, the early warning system is designed to send a warning message about the high-speed train driver's vigilance level.

Experiments and Analysis
The goal of this section is to demonstrate experimentally and scientifically the validity of the proposed fatigue detection system for high-speed trains based on train driver vigilance using the wireless wearable EEG. It is extremely important to affect the high-speed train safety and avoid railway incidents and accidents. An experimental environment to evaluate the proposed system's performance has been implemented in State Key Laboratory of Traction Power, Southwest Jiaotong University in China.
The experimental environment consists of three parts, as shown in Figure 11a. The first part is a homemade wearable BCI model for the train driver's EEG collection in our State Key Laboratory of Traction Power. The second part is the train driver's EEG signal data pre-processing and driver vigilance detection model. As shown in Figure 10, it is used in the virtual driving environment in the simulation centre of the State Key Laboratory of Traction Power, Southwest Jiaotong University for our proposed method.  Figure 11i is the operation interface of the high-speed train monitoring platform. The algorithm is implemented on a laptop computer equipped with an Intel i3 1.9-GHz CPU and 4 GB of RAM with Bluetooth for communication. Figure 11j shows a sample image frame from the experiment on train driver vigilance detection. Eight massage heads with high mechanical vibrational frequency, which are evenly distributed on the chair back, can rotate to massage the back of the driver. The Bluetooth located lateral of the chair is used to receive the information about the driver's vigilance level (drowsy or alert). If the driver is detected drowsy, the massage chair begins to work. At the same time, the early warning system is designed to send a warning message about the high-speed train driver's vigilance level.

Experiments and Analysis
The goal of this section is to demonstrate experimentally and scientifically the validity of the proposed fatigue detection system for high-speed trains based on train driver vigilance using the wireless wearable EEG. It is extremely important to affect the high-speed train safety and avoid railway incidents and accidents. An experimental environment to evaluate the proposed system's performance has been implemented in State Key Laboratory of Traction Power, Southwest Jiaotong University in China.
The experimental environment consists of three parts, as shown in Figure 11a. The first part is a homemade wearable BCI model for the train driver's EEG collection in our State Key Laboratory of Traction Power. The second part is the train driver's EEG signal data pre-processing and driver vigilance detection model. As shown in Figure 10, it is used in the virtual driving environment in the simulation centre of the State Key Laboratory of Traction Power, Southwest Jiaotong University for our proposed method. Figure 11b-f illustrate the EEG collection and vigilance detection experiments in the State Key Laboratory of Traction Power, Southwest Jiaotong University. Figure 11g,h are images of the high-speed train simulator of the simulation centre of the State Key Laboratory of Traction Power, which is the only high-speed simulator in the world. Figure 11i is the operation interface of the high-speed train monitoring platform. The algorithm is implemented on a laptop computer equipped with an Intel i3 1.9-GHz CPU and 4 GB of RAM with Bluetooth for communication. Figure 11j shows a sample image frame from the experiment on train driver vigilance detection.
Sensors 2017, 17,486 13 of 20 In the experiment, ten qualified drivers with no neurological diseases wore the wireless wearable BCI system as in Figure 11b-f, and the collected EEG signals are given in Table 5. The experiments of EEG collection and diver vigilance detection are the actual data. To avoid the traffic risks of actual fatigue driving tests, the train driver experiments in the High-Speed Rail Simulator were finished in the State Key Laboratory of Traction Power. During the entire experiment, the investigators observed and recorded the subject's physical behaviours, yawns and inclinations of the head as the drowsiness indices in a subsequent study. The train driver's fatigue experimental conditions are set as follows: Condition 1: (1) sleep deprivation; (2) the test time is between 4 and 6 a.m. the next day. Condition 2: (1) having a normal night's sleep; (2) the test time is between 9 and 11 a.m. the next day.
Condition 1 is identified as drowsiness, while condition 2 is identified as alertness. Figure 12 shows the raw EEG data of the drowsy state and the alert state from O1, whereas Figure 13 shows the raw EEG data from BP equipment. In the experiment, ten qualified drivers with no neurological diseases wore the wireless wearable BCI system as in Figure 11b-f, and the collected EEG signals are given in Table 5. The experiments of EEG collection and diver vigilance detection are the actual data. To avoid the traffic risks of actual fatigue driving tests, the train driver experiments in the High-Speed Rail Simulator were finished in the State Key Laboratory of Traction Power. During the entire experiment, the investigators observed and recorded the subject's physical behaviours, yawns and inclinations of the head as the drowsiness indices in a subsequent study. The train driver's fatigue experimental conditions are set as follows: Condition 1: (1) sleep deprivation; (2) the test time is between 4 and 6 a.m. the next day. Condition 2: (1) having a normal night's sleep; (2) the test time is between 9 and 11 a.m. the next day.
Condition 1 is identified as drowsiness, while condition 2 is identified as alertness. Figure 12 shows the raw EEG data of the drowsy state and the alert state from O1, whereas Figure 13 shows the raw EEG data from BP equipment.    The good quality of our homemade BCI system is observed. The bursting of the alpha rhythm is observed as in the red box of the drowsy state. To remove the interference, a 6-layer decomposition of the db5 wavelet is implemented in the original EEG signal. The original signal and the decomposition signal at each level and the frequency of them are shown in Figure 14. Because the hardware filter of our homemade equipment is 3-100 Hz, the signal of a6 can be regarded as noise. From Figure 14, the level d2 and level d1 can be regarded as noise. Therefore, by extracting the decomposition signal of d3 (32-64 Hz), d4 (16-32 Hz), d5 (8-16 Hz), and d6 (4-8 Hz), the useful EEG signal is obtained and some low-and high-frequency interferences are removed.    The good quality of our homemade BCI system is observed. The bursting of the alpha rhythm is observed as in the red box of the drowsy state. To remove the interference, a 6-layer decomposition of the db5 wavelet is implemented in the original EEG signal. The original signal and the decomposition signal at each level and the frequency of them are shown in Figure 14. Because the hardware filter of our homemade equipment is 3-100 Hz, the signal of a6 can be regarded as noise. From Figure 14, the level d2 and level d1 can be regarded as noise. Therefore, by extracting the decomposition signal of d3 (32-64 Hz), d4 (16-32 Hz), d5 (8)(9)(10)(11)(12)(13)(14)(15)(16), and d6 (4-8 Hz), the useful EEG signal is obtained and some low-and high-frequency interferences are removed. The good quality of our homemade BCI system is observed. The bursting of the alpha rhythm is observed as in the red box of the drowsy state. To remove the interference, a 6-layer decomposition of the db5 wavelet is implemented in the original EEG signal. The original signal and the decomposition signal at each level and the frequency of them are shown in Figure 14. Because the hardware filter of our homemade equipment is 3-100 Hz, the signal of a6 can be regarded as noise. From Figure 14, the level d 2 and level d 1 can be regarded as noise. Therefore, by extracting the decomposition signal of d 3 , d 4 (16)(17)(18)(19)(20)(21)(22)(23)(24)(25)(26)(27)(28)(29)(30)(31)(32), d 5 (8)(9)(10)(11)(12)(13)(14)(15)(16), and d 6 (4)(5)(6)(7)(8), the useful EEG signal is obtained and some low-and high-frequency interferences are removed. Libsvm-3.20, an SVM toolbox, was used in this paper to implement most functions, including data normalization, parameter optimization of the kernel function, training of the SVM classification model, and classification. Because of the excellent performance, the RBF kernel was used to map the training data to a higher-dimensional space. According to the frequency range of theta (4-8 Hz), alpha (8)(9)(10)(11)(12)(13)(14) and beta , these three frequency bands were used for feature extraction. The feature of the EEG signal at time t was calculated as the average PSD from time t − r to time t, and a Hanning window is used for feature extraction. r is used for feature extraction as the time window. For different r values, for example r = 0, 1, 2, 3, and 4, the contour line of classification accuracy, as shown in Figure 15, corresponds to different C (the error penalty parameter) and g (the parameter of the RBF kernel) values. This contour line provides optimal parameters of C and g, which maximize the classification accuracy, and it indicates that the optimal classification accuracy of the training data increases with the increase in r. To validate the proposed algorithm, cross-validation whit leave-oneout method is utilized. We dividing the original data into three parts, and two parts are considered as training data, while the remain one is considered as testing data.
This paper detects driver's vigilance level at a fixed frequency (r = 0, 1, 2, 3, 4), the classification accuracy rate is defined as Equation (7): Here correctly detection time presents the time which drowsiness is detected as drowsiness, while alertness is detected as alertness.
Besides, the sensitivity and the false positive are computed as Equations (8) and (9): Libsvm-3.20, an SVM toolbox, was used in this paper to implement most functions, including data normalization, parameter optimization of the kernel function, training of the SVM classification model, and classification. Because of the excellent performance, the RBF kernel was used to map the training data to a higher-dimensional space. According to the frequency range of theta (4-8 Hz), alpha (8)(9)(10)(11)(12)(13)(14) and beta , these three frequency bands were used for feature extraction. The feature of the EEG signal at time t was calculated as the average PSD from time t − r to time t, and a Hanning window is used for feature extraction. r is used for feature extraction as the time window. For different r values, for example r = 0, 1, 2, 3, and 4, the contour line of classification accuracy, as shown in Figure 15, corresponds to different C (the error penalty parameter) and g (the parameter of the RBF kernel) values. This contour line provides optimal parameters of C and g, which maximize the classification accuracy, and it indicates that the optimal classification accuracy of the training data increases with the increase in r. To validate the proposed algorithm, cross-validation whit leave-one-out method is utilized. We dividing the original data into three parts, and two parts are considered as training data, while the remain one is considered as testing data.
This paper detects driver's vigilance level at a fixed frequency (r = 0, 1, 2, 3, 4), the classification accuracy rate is defined as Equation (7): accuracy rate = correctly detection time total detection time Here correctly detection time presents the time which drowsiness is detected as drowsiness, while alertness is detected as alertness.
Besides, the sensitivity and the false positive are computed as Equations (8)  Here, true positive means the time which drowsiness is detected as drowsiness, while total actual positive means the actual drowsy time. Ture negative means which alertness is detected as alertness, while total actual negative means the actual alertness time. Tables 6 and 7 show the average classification accuracy of O1 and O2, where drivers 1, 2, 3, 4, 5, 6, 7, 8, 9 and 10 represent different train drivers. With the increase of r, the classification accuracy rate increases. As in the red box of Tables 6 and 7, the equipment yields excellent classification efficiency, which is as high as approximately 90.70%. And as shown in Tables 8-11, the sensitivity can be as high as approximately 86.80%, while the false positive can be down to around 5.40% when r = 4. In addition, the testing time of O1 and O2 as shown in Tables 12 and 13, when r = 4, the minimum time is 2.16 s, which shows the good performance in real-time of this system. All these results indicate the proposed method has good performance in high-speed train drivers' vigilance detection.  Here, true positive means the time which drowsiness is detected as drowsiness, while total actual positive means the actual drowsy time. Ture negative means which alertness is detected as alertness, while total actual negative means the actual alertness time. Tables 6 and 7 show the average classification accuracy of O1 and O2, where drivers 1, 2, 3, 4, 5, 6, 7, 8, 9 and 10 represent different train drivers. With the increase of r, the classification accuracy rate increases. As in the red box of Tables 6 and 7, the equipment yields excellent classification efficiency, which is as high as approximately 90.70%. And as shown in Tables 8-11, the sensitivity can be as high as approximately 86.80%, while the false positive can be down to around 5.40% when r = 4. In addition, the testing time of O1 and O2 as shown in Tables 12 and 13, when r = 4, the minimum time is 2.16 s, which shows the good performance in real-time of this system. All these results indicate the proposed method has good performance in high-speed train drivers' vigilance detection. Finally, other two related studies which is also involved EEG signal are compared. One is Lin et al. [19], which proposed a BCI based smart living environmental auto-adjustment control system in UPnP home networking. They employed the Mahalanobis distance to estimate the human's vigilance level. The other is Li et al. [20]. They propose to apply SVM based posterior probabilistic model (SVMPPM) for automated drowsiness detection. Concrete details are seen in Table 14.

Conclusions
In this paper, the design of a fatigue detection system for high-speed trains based on the train driver vigilance using wireless wearable EEG is presented. EEG collection technology, wireless wearable technology and human's vigilance detection technology are combined for the first time to address high-speed train safety. In addition, a high-speed train driver's fatigue warning device is designed to warn the train driver and the TCC.
The final experimental results show the validity of our method in simulation and tests. Especially, the equipment gives an excellent classification efficiency, which is as high as approximately 90.70%, when the time-window is 4. At the same time, the sensitivity can be as high as approximately 86.80%, while the false positive rate can be reduced to around 5.40%. In addition, the minimum testing time is 2.16 s, which shows the good performance in real-time of this system. All these results indicate that the proposed method has good performance in driver vigilance detection. In both theoretical analysis and practical experiments, the proposed system demonstrates the feasibility of the proposed fatigue-detecting system for high-speed train. The proposed method can be essential part of high-speed train operational safety.

Author Contributions:
The asterisk indicates the corresponding author, and the first four authors contributed equally to this work. Xiaoliang Zhang, Jiali Li, Yugang Liu and Zutao Zhang, designed the system. Jiali Li, Zhuojun Wang, Dianyuan Luo, Xiang Zhou, Miankuan Zhu and Waleed Salman designed the experimental system and analysed the data. Guangdi Hu and Chunbai Wang provided valuable insight in preparing this manuscript.

Conflicts of Interest:
The authors declare no conflict of interest.