Open access peer-reviewed chapter

Pain Identification in Electroencephalography Signal Using Fuzzy Inference System

Written By

Vahid Asadpour, Reza Fazel-Rezai, Maryam Vatankhah and Mohammad-Reza Akbarzadeh-Totonchi

Submitted: April 15th, 2021 Reviewed: February 16th, 2022 Published: April 14th, 2022

DOI: 10.5772/intechopen.103753

Chapter metrics overview

13 Chapter Downloads

View Full Metrics


Diagnosing pain mechanisms is one of main approaches to improve clinical treatments. Especially, detection of existence and/or level of pain could be vital when oral information is not present for instant for neonates, disabled persons, anesthetized patients and animals. Various researches have been performed to originate and classify the pain; however, consistent results are surprising. The aim of this study is to show a strict relation between electroencephalography (EEG) features and perceptual pain levels and to clarify the relation of classified signal to pain origin. Cortical regions on scalp are assigned based on an evolutional method for optimized alignment of electrodes that improve the clinical monitoring results. The EEG signals are recorded during relax condition and variety of pain conditions. Evolutionary optimization method is used to reduce the features space dimension and computational costs. A hybrid adaptive network fuzzy inference system (ANFIS) and support vector machine (SVM) scheme is used for classification of pain levels. ANFIS optimizer is used to fine tune the non-linear alignment of kernels of SVM. The results show that pain levels could be differentiated with high accuracy and robustness even for few recording electrodes. The proposed classification method provides up to 95% accuracy.


  • electro-encephalogram
  • pain
  • adaptive network fuzzy inference system
  • support vector machine

1. Introduction

Diagnosis of the pain is one of the main concerns in clinical treatments procedure. In particular, detection of chronic or acute stage of the pain could be vital in the situations that oral information is not available for example instant for neonates, disabled persons, anesthetized patients and also animals. Multiple research projects have been done to originate and classify the pain. It is shown that achieving consistent is a challenge.

Identification of the human sensory perception have been of high interest in recent years. These studies are required for protection of the body and for restoring the embodiment sense. The advance in this field shows that not only the accurate design of the sensors improves the sensitivity of the identification but understanding the dynamics of pain perception and successful reversing of the coding mechanism are essential stages of the processing and classification process.

Localization of the source of the pain is very important for the neurological therapeutic processes [1]. The localization of cortical sources and observation of the spatiotemporal activation is also used for pre-treatment monitoring and surgical process [2]. The studies in this area would create an infrastructure for real-time monitoring of the pain to be used in alarming systems, surgery monitors and automated activated systems.

The aim of this work is to show the relation of EEG signal and perceptual level of pain. We also try to clarify the relation between the signal and the origin of the pain. The alignment of electrodes in cortical regions on scalp are assigned based on an evolutional algorithm to improve the clinical monitoring results. The normal and pain conditions are used for recording the signal. Some defined spectral features are combined with non-linear features including approximate entropy and Lyapunov exponent to create the feature vector. It is shown that there is consistency between these features and the dynamical characteristic of EEG signals. Evolutionary optimization method is used for reduction of the features space dimension and computational costs. A hybrid adaptive network fuzzy inference system (ANFIS) and support vector machine (SVM) scheme is used as the classifier. ANFIS optimizer is used for alignment of kernels of SVM. The classification results show that pain levels could be differentiated with high accuracy, sensitivity, and specificity with few recording electrodes. This research shows that electrical variations of brain patterns could be used for determination of pain levels. The proposed classification method reaches an accuracy of 95%.


2. Literature review

The study of human brain functionality in special conditions like stress and pain has significantly improved in the last decades [2]. Only some few changes in EEG signal have been observed during pain condition. An experimental pain stimulus will cause a decrease in alpha spectrum and an increase in gamma power in the surface of cortex while tonic muscle pain usually led to a stronger beta activity [3]. In most of the works a cold press has been mainly used to induce pain to the subjects. The achieved results are not necessarily consistent and do not allow for generalization of the events.

