Modified Support Vector Machine for Detecting Stress Level Using EEG Signals

Stress is categorized as a condition of mental strain or pressure approaches because of upsetting or requesting conditions. There are various sources of stress initiation. Researchers consider human cerebrum as the primary wellspring of stress. To study how each individual encounters stress in different forms, researchers conduct surveys and monitor it. The paper presents the fusion of 5 algorithms to enhance the accuracy for detection of mental stress using EEG signals. The Whale Optimization Algorithm has been modified to select the optimal kernel in the SVM classifier for stress detection. An integrated set of algorithms (NLM, DCT, and MBPSO) has been used for preprocessing, feature extraction, and selection. The proposed algorithm has been tested on EEG signals collected from 14 subjects to identify the stress level. The proposed approach was validated using accuracy, sensitivity, specificity, and F1 score with values of 96.36%, 96.84%, 90.8%, and 97.96% and was found to be better than the existing ones. The algorithm may be useful to psychiatrists and health consultants for diagnosing the stress level.


Introduction
Mental stress has become a social problem of the 21 st century. It affects the functionality of the routine work and economy of an individual human and a nation as well. 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 as one does not get relaxation in between various challenges. Enthusiastic stress emerges because of work pressure, complying with up time constraint, tests, and so on [1]. ere are various sources of stress initiation [2]. Researchers consider human cerebrum as the primary wellspring of stress [3,4]. To study the effect of stress on different individuals, surveys are conducted and even monitoring of individuals takes place [5]. Self-report surveys are one of the most regularly utilized techniques to gauge a person's degree of stress [6][7][8]. To distinguish human feelings and stress discovery, electroencephalogram (EEG) is a significant technique used in stress detection and has shown some significant results [9]. Electroencephalography (EEG) is a test to estimate and record the brain's electrical activity [10,11]. e handling of EEG signals is the most basic part in the present investigations [12]. Various techniques have been developed either on the basis of a questionnaire or quantifying the changes in physiological signals to measure and study the stress level. Physiological signals are online real-time system and gives better accuracy in stress estimation. ese can be classified into two types: (i) invasive type and (ii) noninvasive type. Invasive type methods such as local field potential (LFP) and electrocorticography (EcoG) provide high resolution in temporal and spatial axes and high specificity. However, they have limited coverage and may be not suitable to all situations. e noninvasive methods such as (i) functional magnetic resonance imaging (fMRI), (ii) electroencephalography (EEG), and (iii) magnetic encephalography (MEG) are presently used for assessment of stress effect on human health. EEG and MEG have higher resolution whereas fMRI has high spatial resolution but very low temporal resolution. e proposed modified Whale Optimization Algorithm (WOA) selects the optimal kernel in the support vector machine (SVM) classifier for stress detection. Besides, the other main contributions of this paper are the following: (1) We integrated a certain set of algorithms (namely, NLM, DCT, and MBPSO) for preprocessing, feature extraction, and selection from noisy EEG. (2) Optimal set of features which depend on the frequency level are selected using MBPSO technique. (3) e Kernel of SVM is modified using WOA, since the optimal SVM machine learning classifier has been used for long term stress classification in which it attains the better performance. (4) Also, the proposed algorithm has been tested to identify the stress level among 14 subjects. (5) Further, the results of modified and existing algorithm have been compared to identify the efficiency of the 2 algorithms. Here, the authors want to mention that WOA has not been used in any neurological application and an attempt has been made by the authors to observe this algorithm effect in identifying stress through EEG signals.
is paper is divided into 5 sections. Section 1 explains the stress behavior and its analysis in Introduction, Section 2 explores the different research work carried out in the related area, Section 3 explains the methodology proposed in the paper, and Section 4 explains and discusses the results obtained after implementing our methodology on our original work and presents comparison with modified version of our original implemented work. Section 5 concludes the study of this research paper.

