1 Introduction

The use of the electroencephalogram (EEG) to monitor level of hypnosis during surgery is highly desirable to prevent delayed recovery [1] and also minimize the possibility of the patient being aware or experiencing pain intraoperatively [2, 3]. Currently, some commercial EEG devices such as the M-Entropy module (Datex-Ohmeda, Helsinki, Finland) [4], Bispectral index (BIS, Covidien) [5] and Narcotrend index monitor [6] are widely used in clinical practice for the estimation of level of hypnosis with moderate success.

In the last decade, a large number of features from the EEG have been proposed to assess level of hypnosis with more precision; such as relative power in the classical frequency bands [7, 8], largest Lyapunov exponent [9], Lempel–Ziv complexity analysis [10], Bayesian methods [11, 12], phase-rectified signal averaging [13], distribution of auto-regressive moving average model parameters [14], Hilbert–Huang transform [15], recurrence analysis [16], Detrended Fluctuation Analysis (DFA) [17, 18] and entropies [19,20,21,22]. These analyses provide information which describes the complexity of EEG signals. But, none of the above mentioned methods has been proved to be adequately reliable for measuring level of hypnosis in the clinical setting. Anesthetic drugs cause complicated neurophysiological changes during the transition from awake to deep anesthesia and a comprehensive set of features is required to adequately describe these processes. Therefore, some researchers have combined a number of features to extract most aspects of brain activity [23,24,25,26,27]. Moreover, diverse classification methods have been utilized for mapping a set of features to different states of hypnosis. For example, some researchers have used Artificial Neural Network [9, 21], and adaptive neuro-fuzzy inference system [28,29,30]. These structures can successfully model systems with nonlinear relationships between inputs and outputs. However, there is the unsolved problem of the accurate classification of the overlapping states.

Recently in other biomedical research application, features and classifiers are combined in an efficient manner—using a hierarchical structure—to determine the classification performance robustly in overlapping classes [31,32,33,34,35,36,37]. Using the divide-and-conquer strategy [38], hierarchical classification attempts to combine classes with similar characteristics in specific features into one class, which can then be separated later at the succeeding steps with other features. The main idea behind this method is to separate the data into two classes (the ‘specific class’ and other classes) at each level using specific features. The data of other classes is then reclassified at the next level using different features. This approach is shown to be very useful for biomedical applications, because using different feature set to classify different classes in a hierarchical structure is very efficient compared to using a single feature set for the whole dataset.

The main contribution of this paper is to identify a set of robust and discriminative features from EEG signal and develop a hierarchical classification structure based on a support vector machine (SVM) to distinguish the four levels of anesthesia (awake, light, general, and deep anesthetic states) effectively. The ability of this novel system to classify EEG into four anesthetic states is evaluated with a commercial monitoring system (Response entropy (RE) index), in 17 patients during sevoflurane anesthesia.

2 Materials and methods

2.1 Subjects and data acquisition

Seventeen patients with age 18–63 years are used in this study. These patients were scheduled for orthopedic, gynecological or general surgery. The details have been previously published [39]. The GE electrode system was applied to the forehead of all the patients. EEG data is recorded with 100 sample per second and M-Entropy system was used to measure the RE Index (0.2/s). Based on the anesthesiologist’s judgment, the EEG data of patients were classified into awake, light anesthesia, general anesthesia and deep anesthesia. A 680 s (s) segment of EEG signal was extracted in each state for each patient. Then, for analysis, EEG data were separated into 10 s sections. As a result, each state comprised 68 test sections. Details of separating EEG signal in one of the four states of anesthesia based on the anesthesiologist’s judgment have been previously published [40].

2.2 EEG-derived parameter extraction

A comprehensive set of features is required to adequately quantify the complexity of EEG dynamic patterns during the transition from awake to deep anesthesia. We have extracted the following four features to do this.

2.2.1 Frequency-index

Frequency-index is the logarithmic relative spectral energy of frequency bands in (30–47) Hz and (11–21) Hz respectively

$$Beta\_index = \log \frac{E(30 - 47)}{E(11 - 21)}$$
(1)

These frequencies are chosen based on other studies [6, 7].

2.2.2 Sample entropy (SampEn)

