pyriemann.utils.mean.mean_riemann

pyriemann.utils.mean.mean_riemann(covmats, tol=1e-08, maxiter=50, init=None, sample_weight=None)

Mean of SPD matrices according to the Riemannian metric.

The affine-invariant Riemannian mean minimizes the sum of squared affine-invariant Riemannian distances \(d_R\) to all matrices [1]:

\[\arg \min_{\mathbf{C}} \sum_i w_i d_R (\mathbf{C}, \mathbf{C}_i)^2\]
Parameters
covmatsndarray, shape (n_matrices, n_channels, n_channels)

Set of SPD matrices.

tolfloat, default=10e-9

The tolerance to stop the gradient descent.

maxiterint, default=50

The maximum number of iterations.

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

A SPD matrix used to initialize the gradient descent. If None, the weighted Euclidean mean is used.

sample_weightNone | ndarray, shape (n_matrices,), default=None

Weights for each matrix. If None, it uses equal weights.

Returns
Cndarray, shape (n_channels, n_channels)

Affine-invariant Riemannian mean.

References

1

A differential geometric approach to the geometric mean of symmetric positive-definite matrices M. Moakher, SIAM Journal on Matrix Analysis and Applications. Volume 26, Issue 3, 2005