Literature Review
A lot of work has been carried out on detecting the stress. Some are discussed in this section.
In [13], authors have enhanced some statistical technique using Renyi's entropy to develop a technique for removing artifacts that get introduced during the EEG recordings.
Authors in [14] had stated the difficulty in removing artifacts present in biomedical signals. To overcome this difficulty, they had developed a method where they used discrete wavelet transform (DWT) and independent component analysis (ICA) together. ey tested their method on new real-time data to show its effectiveness.
Authors of [15] had used support vector machine (SVM) for predicting protein stability that changes from single amino acid mutations.
is inspired us to use SVM in detecting stress from EEG signals.
In [16], authors have proposed a strategy for identifying the stress by using the EEG signals. ey had used K-means clustering method for data classification and technique.
Gaurav et al. [17] have portrayed a strategy to distinguish mental stress level dependent on physiological parameters. ey had used SVM based on the binary classifier and classified stress in 2 levels and 3 levels, respectively. Out of 41 volunteers, 30 subjects had been correctly classified in the binary classifier and 26 subjects were identified correctly in the ternary classifier.
In [18], authors have proposed mental stress discovery utilizing phonocardiography signals. Precompetitive (or exam related) mental stress was identified from the S1-S1 interim of PCG signals, also termed as Interbeat Interval (IBI). ey had also performed another experiment; Kruskal-Wallis statistical test was used for identifying and extracting various features. e extracted features are then fed into SVM based on the least square classifier.
Authors of [19] have analyzed the effect of English and Urdu music tracks on human stress level. e EEG signals were collected while the subjects were listening either to English or Urdu music. Authors had implemented algorithm based on 4 classifiers, namely, sequential minimal optimization, stochastic decent gradient, logistic regression (LR), and multilayer perceptron. ey classified stress into 2 and 3 classes. It was concluded that females are more responsive than males to music.
An extensive structure for the initial identification of mental stress by breaking down varieties in electroencephalogram (EEG) and electrocardiogram (ECG) signals has been proposed in [20]. e prediction of treatment efficacy compared to accuracy had been emphasized. e model explained in the paper defined the stress in 4 classes.
e results had shown significant difference in the stress and the control conditions.
In another research illustrated in [21], a technique has been proposed to consequently perceive laborers' stress in building locals. Authors had extracted features in frequency and time domain using fixed and sliding window techniques. ey had shown that fixed window approach along with the Gaussian support vector machine resulted in highest accuracy. Authors also collected cortisol, stress hormone from workers during working hours, to classify into low and high stress.
In [22], a machine learning-based approach has been proposed to deal with driving-actuated stress. ey had used 3 classifiers, namely, SVM, neural networks, and Random Forest, to classify the EEG signals collected from the subjects. e study concluded by stating SVM performed better during rest and stress states, over others.
In [23], two sparsity based techniques are used to remove the eye blink artifacts, namely, Morphological Component Analysis (MCA) and K-SVD. Results of both algorithms were correlated with the developed FORCe method. K-SVD algorithm removes eye blink better than the MCA algorithm.
Qi1 [24] discussed the elimination of the EOG product from EEG signals using Recursive Least Square (RLS) algorithm. In addition to it, Second-order Blind Identification (SBI) algorithm was also used.
In [25], authors employed low-cost wireless EEG headset for quantifying various cognitive stress states on the singletrial basis. Here, Stroop-type color-word interference test was conducted for eliciting the mild stress responses when recording the scalp EEG of 18 subjects. en, the computational feature was extracted from EEG signals during each stimulus presentation. en, the feature extraction output was provided as the input to quadratic discriminant analysis, logistic regression, and k-nearest neighbor classifier for 2 Computational Intelligence and Neuroscience classification. Here, the accuracy was found better, but failed to examine cognitive stress in real time.
Authors of [26] have developed a multiclass support vector machine (SVM). To identify and classify stress, authors had added error correction code (ECOC) to SVM. To better record stress from PFC region, a limited number of EEG-electrodes were used.
us, classification of stress resulted in average accuracy. e research in [27] presented stage-wise methodology for stress classification in humans. e method suggested in this paper can prepare classification model in limited time and increased the accuracy. Data was collected from volunteers, who wore single channel EEG device.
In [28], a technique was developed using multiclass support vector machine for brain stress classification. Although this framework achieves better performance in monitoring the brain network states, it failed to consider samples for training process.
e research carried out in [29] employed SVM classification for stress classification using EEG signals. However, the accuracy was found better, but failed to examine a large data for stress and nonstress subjects.
In another research carried out in [30], a fNIRS-based brain-computer interface for EEG stress classification was developed. Here, the accuracy was found better, but failed to include the bundle type dataset to achieve minimal error.

