# EEG Based Aptitude Detection System for Stress Regulation in Health Care Workers

Authors: Tehseen Khan; Huma Javed; Mohammad Amin; Omar Usman; Syed Ishtiaq Hussain; Amjad Mehmoood; Carsten Maple
Journal: Scientific Programming
 (2021)

---

## Abstract

Stress is a complex multifaceted concept that is the result of adverse or demanding circumstances. Workers, especially health care workers, suffer significantly from distress, burnout, and other physical illnesses such as hypertension and diabetes caused by stress. Numerous stress detection systems are realized but they only help in detecting the stress in early stages, and, for regularizing it, these systems employ other means. These systems lack any inherent feature for regularization of stress. In contributing toward this aim, a novel system “EEG-Based Aptitude Detection System” is proposed. This system will help in considering working aptitude of employees working in work places with an intention to help them in assigning proper job roles based on their working aptitude. Selection of right job role for workers not only helps in uplifting productivity but also helps in regulating stress level of employees caused by improper job role assignments and reduces fatigue. Being able to select right job role for workers will help them in providing productive working environment. This paper presents detail layered architecture, implementation details, and outcomes of the proposed novel system. Integration of this system in work places will help supervisors in utilizing the human resource more suitably and will help in regulating stress related issues with improvement in overall performance of entire office. In this work, different implementation architectures based on KNN, SVM, DT, NB, CNN, and LSTM are tested, where LSTM has provided better results and achieved accuracy up to 94% in correctly classifying an EEG signal. The rest of the details can be seen in Sections 3 and 5.


---

## Body

## 1. Introduction

The exponential increase in usage of ubiquitous computing systems and urban living has led to the development of a unique class of complex monitoring and control subsystems. These systems are used in diverse areas and their components can affect sectors such as transport, health, energy, home/buildings, and the environment. Such systems are identified by the general nomenclature ofsmart city. Their functioning involves the usage of a vast number of hardware sensors and they are typically realized using Wireless Sensor Networks, IoT devices, and smart phones but are certainly not restricted to these architectures only. Research in this field is further classified into areas such as health monitoring [1–4], traffic management [5], intelligent agriculture [6], smart power grids [7], environment monitoring [8–10], human psychology [11–14], smart water grids, smart homes [15], and smart offices [16]. Each of these applications involves the formulation of architecture that integrates sensing, storage, communication, processing, and human computer interfacing. In this context, this manuscript describes an architecture that incorporates aspects of both smart offices and human psychology, with the objective that this architecture can be used to create a conducive and interconnected office environment, where employee productivity can be realized to its full potential.The termsmart office generally applies to an environment that benefits both the employees and the organization where it is deployed. Employee’s work experience, on the one hand, and office productivity, on the other hand, are improved. Major research problems in the field belong to the domains of communications, human computer interfacing, efficient information processing, office management, adaptation services, and assistance [17, 18].More recently, aspects such as stress detection and emotion detection, have been included into the context of smart offices [19–27]. Identification of stress levels of employees allows organizations to regulate them at early stages before it affects their performance and becomes cause of deterioration in health. Globally, all workers and especially health care workers are more prone to risks caused by stress. Because of their frequent exposure to risk factors such as high work demands, low work control, and high emotional involvement [1], high exposure to these risk factors enhances stress and mental health complaints and is the main cause behind degrading work performance [2]. These complaints also have other undesirable aspects like quality interaction with patients and colleagues [3]. It is known that moderate and high psychological distress increases the odds for workplace failure and decreases the odds for workplace success [4].Similarly, emotion detection systems map employees’ emotion states with routine activities in an office environment. This manner of parametrizing aspects of human psychology allows managers to forecast and assign appropriate job roles for employees [28–30]. Role assignment can be further optimized, eventually improving productivity. This research work proposes the usage of an additional parameter in the form of aptitude for job role assignment.Aptitude is a qualitative inborn ability to perform a particular task more efficiently than an average person and is also inversely linked to stress [31, 32]. It is usually quantified by means of testing mechanisms. A number of tests are standardized and used globally for various types of professional aptitude assessment. Examples are the GRE (Graduate Record Examinations), GMAT (Graduate Management Admission Test), SAT (Scholastic Aptitude Test), and other similar tests.This research work performs this quantification by means of Electroencephalography EEG signals and proposes an EEG-based Aptitude Detection architecture. To the best of our knowledge, the inclusion of aptitude as a parameter in smart-office environments is novel. As a proof of concept, analytical skills as a binary ability are considered in this system. Analytical skills, along with IQ level, and dexterities are a number of facets that collectively define aptitude. These additional facets will be addressed in the future. In its current scope, the implementation pipeline includes convolutional neural network (CNN), decision tree (DT), K-nearest neighbors (KNN), Naïve Bayes (NB), support vector machine (SVM), and long-short-term memory (LSTM). This research work reports highest accuracy of 94% using LSTM. For deep networks, it also proposes different topologies and filters for the EEG signals. Lastly, an aptitude-based EEG data set is also a novel contribution of this manuscript.In the remainder of the manuscript, literature review is given in Section2, the proposed system and architecture are given in Section 4, and, finally, the outcomes and results are discussed in Section 5, followed by conclusion in Section 6.


