pyriemann.utils.kernel.kernel_riemann

pyriemann.utils.kernel.kernel_riemann(X, Y=None, *, Cref=None, reg=1e-10)

Affine-invariant Riemannian kernel between two sets of SPD matrices.

Calculates the affine-invariant Riemannian kernel matrix K of inner products of two sets X and Y of SPD matrices on tangent space of Cref by calculating pairwise [1]:

\[K_{i,j} = \text{tr}(\log(C_\text{ref}^{-1/2} X_i C_\text{ref}^{-1/2}) \log(C_\text{ref}^{-1/2} Y_j C_\text{ref}^{-1/2}) )\]
Parameters
Xndarray, shape (n_matrices_X, n_channels, n_channels)

First set of SPD matrices.

YNone | ndarray, shape (n_matrices_Y, n_channels, n_channels), default=None

Second set of SPD matrices. If None, Y is set to X.

CrefNone | ndarray, shape (n_channels, n_channels), default=None

Reference point for the tangent space and inner product calculation. If None, Cref is calculated as the Riemannian mean of X.

regfloat, default=1e-10

Regularization parameter to mitigate numerical errors in kernel matrix estimation.

Returns
Kndarray, shape (n_matrices_X, n_matrices_Y)

The affine-invariant Riemannian kernel matrix between X and Y.

See also

kernel

Notes

New in version 0.3.

References

1

Classification of covariance matrices using a Riemannian-based kernel for BCI applications A. Barachant, S. Bonnet, M. Congedo and C. Jutten. Neurocomputing, Elsevier, 2013, 112, pp.172-178.