**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 *H* is defined as:

$$H = -\sum\_{i=1}^{N} P\_i \log\_2 P\_i \tag{1}$$

in which *Pi* is the average probability at *i* th frequency band of brain rhythm that is grater that *r*times of standard deviation and *N* is the total number of frequency bands. *H* is 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 *m* and *m* þ 1 increases. *m* and *r* are critical in finding the outcome of approximate entropy. The approximate entropy is estimated with *m* ¼ 3 and *r* ¼ 0*:*25 based 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 *k* new time series are constructed from the signal under study as [7]:

$$\boldsymbol{\alpha}\_{m}^{k} = \left\{ \boldsymbol{\pi}(m), \boldsymbol{\pi}(m+k), \boldsymbol{\pi}(m+2k), \dots, \boldsymbol{\pi}\left(m+\lfloor \frac{N-m}{k} \rfloor k\right) \right\} \tag{2}$$

in which *m* ¼ 1, 2, … , *k* and *k* indicate the initial time value, and the discrete time interval between points, respectively. For each of the *k* time series *xk <sup>m</sup>* the length *Lm*ð Þ*k* is calculated as:

$$L\_m(k) = \frac{\sum\_{i=1}^{\sum\_{i=1}^{\infty} |\mathbf{x}(m+ik) - \mathbf{x}(m+(i-1)k)|(N-1)}}{|\frac{N-m}{k}|k} \tag{3}$$

in which *N* is the total length of the signal *x*. An average length is computed as the mean of the *k* lengths *Lm*ð Þ*k* (for*m* ¼ 1, 2, … , *k* ). This procedure is repeated for each *k* ranging from 1 to *kmax* , obtaining an average length for each *k*. In the curve of*ln L k* ð Þ ð Þ versus*ln* <sup>1</sup> *k* � � , 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 *t* that corresponds to the distances of the points in the *i* th direction are k k *δXi*ð Þ 0 and k k *δXi*ð Þ*t* , respectively. The Lyapunov exponent is defined as the average growth rate *λ<sup>i</sup>* of the initial distance [9]:

$$\frac{||\delta \mathbf{X}\_i(t)||}{||\delta \mathbf{X}\_i(\mathbf{0})||} = \mathbf{2}^{\lambda\_i}(\mathbf{t} \to \infty) \tag{4}$$

or

$$\lambda\_i = \lim\_{t \to \infty} \frac{1}{t} \log\_2 \frac{||\delta \mathbf{X}\_i(t)||}{||\delta \mathbf{X}\_i(\mathbf{0})||} \tag{5}$$

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.