The staging of the signals has shown more progress regardless of the specificity of the described EEG changes for pain. The EEG spectrum is affected by sensory processing in general and cognitive sensory signals change during these events. The ambiguity of the effects of these events on EEG is probably a consequence of the methods used for EEG analysis, which do not allow for sufficient experimental control. In the present work a machine learning approach is used for classification and recognition of pain to be used for diagnosing purposes.

The aim of this research is to identify the difference between “normal”, “low pain” and “pain” conditions. A kernel based SVM is used for the classification of the signals in the desired classes [4]. The optimized hyperplane is adjusted by finding the maximum distance from the nearest training points. An ANFIS optimizer is used for adjusting the hyper-planes of SVM classifier. ANFIS is trained by the features in the data set and adjusts the system parameters according to the error criteria [5]. Our results show that the combination of ANFIS-SVM results to the best performance on nonlinear features.


3. Materials and methods

3.1 Energy ratio features

The EEG signal could be categorized based on the spectrum in the frequency domain. The spectrum analysis could provide a demonstration of the functionality of the brain. Because of the spectrum changes in pain condition the Energy ratios between different bands could be used as the classification features. The ratio of Alpha, Beta, Delta, and Theta energy to the total spectrum on each EEG lead are used as the features for the classifier.

3.2 Approximate entropy

Approximate entropy is a non-negative number that is assigned to a time series that is a measure of the complexity or irregularity in the data. EEG signal has a steady pattern during synchronized cooperative function of cortical cells with low entropy index values. In contrast concentric functions and higher levels of brain activity led to high values of entropy. The entropy His defined as:


in which Piis the average probability at ith frequency band of brain rhythm that is grater that rtimes of standard deviation and Nis the total number of frequency bands. His 0 for a single frequency and 1 for uniform spectrum distribution over total spectrum. Approximate entropy can be used as a powerful tool in the study of the EEG activity because of the non-linear characteristics of EEG signals. The accuracy and confidence of the entropy estimate improves as the number of matches of length mand m+1increases. mand rare critical in finding the outcome of approximate entropy. The approximate entropy is estimated with m=3and r=0.25based on an investigation on original data sequence in this work.

3.3 Fractal dimension

Fractal dimension is a demonstration of the geometric property of basin of attraction in the feature space. This dimension shows geometrical property of attractors and is also computed very fast [6]. Features were extracted from each one second segment with 50% overlap, and sequence of 9 extracted features was considered as the feature vector of a five second segment. We have used Higuchi’s algorithm, in which knew time series are constructed from the signal under study as [7]:


in which m=1,2,,kand kindicate the initial time value, and the discrete time interval between points, respectively. For each of the ktime series xmkthe length Lmkis calculated as:


in which Nis the total length of the signal x. An average length is computed as the mean of the klengths Lmk(form=1,2,,k). This procedure is repeated for each kranging from 1to kmax, obtaining an average length for each k. In the curve oflnLkversusln1k, the slope of the best matched line to this curve is the estimate of the fractal dimension.

3.4 Lyapunov exponent

Lyapunov exponents are used as a measure for differentiating between types of orbits in feature space based on the initial conditions. These features can determine the stability of steady-state and chaotic behavior [8]. Chaotic systems show aperiodic dynamics because the phase space trajectories with similar initial states tend to move from each other at an exponentially increasing speed that is defined as Lyapunov exponent. This feature is extracted from the observed time series. The algorithm starts from the two nearest neighboring points in phase space at the beginning time 0 and at the current time tthat corresponds to the distances of the points in the ith direction are δXi0and δXit, respectively. The Lyapunov exponent is defined as the average growth rate λiof the initial distance [9]:




The existence of a positive Lyapunov exponent is an indication of chaos. Lyapunov exponents can be extracted from observed signals using two approaches. The first method is based on the following of the time-evolution of nearby points in the state space. This method can only estimate the largest Lyapunov. In the other approach the Jacobi matrices and can estimate all the Lyapunov exponents for a systems that often called their Lyapunov spectra [10]. This vector is used as the parameter vector in this work.


4. Classification

SVM classifiers discriminants the hyperplanes to reach optimal classification. The hyperplanes should be adjusted to maximize the margin of classification boundaries. The distance from the nearest training points is measured using a non-linear kernel to map the problem from the feature space into the linear space [11]. Radial Basis Function (RBF) kernel is proposed in this paper and the Lagrangian optimization of the kernel is performed using an ANFIS structure. This proposed method leads to adjustable soft-decision classification because of the conceptual nature of the pain for patients.

