API reference

SPD Matrices Estimation


Estimation of covariance matrices.

ERPCovariances([classes, estimator, svd])

Estimate special form covariance matrices for ERP.

XdawnCovariances([nfilter, applyfilters, ...])

Estimate special form covariance matrices for ERP combined with Xdawn.

BlockCovariances(block_size[, estimator])

Estimation of block covariance matrices.

CrossSpectra([window, overlap, fmin, fmax, fs])

Estimation of cross-spectral matrices.

CoSpectra([window, overlap, fmin, fmax, fs])

Estimation of co-spectral matrices.

Coherences([window, overlap, fmin, fmax, ...])

Estimation of squared coherence matrices.

TimeDelayCovariances([delays, estimator])

Estimation of covariance matrices with time delay matrices.

Kernels([metric, n_jobs])

Estimation of kernel matrices between channels of time series.


Regularization of SPD matrices by shrinkage.


locally_linear_embedding(X, *[, ...])

Perform a Locally Linear Embedding (LLE) of SPD matrices.

barycenter_weights(X, Y, indices[, metric, ...])

Compute Riemannian barycenter weights of X from Y along the first axis.

SpectralEmbedding([n_components, metric, eps])

Spectral embedding of SPD matrices into an Euclidean space.

LocallyLinearEmbedding([n_components, ...])

Locally Linear Embedding (LLE) of SPD matrices.


MDM([metric, n_jobs])

Classification by Minimum Distance to Mean.

FgMDM([metric, tsupdate, n_jobs])

Classification by Minimum Distance to Mean with geodesic filtering.

TSclassifier([metric, tsupdate, clf])

Classification in the tangent space.

KNearestNeighbor([n_neighbors, metric, n_jobs])

Classification by k-nearest neighbors.

SVC(*[, metric, kernel_fct, Cref, C, ...])

Classification by support-vector machine.

MeanField([power_list, method_label, ...])

Classification by Minimum Distance to Mean Field.

class_distinctiveness(X, y[, exponent, ...])

Measure class distinctiveness between classes of SPD matrices.


KNearestNeighborRegressor([n_neighbors, metric])

Regression by k-nearest-neighbors.

SVR(*[, metric, kernel_fct, Cref, tol, C, ...])

Regression by support-vector machine.


Kmeans([n_clusters, max_iter, metric, ...])

Clustering by k-means with SPD matrices as inputs.


Clustering by k-means for each class with SPD matrices as inputs.

Potato([metric, threshold, n_iter_max, ...])

Artefact detection with the Riemannian Potato.

PotatoField([n_potatoes, p_threshold, ...])

Artefact detection with the Riemannian Potato Field.

Tangent Space

TangentSpace([metric, tsupdate])

Tangent space project TransformerMixin.

FGDA([metric, tsupdate])

Fisher Geodesic Discriminant analysis.

Spatial Filtering

Xdawn([nfilter, classes, estimator, ...])

Xdawn algorithm.

CSP([nfilter, metric, log])

CSP spatial filtering with covariance matrices as inputs.

SPoC([nfilter, metric, log])

SPoC spatial filtering with covariance matrices as inputs.

BilinearFilter(filters[, log])

Bilinear spatial filter.

AJDC([window, overlap, fmin, fmax, fs, ...])

AJDC algorithm.


Whitening([metric, dim_red, verbose])

Whitening, and optional unsupervised dimension reduction.

Channel selection

ElectrodeSelection([nelec, metric, n_jobs])

Channel selection based on a Riemannian geometry criterion.


Finds and removes flat channels.

Transfer Learning

encode_domains(X, y, domain)

Encode the domains of the matrices in the labels.

decode_domains(X_enc, y_enc)

Decode the domains of the matrices in the labels.

TLSplitter(target_domain, cv)

Class for handling the cross-validation splits of multi-domain data.

TLEstimator(target_domain, estimator[, ...])

Transfer learning wrapper for estimators.

TLClassifier(target_domain, estimator[, ...])

Transfer learning wrapper for classifiers.

TLRegressor(target_domain, estimator[, ...])

Transfer learning wrapper for regressors.


No transformation on data for transfer learning.

TLCenter(target_domain[, metric])

Recenter data for transfer learning.

TLStretch(target_domain[, final_dispersion, ...])

Stretch data for transfer learning.

TLRotate(target_domain[, weights, metric, ...])

Rotate data for transfer learning.

MDWM(domain_tradeoff, target_domain[, ...])