## 2. Literature Review

EEG signals are a measure of difference in electrical brain activity attributed to neurons. The signals appear as wave patterns that can be captured using EEG devices [14, 27, 33]. The wavebands represent brain activity due to different types of stimulants such as sensory usage, memory recall, focus and attention, problem solving, relaxation, drowsiness, deep sleep, and others (see Table 1). Some stimulants may result in disappearance of one waveband but an increase in bandwidth of another [41]. EEG signals and EEG devices form the core operations in a number of medical applications, including detection of dementia and epilepsy, sleep disorders, stress or workload measurement [39, 41, 42], and emotion recognition [20–24, 33]. The latter application of emotions detection and recognition has formed one of the core components in smart offices and brain computer interaction (BCI). Different researchers have made contributions in emotion detection and recognition utilizing physiological signals as input (see Table 2).Table 1
Frequency wavebands of EEG signals considered in this study.
TypeFreq. range (Hz)StimulantsDelta0.5–4.0Deep sleep and unconsciousnessTheta4.0–8.0Drowsiness, fatigue, and day dreamingAlpha8.0–13.0Relaxation and meditationBeta13.0–30.0Focus, attention, and problem solvingGamma30–50Memory and sensesTable 2
Literature review.
RefModality signalFeaturesClassificationEmotionsAccuracy (%)[11]EEGEnergy, entropySVM, KNNArousal, valence86[13]EEGMin, Max peak, powerLSTMArousal, valence, and liking87[14]EEGMin, Max peak, powerANNStress, normal60[20]EMG, ECG, RSPStatistical, energy, entropyLDAJoy, anger, sadness, and pleasure95[24]BVP, EMG, EDA, RSPStatistical featuresSVM, Fisher LDAAmusement, contentment, disgust, fear, sadness, and neutral92[26]EMG, EDA, ECGNo specific featureNo specific classifierArousal, valenceNA[27]EEGStatistical featuresSVM, ANNPositive, negative, and neutral91[33]EEG, EMG, Temp, GSR, RSPDifferent featuresMESAEArousal, valence77[34]EEGNo specific featuresLDAArousal, valence87[35]EEGDE, PSDSVMNegative, positive, and neutral91.5[36]EEGSpatial, spectral, temporalCNNDepression86[37]EDA, HR, EMGNo specific featuresHMMArousal, valence81[38]EEGAverage PSD, mean, variance, Shannon’s entropy, zero crossingLSSVMJoy, peace, anger, and depression65[39]EDA, HRNo specific featuresFuzzy logicStress99.5[40]EEGNo specific featuresCorrelation analysisNeutral, anger, sadness, anxiety, disgust, and surprise90Nomenclature for signal modalities: RSP denotes relative spectral power, EEG denotes electroencephalogram, ECG denotes electrocardiogram, GSR denotes galvanic skin response, EDA denotes electrodermal activity, BVP denotes blood volume pulse, HR/HP denotes heart rate/pulse, and Temp denotes temperature. Nomenclature for classifiers: LDA denotes latent discriminant analysis, KNN denotes K-nearest neighbors, ANN denotes artificial neural network, SVM denotes support vector machine, HMM denotes hidden Markov model, LSTM denotes long-short-term memory, DFA denotes deterministic finite automata, MESAE denotes multiple fusion layer based-ensemble classifier of stacked autoencoder, and MEMD denotes multiencoder to multidecoder.The highest classification accuracy reported is 99.5%, which is achieved using Electrodermal Activity (EDA) and Heart Rate (HR) signals by means of a fuzzy logic classifier [39]. Here, a single emotion trait is captured. For two emotion traits (arousal and valance), the maximum reported accuracy is 96.6% using multimodal signals using standard statistical features [22]. Here, an ANN is used as a classifier. With four emotion traits (joy, anger, sadness, and pleasure), the maximum reported accuracy is 95% using standard statistical and entropy-based features [20]. Here, Linear Discriminant Analysis is used as a classifier using EMG, ECG, and RSP signals. The highest accuracy using Support Vector Machines is reported in [24] as 92%, followed by 91% in [27]. The former used multimodal physiological signals, while the latter used only EEG. In all cases, a number of factors, including number of modality signals, feature set, and classification techniques, contribute toward an increase in accuracy.The authors in [32] have proposed aptitude modeling; they have provided multimodal system based on signals such as heart rate, skin temperature, breathing, and Galvanic Skin Response. They have managed to achieve an accuracy up to 96% using a multimodal approach with F1-score of 0.91. The proposed system in this paper is based on encephalographic signal. To the best of the authors’ knowledge, no such work has been done before. Before going in to the implementation details of the proposed system, a brief introduction of tools utilized in implementation is covered in Section 3.