4.1 SVM with RBF kernel

Training of the SVM is a quadratic optimization problem on the hyperplanes that are defined as:


that xiis the feature vector, bis the bias, wis the weight vector, ξiis class separation factor, Φxiyjis the RBF mapping kernel, lis the number of training vectors, jis the number of output vectors, and yjis the desired output vector. The weight parameter should be optimized to maximize the margin between the hyperplane and the neighboring points in the feature space. This is a compromise between the maximization of margin and the number of misclassified points. Optimization of Eq. (6) results to optimum weight w.

Figure 1 shows the RBF kernel SVM classification system. The kernel parameters could be selected by optimizing the upper bound of the generalization error based on the training data. The support vector fractions and the relation between the number of support vectors and all the training samples define an upper bound on the error estimate. The resulting decision function can only change when support vectors are excluded. A low fraction of support vectors could be used as a criterion for the parameter selection.

Figure 1.

Block diagram of RBF-SVM classification system.

4.2 Adjustable ANFIS optimization

An ANFIS is used with for optimization of the SVM classification kernels. The optimization process would be less reliant on expert knowledge compared to the conventional fuzzy systems using this adaptive method. The result of the learning algorithm for this architecture is to adjust all the parameters of the kernel to adjust the hyperplanes for optimized output. Since the initial parameters are not fixed, the search space becomes larger, and the convergence of the training becomes slower. The training method is using a combining of the least squares and the gradient descent method is used to train the network. The hybrid algorithm is composed of forward and backward pass. The least squares method on the forward pass is used to optimize the consequent parameters with the fixed premise parameters. The backward pass is using the gradient descent method afterward to optimize the consequent parameters and to adjust the premise parameters corresponding to the fuzzy sets in the input domain. The output of the ANFIS network is achieved by defuzzification of the consequent parameters in the forward pass. The output error is used to adjust the premise parameters using a standard back propagation algorithm.


5. Results

Three montages of electrodes are used for clinical experiments as are shown in Figure 2. The classification results of for the arrangements are compared with each other to find the best montage. All of the experiments performed with 70% training and 30% testing signals. Table 1 shows the classification accuracy rates for ANFIS-SVM using these electrode arrangements. Montage III led to best classification and is used as the electrode set for pain classification in this work. The SVM parameters and the related Kernel function are adjusted to achieve the best possible results. This optimization was done using ANFIS as described in the materials and methods section. The over fitting is reduced by controlling the compromise between the training error minimization and the learning capacity of the fuzzy if-then functions. The final decision function parameters can be updated because they depend on the support vectors only.

Figure 2.

The electrode arrangement (a) I, (b) II, and (c) III for electrodes based on 10/20 standard.

Montage IMontage IIMontage III
Classification rate for ANFIS-SVM78%81%88%

Table 1.

ANFIS-SVM Classification rate for three electrode arrangements.

Furthermore, approximate entropy, Lyapunov exponent and fractal dimension are also examined as non-linear features. An evolutionary feature selection was applied on these elements that showed the theta and alpha ratio and the entropy led to best classification rates for ANFIS-SVM classifier. The accuracies for classification of two classes of pain and no pain are shown in Table 2 for two cases of using all the features in the feature vector and using the high rank features only. The results for SVM and ANFIS-SVM show the identification rate shows a reduction of 7% and 8% for reduced features, respectively. This reduction happens for identification based on three most effective features, and it could be concluded that the effect of “standard deviation” and “fractal dimension” could not be neglected. The accuracy of 95 % is achieved for ANFIS-SVM proposed method using non-reduced features.

FeaturesSVM (%)ANFIS-SVM (%)
Non-reduced featuresStandard deviation, theta ratio, alpha ratio, entropy, lyapunov, and fractal dimension9095
Reduced FeaturesTheta ratio, alpha ratio, and entropy8387

Table 2.

Classification rates of SVM and ANFIS-SVM for reduced and non-reduced features.