Proposed Methodology
e suggested method has four main phase algorithms, namely, (i) preprocessing, (ii) feature extraction, (iii) feature selection, and (iv) classification (stress level identification), besides data acquisition stage. e block diagram of the suggested methodology is shown in Figure 1.

Data Acquisition.
e dataset used in the work was taken from [31]. Around 14 human subjects with normal vision (7 women and 7 men) of an average age of 26 years (ranging between 22 and 46) volunteered for the study. e subjects sat in a dimly lit room, at a distance of 110 cm from a colored computer screen having a block of 100 images. Subjects were also holding a touch-sensitive button. e 32 electrodes mounted on the EEG cap recorded the associated EEG. Electrodes were placed in 10-20 system and are divided into 2 categories: frontal electrodes and occipital electrodes. A SynAmps recording system (Neuroscan Inc.) was attached to a PC, which documented data at 1000 Hz. In addition, 500 Hz of a low-pass filter was used and impedance was maintained below 5 kOhms. Images were divided in targets and nontargets (distractors) while shown to subjects. Targets are photographs including images of mammals, reptiles, arthropods, fish, and birds and nontargets include images of outdoor and indoor places, natural landscapes or urban sites, fruit, vegetables, trees, and flowers. ere are two types of tasks, namely, categorization or recognition. Categorization had 1000 pictures (50% distractors and 50% objectives), shown only once to subjects. During the categorization task, targets and nontargets 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 nontarget images. Fifteen targets (a total of 210 targets) and therefore the same 750 nontarget 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. 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 nontargets, the button should not be released. Time to react is 1000 ms, beyond which it was recorded as no-go or nontarget.
is 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 training or learning phase, the target images were flashed perpetually for twenty ms (comparable to the test circumstances). In order to respond to images accurately and quickly in the respective sequence of images, participants were advised to memorize images. e block of testing began instantly after the learning stage. Figure 2 shows the international system used for 32-electrode setup for the said experiment.

Preprocessing.
e preprocessing techniques remove undesirable artifacts from the EEG signal and remove the eye blinking artifacts [32]. Normalized least mean square (NLMS) technique is used [33] for preprocessing. e NLMS algorithm updates the coefficients of an adaptive filter as tapweight at (m + 1) iterations as per the following: where μ is a time varying step size and should be carefully chosen, as large value can lead to algorithm instability while less value can make algorithm large time converge. e (m) is estimated error and its conjugate is found at m th iteration. e modification in NLMS is normalized to squared Euclidean norm of μ (m) at (m + 1) iteration. Based on the above process, the input raw signal is preprocessed and the resultant output was fed to the next step, feature extraction. Computational Intelligence and Neuroscience

Feature Extraction.
Feature extraction retrieves the most significant features from the input signal. In the proposed algorithm, features were extracted using the discrete cosine transform (DCT). In the two stages of the DCT, there exist 2 coefficients, each concentrated on the low and high frequency components. To obtain the DCT coefficients, the DCT was applied on the input signal, in the first phase. Later, in the second phase, feature vectors were constructed using some of the selected coefficients. e DCT input a (n) is a set of N data values (EEG samples, audio samples, or other data) and the output A (n) is a set of N Discrete Cosine Transform coefficients [34].
e first coefficient A (0) is called the DC coefficient and rests are referred to as AC coefficients. e DC coefficient encompasses mean from the input signal. e DCT displays good energy compaction for highly correlated signals. e feature vector has been generated from the input signal by utilizing the DCT. Some of the features extracted were mean, median, standard deviation, kurtosis, skewness, variance, short time energy, waveform length, frequency value, SNR, and mean absolute deviation. ere are a total of 22 features extracted.