## 3. Tools and Methods

A collaborative setup is established using Python and data science/numerical libraries, and the details related to these libraries are provided below. It is worth mentioning that, in implementation of complete system famous NumPy package and respective support has played a very vital role.


### 3.1. Tools

Different libraries and packages are given below , which are utilized in actual implementation of the proposed system as well as in its validation and testing.(1)
NumPy and Pandas. In Python for array processing, mathematical computation, and data sciences, special packages NumPy and Pandas are utilized.(2)
h5py. This library uses traditional batch processing and makes Python compatible with a huge amount of numerical data in HDF5 format. This library takes burden of the system in training our models, especially in case of physiological signals.(3)
Matplotlib. This library is utilized for generating and plotting different graphs and charts for the visualization of results generated by employing the proposed system.(4)
Sklearn. This tool serves as a main constituting part behind generation of confusion matrix and other related metrics. These metrics actually help us in figuring out the actual results generated by our models. These metrics also help in verifying the authenticity and validation of generated results.(5)
Think Gear. It is a library provided by Neurosky to connect and communicate data between Bluetooth-enabled system and MindWave Mobile EEG device. This library employs COMM port for establishing connection and communication.(6)
Neurosky MindWave Mobile EEG Headset. This headset is used to capture electroencephalogram signal produced by brain as a result of brain activity. It is a single-channel device and it is able to provide 12-bit raw EEG signals with sampling rate Fs of 512 Hz and band range of 3–100 Hz.Section4 covers the details more comprehensively.


### 3.2. Data Set

