# VLSI Implementation of an Efficient Lossless EEG Compression Design for Wireless Body Area Network
## 3 Methodology
### Second-Stage Prediction  
The second-stage prediction involves a fuzzy decision component [20]. This step organizes the results of the first-stage prediction according to the two slope values _diff_1_ and _diff_2_ as shown in Figure 1. The values of _diff_1_ and _diff_2_ are equivalent to the absolute differences of \(X(n-1)\) and \(X(n-1)\), and \(X(n-1)\) and \(X(n-2)\), respectively.  
\begin{table}
\begin{tabular}{c c} \hline \hline
**Prediction Function** & **Compression Rate** \\ \hline Linear [6] & 1.90 \\ Slope [18] & 2.38 \\ Adaptive Trending [20] & 2.56 \\ \hline \hline \end{tabular}
\end{table}
Table 1: Compression rate on ECG signals of previously-proposed prediction functions.  
Fuzzy Decision Rules  
Figure 2 illustrates the fuzzy decision rule of the proposed EEG prediction methodology with threshold values of low, medium and high. The first-stage prediction outcomes are matched and picked by one of the six modules M1-M6 in the voting prediction stage. Given the compression rate of the different prediction functions in Table 1, the adaptive trending method shows higher performance than the linear and slope functions for ECG signal. Hence, the use of the fuzzy decision rule is selected as the base prediction scheme for the proposed prediction methodology for EEG signals.  
Figure 1: Slope prediction using _diff_1_ and _diff_2_.  
Figure 2: Fuzzy decision rules of the proposed prediction methodology for EEG signal.  
The dynamic voting scheme component is developed to dynamically choose the optimal function during signal trend fluctuations. For every prediction session, one of the six modules will be activated to receive the data coming from the fuzzy decision module. Each of the modules contain five second-stage prediction functions, as shown in Figure 2. The following lists the constant and/or preset values: \(e_{ij}\) is a constant where \(1\leq i\leq 6\) and \(1\leq j\leq 6\). Each fuzzy module contains 5 prediction equations, where each prediction equation has its own \(e_{ij}\) value. \(e_{ij}\) denotes the jth e value of the ith fuzzy module. A preset coefficient \(e_{ij}\) value was used that is from the distribution of the difference value between the sampling points in the EEG dataset. The parameter \(S\) is determined by getting the absolute value of _diff_2_ over _diff_2_. The number of votes for each function is monitored using five registers. The number of votes for each function is equal to the number of times that that particular function has the closest prediction among the five prediction functions. The function with the most number of votes will be executed with its resulting value stored in register \(PD_{2}\) of the said voting prediction stage. The same procedure is performed for all the other four functions.  
Figure 3 shows the dynamic voting procedure. \(PD_{1}\) is the subtractor output with inputs \(X(n)\) and \(X(n-1)\). The upper flow shows that given \(PD_{1}\), the optimal function is selected according to the highest number of votes where its value is to be stored in \(PD_{2}\). The lower flow of data acquires the current result of the prediction module. The current prediction result will be used as a vote to change the numbers of the corresponding function and contribute to the next prediction session. Register \(PD_{2}\) stores the resulting value of the function with the highest number of votes.  
Figure 4 shows a sample prediction session. Figure 4a shows the result of each function together with the number of votes for each corresponding function. As can be seen, function 2 has the largest number of votes. Hence, the value stored in \(PD_{2}\) register is chosen as the output of function 2. However, in this session, function 1 has a resulting function value that is closest to \(-1\). As such, the optimal function is function 1 rather than function 2. As such, the dynamic voting predictor will cast a vote to function 1 as shown in Figure 4b.  
Figure 3: Dynamic voting process.