Feature Selection.
In order to choose the optimal feature for stress level identification issue, the modified binary particle swarm optimization (MBPSO) algorithm was utilized. In the proposed method, traditional particle swarm optimization algorithm was modified by means of binary value to modified binary particle swarm optimization (MBPSO) [35]. e new random particle for selecting the new optimal feature set generation is used as follows: where gbest and pbest are global best and local best values of fitness function from entire iterations and current iteration, respectively, v new pd represents the new velocity particles, and v old pd represents the previous velocity of particle p in dth iteration. e c 1 � c 2 � 2 are constant variable. Each particle representing the feature selection is given by e feature on renewal is calculated by the function S(v new pd ), in which the speed value is V new pd . e x new pd represents the new particle in the MBPSO technique. If S(V new pd ) is larger than a randomly formed disorder number within (0, 1), then the feature is selected; otherwise, the feature is not selected. us, the final optimal feature set has been extracted by utilizing the MBPSO technique.

Classification (Stress Level Identification).
e proposed stress level identification is finally performed with the help of support vector machine (SVM). Here, the Modified Whale Optimization Algorithm (MWOA) is used to select the optimal kernel in the SVM classifier. e kernel function used in support vector machines (SVM), K (x n , x i ), transformed the original data space into a new space with a higher dimension. e accuracy of the WOA algorithm as discussed in [36] is enhanced by assigning fitness objective function values to random numbers. is is discussed as (i) encircling prey phase, (ii) exploitation (bubble-net attacking) phase, and (ii) exploration (search for a prey) phase. For hunting, whales use the spiral bubble technique which is depicted in the WOA.

Encircling Prey Phase.
During the said phase, the whales, which are search agents looking for the prey, identifies the position of the prey, and then they start circling them. is can be formulated using the following: where A and C are coefficient vector, the current iteration is recorded by t, and X * represents the best position vector obtained till current phase while X indicates the overall best value of respective position vector. e coefficient vectors, A and C, are evaluated as follows:  Figure 2: e 32-electrode location map used in the data acquisition step as per 10-20 international system.
where r 1 , r 2 are random numbers that decrease linearly during exploitation and exploration phases.
Whales update their position as per the following equation: where D � |X * (t) − X(t)| indicates the distance between the current whale's position and the prey's position and b represents a constant which describes the movement of whales in a spiral path. is switching can be expressed mathematically by De bt cos(2πt) + X * (t), p ≥ 0.5, where p is a random number over the interval [0, 1].

Exploration (Search for a Prey) Phase.
is phase explores the property of the whales to refresh their position in accordance with the reference whale, which is selected randomly. us, the updation to identify the best whale for a global search is presented by equations (10) and (11) [36]: where X rand is a random value that identifies the location of the randomly selected whale from the pool of available whales. e iteration will continue till it reaches the maximum iteration. Further, the WOA is enhanced to the MWOA by calculating random values, r 1 and r 2, used in encircling prey phase as per equations (12) and (13) [33][34][35][36][37][38]: Figure 3: WOA shrinking encircling mechanism [37].   Computational Intelligence and Neuroscience 7 where f max is maximum value of fitness function and f min is minimum value of fitness function from MBPSO.

e Objective Function.
e purpose of calculating objective function is to enhance the accuracy of the WOA for the stress level identification and is given by where t p and t n correspondingly represent true positive and true negative and f p and fn correspondingly represent false positive and false negative.