The proposed system is a novel indigenous system; therefore, no data set is present. So, the first task that needs to be accomplished is to collect and organize the data set with proper labels for the proposed system. Collected data set contains data related to two classes: “with analytical skills” and “without analytical skills.” For collecting this data, proper experimental setup is created where participants have given analytical reasoning test to solve. While they are solving the test, our system collected the data; this data is then assigned proper labels, which is then utilized in training and validation of our models. See Figure1 for depicting overall structure of the data flow used in collecting data set, while the rest of the details are provided briefly in Section 4. For availability of data, see Section 7.Figure 1
Ground truth acquisition work flow.


## 3.1. Tools

Different libraries and packages are given below , which are utilized in actual implementation of the proposed system as well as in its validation and testing.(1)
NumPy and Pandas. In Python for array processing, mathematical computation, and data sciences, special packages NumPy and Pandas are utilized.(2)
h5py. This library uses traditional batch processing and makes Python compatible with a huge amount of numerical data in HDF5 format. This library takes burden of the system in training our models, especially in case of physiological signals.(3)
Matplotlib. This library is utilized for generating and plotting different graphs and charts for the visualization of results generated by employing the proposed system.(4)
Sklearn. This tool serves as a main constituting part behind generation of confusion matrix and other related metrics. These metrics actually help us in figuring out the actual results generated by our models. These metrics also help in verifying the authenticity and validation of generated results.(5)
Think Gear. It is a library provided by Neurosky to connect and communicate data between Bluetooth-enabled system and MindWave Mobile EEG device. This library employs COMM port for establishing connection and communication.(6)
Neurosky MindWave Mobile EEG Headset. This headset is used to capture electroencephalogram signal produced by brain as a result of brain activity. It is a single-channel device and it is able to provide 12-bit raw EEG signals with sampling rate Fs of 512 Hz and band range of 3–100 Hz.Section4 covers the details more comprehensively.


## 3.2. Data Set

The proposed system is a novel indigenous system; therefore, no data set is present. So, the first task that needs to be accomplished is to collect and organize the data set with proper labels for the proposed system. Collected data set contains data related to two classes: “with analytical skills” and “without analytical skills.” For collecting this data, proper experimental setup is created where participants have given analytical reasoning test to solve. While they are solving the test, our system collected the data; this data is then assigned proper labels, which is then utilized in training and validation of our models. See Figure1 for depicting overall structure of the data flow used in collecting data set, while the rest of the details are provided briefly in Section 4. For availability of data, see Section 7.Figure 1
Ground truth acquisition work flow.


## 4. Proposed System

