Abstract
Identifying stress and its level has always been a challenging area for researchers. A lot of work is going on around the world on the same. An attempt has been made by the authors in this paper as they present a methodology for detecting stress in EEG signals. Electroencephalogram (EEG) is commonly used to acquire brain signal activity. Though there exist other techniques to extract the same like Functional magnetic resonance imaging (fMRI), positron emission tomography (PET) we have used EEG as it is economical. We have used an open-source dataset for EEG data. Various images are used as the target stressor for collecting EEG signals. After feature selection and extraction, a support vector machine (SVM) with a whale optimization algorithm (WOA) in its kernel function for classification is used. WOA is a bio-inspired meta-heuristic algorithm, based on the hunting behavior of humpback whales. Using this method, we had obtained 91% accuracy for detecting the stress. The paper also compared the previous work done in detecting stress with the work proposed in this paper.
Keywords
Introduction
Mental stress has become a social problem in the 21st century. It affects the functionality of the routine work and economy of an individual human. Stress can be classified as positive and negative. Positive stress alerts us and avoids the danger leading to performance enhancement while negative stress can cause mental and behavioral changes [14]. Various techniques have been developed either based on a questionnaire or quantifying the changes in physiological signals, to measure and study the stress level. Physiological signals are an on-line-real time system and give better accuracy in stress estimation. These can be classified into two types: (i) invasive type and (ii) non- invasive type. Invasive type methods such as local field potential (LFP) and Electrocorticography (ECoG), etc. provide high resolution in temporal and spatial axes and high specificity. The non-invasive methods like Functional magnetic resonance imaging (fMRI), Electroencephalography (EEG), and Magnetic encephalography (MEG) are presently used for assessment of stress [15, 17]. EEG and MEG have higher resolution whereas fMRI has high spatial resolution but very low temporal resolution. The authors, in this paper, have considered the EEG signal for identifying the stress using Support Vector Machine (SVM) as a classifier and Whale optimization algorithm to maximize the hyperplane distance in SVM, integrating WOA to the kernel function of SVM. The validations of results are done based on 4 parameters, namely sensitivity, specificity, accuracy, and f-score. Brain activities recorded in the EEG signal are mostly corrupted with the eye blink artifact. To avoid the eye blink artifact, sparsity-based methods are proposed: (i) Morphological Component Analysis (MCA) and (ii) K-Singular Value Decomposition (K-SVD) techniques. The MCA method extracts the morphological component and eye blink artifact of the EEG signal. K-SVD method was developed to represent eye blink characteristics and read the data from the EEG signal. The subtraction method is used in the above two methods, to separate the original EEG signal from the corrupted eye blink artifact signal [4, 5, 6].
The main contributions of this paper are:
Using WOA (Whale Optimization Algorithm) to detect stress in EEG signals. To our best knowledge, WOA has not been used for stress detection so far. An attempt has been made for the same in this paper by considering a dataset of EEG signals obtained from 14 subjects while performing a task in limited time. The discussed methodology in this paper has been implemented using MATLAB and EEGLAB. The authors developed a methodology, where 4 different algorithms have been used at different phases to achieve a good accuracy of 91% for stress detection. In the pre-processing step, Normalised Least Mean Square (NLMS) was used. For feature extraction, DCT has been used while MBPSO (Modified Binary Particle Swarm Optimization) has been used at the feature selection step. At the classification step, Whale Optimization Algorithm (WOA) was used. The proposed methodology has been compared with some of the previous work done, concerning the classification step. It was observed that our methodology achieved 91% accuracy with SVM while some of the related work has achieved accuracy in the range of 63–89% with SVM.
The remaining section of the paper is structured as: Section 2 informs about the work done so far in this area, section 3 elaborates the details of the methodology, section 4 explains the result obtained and compares our proposed methodology’s result with existing work. Section 5 concludes the study.
This section describes some important work associated with the present paper.
The mental stress is detected at multiple levels using three different classifiers namely Logistic Regression, Support Vector Machine, and Naive Bayes classification as shown in [1]. Stress was induced by the Montreal Imaging Stress Task (MIST). EEG signals are pre-processed in offline. A chunk of recorded data is shelved manually to eliminate the eye blink and muscle artifacts. Feature extraction phase extracted features, namely: relative power, absolute power, phase lag, and coherence. These features are classified using three classifiers. Among them, SVM and Naive Bayes classifiers produce higher accuracy.
The EEG signals from the working people are pre-processed to extract the features as explained in [2]. Precision and assortment analysis are carried out to extract features. Classification steps use the SVM and KNN classifier to classify the stress level in working people.
The mental stress was detected using the decision fusion of the EEG signal and Functional near-infrared spectroscopy (fNIRS) signal in [3]. Pre-processing steps use the IIR Butterworth filter to remove the noise in the EEG signal. SVM classifier is used for the classification of the stress. The decision fusion was achieved by fusing the output/decisions from two local classifiers (SVMs), one of the EEG signals, and the other for fNIRS signals. Finally, stress was detected. It was found that the IIR Butterworth filter in noise removal may act as an ideal filter when its order is increased and its horrible stop band gradually goes to zero. Besides fNIRS signal has a slow transformation rate and a high error rate.
The eye blink artifacts were removed using the K-singular value decomposition (K-SVD) algorithm [4]. Two sparsely based techniques are used to remove the eye blink artifacts namely Morphological Component Analysis (MCA) and K-SVD. Results of both algorithms are compared with the recent state of the art FORCe method. K-SVD algorithm removes eye blink better than the MCA algorithm. In [5], to remove the EOG artifact from the EEG signal, Recursive Least Square (RLS) algorithm is used. Also, Second-order Blind Identification (SBI) algorithm is used.
In [7], the stress detection using the physiological signals like EEG and ECG is discussed. EEG signals and ECG signals are analyzed to detect variations in the stress level of 22 male subjects. This approach detects the stress on four different levels and creates a model for the individual levels. The result reveals the differences between the stress and control level of the individual. The paper considers three characterizations namely sensitivity, specificity, and accuracy. The characterization is computed to evaluate the performance of the classifiers, however, the accuracy obtained is very low compared to other methods.
The stress can be detected using the fusion link between the EEG and peripheral signals, as explained by the authors of [9]. Peripheral signals are used as confirming characteristics to improve the labeling process. An efficient protocol is created to acquire the EEG signal in five different channels and peripheral signals such as blood volume pulse, skin conductance, and respiration. The evaluations of peripheral signals are used to select the appropriate signal in EEG which interns improve the accuracy of the stress detection. Digital wave transform (DWT) is used to extract the features of the EEG wave. The SVM classifier is used to classify the stress levels. The problem with the DWT algorithm is that it induces the greater complexity in computation and it is not flexible.
EEG single electrode rhythms can help in detecting the stress. EEG signals are analyzed in the MATLAB environment to improve efficiency in stress detection. Discrete Cosine Transform (DCT) helps eliminate the noise in the EEG data. Further, the KNN classifier is used to detect the stress level, which produces higher accuracy than the ANN and LDA classifier [10].
The wearable EEG headband can be used to detect the mental stress as explained in [11]. Stress or relax state of humans in real-time is evaluated using signal pre-processing step and a histogram of each frequency band is created. Naïve measure and four entropy-based measures are evaluated using frequency band powers of EEG signals. These two measures give a perfect score to the stress and relax state. Using this score stress of the individual is detected.
EEG metrics are used to detect the stress in humans as stated in reference [12]. In this paper, the DSI questionnaire is used to evaluate and comprehend behavioral stress. DSI is based on the psychological battery test provided by the Vienna test system. The final evaluation result is expressed in four types of stresses. EEG metric parameters based on binary and ternary stress classifier is developed. A Multilayer perceptron kernel-based SVM classifier is used to detect the stress in humans. Binary classifier detects stress, greater than ternary classifier.
Emotions are one of the reasons for causing stress. Incase, emotions can be captured and evaluated properly can help to solve the problem of stress. The authors in [13], had proposed a combination of Fourier Fast Transform (FFT), Principal Component Analysis (PCA), and k Nearest Neighbor (k-NN) for detecting emotion. They acquired an accuracy of 96.22% using this methodology.
Methodology
Figure 1 shows the flow of data across various algorithms used at various steps to detect stress.
Flow of data across various algorithms.
The dataset used in our work has been withdrawn from [20]. Around 14 Human subjects with normal vision (7-Women, 7-men) of average age 26 (and ranges between 22–46) volunteered for the study. The subjects sat in a dimly lit room, at a distance of 110 cm from a color computer screen having a block of 100 images. Subjects were also holding a touch-sensitive button. The associated EEG was recorded by the 32 electrodes mounted on the EEG cap. A SynAmps recording system (Neuroscan Inc.) was attached to a PC, which recorded the data at 1000 Hz. Also, 500 Hz low-pass filter is used and impedance was maintained below 5kOhms. Images that are shown to subjects are divided as targets and non-targets (distracters) groups, where targets are photographs including images of mammals, reptiles, arthropods, fish, and birds and non-targets include images of outdoor and indoor places, natural landscapes or urban sites, fruit, vegetables, trees, and flowers. Tasks are divided into categorization or recognition. 1000 pictures (50% distracters and 50% objectives) were used in the categorization assignment and each of them was viewed by each subject only once.
During the categorization task, targets and non-targets had an equal chance in every block of a hundred pictures so the target photograph assigned to the block was viewed fifty times between 50 completely different non-target images. Fifteen targets (a total of 210 targets) and therefore the same 750 non-target stimuli were tested by every one of the fourteen subjects. One hundred forty targets (10 pictures per subject) contained an animal within the 210 pictures used as targets and were, therefore, closest to the target images employed in the categorization method. Stimuli onset between 2 images was random from 1800 ms to 2200 ms. The subject’s response as go/no-go is recorded. On seeing the target image, they had to release the button as soon as possible while, on watching the non-targets, the button should not be released. Time to react is 1000 ms, beyond which it was recorded as no-go or non-target. This experiment was performed for 2 days. Subjects were screened for alternating tasks of categorization and recognition in a session of 10 blocks each and corresponding EEG is documented.
For the method of recognition task, every test block was preceded by a learning stage. During the training or learning phase, the target images were flashed perpetually for twenty ms (comparable to the test circumstances). To respond to images accurately and quickly in the respective sequence of images, participants were advised to memorize images. The block of testing began instantly after the learning stage.
All electrodes were divided into 2 groups: frontal electrodes (10–20 system nomenclature: Fz, FP1, FP2, F3, F4, F7, F8) and occipital electrodes (10–20 system nomenclature: O1 and O2 with Oz, I, O1’, O2’, PO9, PO10, PO9’, PO10).
Pre-processing of data
To meet the dataset according to the need of the task, the pre-processing of the data is carried out after normalization is performed on the data. Temporal normalization is performed before ensemble normalization, which is an important pre-processing step when using the multi-trial sliding window [21].
After the normalization process, eye blink artifacts are removed. Brain activities recorded in the EEG signal are mostly corrupted with eye blink artifact [3]. Normalized Least Mean Square (NLMS) algorithm is used for removing the eye blink artifacts. The Normalized least mean squares filter (NLMS) is a variant of the Least Mean Square (LMS) algorithm that solves the problem of choosing a learning rate,
If
Feature extraction involves finding a set of information that includes hidden information embedded in the EEG signals. A time series is converted to basic frequency components with the help of discrete cosine transform (DCT). DCT takes associated input data and focuses its energy on just the first few transform coefficients. This method helps in compressing the dataset while saving the necessary information [23]. For a list of
where,
A set of
This feature is applied, during the training and classification of EEG signals to reduce the input vector size and time. It results in compressing helpful information to the primary coefficients, which may be used for classification [23]. The various statistical features extracted are discussed in the following section.
In this step, the best features are selected using Modified Binary Particle Swarm Optimization (MBPSO) algorithm [25]. These are selected considering local best and global best. The iterative best values are used for the classification computations. Some of the selected features are mean, standard deviation, median, mode, SNR, skewness, kurtosis [26].
Showing SVM finding the optimal hyper plane [27].
Various steps in WOA algorithm.
Support vector machine (SVM) is one kind of classification method which learns from statistical theory. SVM finds a hyperplane that separates the input space with the highest margin [28], for a linearly separable classification problem having 2 classes. The optimum hyperplane can be constructed by:
where
Figure 2 shows the SVM finding the optimal hyperplane.
In the proposed work, a kernel function is developed using the Whale optimization algorithm (WOA). WOA searches the global optimum through location update steps that include encircling prey, spiral bubble-net feeding maneuver, and search for prey [19, 29]. WOA shows the hunting conduct of humpback whale and is a population-based meta-heuristic algorithm. A brief idea of WOA is explained in Fig. 3.
Figure 3 explains the various steps involved in WOA (Whale Optimization Algorithm).
During this phase, the current best location is treated as the global optimum (or the target prey) so that the whales can adjust their positions. Two mechanisms are used for determining the positions: (a) shrinking encircling (encircling prey) and (b) spiral updating position (spiral bubble-net feeding movement). The shrinking encircling mechanism is represented as [19, 29]:
where
For capturing the shrinking encircling behavior, random numbers
Under this phase, 2 different approaches are designed [19]:
Shrinking encircling mechanism: The shrinking encircle conduct is accomplished by lowering the value of ‘a’. Further, fixing A
Showing WOA shrinking encircling mechanism [30]. Figure 4 shows WOA Shrinking Encircling Mechanism. This phase finds the best search agent position that can trap the prey. Shrinking updating mechanism To find the distance between the whale at
where