Results and Discussion
e proposed optimal stress level predictions have been computed using MATLAB. In this section, the proposed strategy is explained through the results. e input EEG signal dataset is taken from [31]. For each of the 14 subjects (25 files for each subject), preprocessing was performed using the NLMS algorithm. e adaptive filter removes the eye blink artifacts. e input signals have 31 different attributes as shown by different colors in Figure 5. e results of Figure 4 are images before preprocessing step. e subjects are named as cba, clm, ega, fsa, gro, hth, lmi, mba, mma, mta, pla, sce, sph, and wpa.
Further, Figure 6 shows the NLMS output after eye blink removal for 14 subjects. is shows the results after preprocessing step. In the preprocessing, each input signal has 31 different attributes. e NLMS preprocessing technique is used to uniquely identify a signal which depends on 31 attributes of each subjects. Hence, the signal data has been compressed which is represented in the graphical plots. Figure 7 shows a total of 24 features extracted (for cba subject) using the DCT. e DCT is used to compress the signal from different attributes and the feature extraction has been computed for the vector subject. e DCT converts the original signal into vectorized outcomes in which it is used to enhance the classification process to acquire the different long term stress level classification.
While Figure 8 shows the DCT output for all 14 subjects. From the DCT signal, the proposed features are extracted and then the optimal features are selected by MBPSO. e algorithm runs for 100 iterations to find the best among the 24 extracted. Finally, the stress level identification is done by SVM. It should be noted that, from 25 files for each subject, 18 were considered for training and 7 were considered for testing purposes.
Among these 24, 10 best features are selected for both current and proposed algorithm, respectively. For one of the subjects, cba, selected features are shown in Table 1. Here it should be noted that the algorithm for selecting best features had run for 100 iterations and the best results after each iteration were noted. e iterations which had best result among each other are selected for the next step. e performance analysis is based on the confusion matrix parameters. e results are assessed by accuracy, sensitivity, specificity, and F1 score.
where TP refers to true positive, TN refers true negative, FP refers to false positive, and FN refers to false negative. Table 2 demonstrates the overall result attained for all subjects.
e performance analysis comprising accuracy, sensitivity, specificity, and F1 score has been evaluated. e different techniques were such as MPSO_MWOA_SVM (proposed technique), PSO_MWOA_SVM, MBPSO_-WOA_SVM, and MBPSO_SVM. From the comparative analysis, the proposed technique shows the better outcomes when compared with the other techniques. Figure 9 is graphical representation of Table 2 for easier understanding.  Computational Intelligence and Neuroscience e effectiveness of the proposed strategy (SVM + MWOA) contrasted with current method (SVM + WOA) is presented in Table 3. e average computational time taken by the proposed algorithm is 46 sec. Figure 10 shows the histogram of the results in Table 3. Average accuracy, sensitivity, specificity,  On the basis of above parameters, files in each subject were categorized as low, high, medium, or no stress level. e tasks were carried out in 2 days. Table 4 shows the stress level identification for each task carried out in 2 days, for subject cba. Figure 11 shows the overall average performance of the entire input dataset.
When the various results are analyzed, it is found that the proposed method (SVM + MWOA) attains the maximum performance value compared to the original method (SVM + WOA). e graphical representation of the ROC plot for cba is shown below in Figure 12.
From the outcomes, it is observed that the proposed stress level identification accomplishes better classification accuracy when contrasted with current techniques.   Figure 9: Average performance comparison of various techniques used along with particle swarm optimization (PSO) and modified binary particle swarm optimization (MBPSO).    Figure 11: Average performance comparison of the input EEG dataset.

Conclusion
e test outcomes depict the effectiveness of the stress level identification by figuring the right and accurate estimation with the maximum accuracy value. e proposed method accomplishes the maximum accuracy, sensitivity, specificity, and F1 score with values 96.36%, 96.84%, 90.8%, and 97.96%. From the analyses of the above results, we found that adding fitness function in the WOA could enhance the efficiency of the algorithm. Also, it can be well concluded after the discussions of the results that the set of algorithms chosen for the study suits best to enhance the efficiency of our proposed algorithm. Eye blink artifacts had been removed during preprocessing step using NLMS. Later, for feature extraction, the DCT had been used and further MBPSO has been for feature selection. Further for classification step, SVM has been used along with the WOA, which was further modified for classifying stress effectively. Although an attempt to classify the stress level for each subject using the WOA has been made in this research, we still feel if few other biological features along with EEG can be added, then we can detect level stress much accurately and efficiently. Besides, implementation of the WOA and its modified version has been successfully done in this application of stress detection. e future work can also be broadened by utilizing some other independent component analysis and other machine learning techniques to improve the characterization exactness.

Data Availability
Data used to support the findings of this study were obtained from this site: https://sccn.ucsd.edu/∼arno/fam2data/ publicly_available_EEG_data.html.

Conflicts of Interest
e authors declare that there are no conflicts of interest among authors. Also, the research was conducted in the absence of any commercial or financial relationships that could be construed as a potential conflict of interest.