Another evaluation is performed on feature space to find the feature sets for ANFIS-SVM classification. The features are classified as spectral feature set that includes “theta ratio” and “alpha ratio,” and nonlinear features namely that include “entropy,” “standard deviation” and “fractal dimension.” Table 3 shows the results for classification of pain and no-pain condition. It could be observed that non-linear features result into about 17% improvement for SVM and 14% improvement for ANFIS-SVM classification.

Spectral features (%)Non-linear features (%)

Table 3.

Classification rate for ANFIS-SVM with two sets of features.


6. Discussion

The aim of this chapter was to introduce a classification method base on ANFIS-SVM method for identification of pain condition in EEG signal. In this study, we explored the effectiveness of the identification of pain level and localization of the signals on cortex for therapeutic use [12]. The extracted features of EEG including standard deviation, theta ratio, alpha ratio, entropy, Lyapunov, and fractal dimension and the recording channels in pain EEG signals are studied. The classification method is optimized to identify acute pain. The results of the experiments show that non-linear features combined with the proposed classification method are capable of effective classification. The feature vector is built by entropy, fractal dimension and conventional spectral features. The results also show that the reduction of the number of features could improve the accuracy of the system. Therapeutic usage of this system would be beneficial with patients with anesthesia and the patients who are unable of regular communication.


  1. 1. Misra G, Wang WE, Archer DB, Roy A, Coombes SA. Automated classification of pain perception using high-density electroencephalography data. Journal of Neurophysiology. 2017;2(117):786-795
  2. 2. Tayeb Z, Bose R, Dragomir A, Luke E, Osborn NV, Thakor GC. Decoding of pain perception using EEG signals for a real-time reflex system in prostheses: A case study. Nature Scientific Reports. 2020;10:1-11
  3. 3. Chouchou F, Perchet C, Garcia-Larrea L. EEG changes reflecting pain: is alpha suppression better than gamma enhancement? Neurophysiologie Clinique. 2021;51(3):209-218
  4. 4. Asraf H, Tahir N, Rizam MSB. A comparative study in kernel-based support vector machine of oil palm leaves nutrient disease. Procedia Engineering. 2012;41:1353-1359
  5. 5. Shankar K et al. Optimal feature level fusion based ANFIS classifier for brain MRI image classification. Concurrency and Computation: Practice and Experience. 2020;32:1-12
  6. 6. Sebastián M, Navascués M, Otal A, Ruiz C, Idiazábal M, Stasi LLD, et al. Fractal dimension as quantifier of EEG activity in driving simulation. Mathematics. 2021;9:1311
  7. 7. Anier A, Lipping T, Mel S, Hovilehto S. Higuchi fractal dimension and spectral entropy as measures of depth of sedation in intensive care unit. In: Annual International Conference of the IEEE Engineering in Medicine and Biology Society. San Francisco: IEEE; 2004. pp. 526-529
  8. 8. Kutepov IE, Dobriyan VV, Zhigalov MV, Stepanov MF, Krysko AV, Yakovleva TV, et al. EEG analysis in patients with schizophrenia based on Lyapunov exponents. Informatics in Medicine Unlocked. 2020;18:1-7
  9. 9. Derya E.Lyapunov exponents/probabilistic neural networks for analysis of EEG signals. Expert Systems with Applications. 2010;37(2):985-992
  10. 10. Hallam A, Morley JG, Green AG. The Lyapunov spectra of quantum thermalization. Nature Communications. 2019;10:2708
  11. 11. Murty MN, Raghava R. Kernel-based SVM. In: Support vector machines and perceptrons: Learning, optimization, classification, and application to social networks. Springer International Publishing; 2016. pp. 57-67
  12. 12. Tripanpitak K, He S, Sönmezışık I, Morant T, Huang SY, Yu W. Granger Causality-Based Pain Classification Using EEG Evoked by Electrical Stimulation Targeting Nociceptive Aδ and C fibers. Vol. 9. New York: IEEE Access; 2021. pp. 10089-10106

Written By

Vahid Asadpour, Reza Fazel-Rezai, Maryam Vatankhah and Mohammad-Reza Akbarzadeh-Totonchi

Submitted: April 15th, 2021 Reviewed: February 16th, 2022 Published: April 14th, 2022