Comparison of embeddings of covariance matrices

Comparison of several embeddings of a set of ERP covariance matrices extracted on MEG data: SE, LLE and t-SNE

Spectral Embedding (SE) is based on computing the low-dimensional representation that best preserves locality instead of local linearity in LLE [1].

Locally Linear Embedding (LLE) assumes that the local neighborhood of a matrix on the manifold can be well approximated by the affine subspace spanned by the k-nearest neighbors of the matrix and finds a low-dimensional embedding of the data based on these affine approximations.

t-SNE reduces SPD matrices into lower dimensional SPD matrices by computing conditional probabilities that represent similarities [2]. This fully Riemannian algorithm helps preserve the non-Euclidean structure of the data.

# Authors:  Pedro Rodrigues <pedro.rodrigues01@gmail.com>,
#           Gabriel Wagner vom Berg <gabriel@bccn-berlin.de>
#           Thibault de Surrel <thibault.de-surrel@lamsade.dauphine.fr>
#
# License: BSD (3-clause)

import matplotlib.pyplot as plt
import mne
from mne import io
from mne.datasets import sample
from sklearn.model_selection import train_test_split

from pyriemann.estimation import XdawnCovariances
from pyriemann.utils.viz import plot_embedding

print(__doc__)

Set parameters and read data

data_path = str(sample.data_path())
raw_fname = data_path + "/MEG/sample/sample_audvis_filt-0-40_raw.fif"
event_fname = data_path + "/MEG/sample/sample_audvis_filt-0-40_raw-eve.fif"
tmin, tmax = -0., 1
event_id = dict(aud_l=1, aud_r=2, vis_l=3, vis_r=4)

# Setup for reading the raw data
raw = io.Raw(raw_fname, preload=True, verbose=False)
raw.filter(2, None, method="iir")  # replace baselining with high-pass
events = mne.read_events(event_fname)

raw.info["bads"] = ["MEG 2443"]  # set bad channels
picks = mne.pick_types(raw.info, meg=True, eeg=False, stim=False, eog=False,
                       exclude="bads")

# Read epochs
epochs = mne.Epochs(raw, events, event_id, tmin, tmax, proj=False,
                    picks=picks, baseline=None, preload=True, verbose=False)

