pyriemann.utils.median_riemann

pyriemann.utils.median_riemann(X, *, tol=1e-05, maxiter=50, init=None, weights=None, step_size=1)

Affine-invariant Riemannian geometric median of SPD matrices.

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

\[\arg \min_{\mathbf{M}} \sum_i w_i d_R (\mathbf{M}, \mathbf{X}_i)\]
Parameters
Xndarray, shape (n_matrices, n_channels, n_channels)

Set of SPD matrices.

tolfloat, default=10e-6

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.

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

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

step_sizefloat, default=1.0

The step size of the gradient descent, in (0,2].

Returns
Mndarray, shape (n_channels, n_channels)

Affine-invariant Riemannian geometric median.

Notes

New in version 0.3.1.

References

1

The geometric median on Riemannian manifolds with application to robust atlas estimation PT. Fletcher, S. Venkatasubramanian S and S. Joshi. NeuroImage, 2009, 45(1), S143-S152

2

Riemannian median, geometry of covariance matrices and radar target detection L Yang, M Arnaudon and F Barbaresco. 7th European Radar Conference, 2010, pp. 415-418