# Multiple Kernel Stein Spatial Patterns for the Multiclass Discrimination of Motor Imagery Tasks
## 2 Methods
### Time-Series Similarity through the Stein Kernel for PSD Matrices  
Since each trial in the component space is band-pass filtered, the expected value of \(\mathbf{z}_{nb}(t)\) becomes zero. Hence, the band-wise covariance is computed as  
\[\mathbf{S}_{nb}{=} \mathbf{z}_{nb}(t)\mathbf{z}_{nb}(t)^{\top} \tag{3}\] \[\mathbf{S}_{nb}{=} \mathbf{W}_{b}^{\top}\mathbf{x}_{nb}(t)\mathbf{x}_{nb}(t)^{\top}\mathbf{W}_{b} \tag{4}\]  
with \(\mathbf{S}_{nb}\in\mathbb{R}^{Q\times Q}\). The set of covariance matrices from the dataset \(\mathcal{X}\) holds the linear relationships between component pairs:  
\[\mathcal{S}{=}\Big{\{}\mathbf{S}_{nb}=\mathbf{W}_{b}^{\top}\mathbf{\Sigma}_{nb}\mathbf{W}_{b}:b \in[1,B]\Big{\}}_{n=1}^{N} \tag{5}\]being \(\mathbf{\Sigma}_{nb}=\mathbf{x}_{nb}(t)\mathbf{x}_{nb}(t)^{\top}\in\mathbb{R}^{C\times C}\) the trial covariance for the \(b\)-th band in the input channel space. Given that each matrix in the set \(\mathcal{S}\) satisfies that \(\langle\ \mathbf{A},\mathbf{S}_{nb}\mathbf{A}\rangle\leq 0\) for any \(\mathbf{A}\
eq\mathbf{0}\), then \(\mathbf{S}_{nb}\in\mathcal{S}\) is positive semidefinite (PSD). As a set of PSD matrices, \(\mathcal{S}\) belongs to the Riemannian manifold \(\mathbb{P}_{Q}\), which is differentiable and a canonical higher-rank symmetric space within the real symmetric matrix space \(\mathbb{S}_{Q}\)[21]. Therefore, there exists a PSD matrix representing each time-series in a Hilbert space of matrices endowed with a metric allowing to compare two trials. For such a manifold, the Jensen-Bregman divergence \(\delta_{F}(\mathbf{S}_{nb},\mathbf{S}_{mb})\in\mathbb{R}^{+}\) measures the dissimilarity between two matrix elements \(\mathbf{S}_{nb}\) and \(\mathbf{S}_{mb}\) as:  
\[\delta(\mathbf{S}_{nb},\mathbf{S}_{mb}) =\frac{B_{F}(\mathbf{S}_{nb},\mathbf{\bar{S}}_{b})+B_{F}(\mathbf{\bar{S}}_{b},\mathbf{S}_{mb})}{2} \tag{6}\] \[B_{F}(\mathbf{S}_{nb},\mathbf{S}_{mb}) =F(\mathbf{S}_{nb})-F(\mathbf{S}_{mb})-\langle\mathbf{S}_{nb}-\mathbf{S}_{mb}, \
abla F(\mathbf{S}_{mb})\rangle_{F}\] (7) \[\bar{S}_{b} =\frac{\mathbf{S}_{nb}+\mathbf{S}_{mb}}{2} \tag{8}\]  
where \(\
abla F\) denotes the gradient of the strictly convex and differentiable function \(F(\cdot)\), \(\langle\mathbf{A},\mathbf{B}\rangle_{F}=\text{tr}\left(\mathbf{A}^{\top}B\right)\) the Frobenius inner product in the PSD matrix space, and \(\text{tr}\left(\cdot\right)\) the trace operator. Equation (7) defines the Bregman divergence as the positive tail of the first-order Taylor expansion of \(F(\cdot)\). Then, Equation (6) corresponds to the symmetrized version of \(B_{F}\) and holds the properties of a distance function in \(\mathbb{P}_{Q}\)[22]. In particular, using as the convex function \(F(\mathbf{S}_{nb})=-\log|\mathbf{S}_{nb}|\) yields the Jensen-Bregman LogDet divergence defined in Equation (9), with \(|\cdot|\) as the determinant operator. \[D(\mathbf{S}_{nb},\mathbf{S}_{mb})=\log\left|\frac{\mathbf{S}_{nb}+\mathbf{S}_{ mb}}{2}\right|-\frac{\log|\mathbf{S}_{nb}\mathbf{S}_{mb}|}{2} \tag{9}\]  
Moreover, Equation (9) is invariant to affine transformations, that is, the LogDet divergence at the component space is the same in the channel space if the number of components equals the number of channels (\(Q=C\)).