X = epochs.get_data(copy=False)
y = epochs.events[:, -1]
Using default location ~/mne_data for sample...
Fetching 1 file for the sample dataset ...

  0%|                                              | 0.00/1.65G [00:00<?, ?B/s]
  0%|                                      | 179k/1.65G [00:00<15:46, 1.75MB/s]
  0%|                                     | 2.19M/1.65G [00:00<02:13, 12.4MB/s]
  1%|▏                                    | 8.78M/1.65G [00:00<00:44, 36.7MB/s]
  1%|▎                                    | 15.3M/1.65G [00:00<00:34, 48.0MB/s]
  1%|▌                                    | 22.6M/1.65G [00:00<00:28, 56.8MB/s]
  2%|▋                                    | 29.9M/1.65G [00:00<00:26, 62.3MB/s]
  2%|▊                                    | 37.1M/1.65G [00:00<00:24, 65.4MB/s]
  3%|▉                                    | 44.2M/1.65G [00:00<00:23, 67.4MB/s]
  3%|█▏                                   | 51.4M/1.65G [00:00<00:23, 68.8MB/s]
  4%|█▎                                   | 58.6M/1.65G [00:01<00:22, 69.8MB/s]
  4%|█▍                                   | 65.8M/1.65G [00:01<00:22, 70.5MB/s]
  4%|█▋                                   | 73.0M/1.65G [00:01<00:22, 70.8MB/s]
  5%|█▊                                   | 80.3M/1.65G [00:01<00:22, 71.4MB/s]
  5%|█▉                                   | 87.6M/1.65G [00:01<00:21, 72.0MB/s]
  6%|██                                   | 94.9M/1.65G [00:01<00:21, 72.3MB/s]
  6%|██▎                                   | 102M/1.65G [00:01<00:21, 72.5MB/s]
  7%|██▌                                   | 109M/1.65G [00:01<00:21, 72.6MB/s]
  7%|██▋                                   | 117M/1.65G [00:01<00:21, 72.8MB/s]
  8%|██▊                                   | 124M/1.65G [00:01<00:21, 72.7MB/s]
  8%|███                                   | 131M/1.65G [00:02<00:20, 72.6MB/s]
  8%|███▏                                  | 139M/1.65G [00:02<00:20, 72.7MB/s]
  9%|███▎                                  | 146M/1.65G [00:02<00:20, 72.6MB/s]
  9%|███▌                                  | 153M/1.65G [00:02<00:20, 72.5MB/s]
 10%|███▋                                  | 160M/1.65G [00:02<00:20, 72.5MB/s]
 10%|███▊                                  | 168M/1.65G [00:02<00:20, 72.6MB/s]
 11%|████                                  | 175M/1.65G [00:02<00:20, 72.5MB/s]
 11%|████▏                                 | 182M/1.65G [00:02<00:20, 72.0MB/s]
 11%|████▎                                 | 189M/1.65G [00:02<00:20, 71.8MB/s]
 12%|████▌                                 | 197M/1.65G [00:02<00:20, 71.6MB/s]
 12%|████▋                                 | 204M/1.65G [00:03<00:20, 71.5MB/s]
 13%|████▊                                 | 211M/1.65G [00:03<00:20, 71.4MB/s]
 13%|█████                                 | 218M/1.65G [00:03<00:20, 70.8MB/s]
 14%|█████▏                                | 225M/1.65G [00:03<00:20, 71.1MB/s]
 14%|█████▎                                | 232M/1.65G [00:03<00:19, 71.2MB/s]
 14%|█████▌                                | 240M/1.65G [00:03<00:19, 71.3MB/s]
 15%|█████▋                                | 247M/1.65G [00:03<00:19, 71.6MB/s]
 15%|█████▊                                | 254M/1.65G [00:03<00:19, 72.0MB/s]
 16%|██████                                | 261M/1.65G [00:03<00:19, 72.0MB/s]
 16%|██████▏                               | 268M/1.65G [00:03<00:19, 72.0MB/s]
 17%|██████▎                               | 276M/1.65G [00:04<00:19, 72.1MB/s]
 17%|██████▌                               | 283M/1.65G [00:04<00:18, 72.2MB/s]
 18%|██████▋                               | 290M/1.65G [00:04<00:18, 72.1MB/s]
 18%|██████▊                               | 297M/1.65G [00:04<00:18, 72.3MB/s]
 18%|███████                               | 305M/1.65G [00:04<00:18, 72.3MB/s]
 19%|███████▏                              | 312M/1.65G [00:04<00:18, 72.4MB/s]
 19%|███████▎                              | 319M/1.65G [00:04<00:18, 72.5MB/s]
 20%|███████▌                              | 326M/1.65G [00:04<00:18, 72.5MB/s]
 20%|███████▋                              | 334M/1.65G [00:04<00:18, 72.6MB/s]
 21%|███████▊                              | 341M/1.65G [00:04<00:18, 72.4MB/s]
 21%|████████                              | 348M/1.65G [00:05<00:18, 72.1MB/s]
 22%|████████▏                             | 355M/1.65G [00:05<00:17, 72.1MB/s]
 22%|████████▎                             | 363M/1.65G [00:05<00:18, 68.4MB/s]
 22%|████████▍                             | 370M/1.65G [00:05<00:21, 60.8MB/s]
 23%|████████▋                             | 377M/1.65G [00:05<00:19, 63.9MB/s]
 23%|████████▊                             | 384M/1.65G [00:05<00:19, 66.5MB/s]
 24%|████████▉                             | 391M/1.65G [00:05<00:18, 68.2MB/s]
 24%|█████████▏                            | 399M/1.65G [00:05<00:17, 69.9MB/s]
 25%|█████████▎                            | 406M/1.65G [00:05<00:17, 70.6MB/s]
 25%|█████████▍                            | 413M/1.65G [00:05<00:17, 70.9MB/s]
 25%|█████████▋                            | 420M/1.65G [00:06<00:17, 71.5MB/s]
 26%|█████████▊                            | 428M/1.65G [00:06<00:17, 71.7MB/s]
 26%|█████████▉                            | 435M/1.65G [00:06<00:16, 71.9MB/s]
 27%|██████████▏                           | 442M/1.65G [00:06<00:16, 72.1MB/s]
 27%|██████████▎                           | 449M/1.65G [00:06<00:16, 72.4MB/s]
 28%|██████████▌                           | 457M/1.65G [00:06<00:16, 72.8MB/s]
 28%|██████████▋                           | 464M/1.65G [00:06<00:16, 72.6MB/s]
 29%|██████████▊                           | 471M/1.65G [00:06<00:16, 72.6MB/s]
 29%|███████████                           | 479M/1.65G [00:06<00:16, 72.5MB/s]
 29%|███████████▏                          | 486M/1.65G [00:06<00:16, 72.0MB/s]
 30%|███████████▎                          | 493M/1.65G [00:07<00:16, 72.0MB/s]
 30%|███████████▌                          | 500M/1.65G [00:07<00:16, 71.4MB/s]
 31%|███████████▋                          | 508M/1.65G [00:07<00:15, 71.9MB/s]
 31%|███████████▊                          | 515M/1.65G [00:07<00:15, 72.1MB/s]
 32%|████████████                          | 522M/1.65G [00:07<00:15, 72.1MB/s]
 32%|████████████▏                         | 529M/1.65G [00:07<00:15, 72.6MB/s]
 32%|████████████▎                         | 537M/1.65G [00:07<00:15, 72.7MB/s]
 33%|████████████▌                         | 544M/1.65G [00:07<00:15, 73.0MB/s]
 33%|████████████▋                         | 551M/1.65G [00:07<00:15, 72.9MB/s]
 34%|████████████▊                         | 559M/1.65G [00:07<00:15, 72.6MB/s]
 34%|█████████████                         | 566M/1.65G [00:08<00:14, 72.7MB/s]
 35%|█████████████▏                        | 573M/1.65G [00:08<00:14, 72.9MB/s]
 35%|█████████████▎                        | 581M/1.65G [00:08<00:14, 73.0MB/s]
 36%|█████████████▌                        | 588M/1.65G [00:08<00:14, 73.0MB/s]
 36%|█████████████▋                        | 595M/1.65G [00:08<00:14, 73.0MB/s]
 36%|█████████████▊                        | 603M/1.65G [00:08<00:14, 73.1MB/s]
 37%|██████████████                        | 610M/1.65G [00:08<00:14, 73.2MB/s]
 37%|██████████████▏                       | 617M/1.65G [00:08<00:14, 72.0MB/s]
 38%|██████████████▎                       | 625M/1.65G [00:08<00:14, 72.4MB/s]
 38%|██████████████▌                       | 632M/1.65G [00:08<00:14, 71.6MB/s]
 39%|██████████████▋                       | 639M/1.65G [00:09<00:14, 71.6MB/s]
 39%|██████████████▊                       | 646M/1.65G [00:09<00:14, 71.5MB/s]
 40%|███████████████                       | 653M/1.65G [00:09<00:13, 71.6MB/s]
 40%|███████████████▏                      | 661M/1.65G [00:09<00:13, 71.8MB/s]
 40%|███████████████▎                      | 668M/1.65G [00:09<00:13, 72.3MB/s]
 41%|███████████████▌                      | 675M/1.65G [00:09<00:13, 71.8MB/s]
 41%|███████████████▋                      | 683M/1.65G [00:09<00:13, 72.3MB/s]
 42%|███████████████▊                      | 690M/1.65G [00:09<00:13, 72.7MB/s]
 42%|████████████████                      | 697M/1.65G [00:09<00:13, 71.9MB/s]
 43%|████████████████▏                     | 705M/1.65G [00:10<00:13, 72.1MB/s]
 43%|████████████████▎                     | 712M/1.65G [00:10<00:12, 72.4MB/s]
 44%|████████████████▌                     | 719M/1.65G [00:10<00:12, 71.9MB/s]
 44%|████████████████▋                     | 727M/1.65G [00:10<00:12, 72.6MB/s]
 44%|████████████████▊                     | 734M/1.65G [00:10<00:12, 72.9MB/s]
 45%|█████████████████                     | 741M/1.65G [00:10<00:12, 72.3MB/s]
 45%|█████████████████▏                    | 748M/1.65G [00:10<00:12, 72.6MB/s]
 46%|█████████████████▍                    | 756M/1.65G [00:10<00:12, 72.7MB/s]
 46%|█████████████████▌                    | 763M/1.65G [00:10<00:12, 72.0MB/s]
 47%|█████████████████▋                    | 770M/1.65G [00:10<00:12, 72.3MB/s]
 47%|█████████████████▉                    | 778M/1.65G [00:11<00:12, 72.5MB/s]
 47%|██████████████████                    | 785M/1.65G [00:11<00:12, 71.9MB/s]
 48%|██████████████████▏                   | 792M/1.65G [00:11<00:11, 71.8MB/s]
 48%|██████████████████▍                   | 799M/1.65G [00:11<00:11, 71.6MB/s]
 49%|██████████████████▌                   | 807M/1.65G [00:11<00:11, 72.4MB/s]
 49%|██████████████████▋                   | 814M/1.65G [00:11<00:13, 64.0MB/s]
 50%|██████████████████▉                   | 821M/1.65G [00:11<00:12, 66.5MB/s]
 50%|███████████████████                   | 828M/1.65G [00:11<00:12, 67.7MB/s]
 51%|███████████████████▏                  | 836M/1.65G [00:11<00:11, 69.1MB/s]
 51%|███████████████████▍                  | 843M/1.65G [00:11<00:11, 70.1MB/s]
 51%|███████████████████▌                  | 850M/1.65G [00:12<00:11, 70.2MB/s]
 52%|███████████████████▋                  | 857M/1.65G [00:12<00:11, 70.8MB/s]
 52%|███████████████████▉                  | 864M/1.65G [00:12<00:11, 71.5MB/s]
 53%|████████████████████                  | 872M/1.65G [00:12<00:10, 72.0MB/s]
 53%|████████████████████▏                 | 879M/1.65G [00:12<00:10, 71.5MB/s]
 54%|████████████████████▍                 | 886M/1.65G [00:12<00:10, 72.0MB/s]
 54%|████████████████████▌                 | 894M/1.65G [00:12<00:10, 72.3MB/s]
 55%|████████████████████▋                 | 901M/1.65G [00:12<00:10, 71.4MB/s]
 55%|████████████████████▉                 | 908M/1.65G [00:12<00:10, 71.8MB/s]
 55%|█████████████████████                 | 915M/1.65G [00:12<00:10, 71.7MB/s]
 56%|█████████████████████▏                | 923M/1.65G [00:13<00:10, 72.0MB/s]
 56%|█████████████████████▍                | 930M/1.65G [00:13<00:10, 70.5MB/s]
 57%|█████████████████████▌                | 937M/1.65G [00:13<00:10, 71.2MB/s]
 57%|█████████████████████▋                | 944M/1.65G [00:13<00:09, 71.6MB/s]
 58%|█████████████████████▉                | 952M/1.65G [00:13<00:09, 71.0MB/s]
 58%|██████████████████████                | 959M/1.65G [00:13<00:09, 71.5MB/s]
 58%|██████████████████████▏               | 966M/1.65G [00:13<00:09, 72.0MB/s]
 59%|██████████████████████▍               | 973M/1.65G [00:13<00:09, 72.1MB/s]
 59%|██████████████████████▌               | 981M/1.65G [00:13<00:09, 69.9MB/s]
 60%|██████████████████████▋               | 988M/1.65G [00:13<00:09, 70.5MB/s]
 60%|██████████████████████▉               | 995M/1.65G [00:14<00:09, 71.1MB/s]
 61%|██████████████████████▍              | 1.00G/1.65G [00:14<00:09, 71.6MB/s]
 61%|██████████████████████▌              | 1.01G/1.65G [00:14<00:09, 70.8MB/s]
 62%|██████████████████████▊              | 1.02G/1.65G [00:14<00:08, 71.1MB/s]
 62%|██████████████████████▉              | 1.02G/1.65G [00:14<00:08, 71.5MB/s]
 62%|███████████████████████              | 1.03G/1.65G [00:14<00:08, 71.8MB/s]
 63%|███████████████████████▏             | 1.04G/1.65G [00:14<00:08, 70.7MB/s]
 63%|███████████████████████▍             | 1.05G/1.65G [00:14<00:08, 70.9MB/s]
 64%|███████████████████████▌             | 1.05G/1.65G [00:14<00:08, 71.3MB/s]
 64%|███████████████████████▋             | 1.06G/1.65G [00:14<00:08, 71.4MB/s]
 65%|███████████████████████▉             | 1.07G/1.65G [00:15<00:08, 70.6MB/s]
 65%|████████████████████████             | 1.07G/1.65G [00:15<00:08, 70.4MB/s]
 65%|████████████████████████▏            | 1.08G/1.65G [00:15<00:08, 71.2MB/s]
 66%|████████████████████████▎            | 1.09G/1.65G [00:15<00:08, 70.2MB/s]
 66%|████████████████████████▌            | 1.10G/1.65G [00:15<00:07, 69.8MB/s]
 67%|████████████████████████▋            | 1.10G/1.65G [00:15<00:07, 70.9MB/s]
 67%|████████████████████████▊            | 1.11G/1.65G [00:15<00:07, 71.8MB/s]
 68%|█████████████████████████            | 1.12G/1.65G [00:15<00:07, 72.2MB/s]
 68%|█████████████████████████▏           | 1.12G/1.65G [00:15<00:07, 71.3MB/s]
 68%|█████████████████████████▎           | 1.13G/1.65G [00:16<00:07, 71.6MB/s]
 69%|█████████████████████████▌           | 1.14G/1.65G [00:16<00:07, 72.4MB/s]
 69%|█████████████████████████▋           | 1.15G/1.65G [00:16<00:06, 72.6MB/s]
 70%|█████████████████████████▊           | 1.15G/1.65G [00:16<00:06, 71.7MB/s]
 70%|██████████████████████████           | 1.16G/1.65G [00:16<00:06, 72.2MB/s]
 71%|██████████████████████████▏          | 1.17G/1.65G [00:16<00:06, 72.6MB/s]
 71%|██████████████████████████▎          | 1.18G/1.65G [00:16<00:06, 72.9MB/s]
 72%|██████████████████████████▍          | 1.18G/1.65G [00:16<00:06, 71.8MB/s]
 72%|██████████████████████████▋          | 1.19G/1.65G [00:16<00:06, 72.1MB/s]
 72%|██████████████████████████▊          | 1.20G/1.65G [00:16<00:06, 72.2MB/s]
 73%|██████████████████████████▉          | 1.21G/1.65G [00:17<00:06, 72.4MB/s]
 73%|███████████████████████████▏         | 1.21G/1.65G [00:17<00:06, 71.1MB/s]
 74%|███████████████████████████▎         | 1.22G/1.65G [00:17<00:06, 67.6MB/s]
 74%|███████████████████████████▍         | 1.23G/1.65G [00:17<00:06, 68.3MB/s]
 75%|███████████████████████████▌         | 1.23G/1.65G [00:17<00:06, 69.4MB/s]
 75%|███████████████████████████▊         | 1.24G/1.65G [00:17<00:05, 70.1MB/s]
 76%|███████████████████████████▉         | 1.25G/1.65G [00:17<00:05, 71.0MB/s]
 76%|████████████████████████████         | 1.26G/1.65G [00:17<00:05, 71.7MB/s]
 76%|████████████████████████████▎        | 1.26G/1.65G [00:17<00:05, 72.2MB/s]
 77%|████████████████████████████▍        | 1.27G/1.65G [00:17<00:05, 72.5MB/s]
 77%|████████████████████████████▌        | 1.28G/1.65G [00:18<00:05, 72.9MB/s]
 78%|████████████████████████████▊        | 1.29G/1.65G [00:18<00:05, 70.7MB/s]
 78%|████████████████████████████▉        | 1.29G/1.65G [00:18<00:05, 60.6MB/s]
 79%|█████████████████████████████        | 1.30G/1.65G [00:18<00:05, 63.8MB/s]
 79%|█████████████████████████████▎       | 1.31G/1.65G [00:18<00:05, 66.6MB/s]
 80%|█████████████████████████████▍       | 1.31G/1.65G [00:18<00:04, 68.5MB/s]
 80%|█████████████████████████████▌       | 1.32G/1.65G [00:18<00:04, 69.9MB/s]
 80%|█████████████████████████████▋       | 1.33G/1.65G [00:18<00:04, 70.8MB/s]
 81%|█████████████████████████████▉       | 1.34G/1.65G [00:18<00:04, 71.3MB/s]
 81%|██████████████████████████████       | 1.34G/1.65G [00:19<00:04, 71.6MB/s]
 82%|██████████████████████████████▏      | 1.35G/1.65G [00:19<00:04, 72.0MB/s]
 82%|██████████████████████████████▍      | 1.36G/1.65G [00:19<00:04, 71.8MB/s]
 83%|██████████████████████████████▌      | 1.37G/1.65G [00:19<00:03, 72.3MB/s]
 83%|██████████████████████████████▋      | 1.37G/1.65G [00:19<00:03, 72.7MB/s]
 83%|██████████████████████████████▉      | 1.38G/1.65G [00:19<00:03, 73.1MB/s]
 84%|███████████████████████████████      | 1.39G/1.65G [00:19<00:03, 73.3MB/s]
 84%|███████████████████████████████▏     | 1.39G/1.65G [00:19<00:03, 73.6MB/s]
 85%|███████████████████████████████▍     | 1.40G/1.65G [00:19<00:03, 73.5MB/s]
 85%|███████████████████████████████▌     | 1.41G/1.65G [00:19<00:03, 73.4MB/s]
 86%|███████████████████████████████▋     | 1.42G/1.65G [00:20<00:03, 72.1MB/s]
 86%|███████████████████████████████▉     | 1.42G/1.65G [00:20<00:03, 72.6MB/s]
 87%|████████████████████████████████     | 1.43G/1.65G [00:20<00:03, 72.9MB/s]
 87%|████████████████████████████████▏    | 1.44G/1.65G [00:20<00:02, 73.3MB/s]
 88%|████████████████████████████████▍    | 1.45G/1.65G [00:20<00:02, 72.5MB/s]
 88%|████████████████████████████████▌    | 1.45G/1.65G [00:20<00:02, 73.2MB/s]
 88%|████████████████████████████████▋    | 1.46G/1.65G [00:20<00:02, 73.6MB/s]
 89%|████████████████████████████████▉    | 1.47G/1.65G [00:20<00:02, 73.8MB/s]
 89%|█████████████████████████████████    | 1.48G/1.65G [00:20<00:02, 72.8MB/s]
 90%|█████████████████████████████████▏   | 1.48G/1.65G [00:20<00:02, 72.3MB/s]
 90%|█████████████████████████████████▎   | 1.49G/1.65G [00:21<00:02, 72.6MB/s]
 91%|█████████████████████████████████▌   | 1.50G/1.65G [00:21<00:02, 72.9MB/s]
 91%|█████████████████████████████████▋   | 1.51G/1.65G [00:21<00:02, 72.8MB/s]
 92%|█████████████████████████████████▊   | 1.51G/1.65G [00:21<00:01, 73.0MB/s]
 92%|██████████████████████████████████   | 1.52G/1.65G [00:21<00:01, 72.3MB/s]
 92%|██████████████████████████████████▏  | 1.53G/1.65G [00:21<00:01, 73.0MB/s]
 93%|██████████████████████████████████▎  | 1.53G/1.65G [00:21<00:01, 73.4MB/s]
 93%|██████████████████████████████████▌  | 1.54G/1.65G [00:21<00:01, 73.7MB/s]
 94%|██████████████████████████████████▋  | 1.55G/1.65G [00:21<00:01, 73.7MB/s]
 94%|██████████████████████████████████▊  | 1.56G/1.65G [00:21<00:01, 72.0MB/s]
 95%|███████████████████████████████████  | 1.56G/1.65G [00:22<00:01, 72.7MB/s]
 95%|███████████████████████████████████▏ | 1.57G/1.65G [00:22<00:01, 73.1MB/s]
 96%|███████████████████████████████████▎ | 1.58G/1.65G [00:22<00:00, 73.6MB/s]
 96%|███████████████████████████████████▌ | 1.59G/1.65G [00:22<00:00, 73.8MB/s]
 96%|███████████████████████████████████▋ | 1.59G/1.65G [00:22<00:00, 72.8MB/s]
 97%|███████████████████████████████████▊ | 1.60G/1.65G [00:22<00:00, 73.3MB/s]
 97%|████████████████████████████████████ | 1.61G/1.65G [00:22<00:00, 73.6MB/s]
 98%|████████████████████████████████████▏| 1.62G/1.65G [00:22<00:00, 73.8MB/s]
 98%|████████████████████████████████████▎| 1.62G/1.65G [00:22<00:00, 74.0MB/s]
 99%|████████████████████████████████████▌| 1.63G/1.65G [00:22<00:00, 73.9MB/s]
 99%|████████████████████████████████████▋| 1.64G/1.65G [00:23<00:00, 72.3MB/s]
