# A Sparse Multiclass Motor Imagery EEG Classification Using 1D-ConvResNet
## 2 Materials and Methods
### Sparse Representation  
A sparse signal is a linear combination of a few coefficients selected from a prearranged overcomplete dictionary. The dictionary is constructed with the feature vector obtained from the wavelet features in D. According to CS theory, we can represent sparse signals using some basis. For a dictionary \(D\in\mathbb{R}^{m\times n}\) and test data \(y_{i}\in\mathbb{R}^{m}\) of class \(\text{C}_{i}\) (see Figure 5), we aimed to find the sparse feature (coefficient) vector \(\alpha_{i}\in\mathbb{R}^{n}\) such that  
\[y_{i}=D\alpha_{i} \tag{2}\]  
which can be represented as  
\[y_{i}=\alpha_{i,1}d_{i,1}+\alpha_{i,2}d_{i,2}+\cdots+\alpha_{i,n_{i}}d_{i,n_{i}} \tag{3}\]  
where sparse coefficient vector is defined by \(\alpha=\left[0,0,0,\ldots,\alpha_{i,1},\alpha_{i,2},\ldots,\alpha_{i,n_{i}},0,0,\ldots,0\right]\), representing the nonzero coefficients for the ith class; thus, the corresponding EEG feature class can be determined. The given test feature vector is a linear superposition of the training sample feature vectors.  
The sparsest solution of \(y_{i}=D\alpha_{i}\) can be obtained by minimizing the l0-norm given by Equation (4) as follows:  
\[\underset{\alpha_{i}}{min}\|\alpha_{i}\|_{0}\text{ {subject to }}y_{i}=D\alpha_{i} \tag{4}\]  
where \(\|.\|_{0}\) calculates the nonzero coefficients in \(\alpha_{i}\). The sparsest solution for the above equation is both NP-hard and numerically unstable because it requires all the possible combinations for the nonzero element positions in \(\alpha_{i}\), which is a large number. The literature provides many algorithms divided into convex relaxation methods and greedy approximation methods to solve the above equation. The convex relaxation methods include linear programming (LP), least absolute and shrinkage operator (LASSO), and iterative shrinkage and thresholding (ISTA); these methods relax \(l_{0}\)-minimization to \(l_{1}\)-minimization. Greedy approximation algorithms, such as orthogonal matching pursuit (OMP), give an  
Figure 5: Sparse representation of the signal in compressive sensing.  
approximate optimal solution instead of solving the \(l_{0}\)-minimization problem. In this paper, we performed the \(l_{1}\)-minimization given in Equation (5):  
\[\hat{\alpha}=\text{arg}mit\|\alpha_{i}\|_{0}\;subject\;to\;D\alpha_{i}=y_{i}, \tag{5}\]  
In an ideal situation, Equation (5) should have nonzero elements corresponding to \(y_{i}\). By analyzing nonzero coefficients in \(\hat{\alpha}\), the ith class can be determined. While considering the limitations in modeling and noise, \(\hat{\alpha}\) is not precisely zero, but it is close. Equation (6) was used to overcome this issue.  
\[r_{1}(y)=\|y-D\delta_{i}(\alpha)\|_{2} \tag{6}\]  
We classified the test sample (sparse coefficients) using the above equation according to the residual approximations. The residual approximation must be sufficiently small to ensure that the test sample is close to the given class. By nullifying all the other coefficients corresponding to the other classes, \(i,\;\delta_{i}(\alpha)\) is obtained, and we can classify class (i) by assessing the residuals as expressed in Equation (7).  
\[class\;(y)\;=\text{arg}mitr_{i}(y) \tag{7}\]