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%|                                      | 163k/1.65G [00:00<17:47, 1.55MB/s]
  0%|                                     | 1.97M/1.65G [00:00<02:29, 11.1MB/s]
  0%|▏                                    | 7.97M/1.65G [00:00<00:49, 33.1MB/s]
  1%|▎                                    | 14.3M/1.65G [00:00<00:36, 44.8MB/s]
  1%|▍                                    | 20.7M/1.65G [00:00<00:31, 51.7MB/s]
  2%|▌                                    | 27.0M/1.65G [00:00<00:29, 55.7MB/s]
  2%|▋                                    | 33.4M/1.65G [00:00<00:27, 58.4MB/s]
  2%|▉                                    | 39.8M/1.65G [00:00<00:26, 60.1MB/s]
  3%|█                                    | 46.1M/1.65G [00:00<00:26, 60.9MB/s]
  3%|█▏                                   | 52.5M/1.65G [00:01<00:25, 61.8MB/s]
  4%|█▎                                   | 58.9M/1.65G [00:01<00:25, 62.6MB/s]
  4%|█▍                                   | 65.2M/1.65G [00:01<00:25, 62.7MB/s]
  4%|█▌                                   | 71.7M/1.65G [00:01<00:24, 63.3MB/s]
  5%|█▋                                   | 78.1M/1.65G [00:01<00:24, 63.6MB/s]
  5%|█▉                                   | 84.5M/1.65G [00:01<00:24, 63.9MB/s]
  6%|██                                   | 91.0M/1.65G [00:01<00:24, 64.0MB/s]
  6%|██▏                                  | 97.4M/1.65G [00:01<00:24, 64.0MB/s]
  6%|██▍                                   | 104M/1.65G [00:01<00:24, 63.8MB/s]
  7%|██▌                                   | 110M/1.65G [00:01<00:24, 63.8MB/s]
  7%|██▋                                   | 117M/1.65G [00:02<00:23, 64.1MB/s]
  7%|██▊                                   | 123M/1.65G [00:02<00:23, 64.4MB/s]
  8%|██▉                                   | 130M/1.65G [00:02<00:23, 64.6MB/s]
  8%|███▏                                  | 136M/1.65G [00:02<00:23, 64.6MB/s]
  9%|███▎                                  | 143M/1.65G [00:02<00:23, 64.5MB/s]
  9%|███▍                                  | 149M/1.65G [00:02<00:23, 64.3MB/s]
  9%|███▌                                  | 155M/1.65G [00:02<00:23, 64.3MB/s]
 10%|███▋                                  | 162M/1.65G [00:02<00:23, 64.2MB/s]
 10%|███▊                                  | 168M/1.65G [00:02<00:23, 64.4MB/s]
 11%|████                                  | 175M/1.65G [00:02<00:23, 64.2MB/s]
 11%|████▏                                 | 181M/1.65G [00:03<00:23, 63.5MB/s]
 11%|████▎                                 | 188M/1.65G [00:03<00:23, 62.6MB/s]
 12%|████▍                                 | 194M/1.65G [00:03<00:23, 61.8MB/s]
 12%|████▌                                 | 200M/1.65G [00:03<00:23, 61.4MB/s]
 12%|████▋                                 | 206M/1.65G [00:03<00:23, 61.0MB/s]
 13%|████▉                                 | 212M/1.65G [00:03<00:23, 60.9MB/s]
 13%|█████                                 | 218M/1.65G [00:03<00:23, 60.9MB/s]
 14%|█████▏                                | 225M/1.65G [00:03<00:23, 60.8MB/s]
 14%|█████▎                                | 231M/1.65G [00:03<00:23, 60.5MB/s]
 14%|█████▍                                | 237M/1.65G [00:03<00:23, 60.6MB/s]
 15%|█████▌                                | 243M/1.65G [00:04<00:23, 60.7MB/s]
 15%|█████▋                                | 249M/1.65G [00:04<00:23, 60.6MB/s]
 15%|█████▊                                | 255M/1.65G [00:04<00:23, 60.6MB/s]
 16%|█████▉                                | 261M/1.65G [00:04<00:22, 60.6MB/s]
 16%|██████▏                               | 267M/1.65G [00:04<00:22, 60.3MB/s]
 17%|██████▎                               | 273M/1.65G [00:04<00:22, 60.3MB/s]
 17%|██████▍                               | 279M/1.65G [00:04<00:22, 60.4MB/s]
 17%|██████▌                               | 285M/1.65G [00:04<00:22, 60.1MB/s]
 18%|██████▋                               | 291M/1.65G [00:04<00:22, 60.4MB/s]
 18%|██████▊                               | 297M/1.65G [00:04<00:22, 60.1MB/s]
 18%|██████▉                               | 303M/1.65G [00:05<00:22, 60.3MB/s]
 19%|███████                               | 309M/1.65G [00:05<00:22, 60.4MB/s]
 19%|███████▎                              | 316M/1.65G [00:05<00:22, 60.5MB/s]
 19%|███████▍                              | 322M/1.65G [00:05<00:21, 60.6MB/s]
 20%|███████▌                              | 328M/1.65G [00:05<00:21, 60.5MB/s]
 20%|███████▋                              | 334M/1.65G [00:05<00:21, 60.6MB/s]
 21%|███████▊                              | 340M/1.65G [00:05<00:21, 60.7MB/s]
 21%|███████▉                              | 346M/1.65G [00:05<00:21, 60.8MB/s]
 21%|████████                              | 352M/1.65G [00:05<00:21, 60.6MB/s]
 22%|████████▏                             | 358M/1.65G [00:05<00:21, 60.5MB/s]
 22%|████████▎                             | 364M/1.65G [00:06<00:21, 60.6MB/s]
 22%|████████▌                             | 370M/1.65G [00:06<00:21, 60.5MB/s]
 23%|████████▋                             | 376M/1.65G [00:06<00:21, 60.6MB/s]
 23%|████████▊                             | 382M/1.65G [00:06<00:21, 60.5MB/s]
 24%|████████▉                             | 389M/1.65G [00:06<00:20, 61.1MB/s]
 24%|█████████                             | 395M/1.65G [00:06<00:20, 61.8MB/s]
 24%|█████████▏                            | 401M/1.65G [00:06<00:20, 62.5MB/s]
 25%|█████████▎                            | 408M/1.65G [00:06<00:19, 62.7MB/s]
 25%|█████████▌                            | 414M/1.65G [00:06<00:19, 63.1MB/s]
 25%|█████████▋                            | 420M/1.65G [00:06<00:19, 63.1MB/s]
 26%|█████████▊                            | 427M/1.65G [00:07<00:19, 62.7MB/s]
 26%|█████████▉                            | 433M/1.65G [00:07<00:19, 63.1MB/s]
 27%|██████████                            | 440M/1.65G [00:07<00:19, 63.4MB/s]
 27%|██████████▎                           | 446M/1.65G [00:07<00:18, 63.6MB/s]
 27%|██████████▍                           | 452M/1.65G [00:07<00:18, 63.8MB/s]
 28%|██████████▌                           | 459M/1.65G [00:07<00:18, 64.1MB/s]
 28%|██████████▋                           | 465M/1.65G [00:07<00:18, 63.7MB/s]
 29%|██████████▊                           | 472M/1.65G [00:07<00:18, 63.6MB/s]
 29%|██████████▉                           | 478M/1.65G [00:07<00:18, 63.5MB/s]
 29%|███████████▏                          | 484M/1.65G [00:07<00:18, 63.5MB/s]
 30%|███████████▎                          | 491M/1.65G [00:08<00:18, 63.5MB/s]
 30%|███████████▍                          | 497M/1.65G [00:08<00:18, 63.6MB/s]
 30%|███████████▌                          | 503M/1.65G [00:08<00:18, 63.6MB/s]
 31%|███████████▋                          | 510M/1.65G [00:08<00:17, 63.7MB/s]
 31%|███████████▊                          | 516M/1.65G [00:08<00:17, 63.6MB/s]
 32%|████████████                          | 523M/1.65G [00:08<00:17, 63.6MB/s]
 32%|████████████▏                         | 529M/1.65G [00:08<00:17, 62.8MB/s]
 32%|████████████▎                         | 535M/1.65G [00:08<00:18, 61.9MB/s]
 33%|████████████▍                         | 541M/1.65G [00:08<00:18, 61.5MB/s]
 33%|████████████▌                         | 548M/1.65G [00:08<00:18, 60.9MB/s]
 33%|████████████▋                         | 554M/1.65G [00:09<00:18, 60.9MB/s]
 34%|████████████▊                         | 560M/1.65G [00:09<00:17, 60.8MB/s]
 34%|█████████████                         | 566M/1.65G [00:09<00:17, 60.8MB/s]
 35%|█████████████▏                        | 572M/1.65G [00:09<00:17, 60.7MB/s]
 35%|█████████████▎                        | 578M/1.65G [00:09<00:17, 60.8MB/s]
 35%|█████████████▍                        | 584M/1.65G [00:09<00:17, 60.9MB/s]
 36%|█████████████▌                        | 590M/1.65G [00:09<00:17, 60.8MB/s]
 36%|█████████████▋                        | 596M/1.65G [00:09<00:17, 60.8MB/s]
 36%|█████████████▊                        | 602M/1.65G [00:09<00:17, 60.5MB/s]
 37%|█████████████▉                        | 608M/1.65G [00:09<00:17, 60.4MB/s]
 37%|██████████████▏                       | 614M/1.65G [00:10<00:17, 60.2MB/s]
 38%|██████████████▎                       | 620M/1.65G [00:10<00:17, 59.9MB/s]
 38%|██████████████▍                       | 627M/1.65G [00:10<00:16, 60.8MB/s]
 38%|██████████████▌                       | 633M/1.65G [00:10<00:16, 61.6MB/s]
 39%|██████████████▋                       | 639M/1.65G [00:10<00:16, 61.5MB/s]
 39%|██████████████▊                       | 646M/1.65G [00:10<00:16, 62.2MB/s]
 39%|██████████████▉                       | 652M/1.65G [00:10<00:15, 62.6MB/s]
 40%|███████████████▏                      | 658M/1.65G [00:10<00:17, 56.4MB/s]
 40%|███████████████▎                      | 664M/1.65G [00:10<00:18, 53.7MB/s]
 41%|███████████████▍                      | 670M/1.65G [00:11<00:17, 56.1MB/s]
 41%|███████████████▌                      | 676M/1.65G [00:11<00:16, 57.7MB/s]
 41%|███████████████▋                      | 683M/1.65G [00:11<00:16, 59.3MB/s]
 42%|███████████████▊                      | 689M/1.65G [00:11<00:15, 60.5MB/s]
 42%|███████████████▉                      | 696M/1.65G [00:11<00:15, 61.4MB/s]
 42%|████████████████▏                     | 702M/1.65G [00:11<00:15, 61.7MB/s]
 43%|████████████████▎                     | 708M/1.65G [00:11<00:15, 62.4MB/s]
 43%|████████████████▍                     | 715M/1.65G [00:11<00:14, 63.0MB/s]
 44%|████████████████▌                     | 721M/1.65G [00:11<00:14, 62.5MB/s]
 44%|████████████████▋                     | 727M/1.65G [00:11<00:14, 63.0MB/s]
 44%|████████████████▊                     | 734M/1.65G [00:12<00:14, 63.4MB/s]
 45%|█████████████████                     | 740M/1.65G [00:12<00:14, 63.3MB/s]
 45%|█████████████████▏                    | 746M/1.65G [00:12<00:14, 63.4MB/s]
 46%|█████████████████▎                    | 753M/1.65G [00:12<00:14, 63.7MB/s]
 46%|█████████████████▍                    | 759M/1.65G [00:12<00:14, 63.7MB/s]
 46%|█████████████████▌                    | 766M/1.65G [00:12<00:14, 63.2MB/s]
 47%|█████████████████▊                    | 772M/1.65G [00:12<00:13, 63.4MB/s]
 47%|█████████████████▉                    | 778M/1.65G [00:12<00:13, 63.4MB/s]
 47%|██████████████████                    | 785M/1.65G [00:12<00:13, 62.8MB/s]
 48%|██████████████████▏                   | 791M/1.65G [00:12<00:13, 62.9MB/s]
 48%|██████████████████▎                   | 798M/1.65G [00:13<00:13, 63.4MB/s]
 49%|██████████████████▍                   | 804M/1.65G [00:13<00:13, 62.9MB/s]
 49%|██████████████████▋                   | 810M/1.65G [00:13<00:13, 62.6MB/s]
 49%|██████████████████▊                   | 817M/1.65G [00:13<00:13, 63.0MB/s]
 50%|██████████████████▉                   | 823M/1.65G [00:13<00:13, 63.4MB/s]
 50%|███████████████████                   | 829M/1.65G [00:13<00:13, 63.0MB/s]
 51%|███████████████████▏                  | 836M/1.65G [00:13<00:12, 63.5MB/s]
 51%|███████████████████▎                  | 842M/1.65G [00:13<00:12, 63.9MB/s]
 51%|███████████████████▌                  | 849M/1.65G [00:13<00:12, 63.1MB/s]
 52%|███████████████████▋                  | 855M/1.65G [00:13<00:12, 63.4MB/s]
 52%|███████████████████▊                  | 862M/1.65G [00:14<00:12, 63.8MB/s]
 53%|███████████████████▉                  | 868M/1.65G [00:14<00:12, 63.0MB/s]
 53%|████████████████████                  | 874M/1.65G [00:14<00:12, 63.4MB/s]
 53%|████████████████████▎                 | 881M/1.65G [00:14<00:12, 63.6MB/s]
 54%|████████████████████▍                 | 887M/1.65G [00:14<00:12, 63.8MB/s]
 54%|████████████████████▌                 | 894M/1.65G [00:14<00:12, 63.1MB/s]
 54%|████████████████████▋                 | 900M/1.65G [00:14<00:11, 63.7MB/s]
 55%|████████████████████▊                 | 907M/1.65G [00:14<00:11, 63.8MB/s]
 55%|████████████████████▉                 | 913M/1.65G [00:14<00:11, 64.1MB/s]
 56%|█████████████████████▏                | 919M/1.65G [00:14<00:11, 61.6MB/s]
 56%|█████████████████████▎                | 926M/1.65G [00:15<00:11, 62.4MB/s]
 56%|█████████████████████▍                | 932M/1.65G [00:15<00:11, 63.1MB/s]
 57%|█████████████████████▌                | 939M/1.65G [00:15<00:11, 63.7MB/s]
 57%|█████████████████████▋                | 945M/1.65G [00:15<00:11, 63.0MB/s]
 58%|█████████████████████▉                | 952M/1.65G [00:15<00:11, 63.5MB/s]
 58%|██████████████████████                | 958M/1.65G [00:15<00:10, 63.7MB/s]
 58%|██████████████████████▏               | 965M/1.65G [00:15<00:10, 63.9MB/s]
 59%|██████████████████████▎               | 971M/1.65G [00:15<00:10, 63.1MB/s]
 59%|██████████████████████▍               | 977M/1.65G [00:15<00:10, 63.3MB/s]
 60%|██████████████████████▌               | 984M/1.65G [00:15<00:10, 63.5MB/s]
 60%|██████████████████████▊               | 990M/1.65G [00:16<00:10, 63.6MB/s]
 60%|██████████████████████▉               | 996M/1.65G [00:16<00:10, 63.1MB/s]
 61%|██████████████████████▍              | 1.00G/1.65G [00:16<00:10, 63.6MB/s]
 61%|██████████████████████▌              | 1.01G/1.65G [00:16<00:10, 63.6MB/s]
 61%|██████████████████████▋              | 1.02G/1.65G [00:16<00:10, 63.4MB/s]
 62%|██████████████████████▉              | 1.02G/1.65G [00:16<00:09, 63.2MB/s]
 62%|███████████████████████              | 1.03G/1.65G [00:16<00:09, 63.6MB/s]
 63%|███████████████████████▏             | 1.03G/1.65G [00:16<00:09, 63.7MB/s]
 63%|███████████████████████▎             | 1.04G/1.65G [00:16<00:09, 63.3MB/s]
 63%|███████████████████████▍             | 1.05G/1.65G [00:16<00:09, 63.1MB/s]
 64%|███████████████████████▌             | 1.05G/1.65G [00:17<00:09, 63.4MB/s]
 64%|███████████████████████▋             | 1.06G/1.65G [00:17<00:09, 63.8MB/s]
 65%|███████████████████████▉             | 1.07G/1.65G [00:17<00:09, 63.2MB/s]
 65%|████████████████████████             | 1.07G/1.65G [00:17<00:09, 63.5MB/s]
 65%|████████████████████████▏            | 1.08G/1.65G [00:17<00:09, 63.6MB/s]
 66%|████████████████████████▎            | 1.09G/1.65G [00:17<00:08, 63.6MB/s]
 66%|████████████████████████▍            | 1.09G/1.65G [00:17<00:08, 63.6MB/s]
 66%|████████████████████████▌            | 1.10G/1.65G [00:17<00:08, 62.4MB/s]
 67%|████████████████████████▋            | 1.10G/1.65G [00:17<00:08, 62.4MB/s]
 67%|████████████████████████▉            | 1.11G/1.65G [00:17<00:08, 62.4MB/s]
 68%|█████████████████████████            | 1.12G/1.65G [00:18<00:08, 62.7MB/s]
 68%|█████████████████████████▏           | 1.12G/1.65G [00:18<00:08, 62.8MB/s]
 68%|█████████████████████████▎           | 1.13G/1.65G [00:18<00:08, 62.2MB/s]
 69%|█████████████████████████▍           | 1.14G/1.65G [00:18<00:08, 62.5MB/s]
 69%|█████████████████████████▌           | 1.14G/1.65G [00:18<00:08, 62.7MB/s]
 70%|█████████████████████████▋           | 1.15G/1.65G [00:18<00:07, 63.0MB/s]
 70%|█████████████████████████▊           | 1.16G/1.65G [00:18<00:07, 62.3MB/s]
 70%|██████████████████████████           | 1.16G/1.65G [00:18<00:07, 62.3MB/s]
 71%|██████████████████████████▏          | 1.17G/1.65G [00:18<00:07, 62.5MB/s]
 71%|██████████████████████████▎          | 1.17G/1.65G [00:19<00:07, 62.6MB/s]
 71%|██████████████████████████▍          | 1.18G/1.65G [00:19<00:07, 61.7MB/s]
 72%|██████████████████████████▌          | 1.19G/1.65G [00:19<00:07, 58.7MB/s]
 72%|██████████████████████████▋          | 1.19G/1.65G [00:19<00:08, 52.8MB/s]
 73%|██████████████████████████▊          | 1.20G/1.65G [00:19<00:08, 54.7MB/s]
 73%|██████████████████████████▉          | 1.20G/1.65G [00:19<00:07, 56.3MB/s]
 73%|███████████████████████████          | 1.21G/1.65G [00:19<00:07, 57.2MB/s]
 74%|███████████████████████████▏         | 1.22G/1.65G [00:19<00:07, 57.6MB/s]
 74%|███████████████████████████▎         | 1.22G/1.65G [00:19<00:07, 58.3MB/s]
 74%|███████████████████████████▍         | 1.23G/1.65G [00:19<00:07, 58.8MB/s]
 75%|███████████████████████████▋         | 1.23G/1.65G [00:20<00:07, 59.3MB/s]
 75%|███████████████████████████▊         | 1.24G/1.65G [00:20<00:06, 59.3MB/s]
 75%|███████████████████████████▉         | 1.25G/1.65G [00:20<00:06, 59.0MB/s]
 76%|████████████████████████████         | 1.25G/1.65G [00:20<00:06, 59.5MB/s]
 76%|████████████████████████████▏        | 1.26G/1.65G [00:20<00:06, 59.5MB/s]
 77%|████████████████████████████▎        | 1.26G/1.65G [00:20<00:06, 59.9MB/s]
 77%|████████████████████████████▍        | 1.27G/1.65G [00:20<00:06, 59.3MB/s]
 77%|████████████████████████████▌        | 1.28G/1.65G [00:20<00:06, 59.4MB/s]
 78%|████████████████████████████▋        | 1.28G/1.65G [00:20<00:06, 59.7MB/s]
 78%|████████████████████████████▊        | 1.29G/1.65G [00:20<00:06, 59.6MB/s]
 78%|████████████████████████████▉        | 1.29G/1.65G [00:21<00:05, 59.7MB/s]
 79%|█████████████████████████████        | 1.30G/1.65G [00:21<00:05, 59.2MB/s]
 79%|█████████████████████████████▏       | 1.31G/1.65G [00:21<00:05, 59.5MB/s]
 79%|█████████████████████████████▍       | 1.31G/1.65G [00:21<00:05, 59.7MB/s]
 80%|█████████████████████████████▌       | 1.32G/1.65G [00:21<00:05, 59.9MB/s]
 80%|█████████████████████████████▋       | 1.32G/1.65G [00:21<00:05, 60.2MB/s]
 81%|█████████████████████████████▊       | 1.33G/1.65G [00:21<00:05, 59.2MB/s]
 81%|█████████████████████████████▉       | 1.34G/1.65G [00:21<00:05, 59.6MB/s]
 81%|██████████████████████████████       | 1.34G/1.65G [00:21<00:05, 59.8MB/s]
 82%|██████████████████████████████▏      | 1.35G/1.65G [00:21<00:05, 59.9MB/s]
 82%|██████████████████████████████▎      | 1.35G/1.65G [00:22<00:04, 60.2MB/s]
 82%|██████████████████████████████▍      | 1.36G/1.65G [00:22<00:04, 59.5MB/s]
 83%|██████████████████████████████▌      | 1.37G/1.65G [00:22<00:04, 59.8MB/s]
 83%|██████████████████████████████▋      | 1.37G/1.65G [00:22<00:04, 59.9MB/s]
 83%|██████████████████████████████▊      | 1.38G/1.65G [00:22<00:04, 60.1MB/s]
 84%|███████████████████████████████      | 1.38G/1.65G [00:22<00:04, 60.4MB/s]
 84%|███████████████████████████████▏     | 1.39G/1.65G [00:22<00:04, 59.3MB/s]
 85%|███████████████████████████████▎     | 1.40G/1.65G [00:22<00:04, 59.3MB/s]
 85%|███████████████████████████████▍     | 1.40G/1.65G [00:22<00:04, 59.8MB/s]
 85%|███████████████████████████████▌     | 1.41G/1.65G [00:22<00:04, 59.7MB/s]
 86%|███████████████████████████████▋     | 1.42G/1.65G [00:23<00:03, 60.1MB/s]
 86%|███████████████████████████████▊     | 1.42G/1.65G [00:23<00:03, 59.4MB/s]
 86%|███████████████████████████████▉     | 1.43G/1.65G [00:23<00:03, 59.8MB/s]
 87%|████████████████████████████████     | 1.43G/1.65G [00:23<00:03, 59.9MB/s]
 87%|████████████████████████████████▏    | 1.44G/1.65G [00:23<00:03, 60.2MB/s]
 87%|████████████████████████████████▎    | 1.45G/1.65G [00:23<00:03, 60.5MB/s]
 88%|████████████████████████████████▍    | 1.45G/1.65G [00:23<00:03, 60.6MB/s]
 88%|████████████████████████████████▋    | 1.46G/1.65G [00:23<00:03, 61.4MB/s]
 89%|████████████████████████████████▊    | 1.46G/1.65G [00:23<00:03, 62.0MB/s]
 89%|████████████████████████████████▉    | 1.47G/1.65G [00:23<00:02, 62.5MB/s]
 89%|█████████████████████████████████    | 1.48G/1.65G [00:24<00:02, 61.8MB/s]
 90%|█████████████████████████████████▏   | 1.48G/1.65G [00:24<00:02, 62.3MB/s]
 90%|█████████████████████████████████▎   | 1.49G/1.65G [00:24<00:02, 62.6MB/s]
 91%|█████████████████████████████████▍   | 1.50G/1.65G [00:24<00:02, 62.8MB/s]
 91%|█████████████████████████████████▋   | 1.50G/1.65G [00:24<00:02, 63.0MB/s]
 91%|█████████████████████████████████▊   | 1.51G/1.65G [00:24<00:02, 62.3MB/s]
 92%|█████████████████████████████████▉   | 1.51G/1.65G [00:24<00:02, 62.6MB/s]
 92%|██████████████████████████████████   | 1.52G/1.65G [00:24<00:02, 62.8MB/s]
 92%|██████████████████████████████████▏  | 1.53G/1.65G [00:24<00:01, 63.1MB/s]
 93%|██████████████████████████████████▎  | 1.53G/1.65G [00:25<00:01, 62.4MB/s]
 93%|██████████████████████████████████▍  | 1.54G/1.65G [00:25<00:01, 62.4MB/s]
 94%|██████████████████████████████████▌  | 1.55G/1.65G [00:25<00:01, 62.8MB/s]
 94%|██████████████████████████████████▊  | 1.55G/1.65G [00:25<00:01, 63.3MB/s]
 94%|██████████████████████████████████▉  | 1.56G/1.65G [00:25<00:01, 63.5MB/s]
 95%|███████████████████████████████████  | 1.57G/1.65G [00:25<00:01, 63.6MB/s]
 95%|███████████████████████████████████▏ | 1.57G/1.65G [00:25<00:01, 62.7MB/s]
 96%|███████████████████████████████████▎ | 1.58G/1.65G [00:25<00:01, 63.0MB/s]
 96%|███████████████████████████████████▍ | 1.58G/1.65G [00:25<00:01, 63.1MB/s]
 96%|███████████████████████████████████▌ | 1.59G/1.65G [00:25<00:00, 63.3MB/s]
 97%|███████████████████████████████████▊ | 1.60G/1.65G [00:26<00:00, 63.5MB/s]
 97%|███████████████████████████████████▉ | 1.60G/1.65G [00:26<00:00, 62.6MB/s]
 97%|████████████████████████████████████ | 1.61G/1.65G [00:26<00:00, 63.2MB/s]
 98%|████████████████████████████████████▏| 1.62G/1.65G [00:26<00:00, 63.8MB/s]
 98%|████████████████████████████████████▎| 1.62G/1.65G [00:26<00:00, 63.6MB/s]
 99%|████████████████████████████████████▍| 1.63G/1.65G [00:26<00:00, 63.8MB/s]
 99%|████████████████████████████████████▋| 1.64G/1.65G [00:26<00:00, 62.7MB/s]
 99%|████████████████████████████████████▊| 1.64G/1.65G [00:26<00:00, 63.1MB/s]
100%|████████████████████████████████████▉| 1.65G/1.65G [00:26<00:00, 63.1MB/s]
  0%|                                              | 0.00/1.65G [00:00<?, ?B/s]
100%|█████████████████████████████████████| 1.65G/1.65G [00:00<00:00, 6.13TB/s]
Download complete in 01m03s (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 14.627 seconds)

Gallery generated by Sphinx-Gallery