Figure 5 shows spiral Updating Mechanism in WOA. In this phase, the best search agent’s position gets updated to find its distance between itself and prey.
Humpback whales swim in a shrinking circle around the prey and simultaneously along a spiral-shaped route as shown in Fig. 5. To model the concurrent behavior, we assume a 50% probability of choosing the shrinking encircling system or the spiral model for revising and updating the whale’s position during optimization. The mathematical model of this is given by Eq. (3.5.2):
where
Showing WOA spiral updating position [30].
The exploitation approach can also be used to search for prey (in exploration), by altering the vector, whose random values lie in:
This forces search agents to swim off from the referenced search agent (whale) as shown in Fig. 4.
Compared to the exploitation stage where the search agent position is updated using the best search agent, in the exploration phase the position of a search agent is revised by a randomly selected search agent as explained in Fig. 6.
where
Showing WOA exploration mechanism [30].
Figure 6 shows the exploration mechanism of WOA. In this phase, the current search agent position is informed to other agents to keep them away from the prey.
In this paper, the dataset of 14 subjects is considered provided by [20]. The above-discussed methodology is implemented using MATLAB and EEGLAB. After carrying out categorization and recognition tasks, 13 files were recorded for each of the subjects. In this segment, we portray results to explain our proposed methodology.
The data was first converted into.mat file with the help of EEGLAB, which is executed in MATLAB. Further, results are normalized and eye blink artifacts were removed from one subject. The eyeball is a dipole with a positive pole (anteriorly-cornea) and a negative pole (posteriorly-retina). Besides this, the various waves namely alpha, beta, gamma, and theta range from 2 to 21 Hz frequencies. Therefore, we have considered a range of EEG signals, whose intensity is quite small (in microvolt),
(a) Showing raw signals obtained for candidate 1. (b) Shows the signals obtained after normalization and removal of eye blink artifacts.
Figure 7 shows the image of one subject out of 14. Figure 7a shows the raw signal collected, which has around 31 attributes while Fig. 7b is the signals received after normalization and eye blink removal.
Feature extraction from signals, received after removal of eye blink artifacts (Fig. 8a), is performed. In this process, the Discrete Cosine Transform (DCT) is used. Figure 8b shows the extraction of time-domain features from signals received after pre-processing. It is now transformed into respective frequency domain features in Fig. 8c. Later, the 2 signals combined to have features in both time and frequency domain as shown in Fig. 8d. A total of 31 features have been extracted.
Showing the results of feature extraction using DCT. (a) Is the signal to be used for feature extraction. (b) and (c) results in the time domain and frequency domain respectively on applying DCT. (d) Superimposition of (b) and (c).
Figure 8 shows the results of the feature extraction step. DCT has been used for this step. Figure 8a is the input signal received from the previous step while Fig. 8b shows the output of DCT in frequency and time domain and Fig. 8d shows the superimposition of the 2 results obtained after DCT.
Further, modified binary particle swarm optimization (MBPSO) is used for feature selection. Best 10 among 31 features are extracted, using which the various classes of stress were identified later in the next step. Figure 9a shows the result of various selected features in the time domain, after the application of the MBPSO algorithm on the extracted statistical features. Similarly, Fig. 9b shows the results in the frequency domain, while Fig. 9c, expresses the combination of (a) and (b).
Showing the result of selected features in (a) time domain, (b) frequency domain and (c) combined result of (a) and (b).
Figure 9 shows the results of the feature selection phase. In this phase, some 10 best features have been selected from 24 features extracted in the previous step. Results are shown in frequency and time domains.
Classification is performed using SVM and taking WOA in the kernel function. It should be noted that during the pre-processing step, we had classified 80% file intake as training data and rest 20% as testing data. Further, in classification, a total of 47 support vectors are used. A total of 500 iterations were executed for 30 search agents. After each iteration, it shows the best score. Against each iteration, the 2 functions used in the exploratory phase of WOA are plotted using the parameter space (shown in Fig. 10a), while the best score is plotted in objective space as shown in Fig. 10b. These functions help to find the value of alpha in the given signals. The value of alpha helps to detect the stress level.
Showing stress level in each task carried on the subject named cba
Showing classification results in (a) parameter space (b) objective space, using WOA in the kernel function of SVM.
Figure 10, The results of various iterations in parameter and objective space are graphically shown. These spaces explain with more iteration running the score gets better. In other words, the best solution or signal to detect stress is recovered.
Comparison results of existing feature extraction, classifications and performance techniques for EEG dataset
Out of 500 iterations, the best solutions obtained in parameter space are:
And for this subject, the best optimal solution obtained using WOA is 5.7903e-71.
Also, based on the value of alpha defined in SVM, 3 classes of stress were defined namely low, medium, and high. Based on this, the stress level is identified and results are presented in Table 1. The results are validated using parameters like sensitivity, specificity, accuracy, ROC, and computational time. The Max Sensitivity, the point (i.e. value where the number of false positives is too much), is at 107.00.
Table 1 Shows the results of the 1st-day task for one subject. The table explains the task and the respective stress level during that task. Tasks were divided into categorization and recognition.
The computational time for getting sensitivity and specificity is 54.5034. The average sensitivity was 0.9677 while average specificity was 0.5912. Accuracy for the proposed methodology was 91.443%. Besides, computational, time keeps reducing if for the same subject the algorithm is executed again and again. The same is plotted in Fig. 11.
Showing the ROC curve obtained for various values of sensitivity and specificity at various cutoff points for one subject.
Figure 11 is a graphical depiction of sensitivity and specificity for one subject. It also shows that accuracy to detect stress through the WOA algorithm is 0.91 or 91%.
The accuracy of using SVM with WOA in its kernel function is 91%.
The results obtained from the proposed methodology are compared with available research, presented in Table 2.
Table 2 compares the results of WOA (as proposed in this paper) with some previous works to detect stress.
The authors of [19] proposed a new bio-inspired algorithm named WOA, which is the base of our work. They had tested their algorithm on 29 mathematical and 6 structural design problems. They claimed to have obtained competitive results. Also, the authors of [16] had proposed a modified version of WOA for software usability. Some extension work on WOA has also been proposed by the authors in [18]. We, on the other hand, have used the same algorithm (WOA) but implemented in the medical field. Besides, we used WOA along with SVM and 3 more algorithms to detect stress.
In this paper, we have proposed a methodology to detect stress using SVM. The proposed methodology uses 4 algorithms for detecting stress as accurately as possible. An attempt to use WOA for stress detection has been made through this paper. Eyeblink artifacts are removed using NLMS and later, feature extraction is performed using the DCT. Extracted features are then selected using MBPSO. Then, the classification is performed using SVM, in which WOA is used in the kernel function. The present research work is in the initial state and a lot of enhancements are in the pipeline. The results of this paper are also compared with some of the available research and found to achieve a good accuracy of 91% over others. The proposed approach can be used in clinical applications when few more biological features like ECG, blood pressure are added along with EEG. All these features together can detect the level of stress accurately leading to proper medication.