The proposed architecture is comprised of four different layers illustrated in Figure2. The first layer is the sensor and communication layer which is responsible for capturing various EEG power spectrums. Traditional head gear comprised of multiple electrodes and channels is unfeasible in real-world scenarios due to its preparation and positioning time. Additionally, it is uncomfortable to wear for long periods of time and requires supervised use from trained personnel. Comfortable and cheaper commodity hardware has started to be popular in the last decade. Examples are the Neurosky MindWave Mobile EEG headset, which is popularly used in the entertainment and gaming sector, as well as development of motor development skills in children. This headset is a single-channel device and is able to provide 12-bit raw EEG signals with sampling rate Fs of 512 Hz and band range of 3–100 Hz. In this case, this device is a server system configured to use the Think-Gear library configured to work with Python. The received raw signals using EEG headset constitute input to this layer and are stored in CSV format.Figure 2
Proposed system architecture.The secondpreprocessing layer is responsible for cleaning the acquired signal using a number of DSP filters before acquisition of the relevant features. This is essential because when the EEG device captures neuron activity, it also captures crossover noise and other electrical activities within proximity of the electrode point (which may include muscle activity). Since the EEG is a composite signal, its constituent alpha, beta, gamma, delta, and theta wave patterns can be acquired by application of the fast Fourier transform, followed by a bandpass filter of relevant frequency range. An illustration of the complex EEG signal after Fourier transform is given in Figure 3, where imaginary and real parts of signal are superposed on its own amplitude for comparison purpose. Figure 3 also shows the different frequency bands given in Table 1. Here, the amplitude of frequency bands decreases exponentially as their frequency range decreases. This makes lower frequency ranges prone to noise. Effect of crossover noise is mitigated by application of a mean filter. Small and local noise sources (attributed to eye blinking, heart pumping, etc.) are removed using an Independent Component Analysis (ICA) filter, resulting in same amplitude scales for all frequency bands (see Figure 4). It takes raw signal stored in CSV file (generated by sensor and communication layer) as input and after performing necessary processing it stores the output in another CSV file. This newly generated CSV file is then fed as input to the decision layer. The decision layer bears three sublayers: data set, modality transform, and decision sublayers. First is the data set sublayer. Here, a data set is prepared, comprising the preprocessed signal and its associated labels. This data set is used for training and as input for various machine learning models. The ground truth for the data set is determined experimentally using an alternate work flow and makes use of a MindWave Mobile EEG device (see Figure 1). Experiments are designed, where the state of neuron activity is measured, while the subject is performing analytical tasks. Some example analytical tasks are discussed in [42]. For the work at hand, the authors prepared a test comprising questions of analytical portion of the International GRE. These questions were then given to subject participants to solve in a fixed time interval while being attached to the EEG device. Tests are scored afterwards, and a threshold value is used to determine whether the acquired data belongs to a subject participant with or without analytical skills. The data set also includes factors such as humidity, mean of ambient noise levels, and room temperature at the time acquisition was being made. The ground truth is collected from male and female candidates aged between 22 and 45 years. The candidates had normal vision and hearing and are free from any kind of neurological disorder. In the learning sublayer, the trained model is then used formally for classification using a number of schemes such as DT, KNN, SVM, NB, CNN, and LSTM. For KNN, SVM, and DT, hand-crafted features of frequency domain are used to prepare a feature vector. These include the minimum, maximum, and mean frequencies, as well as their standard deviation. Given that the EEG contains five subbands, this gives a total of 20 hand-crafted features. The authors have built CNN model using Convolutional (ReLU activation), max-pooling, dropout, dense, flattened, and fully connected layers with ReLU and Softmax as activation functions (see Figure 5). The LSTM model includes the average pooling, dense, flattened, dropout, and fully connected layers with sigmoid and hyperbolic tangent (tanh) as activation functions (see Figure 6). These models are implemented using Keras and TensorFlow.Figure 3
(a) Real and (b) imaginary components of transformed EEG signal superposed on magnitude of itself. (c) Illustration of diminishing amplitude for lower-frequency wavebands of the EEG signal.
(a)(b)(c)Figure 4
ICA-treated wavebands, showing the same amplitude scales as EEG wavebands.Figure 5
CNN layer architecture.Figure 6
LSTM architecture.The final layer in the architecture isOutput Layer, where the decision of the classifier is validated. Interfaces of the architecture support exchanges, transformations, processing, and classification in real time.


## 5. Results and Discussion

