# Adaptive Feature Extraction of Motor Imagery EEG with Optimal Wavelet Packets and SE-Isomap
## 3 Feature Extraction Method Based on WPD and SE-Isomap
### Selection of Optimal Wavelet Packets  
The frequency bands and associated powers of the MI-EEG signal, which is collected through the brain and the cortical region related to motion, may change with different imaginary actions and different subjects. The recognition of MI-EEG is primarily based on the ERS/ERD-related motion-sensing rhythm characteristics. Therefore, the wavelet packet transform is the best choice to decompose the MI-EEG signal \(\mathbf{x}_{i}\) that is pre-determined by power spectra analysis, and wavelet packet variance is used to select the subject-based frequency bands or subject-specific wavelet packets. Suppose that the corresponding WPD coefficients to wavelet packet \(s(j,n)\) for the sample \(\mathbf{x}_{i}\) are denoted as \(d_{l,j}^{n,i}(k)\), where \(l\) = 3 or 4; it is the label of channel C3 or C4; \(j\) is the number of decomposed levels; \(n\) is the number of wavelet packet subspaces in the \(j\)-th level; and \(k\) is the index of the coefficient sequence. According to the wavelet packet structure theory, if the wavelet basis function is orthogonal, the WPD will then comply with the energy conservation principle [21], that is the square sum of the WPD coefficients on each layer does not change when the number of decomposition layers changes. It can be formulated as:  
\[\sum_{n=0}^{2^{j}-1}\sum_{k=1}^{K}\left|d_{l,j}^{n,i}(k)\right|^{2}\equiv\parallel f ^{2}\parallel^{2} \tag{15}\]  
where \(K\) is the number of wavelet packet coefficients for subspace \(s(j,n)\) and \(\left|d_{l,j}^{n,i}(k)\right|^{2}\) and \(\parallel f\parallel^{2}\) represent the energy density and energy of the wavelet packet, respectively. The energy of \(n\)-th wavelet packet subspace is calculated as:  
\[E_{n}=\sum_{k=1}^{K}\left|d_{l,j}^{n,i}(k)\right|^{2} \tag{16}\]  
The variance of the \(n\)-th WPS is defined as:  
\[V_{n}^{2}=\sigma_{n}^{2}=\frac{1}{K}E_{n}^{2}=\frac{1}{K}\sum_{k=1}^{K}\left| d_{l,j}^{n,i}(k)\right|^{2} \tag{17}\]  
Then, the variance of different wavelet packets at a specific level is obtained.  
After \(j\)-level WPD of the MI-EEG signal \(\mathbf{x}_{i}\), the WPD coefficients \(d_{l,j}^{n,i}\) are divided into \(2^{j}\) subspaces \(s(j,0)\)\(\sim\)\(s(j,2^{j}-1)\).  
Then, according to Equation (17), the variance of the wavelet packet coefficients for each subspace under the specific layer \(j\) is calculated, and the wavelet packet variance of each subspace on this level is computed and added. The mean variance is obtained as follows:  
\[\overline{V_{n}^{2}}=\frac{1}{N}\sum_{i=1}^{N}\sum_{k=1}^{K}\left|d_{l,j}^{n,i }(k)\right|^{2} \tag{18}\]  
where \(\overline{V_{n}^{2}}\) denotes the mean value of wavelet packet variance for all samples, \(N\) represents the number of samples and \(K\) is the dimension of wavelet packet coefficients.  
For each motor imagery task, the \(j\)-level WPD of MI-EEG \(x_{i}\) (\(i\) = 1, 2, \(\ldots\), \(N\)) on channels C3 and C4 is first completed. After that, the mean wavelet packet variances corresponding to channels C3 and C4 are calculated, respectively, for each wavelet packet \(s(j,n)\) (\(n=0,1,\ldots,2^{j}-1\)), and the difference between the mean wavelet packet variances is computed and sorted in the descending order. The partial wavelet packets referring to the top \(m\) mean variance difference are thought of as the OWP; this means they will have the most significant distinction for each motor imagery task. All of the OWP coefficients are constructed as a vector and denoted as:  
\[\mathbf{W}_{f}^{i}=\left[a_{3j}^{n,i}(1),\ldots,d_{3,j}^{n,i}(K),\ldots,d_{3,j}^{ n_{m^{i}}}(1),\ldots,d_{3,j}^{n_{m^{i}}}(K),d_{4,j}^{n_{1},i}(1),\ldots,d_{4,j}^{ n_{1},i}(K),\ldots,d_{4,j}^{n_{m^{i}}}(1),\ldots,d_{4,j}^{n_{m^{i}}}(K) \right]^{T}\in R^{1\times(m\times K\times 2)},\]  
where \(n_{1},\ n_{2},\ldots,n_{m}\) are the indexes of the selected OWP subspaces.