# Adaptive Feature Extraction of Motor Imagery EEG with Optimal Wavelet Packets and SE-Isomap
## 2 Primary Theory
### SE-Isomap Algorithm  
As an extension of original isomap algorithm, SE-isomap [17] is able to effectively exploit the label information of the training samples to aggregate the samples belonging to the same class and disperse others properly; therefore, the separability of the samples is enhanced and the explicit mapping of the samples from the high-dimensional space to the target space is obtained, which significantly shortens the time of the feature extraction procedure. The basic principle is as follows:  
Suppose that the dataset \(\mathbf{X}\) contains two types of samples \(C_{b}(b=1,2)\), namely \(\mathbf{X}=C_{1}\cup C_{2},\ C_{b}=\left\{x_{i}^{b},x_{b}^{b}\in R^{D},\ i=1,2, \ldots,N_{b}\right\}\), where \(N_{b}\) represents the number of samples in the \(C_{b}\) class dataset, and \(D\) denotes the dimension of the observation space where the dataset is located. Assuming that the intrinsic dimension of the manifold embedded in the dataset is \(d\ (d\ll D)\), the SE-isomap algorithm usually consists of three steps:  
1. Constructing the intra-class distance matrix: Calculate the \(k\)-nearest neighbors for each sample \(\mathbf{x}_{i}(i=1,2,\ldots,N_{b})\) in class \(C_{b}(b=1,2)\) to get \(x_{i}^{1},x_{i}^{2},\ldots,x_{i}^{k}\) and regard as \(\mathbf{N}(\mathbf{x}_{i})\). Then, the neighborhood graph \(G_{b}(V,E)\) is constructed with the sample \(x_{i}\) as the vertex and the Euclidean distance \(d\big{(}\mathbf{x}_{i},\mathbf{x}_{j}\big{)}\) between the sample as the edge. The shortest path distance in the neighbor graph \(G_{b}(V,E)\) between the two vertexes will be regarded as an approximation of the geodesic distance between two corresponding samples. For convenience of expression, the geodesic distance \(g\big{(}\mathbf{x}_{i},\mathbf{x}_{j}\big{)}\) is simplified to \(g_{ij}\), then the geodesic distance between \(\mathbf{x}_{i}\) and \(\mathbf{x}_{j}\) is as follows: \[g_{ij}=\ g\big{(}\mathbf{x}_{i},\mathbf{x}_{j}\big{)}=\left\{ \begin{array}{c}g_{ij} \ \forall\mathbf{x}_{i}\in N\big{(}\mathbf{x}_{j}\big{)}\ \text{or}\ x_{j}\in N(\mathbf{x}_{i})\\ \min_{k}\left\{g_{ij},g_{ik}+g_{kj}\right\}\ \text{elsewise}\end{array} \right.\] (3) Then, the intra-class geodesic distance matrix \(\mathbf{G}_{bb}=\big{(}g_{ij}\big{)}_{N_{b}\times N_{b}}\) is constructed according to the approximate geodesic distance between two arbitrary points. 2. Constructing the global discriminative distance matrix: Calculate the inter-class geodetic distance \(g^{*}\big{(}\mathbf{x}_{i},\mathbf{x}_{j}\big{)}\) between any two samples when \(\mathbf{x}_{i}\in C_{1}\) and \(\mathbf{x}_{j}\in C_{2}\), and the computational equation is as follows: \[g^{*}\big{(}\mathbf{x}_{i},\mathbf{x}_{j}\big{)}=g(\mathbf{x}_{i},\mathbf{x}_{i^{*}})+d(C_{1 },C_{2})+\ g\big{(}\mathbf{x}_{i^{*}},\mathbf{x}_{j}\big{)}\] (4) where the sample pairs \(\big{(}\mathbf{x}_{i^{*}},\mathbf{x}_{jThe inter-class distance parameter \(\sigma\) is used to balance the fidelity of visualization and the separability of data. Then, the inter-class distance matrix can be denoted as \(\mathbf{G}_{12}=\left(g_{ij}^{*}\right)_{N_{1}\times N_{2}}\). Finally, the global geodesic distance matrix \(\mathbf{G}\) representing the distance between any individual sample points is constructed as: \[\mathbf{G}=\left( \begin{array}{c}\rho_{1}\mathbf{G}_{11}\ \mathbf{G}_{12}\\ \mathbf{G}_{21}\rho_{2}\mathbf{G}_{22}\end{array} \right)\] (7) where \(\mathbf{G}_{11}\) and \(\mathbf{G}_{22}\) are the intra-class geodesic distance matrices of class \(\mathbf{C}_{1}\) and class \(\mathbf{C}_{2}\), respectively, \(\mathbf{G}_{12}\) and \(\mathbf{G}_{21}\) are the inter-class geodesic distance matrices of the samples belong to different classes and \(\mathbf{G}_{12}=\mathbf{G}_{21}^{\mathrm{T}}\) and parameters \(0<\rho_{1}\) and \(\rho_{2}<1\) are used to reduce the intra-class distance properly for the reason that the gather effect will be reinforced. 3.