Classification by Minimum Distance to Weighted Mean.


PermutationDistance([n_perms, metric, mode, ...])

Permutation test based on distance.

PermutationModel([n_perms, model, cv, ...])

Permutation test using any scikit-learn model for scoring.


make_gaussian_blobs([n_matrices, n_dim, ...])

Generate SPD dataset with two classes sampled from Riemannian Gaussian.

make_outliers(n_matrices, mean, sigma[, ...])

Generate a set of outlier points.

make_matrices(n_matrices, n_dim, kind[, rs, ...])

Generate a set of matrices, with specific properties.

make_masks(n_masks, n_dim0, n_dim1_min[, rs])

Generate a set of masks, defined as semi-orthogonal matrices.

sample_gaussian_spd(n_matrices, mean, sigma)

Sample a Riemannian Gaussian distribution.

generate_random_spd_matrix(n_dim[, ...])

Generate a random SPD matrix.

make_classification_transfer(n_matrices[, ...])

Generate source and target toy datasets for transfer learning examples.

Utils function

Utils functions are low level functions that implement most base components of Riemannian geometry.

Covariance processing

covariances(X[, estimator])

Estimation of covariance matrices.

covariance_mest(X, m_estimator, *[, init, ...])

Robust M-estimators.


Schaefer-Strimmer shrunk covariance estimator.

covariance_scm(X, *[, assume_centered])

Sample covariance estimator.

covariances_EP(X, P[, estimator])

Special form covariance matrix, concatenating a prototype P.

covariances_X(X[, estimator, alpha])

Special form covariance matrix, embedding input X.

block_covariances(X, blocks[, estimator])

Compute block diagonal covariance.

cross_spectrum(X[, window, overlap, fmin, ...])

Compute the complex cross-spectral matrices of a real signal X.

cospectrum(X[, window, overlap, fmin, fmax, fs])

Compute co-spectral matrices, the real part of cross-spectra.

coherence(X[, window, overlap, fmin, fmax, ...])

Compute squared coherence.

normalize(X, norm)

Normalize a set of square matrices, using corr, trace or determinant.


Compute non-diagonality weights of a set of square matrices.


distance(A, B[, metric, squared])

Distance between matrices according to a metric.

distance_euclid(A, B[, squared])

Euclidean distance between matrices.

distance_harmonic(A, B[, squared])

Harmonic distance between invertible matrices.

distance_kullback(A, B[, squared])

Kullback-Leibler divergence between SPD/HPD matrices.

distance_kullback_sym(A, B[, squared])

Symmetrized Kullback-Leibler divergence between SPD/HPD matrices.

distance_logdet(A, B[, squared])

Log-det distance between SPD/HPD matrices.

distance_logeuclid(A, B[, squared])

Log-Euclidean distance between SPD/HPD matrices.

distance_riemann(A, B[, squared])

Affine-invariant Riemannian distance between SPD/HPD matrices.

distance_wasserstein(A, B[, squared])

Wasserstein distance between SPSD/HPSD matrices.

pairwise_distance(X[, Y, metric, squared])

Pairwise distance matrix.

distance_mahalanobis(X, cov[, mean, squared])

Mahalanobis distance between vectors and a Gaussian distribution.


mean_covariance([X, metric, sample_weight, ...])

Mean of matrices according to a metric.

mean_ale([X, tol, maxiter, sample_weight, ...])

AJD-based log-Euclidean (ALE) mean of SPD matrices.

mean_alm([X, tol, maxiter, sample_weight, ...])

Ando-Li-Mathias (ALM) mean of SPD/HPD matrices.

mean_euclid([X, sample_weight, covmats])

Mean of matrices according to the Euclidean metric.

mean_harmonic([X, sample_weight, covmats])

Harmonic mean of invertible matrices.

mean_identity([X, sample_weight, covmats])

Identity matrix corresponding to the matrices dimension.

mean_kullback_sym([X, sample_weight, covmats])

Mean of SPD/HPD matrices according to Kullback-Leibler divergence.

mean_logdet([X, tol, maxiter, init, ...])

Mean of SPD/HPD matrices according to the log-det metric.

mean_logeuclid([X, sample_weight, covmats])

Mean of SPD/HPD matrices according to the log-Euclidean metric.

mean_power([X, p, sample_weight, zeta, ...])

Power mean of SPD/HPD matrices.

mean_riemann([X, tol, maxiter, init, ...])