SampEn algorithms are described below [41]:

  1. 1.

    Suppose a time series XN with N points, produces vectors of length m defined as:

    $$X_{i} = \left[ {x_{i} ,x_{i + 1} , \ldots ,x_{i + m - 1} } \right]. 1 \le i \le N - m$$
    (2)
  2. 2.

    Computing the distance between Xi and Xj, represented by \(d\left( {X_{i} .X_{j} } \right)\) as:

    $$d\left( {X_{i} .X_{j} } \right) = \hbox{max} \left( {\left| {x_{i + k} - x_{j + k} } \right|} \right), 0 \le k \le m - 1, j \ne i$$
    (3)
  3. 3.

    Calculating this possibility is shown below:

    $$P_{i} \left( {m,r} \right) = \frac{{n_{i} \left( {m,r} \right)}}{N - m - 1},\quad i - 1,\,N - m$$
    (4)

    where \(n_{i} \left( {m.r} \right)\) shows the number of vectors \(X_{j}\) which are analogous to \(X_{i}\) conditional on \({\text{d}}\left( {{\text{X}}_{\text{i}} ,{\text{X}}_{\text{j}} } \right) \le {\text{r}}\).

  4. 4.

    Evaluating

    $$A\left( {m.r} \right) = \frac{1}{N - m}\mathop \sum \limits_{i = 1}^{N - m} P_{i} \left( {m.r} \right)$$
    (5)
  5. 5.

    Setting \(m = m + 1\). and again repeating steps 1–4

  6. 6.

    Obtaining SampEn of \(X_{N}\) as:

    $$SampEn\left( {X_{N} ,m,r} \right) = - Ln\frac{{A\left( {m + 1,r} \right)}}{{A\left( {m,r} \right)}}$$
    (6)

2.2.3 Shannon permutation entropy (SPE)

Numerical feature that describe EEG signal complexity is called SPE. The details of this algorithm have been previously published in [42].

2.2.4 Detrended fluctuation analysis (DFA)

The DFA has proven useful in revealing the extent of long-range correlations in time series especially in EEG signal. The details of this algorithm have been previously published in [17, 18].

2.3 Statistical analysis

The Database used for the whole project consist 272 data related to 68 different patients (four data derived from one individual). Due to the limited dataset, we have used a special case of K-fold Cross-Validation in which K is equal to one. In this method which is known as leave one out procedure, one data is considered as the test data and the remaining data are used for the training set at each trial. This is repeated until all data are evaluated as a test data for one time. By averaging the all results, we obtain an estimate of the evaluation performance. Therefore, the obtained result is fair and not dependent to the data division approach since the test and training data have no correlation in each step and all data participate in testing phase for one time. The schematic of how data is divided in leave one out method can be shown in Fig. 1.

Fig. 1
figure 1

The schematic of data division in Leave one out cross validation methodology in SVM classification

2.4 SVM classification

SVMs are broadly applied in classification issues. Assume that a binary classifier is used to categorize the following data:

$$\begin{aligned} \theta = \left\{ {\left( {x_{1} ,y_{1} } \right),\left( {x_{2} ,y_{2} } \right), \ldots ,\left( {x_{l} ,y_{l} } \right)} \right\} \hfill \\ y_{i} = 1 or - 1 \hfill \\ \end{aligned}$$
(7)

where \(x_{i}\) are sample data containing features and \(y_{i}\) are the corresponding class labels. The linear model of the separator function is given by:

$$f(x) = \mathop \sum \limits_{i = 1}^{l} \omega_{i} x_{i} + b$$
(8)

where \(w_{i}\) is the weight vector and b is constant. These parameters should be calculated in such a way that the margin between the hyperplane and nearest data becomes maximum. The resultant optimization problem can be described as follows:

$$\begin{aligned} \min_{\omega ,\zeta } \frac{1}{2}\left( {\omega^{T} \omega } \right) + C\mathop \sum \limits_{i = 1}^{l} \zeta_{i} \hfill \\ subject to \left\{ {\begin{array}{*{20}c} {y_{i} \left( {\left( {\omega^{T} x_{i} } \right) + b} \right) \ge 1 - \zeta_{i} } \\ {\zeta_{i} \ge 0 for i = 1 \ldots l} \\ \end{array} } \right. \hfill \\ \end{aligned}$$
(9)

\({\text{C}}\) is a positive constant which makes a balance between tolerance of deviations and flatness of the function. For example, larger C results overfitting to the training data and less generalization. \(\zeta_{i}\) for \(i = 1,2, \ldots ,l\) are slack variables which allows a slight error for each data. The equivalent dual problem can be introduced by using Karush–Kuhn–Tucker theorem as follows [43]:

$$\begin{aligned} {\text{minimize}} _{{\alpha_{i} }} G\left( \alpha \right) = - \mathop \sum \limits_{i = 1}^{l} \alpha_{i} + \frac{1}{2}\mathop \sum \limits_{i.j = 1}^{l} \omega_{i} \alpha_{i} \alpha_{j} y_{i} y_{j} K\left( {x_{i} .x_{j} } \right) \hfill \\ subject \,to \left\{ {\begin{array}{*{20}c} {0 \le \alpha_{i} \le C} \\ {\mathop \sum \limits_{i = 1}^{l} \alpha_{i} y_{i} = 0.} \\ \end{array} } \right. \hfill \\ \end{aligned}$$
(10)

where \(\alpha_{\text{i}}\) are Lagrangian multipliers and \(K\left( {x,y} \right) = \left( {\phi \left( x \right),\phi \left( y \right)} \right)\) is a kernel function. In advance classification problems, it is usually not practical to find a separable trajectory which can distinct the data especially when there exist overlapped features. In response to this situation, Support vector classification maps the feature space into a higher dimension space by using kernel function \(\left( {\phi :x \in {\text{R}}^{\text{n}} \to {\text{R}}^{\text{m}} } \right)\) and construct an optimal discriminant hyperplane in that space. Common choices for the kernel function are quadratic, polynomial, and Radial Basis Function (RBF). The parameters are set in the optimization process which is known as training phase. With all the above modifications, the decision hyperplane can be rewritten as follows:

$$f(x) = sign\left( {\mathop \sum \limits_{i = 1}^{l} \alpha_{i} y_{i} K\left( {x,x_{i} } \right) + b} \right)$$
(11)

Each test data is fed to this function. If the resultant value of the function is positive, the data is labeled + 1 and the data would be labeled − 1 if the output is negative.

2.5 Hierarchical SVM classification structure

A hierarchical classification structure tries to overcome the overlapped states using the divide-and-conquer strategy so that states with similar characteristics for specific features are combined into one state, which can be separated later at the succeeding steps with other features. This structure based on a sequence of SVM is designed to classify EEG data into different states during anesthesia. In the first step, we separate between awake and non-awake states (light, general and deep anesthetic). The SPE, DFA and Beta features extracted from EEG signal are used as input to SVM which classifies the input data into one of these two states. If the data is classified as the awake state, the procedure is finished. Otherwise, the data is classified as non-awake state and move on to the next stage. In the second stage, we separate the non-awake data into deep and non-deep state (light and general anesthetic). The SampEn feature is used as input to SVM which classifies the non-awake data into one of these two states. If the data is classified as the deep state, the procedure is finished. Otherwise, the data is classified as non-deep state and we pass on to the next stage. Finally, we separate non-deep data into light and general states. In this stage, the DFA, SPE, and Beta features are used as input to SVM which classifies the non-deep data into light or general anesthetic. The process chart of the hierarchical SVM classification structure which is composed of three stages is shown in Fig. 2.

Fig. 2
figure 2

The process chart of the hierarchical SVM classification structure

3 Results

Four features—Beta, SampEn, SPE, and DFA—are computed from each 10 s EEG segment. Figure 3 shows box plots related to the distribution of each of four features for the entire data. \(m = 6\) in SPE and \(k = {\text{mr}} = 0.15\) in SampEn are calculated according to sampling frequency of EEG signal, trial and error and other studies [19, 20]. Hierarchical SVM classification structure described in II.E is used to classify EEG data into different states during anesthesia in 17 patients. The first-stage classifier is responsible for determining the awake state, the second stage classifier is for the deep state and finally, third stage is for separation the light and general states. In all classification levels, RBF is selected as the kernel function of SVM. The sigma value \((\sigma )\) which describes the diversity of RBF is optimized to have the minimum average classification error in each stage by try and error. The optimal σ for RBF kernel are 0.31, 0.90 and 0,80 for first, second and third stage of classifier, respectively. Table 1 shows the confusion matrices obtained from the first, second and third stages of hierarchical SVM classification structure, separately. The confusion matrix shows the differences between the output of the proposed classifier and the real class label. The proposed structure separate between awake and non-awake data with 96.32% accuracy in the first stage, deep and non-deep with 98.48% accuracy and between general and light with 97.69% accuracy in the final stage. When we get the results of the first, second and third stages, the final classification result in detecting the four states is 94.11%. The accuracy obtained by the proposed method in every state of anesthesia is given in Table 2. As you see, the hierarchical classification structure can discriminate the four states of anesthesia effectively.

Fig. 3
figure 3

The box plot of SampEn \(\left( {k = 0.15} \right)\), SPE \(\left( {m = 6} \right)\), Beta index, DFA and RE index which describes the data distribution of each feature in the different states. Awake (I), light anesthetic (II), general anesthetic (III) and deep anesthetic (IV), respectively. The red line indicates the median value; the rectangle lower and upper edges represent 25 and 75 percentiles of the values distribution; the whiskers represent the bounds of 99.7% of the data; and the red “+” symbol represents the data outliers

Table 1 Confusion matrices obtained from the first, second and third stages of hierarchical SVM classification structure
Table 2 Comparison between proposed method, SVM and MLP and also comparison between proposed method with a commercial system (RE index) in term of accuracy (%)

For comparison with other methods, Table 2 shows the values of classification accuracy in every state of anesthesia using SVM classifier (RBF kernel) and MultiLayer Perceptron (MLP) using two hidden layers with three neurons when the four selected features are used as the inputs of the classifiers. The parameters of these two classifiers are optimized by the trial and error to obtain the best results. Clearly, it is demonstrated that, thanks to its multistage structure, the proposed hierarchical structure significantly improves the classification performance in all states. For the test data, the prosed system was quicker to calculate. In Matlab on a laptop computer (CPU:i7-3.5 GHz, RAM:16 GB), the average time spent for the proposed system was 0.0019 s. Finally, the results of the proposed system was compared to a commercial monitoring system (RE Index) on the same database. The box plot related to the distribution of RE values from each 10 s EEG segment for all patients is constructed in Fig. 3. Table 2 represents the value of classification accuracy based on the RE index. Clearly, it is demonstrated that our new system attains higher classification accuracy in all anesthetic states, as compared to the RE Index.

4 Discussion

In this study, we propose a new automated system to assess level of hypnosis from EEG signal, based on a set of discriminative features (DFA, SPE, SampEn, and Beta features) and a hierarchical classification structure based on a SVM. This system could classify the EEG data into awake, light, general and deep states during anesthesia in 17 patients and yields an overall accuracy of 94.11%.

When the characteristics of the data distribution of four features for the entire data are observed (Fig. 3), it is determined that all states cannot be identified fully by extracting any single feature because of overlapping brain states. The SPE feature has a unique ability to distinguish the awake state (I) from non-awake states and this capability is also partly available for the Beta and DFA features. After determining and removing the data from this state, SampEn feature was best at discriminating the deep anesthetic (IV) state from other states. Finally, after determining and removing the data from these two states, the SPE, DFA and Beta features are important features for discriminating the light (II), and general anesthetic (III) states. Consequently, it was observed that different feature sets represent different components for the four anesthetic states. For this reason, we decided to design a sequential hierarchical classification structure to obtain better performance in monitoring level of hypnosis. In this structure, at each level, different feature extraction methods are used to determine the specific state. If the state of data is determined in each level, the procedure is finished; otherwise, other feature extraction methods for another state are used. The speed of parameter learning, the small number of adjustable parameters, and the accuracy of classification in different states are the advantages of our structure compared to the other methods.

Describing the behavior of the EEG as a function of the depth of consciousness and properties of the signal processing algorithms assists to extract the relative features. In anesthetic-induced EEG; First, large waxing and waning ‘spindle-like’ waves appear whose frequencies are often related to the anesthesia drug concentration in the blood [3]. At low anesthetic concentrations, the frequency is in the beta spectral range (light anesthesia) and categorizes well with our Beta index, but with the increased drug concentration (general anesthesia), the frequency of signal slows down to about 8 Hz. This component can be distinguished more precisely using SPE features because it considers both overall signal variability characteristics, naturally related to spectral content and the signal’s complexity [41]. As anesthesia gets deeper, large amplitude delta and sub-delta waves may be seen [17, 18] which can be detected more accurately using DFA feature. Finally, the EEG signal changes into a burst suppression pattern (deep anesthesia) which is a pattern of high amplitude EEG signal, known as the bursts, separated by low amplitude activity normally under 10 µv peak-to-peak, named the suppressions. SampEn is robust in the description of this pattern [20, 21] because it provides naturally regular interpretation of the suppression in so far as the threshold is higher than data points during suppression. These amplitudes of the burst waves help us achieve such high level of threshold. These justifications support the selection of signal processing techniques in this research and rationalize why these kinds of properties of EEG signal can be evaluated properly by our methods.

The result of this paper was also compared to previous studies with the same database. In [20], MLP classifier and in [21] ANFIS classifier are used for assessing level of hypnosis which result in 88% and 92% accuracy, respectively. In the present study, thanks to the proposed hierarchical classification method, we have attained the higher classification accuracy (94.11%) which is proven to have better performance than other methods. However, because of the high variability in response to anesthetic drugs, this work needs to be validated in large patient data sets.

5 Conclusions

A hierarchical classification structure based on a SVM is able to estimate real time level of hypnosis (using EEG data) into awake, light, general and deep anesthetic states. The proposed system combines three classifiers with different features in a cascade manner in order to achieve good performance. SPE, DFA and Beta features are utilized to capture awake state in the first stage, SampEn feature to capture deep anesthetic state in the second stage and finally three mentioned features of first step to capture light and general states.