This toolbox is no longer supported by its author. The code is working on the last 2015 Matlab version, but may not be compatible with future versions. Consider using pyRiemann as a (python) alternative.
Fee free to fork the toolbox and start your own support :)
Covariance Toolbox
This toolbox contain a set of matlab functions dedicated to covariance matrices estimation and manipulation.
The key functions mainly focus on Riemanian geometry of SPD matrices, with distance, geodesic, tangent space and mean estimation of covariance matrices under different metrics.
This toolbox is licenced under GPLv3.
Installation
installer
List of functions
Generate SPD matrices
Generate a set of SPD matrices according to a wishart distribution : [COV, Sig] = generate_wishart_set(N,I,Df,Sig)
Distances
Distance between two covariance matrices (by default euclidean metric) : d = distance(C1,C2,metric)
Kullback-Leibler distance : d = distance_kullback(C1,C2)
Log-euclidean distance : d = distance_logeuclid(C1,C2)
Riemannian distance : d = distance_riemann(C1,C2)
Optimal transportation distance : d = distance_opttransp(C1,C2)
Log Determinant distance : d = distance_ld(C1,C2)
Estimation
SCM
Fixed point
Normalized SCM
MCD
Set of covariance matrices for a set of 3D signals X : Nchannels x Tsamples x Ntrials COV = covariances(X)
Geodesic
Geodesic between two covariance matrices (by default euclidean metric) : Ct = geodesic(C1,C2,t,metric)
Tangent space logistic regression (soon) : Ytest = tsglm(COVtest,COVtrain,Ytrain)
binary classification only
Tangent space regularized LDA : Ytest = tslda(COVtest,COVtrain,Ytrain)
Tangent space SVM (soon) : Ytest = tssvm(COVtest,COVtrain,Ytrain)
Examples
Generate a set of covariance matrices and estimate the riemannian mean
% generate a wishart set of 10 5x5 covariances matrices with a degree of freedom equal to 11
COV =generate_wishart_set(5,10,11);
% estimate the Riemannian mean of this set.
C =mean_covariances(COV,'riemann')
C =14.46251.4332-3.7638-2.005214.25171.433211.5863-2.22927.74458.8240-3.7638-2.229224.4896-0.3460-3.9808-2.00527.7445-0.346012.17406.250314.25178.8240-3.98086.250337.4416
Generate a set of trials and estimate the riemannian mean
% generate a set of trials , 5 channels, 100 time sample and 1000 trials
X =randn(5,100,1000);
% covariance matrix of each trial
COV =covariances(X);
% Riemannian mean
C =mean_covariances(COV,'riemann')
C =0.96990.00120.00260.00500.00400.00120.9659-0.00370.00590.00010.0026-0.00370.9712-0.0009-0.00240.00500.0059-0.00090.9687-0.00340.00400.0001-0.0024-0.00340.9671
请发表评论