Mean of SPD/HPD matrices according to the Riemannian metric.

mean_wasserstein([X, tol, maxiter, init, ...])

Mean of SPD/HPD matrices according to the Wasserstein metric.

maskedmean_riemann([X, masks, tol, maxiter, ...])

Masked Riemannian mean of SPD/HPD matrices.

nanmean_riemann([X, tol, maxiter, init, ...])

Riemannian NaN-mean of SPD/HPD matrices.


median_euclid(X, *[, tol, maxiter, init, ...])

Euclidean geometric median of matrices.

median_riemann(X, *[, tol, maxiter, init, ...])

Affine-invariant Riemannian geometric median of SPD/HPD matrices.


geodesic(A, B, alpha[, metric])

Geodesic between matrices according to a metric.

geodesic_euclid(A, B[, alpha])

Euclidean geodesic between matrices.

geodesic_logeuclid(A, B[, alpha])

Log-Euclidean geodesic between SPD/HPD matrices.

geodesic_riemann(A, B[, alpha])

Affine-invariant Riemannian geodesic between SPD/HPD matrices.


kernel(X[, Y, Cref, metric, reg])

Kernel matrix between matrices according to a specified metric.

kernel_euclid(X[, Y, reg])

Euclidean kernel between two sets of matrices.

kernel_logeuclid(X[, Y, reg])

Log-Euclidean kernel between two sets of SPD matrices.

kernel_riemann(X[, Y, Cref, reg])

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

Tangent Space

exp_map_euclid(X, Cref)

Project matrices back to manifold by Euclidean exponential map.

exp_map_logeuclid(X, Cref)

Project matrices back to manifold by Log-Euclidean exponential map.

exp_map_riemann(X, Cref[, Cm12])

Project matrices back to manifold by Riemannian exponential map.

log_map_euclid(X, Cref)

Project matrices in tangent space by Euclidean logarithmic map.

log_map_logeuclid(X, Cref)

Project matrices in tangent space by Log-Euclidean logarithmic map.

log_map_riemann(X, Cref[, C12])

Project matrices in tangent space by Riemannian logarithmic map.


Return the weighted upper triangular part of matrices.


Inverse upper function.

tangent_space(X, Cref, *[, metric])

Transform matrices into tangent vectors.

untangent_space(T, Cref, *[, metric])

Transform tangent vectors back to matrices.



Exponential of SPD/HPD matrices.


Inverse square root of SPD/HPD matrices.


Logarithm of SPD/HPD matrices.

powm(C, alpha)

Power of SPD/HPD matrices.


Square root of SPD/HPD matrices.

nearest_sym_pos_def(X[, reg])

Find the nearest SPD matrices.

Aproximate Joint Diagonalization

ajd(X[, method, init, eps, n_iter_max])

Aproximate joint diagonalization (AJD) according to a method.

ajd_pham(X, *[, init, eps, n_iter_max, ...])

Approximate joint diagonalization based on Pham's algorithm.

rjd(X, *[, init, eps, n_iter_max])

Approximate joint diagonalization based on JADE.

uwedge(X, *[, init, eps, n_iter_max])

Approximate joint diagonalization based on UWEDGE.

Matrix Tests


Check if matrices are square.


Check if all matrices are symmetric.


Check if all matrices are skew-symmetric.


Check if all matrices are strictly real.


Check if matrices are real type.


Check if all matrices are Hermitian.

is_pos_def(X[, tol, fast_mode])

Check if all matrices are positive definite (PD).


Check if all matrices are positive semi-definite (PSD).

is_sym_pos_def(X[, tol])

Check if all matrices are symmetric positive-definite (SPD).


Check if all matrices are symmetric positive semi-definite (SPSD).

is_herm_pos_def(X[, tol])

Check if all matrices are Hermitian positive-definite (HPD).


Check if all matrices are Hermitian positive semi-definite (HPSD).


plot_bihist(X, y[, n_bins, title])

Plot histogram of bi-class predictions.

plot_biscatter(X, y)

Plot scatter of bi-class predictions.

plot_cospectra(X, freqs, *[, ylabels, title])

Plot cospectral matrices.

plot_cov_ellipse(ax, X[, n_std])

Plot 2x2 covariance matrix as an ellipse.

plot_embedding(X[, y, metric, title, ...])

Plot 2D embedding of SPD matrices.

plot_waveforms(X, display, *[, times, ...])

Plot repetitions of a multichannel waveform.