For brevity, the labelswith and without analytical skills are treated as positive and negative labels, respectively. Using this nomenclature, evaluation can be based on measures of True Positive (TP), i.e., correctly identified positive labels, and True Negative (TN), i.e. correctly identified negative labels. In contrast, we also have False Positive (FP), i.e., positive labels identified as negative labels, and False Negative (FN), i.e., negative labels identified as positive labels. In addition, other metrics such as specificity, recall, precision, and F1-scores can also be formulated. The exact calculation of these measures is given in Table 3. Apart from these metrics, for better understanding of classification probability, receiver operating characteristic (ROC) curve is also being computed. It is a plot of true positive rate (TPR) against false positive rate (FPR). The area under ROC curve shows the classification probability of the models. The greater area means better true positive rate and better classification ability of a model. As can be seen in Figure 7, for validation, a tenfold cross-validation technique is utilized. All signals irrespective of class labels are randomly assigned to ten equal-sized chunks. Of these, training is performed using 9 chunks, while the remainder is used for validation. The process is repeated for 250 epochs for each model. At the end of each epoch, parameters such as accuracy, validation loss, and confusion matrices are extracted. The four labels TP, FP, TN, and FN are then obtained from this confusion matrix. Subsequently, the scores are given in Table 3.Table 3
Scoring measures.
Evaluation metricEvaluation formulaSpecificity (S)False Positive/(True Negative + False Positive)Recall (R)True Positive/(True Positive + False Negative)Precision (P)True Positive/(True Positive + False Positive)F1-score2 ∗ Precision ∗ Recall/(Precision + Recall)Figure 7
Receiver operating characteristic curves for all six models.A number of machine learning models were used to perform the classification as depicted in [43, 44], and the maximum, minimum, and average accuracy after 250 epochs are reported in Table 4.Table 4
Accuracy for various models.
ModelMaximumMinimumAverageConvolutional neural network (training)81.975.277.9Convolutional neural network (validation)99.2054.2Decision tree95.086.090.5K-nearest neighbors95.482.688.8Long-short-term memory (training)94.490.494.4Long-short-term memory (validation)100075.0Naïve Bayes76.469.272.8Support vector machine97.686.292.0For each of the four labels outlined earlier, the confusion matrix and scores of Table3 are given in Tables 5 and 6, respectively.Table 5
Confusion matrix.
ModelTrue PositiveFalse NegativeFalse PositiveTrue NegativeConvolutional neural network642144129443Decision tree7066465525K-nearest neighbors6967775512Long-short-term memory7671325456Naive Bayes513114256477Support vector machine7235454529Table 6
Averaged F1-score, precision, recall, and specificity scores for 250 epochs.
ModelF1-scorePrecisionRecallSpecificityConvolutional neural network0.820.830.810.77Decision tree0.910.910.920.89K-nearest neighbors0.900.900.900.87Long-short-term memory0.910.990.850.99Naïve Bayes0.720.640.800.65Support vector machine0.930.930.930.92The best results reported are those for LSTM with maximum and average validation accuracy of 100% and 75%, respectively, and with a consistent F1-score, precision, and specificity of 0.91, 0.99, and 0.99, respectively. SVM provided maximum accuracy of 97%, while its average accuracy was 92%. Its F1-score, precision, and specificity were quite close at 0.93, 0.93, and 0.92, respectively. KNN and DT provide a maximum accuracy of 95%. Their average accuracy is at 89% and 90% (see Figure8). However, their F1-score, precision, and specificity are quite less than those of LSTM and SVM (see Figure 9). The architecture of CNN used in this manuscript gave a maximum accuracy of 99% but a poor average accuracy of 54%. The other scores of CNN were also not consistent. NB scores were not compared to other models due to high invariance in data. In this study, the implementation pipeline that has been finalized is provided (see Figure 10).Figure 8
Accuracy results of all six models (% age).Figure 9
F1-scores of all six models (% age).Figure 10
Implementation architecture for the proposed system.


## 6. Conclusion

Aptitude is an innate skill to perform a particular task with ease and perfection. It not only plays a vital in enhancing productivity but also regulates the stress level of employees in work environments. This research work addresses the utilization of aptitude to regulate the stress in a working environment. It is an established fact that if an employee is assigned job roles according to his working aptitude, it helps in reducing stress and fatigue caused by improper job role assignments and overburdening. Keeping this fact in view, an implementation pipeline that makes use of an EEG signal for the detection of aptitude is proposed with detailed implementation. The proposed pipeline is tested with different types of machine learning models. Our findings show good results with LSTM- and SVM-based classifiers, giving achieved accuracy of 94% and 97%, with F1-scores of 0.91 and 0.93, respectively. In this research work, our main focus was on analytical skills of workers. For future work, the binary system can be expanded to include poor, fair, good, better, and outstanding analytical capabilities. Other aptitude facets such as IQ, dexterity, and reasoning can also be work for the future.



---

*Source: 4620487-2021-10-11.xml*