100%|████████████████████████████████████▊| 1.65G/1.65G [00:23<00:00, 72.6MB/s]
  0%|                                              | 0.00/1.65G [00:00<?, ?B/s]
100%|█████████████████████████████████████| 1.65G/1.65G [00:00<00:00, 5.57TB/s]
Download complete in 58s (1576.2 MB)
Filtering raw data in 1 contiguous segment
Setting up high-pass filter at 2 Hz

IIR filter parameters
---------------------
Butterworth highpass zero-phase (two-pass forward and reverse) non-causal filter:
- Filter order 8 (effective, after forward-backward)
- Cutoff at 2.00 Hz: -6.02 dB

Extract Xdawn covariance matrices

nfilter = 4
xdwn = XdawnCovariances(estimator="scm", nfilter=nfilter)
split = train_test_split(X, y, train_size=0.25, random_state=42)
Xtrain, Xtest, ytrain, ytest = split
covs = xdwn.fit(Xtrain, ytrain).transform(Xtest)

Spectral Embedding (SE)

plot_embedding(covs, ytest, metric="riemann", embd_type="Spectral",
               normalize=True)
plt.show()
Spectral Embedding of SPD matrices

Locally Linear Embedding (LLE)

plot_embedding(covs, ytest, metric="riemann", embd_type="LocallyLinear",
               normalize=False)
plt.show()
LocallyLinear Embedding of SPD matrices

TNSE

plot_embedding(covs, ytest, metric="riemann", embd_type="TSNE",
               normalize=False, max_iter=50)
plt.show()
TSNE Embedding of SPD matrices
/home/docs/checkouts/readthedocs.org/user_builds/pyriemann/checkouts/latest/pyriemann/optimization/positive_definite.py:284: UserWarning: Convergence not reached. Try increasing max_iter.
  warnings.warn("Convergence not reached. Try increasing max_iter.")

References

Total running time of the script: (1 minutes 9.940 seconds)

Gallery generated by Sphinx-Gallery