Note
Go to the end to download the full example code.
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:41, 1.76MB/s]
0%| | 1.79M/1.65G [00:00<02:43, 10.1MB/s]
0%|▏ | 6.14M/1.65G [00:00<01:05, 25.2MB/s]
1%|▎ | 11.8M/1.65G [00:00<00:43, 37.7MB/s]
1%|▍ | 17.9M/1.65G [00:00<00:35, 45.8MB/s]
1%|▌ | 23.9M/1.65G [00:00<00:32, 50.8MB/s]
2%|▋ | 30.0M/1.65G [00:00<00:30, 53.9MB/s]
2%|▊ | 35.9M/1.65G [00:00<00:28, 55.8MB/s]
3%|▉ | 42.0M/1.65G [00:00<00:28, 57.4MB/s]
3%|█ | 48.2M/1.65G [00:01<00:27, 58.6MB/s]
3%|█▏ | 54.1M/1.65G [00:01<00:27, 58.9MB/s]
4%|█▎ | 60.3M/1.65G [00:01<00:26, 59.7MB/s]
4%|█▍ | 66.4M/1.65G [00:01<00:26, 60.1MB/s]
4%|█▌ | 72.4M/1.65G [00:01<00:26, 60.2MB/s]
5%|█▊ | 78.6M/1.65G [00:01<00:25, 60.7MB/s]
5%|█▉ | 84.7M/1.65G [00:01<00:25, 60.8MB/s]
5%|██ | 90.8M/1.65G [00:01<00:25, 60.9MB/s]
6%|██▏ | 96.9M/1.65G [00:01<00:25, 60.7MB/s]
6%|██▎ | 103M/1.65G [00:01<00:25, 60.7MB/s]
7%|██▌ | 109M/1.65G [00:02<00:25, 61.0MB/s]
7%|██▋ | 115M/1.65G [00:02<00:25, 61.2MB/s]
7%|██▊ | 121M/1.65G [00:02<00:25, 61.2MB/s]
8%|██▉ | 128M/1.65G [00:02<00:24, 61.5MB/s]
8%|███ | 134M/1.65G [00:02<00:24, 61.6MB/s]
8%|███▏ | 140M/1.65G [00:02<00:24, 61.5MB/s]
9%|███▎ | 146M/1.65G [00:02<00:24, 61.7MB/s]
9%|███▌ | 152M/1.65G [00:02<00:24, 61.7MB/s]
10%|███▋ | 159M/1.65G [00:02<00:24, 61.7MB/s]
10%|███▊ | 165M/1.65G [00:02<00:24, 61.7MB/s]
10%|███▉ | 171M/1.65G [00:03<00:23, 61.8MB/s]
11%|████ | 177M/1.65G [00:03<00:23, 61.6MB/s]
11%|████▏ | 183M/1.65G [00:03<00:23, 61.9MB/s]
11%|████▎ | 190M/1.65G [00:03<00:23, 62.1MB/s]
12%|████▌ | 196M/1.65G [00:03<00:23, 62.1MB/s]
12%|████▋ | 202M/1.65G [00:03<00:23, 62.2MB/s]
13%|████▊ | 208M/1.65G [00:03<00:23, 62.1MB/s]
13%|████▉ | 215M/1.65G [00:03<00:23, 61.9MB/s]
13%|█████ | 221M/1.65G [00:03<00:23, 61.7MB/s]
14%|█████▏ | 227M/1.65G [00:03<00:23, 61.6MB/s]
14%|█████▎ | 233M/1.65G [00:04<00:23, 61.6MB/s]
14%|█████▌ | 239M/1.65G [00:04<00:22, 61.6MB/s]
15%|█████▋ | 245M/1.65G [00:04<00:22, 61.7MB/s]
15%|█████▊ | 252M/1.65G [00:04<00:22, 61.7MB/s]
16%|█████▉ | 258M/1.65G [00:04<00:22, 61.7MB/s]
16%|██████ | 264M/1.65G [00:04<00:22, 61.5MB/s]
16%|██████▏ | 270M/1.65G [00:04<00:22, 61.7MB/s]
17%|██████▎ | 276M/1.65G [00:04<00:22, 61.9MB/s]
17%|██████▍ | 283M/1.65G [00:04<00:22, 61.8MB/s]
17%|██████▋ | 289M/1.65G [00:04<00:22, 61.9MB/s]
18%|██████▊ | 295M/1.65G [00:05<00:24, 55.5MB/s]
18%|██████▉ | 301M/1.65G [00:05<00:25, 52.9MB/s]
19%|███████ | 307M/1.65G [00:05<00:24, 55.0MB/s]
19%|███████▏ | 313M/1.65G [00:05<00:23, 56.9MB/s]
19%|███████▎ | 319M/1.65G [00:05<00:22, 58.1MB/s]
20%|███████▍ | 325M/1.65G [00:05<00:22, 59.1MB/s]
20%|███████▌ | 331M/1.65G [00:05<00:22, 59.9MB/s]
20%|███████▊ | 337M/1.65G [00:05<00:21, 60.3MB/s]
21%|███████▉ | 344M/1.65G [00:05<00:21, 60.7MB/s]
21%|████████ | 350M/1.65G [00:05<00:21, 60.8MB/s]
22%|████████▏ | 356M/1.65G [00:06<00:21, 61.2MB/s]
22%|████████▎ | 362M/1.65G [00:06<00:21, 61.0MB/s]
22%|████████▍ | 368M/1.65G [00:06<00:20, 61.2MB/s]
23%|████████▌ | 374M/1.65G [00:06<00:20, 61.4MB/s]
23%|████████▋ | 381M/1.65G [00:06<00:20, 61.2MB/s]
23%|████████▉ | 387M/1.65G [00:06<00:20, 61.4MB/s]
24%|█████████ | 393M/1.65G [00:06<00:20, 61.5MB/s]
24%|█████████▏ | 399M/1.65G [00:06<00:20, 61.6MB/s]
25%|█████████▎ | 405M/1.65G [00:06<00:20, 61.7MB/s]
25%|█████████▍ | 412M/1.65G [00:06<00:20, 61.8MB/s]
25%|█████████▌ | 418M/1.65G [00:07<00:20, 61.3MB/s]
26%|█████████▋ | 424M/1.65G [00:07<00:19, 61.8MB/s]
26%|█████████▉ | 430M/1.65G [00:07<00:19, 61.9MB/s]
26%|██████████ | 436M/1.65G [00:07<00:19, 61.6MB/s]
27%|██████████▏ | 443M/1.65G [00:07<00:19, 61.8MB/s]
27%|██████████▎ | 449M/1.65G [00:07<00:19, 62.1MB/s]
28%|██████████▍ | 455M/1.65G [00:07<00:19, 62.2MB/s]
28%|██████████▌ | 461M/1.65G [00:07<00:19, 62.0MB/s]
28%|██████████▋ | 468M/1.65G [00:07<00:19, 61.9MB/s]
29%|██████████▉ | 474M/1.65G [00:07<00:19, 61.8MB/s]
29%|███████████ | 480M/1.65G [00:08<00:18, 62.0MB/s]
29%|███████████▏ | 486M/1.65G [00:08<00:18, 62.0MB/s]
30%|███████████▎ | 492M/1.65G [00:08<00:18, 62.0MB/s]
30%|███████████▍ | 499M/1.65G [00:08<00:18, 62.0MB/s]
31%|███████████▌ | 505M/1.65G [00:08<00:18, 61.8MB/s]
31%|███████████▊ | 511M/1.65G [00:08<00:18, 62.1MB/s]
31%|███████████▉ | 517M/1.65G [00:08<00:18, 62.0MB/s]
32%|████████████ | 523M/1.65G [00:08<00:18, 61.9MB/s]
32%|████████████▏ | 530M/1.65G [00:08<00:18, 61.8MB/s]
32%|████████████▎ | 536M/1.65G [00:08<00:18, 61.4MB/s]
33%|████████████▍ | 542M/1.65G [00:09<00:18, 60.6MB/s]
33%|████████████▌ | 548M/1.65G [00:09<00:18, 60.9MB/s]
34%|████████████▋ | 554M/1.65G [00:09<00:17, 61.1MB/s]
34%|████████████▉ | 560M/1.65G [00:09<00:17, 61.0MB/s]
34%|█████████████ | 567M/1.65G [00:09<00:17, 60.6MB/s]
35%|█████████████▏ | 573M/1.65G [00:09<00:17, 60.9MB/s]
35%|█████████████▎ | 579M/1.65G [00:09<00:17, 61.1MB/s]
35%|█████████████▍ | 585M/1.65G [00:09<00:17, 61.0MB/s]
36%|█████████████▌ | 591M/1.65G [00:09<00:17, 61.0MB/s]
36%|█████████████▋ | 597M/1.65G [00:09<00:17, 61.0MB/s]
37%|█████████████▊ | 603M/1.65G [00:10<00:17, 60.5MB/s]
37%|██████████████ | 609M/1.65G [00:10<00:17, 61.0MB/s]
37%|██████████████▏ | 616M/1.65G [00:10<00:18, 56.7MB/s]
38%|██████████████▎ | 621M/1.65G [00:10<00:18, 56.9MB/s]
38%|██████████████▍ | 627M/1.65G [00:10<00:17, 57.9MB/s]
38%|██████████████▌ | 633M/1.65G [00:10<00:17, 58.3MB/s]
39%|██████████████▋ | 639M/1.65G [00:10<00:17, 58.8MB/s]
39%|██████████████▊ | 645M/1.65G [00:10<00:16, 59.5MB/s]
39%|██████████████▉ | 652M/1.65G [00:10<00:16, 60.1MB/s]
40%|███████████████ | 658M/1.65G [00:11<00:16, 59.8MB/s]
40%|███████████████▎ | 664M/1.65G [00:11<00:16, 59.7MB/s]
41%|███████████████▍ | 670M/1.65G [00:11<00:16, 60.3MB/s]
41%|███████████████▌ | 676M/1.65G [00:11<00:16, 60.5MB/s]
41%|███████████████▋ | 682M/1.65G [00:11<00:16, 60.5MB/s]
42%|███████████████▊ | 688M/1.65G [00:11<00:16, 60.1MB/s]
42%|███████████████▉ | 694M/1.65G [00:11<00:15, 60.5MB/s]
42%|████████████████ | 700M/1.65G [00:11<00:15, 60.8MB/s]
43%|████████████████▏ | 706M/1.65G [00:11<00:15, 61.1MB/s]
43%|████████████████▍ | 713M/1.65G [00:11<00:15, 60.2MB/s]
43%|████████████████▌ | 719M/1.65G [00:12<00:15, 59.1MB/s]
44%|████████████████▋ | 725M/1.65G [00:12<00:15, 59.9MB/s]
44%|████████████████▊ | 731M/1.65G [00:12<00:15, 60.5MB/s]
45%|████████████████▉ | 737M/1.65G [00:12<00:15, 60.2MB/s]
45%|█████████████████ | 743M/1.65G [00:12<00:15, 60.6MB/s]
45%|█████████████████▏ | 749M/1.65G [00:12<00:14, 60.8MB/s]
46%|█████████████████▎ | 755M/1.65G [00:12<00:14, 61.1MB/s]
46%|█████████████████▌ | 762M/1.65G [00:12<00:14, 60.6MB/s]
46%|█████████████████▋ | 768M/1.65G [00:12<00:14, 60.8MB/s]
47%|█████████████████▊ | 774M/1.65G [00:12<00:14, 61.2MB/s]
47%|█████████████████▉ | 780M/1.65G [00:13<00:14, 61.1MB/s]
48%|██████████████████ | 786M/1.65G [00:13<00:14, 60.4MB/s]
48%|██████████████████▏ | 792M/1.65G [00:13<00:14, 60.8MB/s]
48%|██████████████████▎ | 798M/1.65G [00:13<00:14, 60.5MB/s]
49%|██████████████████▍ | 805M/1.65G [00:13<00:13, 60.7MB/s]
49%|██████████████████▋ | 811M/1.65G [00:13<00:14, 60.1MB/s]
49%|██████████████████▊ | 817M/1.65G [00:13<00:13, 60.5MB/s]
50%|██████████████████▉ | 823M/1.65G [00:13<00:13, 60.6MB/s]
50%|███████████████████ | 829M/1.65G [00:13<00:13, 61.0MB/s]
51%|███████████████████▏ | 835M/1.65G [00:13<00:13, 60.0MB/s]
51%|███████████████████▎ | 841M/1.65G [00:14<00:13, 60.3MB/s]
51%|███████████████████▍ | 847M/1.65G [00:14<00:13, 60.6MB/s]
52%|███████████████████▌ | 853M/1.65G [00:14<00:13, 60.8MB/s]
52%|███████████████████▊ | 860M/1.65G [00:14<00:13, 60.3MB/s]
52%|███████████████████▉ | 866M/1.65G [00:14<00:13, 60.5MB/s]
53%|████████████████████ | 872M/1.65G [00:14<00:12, 60.4MB/s]
53%|████████████████████▏ | 878M/1.65G [00:14<00:12, 60.4MB/s]
53%|████████████████████▎ | 884M/1.65G [00:14<00:12, 59.8MB/s]
54%|████████████████████▍ | 890M/1.65G [00:14<00:12, 60.1MB/s]
54%|████████████████████▌ | 896M/1.65G [00:14<00:12, 60.4MB/s]
55%|████████████████████▋ | 902M/1.65G [00:15<00:12, 60.4MB/s]
55%|████████████████████▉ | 908M/1.65G [00:15<00:12, 60.3MB/s]
55%|█████████████████████ | 914M/1.65G [00:15<00:12, 60.4MB/s]
56%|█████████████████████▏ | 920M/1.65G [00:15<00:12, 60.5MB/s]
56%|█████████████████████▎ | 926M/1.65G [00:15<00:11, 60.8MB/s]
56%|█████████████████████▍ | 932M/1.65G [00:15<00:11, 60.5MB/s]
57%|█████████████████████▌ | 938M/1.65G [00:15<00:11, 60.0MB/s]
57%|█████████████████████▋ | 945M/1.65G [00:15<00:11, 60.1MB/s]
58%|█████████████████████▊ | 951M/1.65G [00:15<00:11, 60.3MB/s]
58%|█████████████████████▉ | 957M/1.65G [00:15<00:11, 60.0MB/s]
58%|██████████████████████▏ | 963M/1.65G [00:16<00:11, 59.5MB/s]
59%|██████████████████████▎ | 969M/1.65G [00:16<00:11, 59.7MB/s]
59%|██████████████████████▍ | 975M/1.65G [00:16<00:11, 59.9MB/s]
59%|██████████████████████▌ | 981M/1.65G [00:16<00:11, 60.0MB/s]
60%|██████████████████████▋ | 987M/1.65G [00:16<00:11, 59.1MB/s]
60%|██████████████████████▊ | 993M/1.65G [00:16<00:11, 59.6MB/s]
60%|██████████████████████▉ | 999M/1.65G [00:16<00:11, 59.3MB/s]
61%|██████████████████████▍ | 1.00G/1.65G [00:16<00:10, 59.5MB/s]
61%|██████████████████████▋ | 1.01G/1.65G [00:16<00:10, 59.3MB/s]
62%|██████████████████████▊ | 1.02G/1.65G [00:16<00:10, 59.5MB/s]
62%|██████████████████████▉ | 1.02G/1.65G [00:17<00:10, 59.3MB/s]
62%|███████████████████████ | 1.03G/1.65G [00:17<00:10, 59.9MB/s]
63%|███████████████████████▏ | 1.03G/1.65G [00:17<00:10, 60.3MB/s]
63%|███████████████████████▎ | 1.04G/1.65G [00:17<00:10, 58.4MB/s]
63%|███████████████████████▍ | 1.05G/1.65G [00:17<00:10, 56.6MB/s]
64%|███████████████████████▌ | 1.05G/1.65G [00:17<00:10, 57.4MB/s]
64%|███████████████████████▋ | 1.06G/1.65G [00:17<00:10, 57.8MB/s]
64%|███████████████████████▊ | 1.06G/1.65G [00:17<00:10, 58.1MB/s]
65%|███████████████████████▉ | 1.07G/1.65G [00:17<00:09, 58.5MB/s]
65%|████████████████████████ | 1.08G/1.65G [00:18<00:09, 58.4MB/s]
65%|████████████████████████▏ | 1.08G/1.65G [00:18<00:09, 58.5MB/s]
66%|████████████████████████▎ | 1.09G/1.65G [00:18<00:09, 58.2MB/s]
66%|████████████████████████▍ | 1.09G/1.65G [00:18<00:09, 58.2MB/s]
67%|████████████████████████▌ | 1.10G/1.65G [00:18<00:09, 58.1MB/s]
67%|████████████████████████▋ | 1.11G/1.65G [00:18<00:09, 57.9MB/s]
67%|████████████████████████▉ | 1.11G/1.65G [00:18<00:09, 57.9MB/s]
68%|█████████████████████████ | 1.12G/1.65G [00:18<00:09, 57.9MB/s]
68%|█████████████████████████▏ | 1.12G/1.65G [00:18<00:09, 57.9MB/s]
68%|█████████████████████████▎ | 1.13G/1.65G [00:18<00:09, 58.2MB/s]
69%|█████████████████████████▍ | 1.13G/1.65G [00:19<00:08, 58.4MB/s]
69%|█████████████████████████▌ | 1.14G/1.65G [00:19<00:08, 58.4MB/s]
69%|█████████████████████████▋ | 1.15G/1.65G [00:19<00:08, 59.0MB/s]
70%|█████████████████████████▊ | 1.15G/1.65G [00:19<00:08, 59.6MB/s]
70%|█████████████████████████▉ | 1.16G/1.65G [00:19<00:08, 59.8MB/s]
70%|██████████████████████████ | 1.16G/1.65G [00:19<00:08, 60.2MB/s]
71%|██████████████████████████▏ | 1.17G/1.65G [00:19<00:08, 59.9MB/s]
71%|██████████████████████████▎ | 1.18G/1.65G [00:19<00:07, 60.0MB/s]
72%|██████████████████████████▍ | 1.18G/1.65G [00:19<00:07, 59.8MB/s]
72%|██████████████████████████▌ | 1.19G/1.65G [00:19<00:07, 59.7MB/s]
72%|██████████████████████████▋ | 1.19G/1.65G [00:20<00:07, 59.3MB/s]
73%|██████████████████████████▉ | 1.20G/1.65G [00:20<00:07, 58.9MB/s]
73%|███████████████████████████ | 1.21G/1.65G [00:20<00:07, 58.7MB/s]
73%|███████████████████████████▏ | 1.21G/1.65G [00:20<00:07, 58.8MB/s]
74%|███████████████████████████▎ | 1.22G/1.65G [00:20<00:07, 58.8MB/s]
74%|███████████████████████████▍ | 1.22G/1.65G [00:20<00:07, 58.8MB/s]
74%|███████████████████████████▌ | 1.23G/1.65G [00:20<00:07, 58.8MB/s]
75%|███████████████████████████▋ | 1.24G/1.65G [00:20<00:07, 58.6MB/s]
75%|███████████████████████████▊ | 1.24G/1.65G [00:20<00:07, 58.6MB/s]
76%|███████████████████████████▉ | 1.25G/1.65G [00:20<00:06, 58.9MB/s]
76%|████████████████████████████ | 1.25G/1.65G [00:21<00:06, 58.9MB/s]
76%|████████████████████████████▏ | 1.26G/1.65G [00:21<00:06, 58.6MB/s]
77%|████████████████████████████▎ | 1.27G/1.65G [00:21<00:06, 59.3MB/s]
77%|████████████████████████████▍ | 1.27G/1.65G [00:21<00:06, 59.6MB/s]
77%|████████████████████████████▌ | 1.28G/1.65G [00:21<00:06, 59.9MB/s]
78%|████████████████████████████▋ | 1.28G/1.65G [00:21<00:06, 60.4MB/s]
78%|████████████████████████████▉ | 1.29G/1.65G [00:21<00:05, 60.5MB/s]
78%|█████████████████████████████ | 1.30G/1.65G [00:21<00:05, 60.6MB/s]
79%|█████████████████████████████▏ | 1.30G/1.65G [00:21<00:05, 60.4MB/s]
79%|█████████████████████████████▎ | 1.31G/1.65G [00:21<00:05, 60.3MB/s]
80%|█████████████████████████████▍ | 1.31G/1.65G [00:22<00:05, 60.3MB/s]
80%|█████████████████████████████▌ | 1.32G/1.65G [00:22<00:05, 60.4MB/s]
80%|█████████████████████████████▋ | 1.33G/1.65G [00:22<00:05, 60.2MB/s]
81%|█████████████████████████████▊ | 1.33G/1.65G [00:22<00:05, 60.5MB/s]
81%|█████████████████████████████▉ | 1.34G/1.65G [00:22<00:05, 60.8MB/s]
81%|██████████████████████████████ | 1.34G/1.65G [00:22<00:05, 60.7MB/s]
82%|██████████████████████████████▏ | 1.35G/1.65G [00:22<00:04, 60.9MB/s]
82%|██████████████████████████████▍ | 1.36G/1.65G [00:22<00:04, 60.5MB/s]
82%|██████████████████████████████▌ | 1.36G/1.65G [00:22<00:04, 60.5MB/s]
83%|██████████████████████████████▋ | 1.37G/1.65G [00:22<00:04, 60.7MB/s]
83%|██████████████████████████████▊ | 1.38G/1.65G [00:23<00:04, 60.7MB/s]
84%|██████████████████████████████▉ | 1.38G/1.65G [00:23<00:04, 59.3MB/s]
84%|███████████████████████████████ | 1.39G/1.65G [00:23<00:04, 59.9MB/s]
84%|███████████████████████████████▏ | 1.39G/1.65G [00:23<00:04, 60.1MB/s]
85%|███████████████████████████████▎ | 1.40G/1.65G [00:23<00:04, 60.1MB/s]
85%|███████████████████████████████▍ | 1.41G/1.65G [00:23<00:04, 60.3MB/s]
85%|███████████████████████████████▌ | 1.41G/1.65G [00:23<00:04, 60.3MB/s]
86%|███████████████████████████████▋ | 1.42G/1.65G [00:23<00:03, 59.0MB/s]
86%|███████████████████████████████▊ | 1.42G/1.65G [00:23<00:03, 59.4MB/s]
86%|████████████████████████████████ | 1.43G/1.65G [00:23<00:03, 59.2MB/s]
87%|████████████████████████████████▏ | 1.44G/1.65G [00:24<00:03, 59.3MB/s]
87%|████████████████████████████████▎ | 1.44G/1.65G [00:24<00:03, 59.7MB/s]
88%|████████████████████████████████▍ | 1.45G/1.65G [00:24<00:03, 60.1MB/s]
88%|████████████████████████████████▌ | 1.45G/1.65G [00:24<00:03, 60.1MB/s]
88%|████████████████████████████████▋ | 1.46G/1.65G [00:24<00:03, 57.7MB/s]
89%|████████████████████████████████▊ | 1.47G/1.65G [00:24<00:03, 56.7MB/s]
89%|████████████████████████████████▉ | 1.47G/1.65G [00:24<00:03, 57.3MB/s]
89%|█████████████████████████████████ | 1.48G/1.65G [00:24<00:03, 57.8MB/s]
90%|█████████████████████████████████▏ | 1.48G/1.65G [00:24<00:02, 58.1MB/s]
90%|█████████████████████████████████▎ | 1.49G/1.65G [00:24<00:02, 58.0MB/s]
90%|█████████████████████████████████▍ | 1.49G/1.65G [00:25<00:02, 57.9MB/s]
91%|█████████████████████████████████▌ | 1.50G/1.65G [00:25<00:02, 58.2MB/s]
91%|█████████████████████████████████▋ | 1.51G/1.65G [00:25<00:02, 52.8MB/s]
92%|█████████████████████████████████▊ | 1.51G/1.65G [00:25<00:02, 54.8MB/s]
92%|█████████████████████████████████▉ | 1.52G/1.65G [00:25<00:02, 56.4MB/s]
92%|██████████████████████████████████▏ | 1.52G/1.65G [00:25<00:02, 57.8MB/s]
93%|██████████████████████████████████▎ | 1.53G/1.65G [00:25<00:02, 58.8MB/s]
93%|██████████████████████████████████▍ | 1.54G/1.65G [00:25<00:01, 59.4MB/s]
93%|██████████████████████████████████▌ | 1.54G/1.65G [00:25<00:01, 59.8MB/s]
94%|██████████████████████████████████▋ | 1.55G/1.65G [00:26<00:01, 59.7MB/s]
94%|██████████████████████████████████▊ | 1.56G/1.65G [00:26<00:01, 60.2MB/s]
94%|██████████████████████████████████▉ | 1.56G/1.65G [00:26<00:01, 56.4MB/s]
95%|███████████████████████████████████ | 1.57G/1.65G [00:26<00:01, 52.9MB/s]
95%|███████████████████████████████████▏ | 1.57G/1.65G [00:26<00:01, 54.7MB/s]
96%|███████████████████████████████████▎ | 1.58G/1.65G [00:26<00:01, 56.2MB/s]
96%|███████████████████████████████████▍ | 1.58G/1.65G [00:26<00:01, 57.3MB/s]
96%|███████████████████████████████████▌ | 1.59G/1.65G [00:26<00:01, 58.2MB/s]
97%|███████████████████████████████████▊ | 1.60G/1.65G [00:26<00:00, 59.1MB/s]
97%|███████████████████████████████████▉ | 1.60G/1.65G [00:26<00:00, 59.8MB/s]
97%|████████████████████████████████████ | 1.61G/1.65G [00:27<00:00, 58.2MB/s]
98%|████████████████████████████████████▏| 1.62G/1.65G [00:27<00:00, 58.7MB/s]
98%|████████████████████████████████████▎| 1.62G/1.65G [00:27<00:00, 59.5MB/s]
98%|████████████████████████████████████▍| 1.63G/1.65G [00:27<00:00, 59.8MB/s]
99%|████████████████████████████████████▌| 1.63G/1.65G [00:27<00:00, 59.8MB/s]
99%|████████████████████████████████████▋| 1.64G/1.65G [00:27<00:00, 59.4MB/s]
100%|████████████████████████████████████▊| 1.65G/1.65G [00:27<00:00, 59.8MB/s]
100%|████████████████████████████████████▉| 1.65G/1.65G [00:27<00:00, 60.2MB/s]
0%| | 0.00/1.65G [00:00<?, ?B/s]
100%|█████████████████████████████████████| 1.65G/1.65G [00:00<00:00, 6.63TB/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()

Locally Linear Embedding (LLE)¶
plot_embedding(covs, ytest, metric="riemann", embd_type="LocallyLinear",
normalize=False)
plt.show()

TNSE¶
plot_embedding(covs, ytest, metric="riemann", embd_type="TSNE",
normalize=False, max_iter=50)
plt.show()

/home/docs/checkouts/readthedocs.org/user_builds/pyriemann/checkouts/v0.12/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.752 seconds)