Spatiotemporal permutation F-test on full sensor data#

Tests for differential evoked responses in at least one condition using a permutation clustering test. The FieldTrip neighbor templates will be used to determine the adjacency between sensors. This serves as a spatial prior to the clustering. Spatiotemporal clusters will then be visualized using custom matplotlib code.

See the FieldTrip website for a caveat regarding the possible interpretation of “significant” clusters.

# Authors: Denis Engemann <denis.engemann@gmail.com>
#          Jona Sassenhagen <jona.sassenhagen@gmail.com>
#          Alex Rockhill <aprockhill@mailbox.org>
#
# License: BSD-3-Clause
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.axes_grid1 import make_axes_locatable

import mne
from mne.stats import spatio_temporal_cluster_test, combine_adjacency
from mne.datasets import sample
from mne.channels import find_ch_adjacency
from mne.viz import plot_compare_evokeds
from mne.time_frequency import tfr_morlet

print(__doc__)

Set parameters#

data_path = sample.data_path()
meg_path = data_path / 'MEG' / 'sample'
raw_fname = meg_path / 'sample_audvis_filt-0-40_raw.fif'
event_fname = meg_path / 'sample_audvis_filt-0-40_raw-eve.fif'
event_id = {'Aud/L': 1, 'Aud/R': 2, 'Vis/L': 3, 'Vis/R': 4}
tmin = -0.2
tmax = 0.5

# Setup for reading the raw data
raw = mne.io.read_raw_fif(raw_fname, preload=True)
raw.filter(1, 30, fir_design='firwin')
events = mne.read_events(event_fname)
Opening raw data file /home/circleci/mne_data/MNE-sample-data/MEG/sample/sample_audvis_filt-0-40_raw.fif...
    Read a total of 4 projection items:
        PCA-v1 (1 x 102)  idle
        PCA-v2 (1 x 102)  idle
        PCA-v3 (1 x 102)  idle
        Average EEG reference (1 x 60)  idle
    Range : 6450 ... 48149 =     42.956 ...   320.665 secs
Ready.
Reading 0 ... 41699  =      0.000 ...   277.709 secs...
Filtering raw data in 1 contiguous segment
Setting up band-pass filter from 1 - 30 Hz

FIR filter parameters
---------------------
Designing a one-pass, zero-phase, non-causal bandpass filter:
- Windowed time-domain design (firwin) method
- Hamming window with 0.0194 passband ripple and 53 dB stopband attenuation
- Lower passband edge: 1.00
- Lower transition bandwidth: 1.00 Hz (-6 dB cutoff frequency: 0.50 Hz)
- Upper passband edge: 30.00 Hz
- Upper transition bandwidth: 7.50 Hz (-6 dB cutoff frequency: 33.75 Hz)
- Filter length: 497 samples (3.310 sec)

[Parallel(n_jobs=1)]: Using backend SequentialBackend with 1 concurrent workers.
[Parallel(n_jobs=1)]: Done   1 out of   1 | elapsed:    0.0s remaining:    0.0s
[Parallel(n_jobs=1)]: Done   2 out of   2 | elapsed:    0.0s remaining:    0.0s
[Parallel(n_jobs=1)]: Done   3 out of   3 | elapsed:    0.0s remaining:    0.0s
[Parallel(n_jobs=1)]: Done   4 out of   4 | elapsed:    0.0s remaining:    0.0s
[Parallel(n_jobs=1)]: Done 366 out of 366 | elapsed:    0.7s finished

Read epochs for the channel of interest#

picks = mne.pick_types(raw.info, meg='mag', eog=True)

reject = dict(mag=4e-12, eog=150e-6)
epochs = mne.Epochs(raw, events, event_id, tmin, tmax, picks=picks,
                    baseline=None, reject=reject, preload=True)

epochs.drop_channels(['EOG 061'])
epochs.equalize_event_counts(event_id)

X = [epochs[k].get_data() for k in event_id]  # as 3D matrix
X = [np.transpose(x, (0, 2, 1)) for x in X]  # transpose for clustering
Not setting metadata
288 matching events found
No baseline correction applied
Created an SSP operator (subspace dimension = 3)
4 projection items activated
Using data from preloaded Raw for 288 events and 106 original time points ...
    Rejecting  epoch based on EOG : ['EOG 061']
    Rejecting  epoch based on EOG : ['EOG 061']
    Rejecting  epoch based on EOG : ['EOG 061']
    Rejecting  epoch based on EOG : ['EOG 061']
    Rejecting  epoch based on EOG : ['EOG 061']
    Rejecting  epoch based on EOG : ['EOG 061']
    Rejecting  epoch based on EOG : ['EOG 061']
    Rejecting  epoch based on EOG : ['EOG 061']
    Rejecting  epoch based on EOG : ['EOG 061']
    Rejecting  epoch based on EOG : ['EOG 061']
    Rejecting  epoch based on EOG : ['EOG 061']
    Rejecting  epoch based on EOG : ['EOG 061']
    Rejecting  epoch based on EOG : ['EOG 061']
    Rejecting  epoch based on EOG : ['EOG 061']
    Rejecting  epoch based on EOG : ['EOG 061']
    Rejecting  epoch based on MAG : ['MEG 1711']
    Rejecting  epoch based on EOG : ['EOG 061']
    Rejecting  epoch based on EOG : ['EOG 061']
    Rejecting  epoch based on EOG : ['EOG 061']
    Rejecting  epoch based on EOG : ['EOG 061']
    Rejecting  epoch based on EOG : ['EOG 061']
    Rejecting  epoch based on MAG : ['MEG 1711']
    Rejecting  epoch based on EOG : ['EOG 061']
    Rejecting  epoch based on EOG : ['EOG 061']
    Rejecting  epoch based on EOG : ['EOG 061']
    Rejecting  epoch based on EOG : ['EOG 061']
    Rejecting  epoch based on EOG : ['EOG 061']
    Rejecting  epoch based on EOG : ['EOG 061']
    Rejecting  epoch based on EOG : ['EOG 061']
    Rejecting  epoch based on EOG : ['EOG 061']
    Rejecting  epoch based on EOG : ['EOG 061']
    Rejecting  epoch based on EOG : ['EOG 061']
    Rejecting  epoch based on EOG : ['EOG 061']
    Rejecting  epoch based on EOG : ['EOG 061']
    Rejecting  epoch based on EOG : ['EOG 061']
    Rejecting  epoch based on EOG : ['EOG 061']
    Rejecting  epoch based on EOG : ['EOG 061']
    Rejecting  epoch based on EOG : ['EOG 061']
    Rejecting  epoch based on EOG : ['EOG 061']
    Rejecting  epoch based on EOG : ['EOG 061']
    Rejecting  epoch based on EOG : ['EOG 061']
    Rejecting  epoch based on EOG : ['EOG 061']
    Rejecting  epoch based on EOG : ['EOG 061']
    Rejecting  epoch based on EOG : ['EOG 061']
    Rejecting  epoch based on EOG : ['EOG 061']
    Rejecting  epoch based on EOG : ['EOG 061']
    Rejecting  epoch based on EOG : ['EOG 061']
    Rejecting  epoch based on EOG : ['EOG 061']
    Rejecting  epoch based on EOG : ['EOG 061']
49 bad epochs dropped
Removing projector <Projection | Average EEG reference, active : True, n_channels : 60>
Dropped 19 epochs: 50, 51, 84, 93, 95, 96, 129, 146, 149, 150, 154, 156, 157, 189, 194, 200, 202, 210, 211

Find the FieldTrip neighbor definition to setup sensor adjacency#

adjacency, ch_names = find_ch_adjacency(epochs.info, ch_type='mag')

print(type(adjacency))  # it's a sparse matrix!

fig, ax = plt.subplots(figsize=(5, 4))
ax.imshow(adjacency.toarray(), cmap='gray', origin='lower',
          interpolation='nearest')
ax.set_xlabel('{} Magnetometers'.format(len(ch_names)))
ax.set_ylabel('{} Magnetometers'.format(len(ch_names)))
ax.set_title('Between-sensor adjacency')
fig.tight_layout()
Between-sensor adjacency
Reading adjacency matrix for neuromag306mag.
<class 'scipy.sparse._csr.csr_matrix'>

Compute permutation statistic#

How does it work? We use clustering to “bind” together features which are similar. Our features are the magnetic fields measured over our sensor array at different times. This reduces the multiple comparison problem. To compute the actual test-statistic, we first sum all F-values in all clusters. We end up with one statistic for each cluster. Then we generate a distribution from the data by shuffling our conditions between our samples and recomputing our clusters and the test statistics. We test for the significance of a given cluster by computing the probability of observing a cluster of that size. For more background read: Maris/Oostenveld (2007), “Nonparametric statistical testing of EEG- and MEG-data” Journal of Neuroscience Methods, Vol. 164, No. 1., pp. 177-190. doi:10.1016/j.jneumeth.2007.03.024

# set cluster threshold
threshold = 50.0  # very high, but the test is quite sensitive on this data
# set family-wise p-value
p_accept = 0.01

cluster_stats = spatio_temporal_cluster_test(X, n_permutations=1000,
                                             threshold=threshold, tail=1,
                                             n_jobs=None, buffer_size=None,
                                             adjacency=adjacency)

F_obs, clusters, p_values, _ = cluster_stats
good_cluster_inds = np.where(p_values < p_accept)[0]
stat_fun(H1): min=0.004107 max=196.094418
Running initial clustering
Found 8 clusters
Permuting 999 times...

  0%|          |  : 0/999 [00:00<?,       ?it/s]
  0%|          |  : 1/999 [00:00<00:34,   29.18it/s]
  0%|          |  : 3/999 [00:00<00:22,   44.38it/s]
  1%|          |  : 6/999 [00:00<00:16,   59.82it/s]
  1%|          |  : 9/999 [00:00<00:14,   67.59it/s]
  1%|1         |  : 12/999 [00:00<00:13,   72.21it/s]
  2%|1         |  : 15/999 [00:00<00:13,   75.30it/s]
  2%|1         |  : 18/999 [00:00<00:12,   77.52it/s]
  2%|2         |  : 21/999 [00:00<00:12,   79.14it/s]
  2%|2         |  : 24/999 [00:00<00:12,   80.40it/s]
  3%|2         |  : 27/999 [00:00<00:11,   81.43it/s]
  3%|3         |  : 30/999 [00:00<00:11,   82.29it/s]
  3%|3         |  : 33/999 [00:00<00:11,   82.99it/s]
  4%|3         |  : 36/999 [00:00<00:11,   83.57it/s]
  4%|3         |  : 39/999 [00:00<00:11,   84.07it/s]
  4%|4         |  : 42/999 [00:00<00:11,   84.48it/s]
  5%|4         |  : 45/999 [00:00<00:11,   84.86it/s]
  5%|4         |  : 48/999 [00:00<00:11,   85.20it/s]
  5%|5         |  : 51/999 [00:00<00:11,   85.49it/s]
  5%|5         |  : 54/999 [00:00<00:11,   85.74it/s]
  6%|5         |  : 57/999 [00:00<00:10,   85.96it/s]
  6%|6         |  : 60/999 [00:00<00:10,   86.15it/s]
  6%|6         |  : 63/999 [00:00<00:10,   86.34it/s]
  7%|6         |  : 66/999 [00:00<00:10,   86.52it/s]
  7%|6         |  : 69/999 [00:00<00:10,   86.67it/s]
  7%|7         |  : 72/999 [00:00<00:10,   86.78it/s]
  8%|7         |  : 76/999 [00:00<00:10,   88.91it/s]
  8%|7         |  : 79/999 [00:00<00:10,   88.90it/s]
  8%|8         |  : 82/999 [00:00<00:10,   88.89it/s]
  9%|8         |  : 85/999 [00:00<00:10,   88.89it/s]
  9%|8         |  : 87/999 [00:01<00:10,   86.98it/s]
  9%|9         |  : 91/999 [00:01<00:10,   88.93it/s]
  9%|9         |  : 94/999 [00:01<00:10,   88.90it/s]
 10%|9         |  : 97/999 [00:01<00:10,   88.87it/s]
 10%|#         |  : 100/999 [00:01<00:10,   88.85it/s]
 10%|#         |  : 103/999 [00:01<00:10,   88.84it/s]
 11%|#         |  : 106/999 [00:01<00:10,   88.83it/s]
 11%|#         |  : 109/999 [00:01<00:10,   88.82it/s]
 11%|#1        |  : 112/999 [00:01<00:09,   88.81it/s]
 12%|#1        |  : 115/999 [00:01<00:09,   88.80it/s]
 12%|#1        |  : 118/999 [00:01<00:09,   88.79it/s]
 12%|#2        |  : 121/999 [00:01<00:09,   88.79it/s]
 12%|#2        |  : 124/999 [00:01<00:09,   88.79it/s]
 13%|#2        |  : 127/999 [00:01<00:09,   88.78it/s]
 13%|#3        |  : 130/999 [00:01<00:09,   88.78it/s]
 13%|#3        |  : 133/999 [00:01<00:09,   88.77it/s]
 14%|#3        |  : 136/999 [00:01<00:09,   88.77it/s]
 14%|#3        |  : 139/999 [00:01<00:09,   88.77it/s]
 14%|#4        |  : 142/999 [00:01<00:09,   88.77it/s]
 15%|#4        |  : 145/999 [00:01<00:09,   88.77it/s]
 15%|#4        |  : 148/999 [00:01<00:09,   88.76it/s]
 15%|#5        |  : 151/999 [00:01<00:09,   88.76it/s]
 15%|#5        |  : 154/999 [00:01<00:09,   88.75it/s]
 16%|#5        |  : 157/999 [00:01<00:09,   88.75it/s]
 16%|#6        |  : 160/999 [00:01<00:09,   88.75it/s]
 16%|#6        |  : 163/999 [00:01<00:09,   88.73it/s]
 17%|#6        |  : 166/999 [00:01<00:09,   88.73it/s]
 17%|#7        |  : 170/999 [00:01<00:09,   90.30it/s]
 17%|#7        |  : 173/999 [00:01<00:09,   90.22it/s]
 18%|#7        |  : 176/999 [00:01<00:09,   90.14it/s]
 18%|#7        |  : 179/999 [00:02<00:09,   90.07it/s]
 18%|#8        |  : 182/999 [00:02<00:09,   90.00it/s]
 19%|#8        |  : 186/999 [00:02<00:08,   91.48it/s]
 19%|#8        |  : 189/999 [00:02<00:08,   91.32it/s]
 19%|#9        |  : 192/999 [00:02<00:08,   91.18it/s]
 20%|#9        |  : 195/999 [00:02<00:08,   91.04it/s]
 20%|#9        |  : 198/999 [00:02<00:08,   90.93it/s]
 20%|##        |  : 201/999 [00:02<00:08,   90.81it/s]
 20%|##        |  : 204/999 [00:02<00:08,   90.71it/s]
 21%|##        |  : 207/999 [00:02<00:08,   90.61it/s]
 21%|##1       |  : 211/999 [00:02<00:08,   92.04it/s]
 21%|##1       |  : 214/999 [00:02<00:08,   91.87it/s]
 22%|##1       |  : 217/999 [00:02<00:08,   91.71it/s]
 22%|##2       |  : 220/999 [00:02<00:08,   91.55it/s]
 22%|##2       |  : 223/999 [00:02<00:08,   91.41it/s]
 23%|##2       |  : 226/999 [00:02<00:08,   91.27it/s]
 23%|##3       |  : 230/999 [00:02<00:08,   92.65it/s]
 23%|##3       |  : 233/999 [00:02<00:08,   92.43it/s]
 24%|##3       |  : 236/999 [00:02<00:08,   92.22it/s]
 24%|##3       |  : 239/999 [00:02<00:08,   92.04it/s]
 24%|##4       |  : 242/999 [00:02<00:08,   91.86it/s]
 25%|##4       |  : 245/999 [00:02<00:08,   91.69it/s]
 25%|##4       |  : 248/999 [00:02<00:08,   91.54it/s]
 25%|##5       |  : 251/999 [00:02<00:08,   91.41it/s]
 26%|##5       |  : 255/999 [00:02<00:08,   92.77it/s]
 26%|##5       |  : 258/999 [00:02<00:08,   92.57it/s]
 26%|##6       |  : 261/999 [00:02<00:07,   92.36it/s]
 26%|##6       |  : 264/999 [00:02<00:07,   92.17it/s]
 27%|##6       |  : 267/999 [00:02<00:07,   91.98it/s]
 27%|##7       |  : 271/999 [00:03<00:07,   93.30it/s]
 27%|##7       |  : 274/999 [00:03<00:07,   93.05it/s]
 28%|##7       |  : 277/999 [00:03<00:07,   92.82it/s]
 28%|##8       |  : 280/999 [00:03<00:07,   92.62it/s]
 28%|##8       |  : 284/999 [00:03<00:07,   93.92it/s]
 29%|##8       |  : 287/999 [00:03<00:07,   93.66it/s]
 29%|##9       |  : 290/999 [00:03<00:07,   93.41it/s]
 29%|##9       |  : 293/999 [00:03<00:07,   93.18it/s]
 30%|##9       |  : 297/999 [00:03<00:07,   94.45it/s]
 30%|###       |  : 300/999 [00:03<00:07,   94.17it/s]
 30%|###       |  : 303/999 [00:03<00:07,   93.89it/s]
 31%|###       |  : 306/999 [00:03<00:07,   93.63it/s]
 31%|###       |  : 309/999 [00:03<00:07,   93.37it/s]
 31%|###1      |  : 313/999 [00:03<00:07,   94.62it/s]
 32%|###1      |  : 316/999 [00:03<00:07,   94.33it/s]
 32%|###1      |  : 319/999 [00:03<00:07,   94.04it/s]
 32%|###2      |  : 323/999 [00:03<00:07,   95.26it/s]
 33%|###2      |  : 326/999 [00:03<00:07,   94.94it/s]
 33%|###3      |  : 330/999 [00:03<00:06,   96.12it/s]
 33%|###3      |  : 333/999 [00:03<00:06,   95.75it/s]
 34%|###3      |  : 336/999 [00:03<00:06,   95.40it/s]
 34%|###4      |  : 340/999 [00:03<00:06,   96.56it/s]
 34%|###4      |  : 343/999 [00:03<00:06,   96.17it/s]
 35%|###4      |  : 347/999 [00:03<00:06,   97.26it/s]
 35%|###5      |  : 350/999 [00:03<00:06,   96.84it/s]
 35%|###5      |  : 353/999 [00:03<00:06,   96.44it/s]
 36%|###5      |  : 357/999 [00:03<00:06,   97.54it/s]
 36%|###6      |  : 360/999 [00:03<00:06,   97.10it/s]
 36%|###6      |  : 364/999 [00:03<00:06,   98.16it/s]
 37%|###6      |  : 367/999 [00:03<00:06,   97.69it/s]
 37%|###7      |  : 370/999 [00:04<00:06,   97.23it/s]
 37%|###7      |  : 374/999 [00:04<00:06,   98.29it/s]
 38%|###7      |  : 377/999 [00:04<00:06,   97.82it/s]
 38%|###8      |  : 381/999 [00:04<00:06,   98.84it/s]
 38%|###8      |  : 384/999 [00:04<00:06,   98.34it/s]
 39%|###8      |  : 387/999 [00:04<00:06,   97.87it/s]
 39%|###9      |  : 390/999 [00:04<00:06,   97.39it/s]
 39%|###9      |  : 394/999 [00:04<00:06,   98.45it/s]
 40%|###9      |  : 397/999 [00:04<00:06,   97.95it/s]
 40%|####      |  : 400/999 [00:04<00:06,   97.46it/s]
 40%|####      |  : 403/999 [00:04<00:06,   97.03it/s]
 41%|####      |  : 407/999 [00:04<00:06,   98.09it/s]
 41%|####1     |  : 410/999 [00:04<00:06,   97.62it/s]
 41%|####1     |  : 412/999 [00:04<00:06,   95.70it/s]
 42%|####1     |  : 415/999 [00:04<00:06,   95.35it/s]
 42%|####1     |  : 418/999 [00:04<00:06,   95.01it/s]
 42%|####2     |  : 421/999 [00:04<00:06,   94.70it/s]
 42%|####2     |  : 424/999 [00:04<00:06,   94.40it/s]
 43%|####2     |  : 427/999 [00:04<00:06,   94.12it/s]
 43%|####3     |  : 430/999 [00:04<00:06,   93.85it/s]
 43%|####3     |  : 433/999 [00:04<00:06,   93.60it/s]
 44%|####3     |  : 436/999 [00:04<00:06,   93.35it/s]
 44%|####3     |  : 439/999 [00:04<00:06,   93.12it/s]
 44%|####4     |  : 443/999 [00:04<00:05,   94.36it/s]
 45%|####4     |  : 446/999 [00:04<00:05,   94.08it/s]
 45%|####4     |  : 449/999 [00:04<00:05,   93.81it/s]
 45%|####5     |  : 452/999 [00:04<00:05,   93.55it/s]
 45%|####5     |  : 454/999 [00:04<00:05,   91.84it/s]
 46%|####5     |  : 458/999 [00:04<00:05,   93.16it/s]
 46%|####6     |  : 461/999 [00:05<00:05,   92.95it/s]
 46%|####6     |  : 464/999 [00:05<00:05,   92.74it/s]
 47%|####6     |  : 467/999 [00:05<00:05,   92.52it/s]
 47%|####7     |  : 470/999 [00:05<00:05,   92.34it/s]
 47%|####7     |  : 473/999 [00:05<00:05,   92.15it/s]
 48%|####7     |  : 476/999 [00:05<00:05,   91.98it/s]
 48%|####7     |  : 479/999 [00:05<00:05,   91.82it/s]
 48%|####8     |  : 483/999 [00:05<00:05,   93.15it/s]
 49%|####8     |  : 486/999 [00:05<00:05,   92.82it/s]
 49%|####8     |  : 489/999 [00:05<00:05,   92.60it/s]
 49%|####9     |  : 492/999 [00:05<00:05,   92.39it/s]
 50%|####9     |  : 495/999 [00:05<00:05,   92.19it/s]
 50%|####9     |  : 498/999 [00:05<00:05,   91.97it/s]
 50%|#####     |  : 500/999 [00:05<00:05,   90.28it/s]
 50%|#####     |  : 503/999 [00:05<00:05,   90.20it/s]
 51%|#####     |  : 506/999 [00:05<00:05,   90.09it/s]
 51%|#####     |  : 509/999 [00:05<00:05,   90.00it/s]
 51%|#####1    |  : 512/999 [00:05<00:05,   89.92it/s]
 52%|#####1    |  : 515/999 [00:05<00:05,   89.87it/s]
 52%|#####1    |  : 518/999 [00:05<00:05,   89.80it/s]
 52%|#####2    |  : 521/999 [00:05<00:05,   89.74it/s]
 52%|#####2    |  : 524/999 [00:05<00:05,   89.69it/s]
 53%|#####2    |  : 527/999 [00:05<00:05,   89.62it/s]
 53%|#####3    |  : 530/999 [00:05<00:05,   89.57it/s]
 53%|#####3    |  : 533/999 [00:05<00:05,   89.51it/s]
 54%|#####3    |  : 536/999 [00:05<00:05,   89.47it/s]
 54%|#####3    |  : 539/999 [00:05<00:05,   89.44it/s]
 54%|#####4    |  : 542/999 [00:05<00:05,   89.39it/s]
 54%|#####4    |  : 544/999 [00:05<00:05,   87.88it/s]
 55%|#####4    |  : 548/999 [00:05<00:05,   89.38it/s]
 55%|#####5    |  : 550/999 [00:06<00:05,   87.86it/s]
 55%|#####5    |  : 553/999 [00:06<00:05,   87.89it/s]
 56%|#####5    |  : 556/999 [00:06<00:05,   87.92it/s]
 56%|#####5    |  : 559/999 [00:06<00:05,   87.96it/s]
 56%|#####6    |  : 562/999 [00:06<00:04,   87.99it/s]
 57%|#####6    |  : 565/999 [00:06<00:04,   88.02it/s]
 57%|#####6    |  : 568/999 [00:06<00:04,   88.06it/s]
 57%|#####7    |  : 571/999 [00:06<00:04,   88.09it/s]
 57%|#####7    |  : 574/999 [00:06<00:04,   88.11it/s]
 58%|#####7    |  : 577/999 [00:06<00:04,   88.13it/s]
 58%|#####8    |  : 580/999 [00:06<00:04,   88.15it/s]
 58%|#####8    |  : 583/999 [00:06<00:04,   88.19it/s]
 59%|#####8    |  : 586/999 [00:06<00:04,   88.22it/s]
 59%|#####8    |  : 589/999 [00:06<00:04,   88.24it/s]
 59%|#####9    |  : 592/999 [00:06<00:04,   88.26it/s]
 59%|#####9    |  : 594/999 [00:06<00:04,   86.80it/s]
 60%|#####9    |  : 598/999 [00:06<00:04,   88.38it/s]
 60%|######    |  : 601/999 [00:06<00:04,   88.38it/s]
 60%|######    |  : 603/999 [00:06<00:04,   86.92it/s]
 61%|######    |  : 606/999 [00:06<00:04,   87.01it/s]
 61%|######    |  : 609/999 [00:06<00:04,   87.08it/s]
 61%|######1   |  : 612/999 [00:06<00:04,   87.15it/s]
 62%|######1   |  : 615/999 [00:06<00:04,   87.23it/s]
 62%|######1   |  : 618/999 [00:06<00:04,   87.31it/s]
 62%|######2   |  : 621/999 [00:06<00:04,   87.38it/s]
 62%|######2   |  : 624/999 [00:06<00:04,   87.43it/s]
 63%|######2   |  : 627/999 [00:06<00:04,   87.49it/s]
 63%|######3   |  : 630/999 [00:06<00:04,   87.55it/s]
 63%|######3   |  : 632/999 [00:06<00:04,   86.13it/s]
 64%|######3   |  : 635/999 [00:07<00:04,   86.26it/s]
 64%|######3   |  : 638/999 [00:07<00:04,   86.37it/s]
 64%|######4   |  : 641/999 [00:07<00:04,   86.49it/s]
 64%|######4   |  : 644/999 [00:07<00:04,   86.60it/s]
 65%|######4   |  : 647/999 [00:07<00:04,   86.69it/s]
 65%|######5   |  : 650/999 [00:07<00:04,   86.78it/s]
 65%|######5   |  : 653/999 [00:07<00:03,   86.87it/s]
 66%|######5   |  : 656/999 [00:07<00:03,   86.94it/s]
 66%|######5   |  : 659/999 [00:07<00:03,   87.02it/s]
 66%|######6   |  : 662/999 [00:07<00:03,   87.10it/s]
 67%|######6   |  : 665/999 [00:07<00:03,   87.15it/s]
 67%|######6   |  : 668/999 [00:07<00:03,   87.21it/s]
 67%|######7   |  : 671/999 [00:07<00:03,   87.27it/s]
 67%|######7   |  : 674/999 [00:07<00:03,   87.33it/s]
 68%|######7   |  : 676/999 [00:07<00:03,   85.92it/s]
 68%|######7   |  : 679/999 [00:07<00:03,   86.05it/s]
 68%|######8   |  : 682/999 [00:07<00:03,   86.17it/s]
 69%|######8   |  : 685/999 [00:07<00:03,   86.28it/s]
 69%|######8   |  : 688/999 [00:07<00:03,   86.39it/s]
 69%|######9   |  : 691/999 [00:07<00:03,   86.50it/s]
 69%|######9   |  : 694/999 [00:07<00:03,   86.61it/s]
 70%|######9   |  : 697/999 [00:07<00:03,   86.72it/s]
 70%|#######   |  : 700/999 [00:07<00:03,   86.80it/s]
 70%|#######   |  : 703/999 [00:07<00:03,   86.90it/s]
 71%|#######   |  : 706/999 [00:07<00:03,   87.00it/s]
 71%|#######   |  : 709/999 [00:07<00:03,   87.07it/s]
 71%|#######1  |  : 712/999 [00:07<00:03,   87.14it/s]
 71%|#######1  |  : 714/999 [00:07<00:03,   85.73it/s]
 72%|#######1  |  : 717/999 [00:07<00:03,   85.87it/s]
 72%|#######2  |  : 720/999 [00:07<00:03,   86.01it/s]
 72%|#######2  |  : 723/999 [00:08<00:03,   86.14it/s]
 73%|#######2  |  : 726/999 [00:08<00:03,   86.27it/s]
 73%|#######2  |  : 729/999 [00:08<00:03,   86.38it/s]
 73%|#######3  |  : 732/999 [00:08<00:03,   86.49it/s]
 74%|#######3  |  : 735/999 [00:08<00:03,   86.60it/s]
 74%|#######3  |  : 738/999 [00:08<00:03,   86.69it/s]
 74%|#######4  |  : 741/999 [00:08<00:02,   86.78it/s]
 74%|#######4  |  : 744/999 [00:08<00:02,   86.87it/s]
 75%|#######4  |  : 747/999 [00:08<00:02,   86.95it/s]
 75%|#######4  |  : 749/999 [00:08<00:02,   85.57it/s]
 75%|#######5  |  : 752/999 [00:08<00:02,   85.71it/s]
 76%|#######5  |  : 755/999 [00:08<00:02,   85.84it/s]
 76%|#######5  |  : 758/999 [00:08<00:02,   85.98it/s]
 76%|#######6  |  : 761/999 [00:08<00:02,   86.12it/s]
 76%|#######6  |  : 764/999 [00:08<00:02,   86.25it/s]
 77%|#######6  |  : 767/999 [00:08<00:02,   86.37it/s]
 77%|#######7  |  : 770/999 [00:08<00:02,   86.49it/s]
 77%|#######7  |  : 773/999 [00:08<00:02,   86.59it/s]
 78%|#######7  |  : 775/999 [00:08<00:02,   85.21it/s]
 78%|#######7  |  : 778/999 [00:08<00:02,   85.38it/s]
 78%|#######8  |  : 781/999 [00:08<00:02,   85.55it/s]
 78%|#######8  |  : 784/999 [00:08<00:02,   85.70it/s]
 79%|#######8  |  : 787/999 [00:08<00:02,   85.84it/s]
 79%|#######9  |  : 790/999 [00:08<00:02,   85.99it/s]
 79%|#######9  |  : 792/999 [00:08<00:02,   84.64it/s]
 80%|#######9  |  : 795/999 [00:08<00:02,   84.83it/s]
 80%|#######9  |  : 798/999 [00:08<00:02,   85.01it/s]
 80%|########  |  : 801/999 [00:08<00:02,   85.18it/s]
 80%|########  |  : 804/999 [00:08<00:02,   85.35it/s]
 81%|########  |  : 806/999 [00:09<00:02,   84.04it/s]
 81%|########  |  : 809/999 [00:09<00:02,   84.26it/s]
 81%|########1 |  : 812/999 [00:09<00:02,   84.49it/s]
 82%|########1 |  : 815/999 [00:09<00:02,   84.70it/s]
 82%|########1 |  : 818/999 [00:09<00:02,   84.90it/s]
 82%|########2 |  : 821/999 [00:09<00:02,   85.07it/s]
 82%|########2 |  : 824/999 [00:09<00:02,   85.25it/s]
 83%|########2 |  : 827/999 [00:09<00:02,   85.42it/s]
 83%|########2 |  : 829/999 [00:09<00:02,   84.11it/s]
 83%|########3 |  : 832/999 [00:09<00:01,   84.34it/s]
 84%|########3 |  : 835/999 [00:09<00:01,   84.55it/s]
 84%|########3 |  : 838/999 [00:09<00:01,   84.75it/s]
 84%|########4 |  : 841/999 [00:09<00:01,   84.95it/s]
 84%|########4 |  : 844/999 [00:09<00:01,   85.14it/s]
 85%|########4 |  : 846/999 [00:09<00:01,   83.83it/s]
 85%|########4 |  : 849/999 [00:09<00:01,   84.07it/s]
 85%|########5 |  : 852/999 [00:09<00:01,   84.30it/s]
 86%|########5 |  : 855/999 [00:09<00:01,   84.52it/s]
 86%|########5 |  : 858/999 [00:09<00:01,   84.73it/s]
 86%|########6 |  : 860/999 [00:09<00:01,   83.46it/s]
 86%|########6 |  : 863/999 [00:09<00:01,   83.71it/s]
 87%|########6 |  : 866/999 [00:09<00:01,   83.95it/s]
 87%|########6 |  : 869/999 [00:09<00:01,   84.17it/s]
 87%|########7 |  : 872/999 [00:09<00:01,   84.40it/s]
 88%|########7 |  : 875/999 [00:09<00:01,   84.61it/s]
 88%|########7 |  : 878/999 [00:09<00:01,   84.81it/s]
 88%|########8 |  : 881/999 [00:09<00:01,   84.99it/s]
 88%|########8 |  : 883/999 [00:09<00:01,   83.69it/s]
 89%|########8 |  : 886/999 [00:09<00:01,   83.94it/s]
 89%|########8 |  : 889/999 [00:09<00:01,   84.18it/s]
 89%|########9 |  : 892/999 [00:10<00:01,   84.41it/s]
 90%|########9 |  : 895/999 [00:10<00:01,   84.63it/s]
 90%|########9 |  : 897/999 [00:10<00:01,   83.36it/s]
 90%|######### |  : 900/999 [00:10<00:01,   83.61it/s]
 90%|######### |  : 903/999 [00:10<00:01,   83.87it/s]
 91%|######### |  : 906/999 [00:10<00:01,   84.11it/s]
 91%|######### |  : 909/999 [00:10<00:01,   84.33it/s]
 91%|#########1|  : 912/999 [00:10<00:01,   84.54it/s]
 92%|#########1|  : 915/999 [00:10<00:00,   84.75it/s]
 92%|#########1|  : 917/999 [00:10<00:00,   83.46it/s]
 92%|#########2|  : 920/999 [00:10<00:00,   83.71it/s]
 92%|#########2|  : 923/999 [00:10<00:00,   83.96it/s]
 93%|#########2|  : 926/999 [00:10<00:00,   84.20it/s]
 93%|#########2|  : 929/999 [00:10<00:00,   84.43it/s]
 93%|#########3|  : 932/999 [00:10<00:00,   84.64it/s]
 94%|#########3|  : 935/999 [00:10<00:00,   84.84it/s]
 94%|#########3|  : 938/999 [00:10<00:00,   85.01it/s]
 94%|#########4|  : 941/999 [00:10<00:00,   85.18it/s]
 94%|#########4|  : 944/999 [00:10<00:00,   85.36it/s]
 95%|#########4|  : 947/999 [00:10<00:00,   85.51it/s]
 95%|#########5|  : 950/999 [00:10<00:00,   85.66it/s]
 95%|#########5|  : 952/999 [00:10<00:00,   84.32it/s]
 96%|#########5|  : 955/999 [00:10<00:00,   84.53it/s]
 96%|#########5|  : 958/999 [00:10<00:00,   84.72it/s]
 96%|#########6|  : 960/999 [00:10<00:00,   83.43it/s]
 96%|#########6|  : 963/999 [00:10<00:00,   83.68it/s]
 97%|#########6|  : 966/999 [00:10<00:00,   83.90it/s]
 97%|#########6|  : 968/999 [00:10<00:00,   82.65it/s]
 97%|#########7|  : 971/999 [00:10<00:00,   82.93it/s]
 97%|#########7|  : 974/999 [00:11<00:00,   83.19it/s]
 98%|#########7|  : 977/999 [00:11<00:00,   83.44it/s]
 98%|#########7|  : 979/999 [00:11<00:00,   82.21it/s]
 98%|#########8|  : 982/999 [00:11<00:00,   82.51it/s]
 99%|#########8|  : 985/999 [00:11<00:00,   82.81it/s]
 99%|#########8|  : 988/999 [00:11<00:00,   83.08it/s]
 99%|#########9|  : 991/999 [00:11<00:00,   83.34it/s]
 99%|#########9|  : 994/999 [00:11<00:00,   83.60it/s]
100%|#########9|  : 996/999 [00:11<00:00,   82.36it/s]
100%|##########|  : 999/999 [00:11<00:00,   82.74it/s]
100%|##########|  : 999/999 [00:11<00:00,   88.33it/s]
Computing cluster p-values
Done.

Note. The same functions work with source estimate. The only differences are the origin of the data, the size, and the adjacency definition. It can be used for single trials or for groups of subjects.

Visualize clusters#

# configure variables for visualization
colors = {"Aud": "crimson", "Vis": 'steelblue'}
linestyles = {"L": '-', "R": '--'}

# organize data for plotting
evokeds = {cond: epochs[cond].average() for cond in event_id}

# loop over clusters
for i_clu, clu_idx in enumerate(good_cluster_inds):
    # unpack cluster information, get unique indices
    time_inds, space_inds = np.squeeze(clusters[clu_idx])
    ch_inds = np.unique(space_inds)
    time_inds = np.unique(time_inds)

    # get topography for F stat
    f_map = F_obs[time_inds, ...].mean(axis=0)

    # get signals at the sensors contributing to the cluster
    sig_times = epochs.times[time_inds]

    # create spatial mask
    mask = np.zeros((f_map.shape[0], 1), dtype=bool)
    mask[ch_inds, :] = True

    # initialize figure
    fig, ax_topo = plt.subplots(1, 1, figsize=(10, 3))

    # plot average test statistic and mark significant sensors
    f_evoked = mne.EvokedArray(f_map[:, np.newaxis], epochs.info, tmin=0)
    f_evoked.plot_topomap(times=0, mask=mask, axes=ax_topo, cmap='Reds',
                          vmin=np.min, vmax=np.max, show=False,
                          colorbar=False, mask_params=dict(markersize=10))
    image = ax_topo.images[0]

    # remove the title that would otherwise say "0.000 s"
    ax_topo.set_title("")

    # create additional axes (for ERF and colorbar)
    divider = make_axes_locatable(ax_topo)

    # add axes for colorbar
    ax_colorbar = divider.append_axes('right', size='5%', pad=0.05)
    plt.colorbar(image, cax=ax_colorbar)
    ax_topo.set_xlabel(
        'Averaged F-map ({:0.3f} - {:0.3f} s)'.format(*sig_times[[0, -1]]))

    # add new axis for time courses and plot time courses
    ax_signals = divider.append_axes('right', size='300%', pad=1.2)
    title = 'Cluster #{0}, {1} sensor'.format(i_clu + 1, len(ch_inds))
    if len(ch_inds) > 1:
        title += "s (mean)"
    plot_compare_evokeds(evokeds, title=title, picks=ch_inds, axes=ax_signals,
                         colors=colors, linestyles=linestyles, show=False,
                         split_legend=True, truncate_yaxis='auto')

    # plot temporal cluster extent
    ymin, ymax = ax_signals.get_ylim()
    ax_signals.fill_betweenx((ymin, ymax), sig_times[0], sig_times[-1],
                             color='orange', alpha=0.3)

    # clean up viz
    mne.viz.tight_layout(fig=fig)
    fig.subplots_adjust(bottom=.05)
    plt.show()
  • Cluster #1, 3 sensors (mean) (GFP)
  • Cluster #2, 15 sensors (mean) (GFP)
  • Cluster #3, 1 sensor
  • Cluster #4, 3 sensors (mean) (GFP)
  • Cluster #5, 1 sensor
  • Cluster #6, 2 sensors (mean) (GFP)
  • Cluster #7, 1 sensor
  • Cluster #8, 1 sensor
combining channels using "gfp"
combining channels using "gfp"
combining channels using "gfp"
combining channels using "gfp"
combining channels using "gfp"
combining channels using "gfp"
combining channels using "gfp"
combining channels using "gfp"
combining channels using "gfp"
combining channels using "gfp"
combining channels using "gfp"
combining channels using "gfp"
combining channels using "gfp"
combining channels using "gfp"
combining channels using "gfp"
combining channels using "gfp"

Permutation statistic for time-frequencies#

Let’s do the same thing with the time-frequency decomposition of the data (see Frequency and time-frequency sensor analysis for a tutorial and Time-frequency on simulated data (Multitaper vs. Morlet vs. Stockwell) for a comparison of time-frequency methods) to show how cluster permutations can be done on higher-dimensional data.

decim = 4
freqs = np.arange(7, 30, 3)  # define frequencies of interest
n_cycles = freqs / freqs[0]

epochs_power = list()
for condition in [epochs[k] for k in ('Aud/L', 'Vis/L')]:
    this_tfr = tfr_morlet(condition, freqs, n_cycles=n_cycles,
                          decim=decim, average=False, return_itc=False)
    this_tfr.apply_baseline(mode='ratio', baseline=(None, 0))
    epochs_power.append(this_tfr.data)

# transpose again to (epochs, frequencies, times, vertices)
X = [np.transpose(x, (0, 2, 3, 1)) for x in epochs_power]
[Parallel(n_jobs=1)]: Using backend SequentialBackend with 1 concurrent workers.
[Parallel(n_jobs=1)]: Done   1 out of   1 | elapsed:    0.0s remaining:    0.0s
[Parallel(n_jobs=1)]: Done   2 out of   2 | elapsed:    0.0s remaining:    0.0s
[Parallel(n_jobs=1)]: Done   3 out of   3 | elapsed:    0.0s remaining:    0.0s
[Parallel(n_jobs=1)]: Done   4 out of   4 | elapsed:    0.0s remaining:    0.0s
[Parallel(n_jobs=1)]: Done 102 out of 102 | elapsed:    0.4s finished
Not setting metadata
Applying baseline correction (mode: ratio)
[Parallel(n_jobs=1)]: Using backend SequentialBackend with 1 concurrent workers.
[Parallel(n_jobs=1)]: Done   1 out of   1 | elapsed:    0.0s remaining:    0.0s
[Parallel(n_jobs=1)]: Done   2 out of   2 | elapsed:    0.0s remaining:    0.0s
[Parallel(n_jobs=1)]: Done   3 out of   3 | elapsed:    0.0s remaining:    0.0s
[Parallel(n_jobs=1)]: Done   4 out of   4 | elapsed:    0.0s remaining:    0.0s
[Parallel(n_jobs=1)]: Done 102 out of 102 | elapsed:    0.4s finished
Not setting metadata
Applying baseline correction (mode: ratio)

Let’s extend our adjacency definition to include the time-frequency dimensions. Here, the integer inputs are converted into a lattice and combined with the sensor adjacency matrix so that data at similar times and with similar frequencies and at close sensor locations are clustered together.

Now we can run the cluster permutation test, but first we have to set a threshold. This example decimates in time and uses few frequencies so we need to increase the threshold from the default value in order to have differentiated clusters (i.e. so that our algorithm doesn’t just find one large cluster). For a more principled method of setting this parameter, threshold-free cluster enhancement may be used or the p-value may be set with

from scipy import stats
n_comparisons = len(X)  # L auditory vs L visual stimulus
n_conditions = X[0].shape[0]  # 55 epochs per comparison
threshold = stats.distributions.f.ppf(
    1 - p_accept, n_comparisons - 1, n_conditions - 1)

See Statistical inference for a discussion.

tfr_threshold = 15.0

# run statistic
cluster_stats = spatio_temporal_cluster_test(
    X, n_permutations=1000, threshold=tfr_threshold, tail=1, n_jobs=None,
    buffer_size=None, adjacency=tfr_adjacency)
stat_fun(H1): min=0.000000 max=45.333033
Running initial clustering
Found 5 clusters
Permuting 999 times...

  0%|          |  : 0/999 [00:00<?,       ?it/s]
  0%|          |  : 1/999 [00:00<01:12,   13.72it/s]
  0%|          |  : 2/999 [00:00<00:55,   17.97it/s]
  0%|          |  : 3/999 [00:00<00:47,   20.84it/s]
  0%|          |  : 4/999 [00:00<03:11,    5.20it/s]
  1%|          |  : 5/999 [00:00<02:46,    5.99it/s]
  1%|          |  : 7/999 [00:00<01:58,    8.38it/s]
  1%|          |  : 9/999 [00:00<01:37,   10.15it/s]
  1%|1         |  : 10/999 [00:00<01:35,   10.41it/s]
  1%|1         |  : 11/999 [00:01<01:28,   11.20it/s]
  1%|1         |  : 12/999 [00:01<01:23,   11.89it/s]
  1%|1         |  : 14/999 [00:01<01:11,   13.86it/s]
  2%|1         |  : 16/999 [00:01<01:02,   15.74it/s]
  2%|1         |  : 17/999 [00:01<01:00,   16.25it/s]
  2%|1         |  : 19/999 [00:01<00:54,   18.08it/s]
  2%|2         |  : 22/999 [00:01<00:46,   21.11it/s]
  2%|2         |  : 23/999 [00:01<00:47,   20.34it/s]
  2%|2         |  : 24/999 [00:01<00:47,   20.72it/s]
  3%|2         |  : 25/999 [00:01<00:46,   20.95it/s]
  3%|2         |  : 26/999 [00:01<00:45,   21.31it/s]
  3%|2         |  : 29/999 [00:01<00:40,   24.15it/s]
  3%|3         |  : 32/999 [00:01<00:35,   26.89it/s]
  3%|3         |  : 33/999 [00:01<00:36,   26.83it/s]
  4%|3         |  : 35/999 [00:01<00:34,   28.21it/s]
  4%|3         |  : 37/999 [00:01<00:34,   28.16it/s]
  4%|4         |  : 40/999 [00:02<00:44,   21.32it/s]
  4%|4         |  : 42/999 [00:02<00:42,   22.33it/s]
  4%|4         |  : 43/999 [00:02<00:42,   22.55it/s]
  4%|4         |  : 44/999 [00:02<00:42,   22.66it/s]
  5%|4         |  : 45/999 [00:02<00:41,   22.87it/s]
  5%|4         |  : 46/999 [00:02<00:42,   22.18it/s]
  5%|4         |  : 47/999 [00:02<00:42,   22.41it/s]
  5%|5         |  : 50/999 [00:02<00:38,   24.50it/s]
  5%|5         |  : 53/999 [00:02<00:35,   26.57it/s]
  6%|5         |  : 56/999 [00:02<00:32,   28.60it/s]
  6%|5         |  : 58/999 [00:02<00:31,   29.57it/s]
  6%|5         |  : 59/999 [00:02<00:31,   29.47it/s]
  6%|6         |  : 61/999 [00:02<00:31,   29.33it/s]
  6%|6         |  : 62/999 [00:02<00:32,   29.19it/s]
  6%|6         |  : 63/999 [00:02<00:32,   29.21it/s]
  6%|6         |  : 64/999 [00:02<00:33,   27.97it/s]
  7%|6         |  : 65/999 [00:02<00:33,   28.03it/s]
  7%|6         |  : 68/999 [00:02<00:32,   28.97it/s]
  7%|7         |  : 70/999 [00:03<00:40,   22.71it/s]
  7%|7         |  : 71/999 [00:03<00:41,   22.15it/s]
  7%|7         |  : 72/999 [00:03<00:41,   22.34it/s]
  7%|7         |  : 73/999 [00:03<00:42,   21.78it/s]
  7%|7         |  : 74/999 [00:03<00:42,   21.99it/s]
  8%|7         |  : 75/999 [00:03<00:41,   22.10it/s]
  8%|7         |  : 76/999 [00:03<00:41,   22.31it/s]
  8%|7         |  : 77/999 [00:03<00:42,   21.72it/s]
  8%|7         |  : 78/999 [00:03<00:41,   21.94it/s]
  8%|8         |  : 80/999 [00:03<00:41,   22.23it/s]
  8%|8         |  : 81/999 [00:03<00:41,   22.36it/s]
  8%|8         |  : 82/999 [00:03<00:41,   21.86it/s]
  8%|8         |  : 83/999 [00:03<00:41,   22.01it/s]
  8%|8         |  : 84/999 [00:03<00:41,   22.12it/s]
  9%|8         |  : 85/999 [00:03<00:40,   22.34it/s]
  9%|8         |  : 86/999 [00:04<00:54,   16.85it/s]
  9%|8         |  : 87/999 [00:04<00:53,   17.12it/s]
  9%|8         |  : 88/999 [00:04<00:53,   16.92it/s]
  9%|9         |  : 90/999 [00:04<00:50,   17.91it/s]
  9%|9         |  : 93/999 [00:04<00:46,   19.62it/s]
  9%|9         |  : 94/999 [00:04<00:47,   19.25it/s]
 10%|9         |  : 95/999 [00:04<00:46,   19.51it/s]
 10%|9         |  : 98/999 [00:04<00:42,   21.26it/s]
 10%|9         |  : 99/999 [00:04<00:42,   21.40it/s]
 10%|#         |  : 100/999 [00:04<00:41,   21.61it/s]
 10%|#         |  : 101/999 [00:04<00:42,   21.09it/s]
 10%|#         |  : 102/999 [00:04<00:42,   21.32it/s]
 10%|#         |  : 103/999 [00:04<00:41,   21.46it/s]
 11%|#         |  : 105/999 [00:04<00:39,   22.51it/s]
 11%|#         |  : 107/999 [00:04<00:37,   23.56it/s]
 11%|#1        |  : 110/999 [00:04<00:34,   25.47it/s]
 11%|#1        |  : 113/999 [00:04<00:32,   27.36it/s]
 12%|#1        |  : 116/999 [00:05<00:31,   28.25it/s]
 12%|#1        |  : 117/999 [00:05<00:39,   22.24it/s]
 12%|#1        |  : 118/999 [00:05<00:39,   22.35it/s]
 12%|#2        |  : 120/999 [00:05<00:37,   23.27it/s]
 12%|#2        |  : 122/999 [00:05<00:36,   24.09it/s]
 12%|#2        |  : 123/999 [00:05<00:36,   24.23it/s]
 13%|#2        |  : 126/999 [00:05<00:34,   25.19it/s]
 13%|#2        |  : 128/999 [00:05<00:34,   25.32it/s]
 13%|#2        |  : 129/999 [00:05<00:34,   25.34it/s]
 13%|#3        |  : 131/999 [00:05<00:33,   26.25it/s]
 13%|#3        |  : 133/999 [00:05<00:32,   26.33it/s]
 14%|#3        |  : 135/999 [00:05<00:32,   26.40it/s]
 14%|#3        |  : 138/999 [00:05<00:30,   28.09it/s]
 14%|#4        |  : 141/999 [00:05<00:29,   28.86it/s]
 14%|#4        |  : 142/999 [00:06<00:29,   28.76it/s]
 14%|#4        |  : 143/999 [00:06<00:29,   28.78it/s]
 15%|#4        |  : 146/999 [00:06<00:28,   29.54it/s]
 15%|#4        |  : 147/999 [00:06<00:28,   29.42it/s]
 15%|#4        |  : 148/999 [00:06<00:28,   29.42it/s]
 15%|#5        |  : 151/999 [00:06<00:28,   30.16it/s]
 15%|#5        |  : 152/999 [00:06<00:35,   23.73it/s]
 16%|#5        |  : 155/999 [00:06<00:34,   24.60it/s]
 16%|#5        |  : 158/999 [00:06<00:32,   26.12it/s]
 16%|#5        |  : 159/999 [00:06<00:32,   26.10it/s]
 16%|#6        |  : 160/999 [00:06<00:32,   26.19it/s]
 16%|#6        |  : 161/999 [00:06<00:32,   26.18it/s]
 16%|#6        |  : 162/999 [00:06<00:31,   26.26it/s]
 16%|#6        |  : 163/999 [00:06<00:32,   25.47it/s]
 16%|#6        |  : 164/999 [00:06<00:32,   25.58it/s]
 17%|#6        |  : 166/999 [00:07<00:31,   26.49it/s]
 17%|#6        |  : 168/999 [00:07<00:31,   26.53it/s]
 17%|#6        |  : 169/999 [00:07<00:32,   25.72it/s]
 17%|#7        |  : 170/999 [00:07<00:32,   25.80it/s]
 17%|#7        |  : 171/999 [00:07<00:32,   25.83it/s]
 17%|#7        |  : 172/999 [00:07<00:32,   25.83it/s]
 17%|#7        |  : 173/999 [00:07<00:31,   25.94it/s]
 17%|#7        |  : 174/999 [00:07<00:31,   25.93it/s]
 18%|#7        |  : 175/999 [00:07<00:31,   26.04it/s]
 18%|#7        |  : 176/999 [00:07<00:40,   20.13it/s]
 18%|#7        |  : 179/999 [00:07<00:38,   21.19it/s]
 18%|#8        |  : 180/999 [00:07<00:38,   21.32it/s]
 18%|#8        |  : 181/999 [00:07<00:38,   21.52it/s]
 18%|#8        |  : 183/999 [00:07<00:37,   21.84it/s]
 18%|#8        |  : 184/999 [00:07<00:37,   21.95it/s]
 19%|#8        |  : 186/999 [00:08<00:35,   22.91it/s]
 19%|#8        |  : 187/999 [00:08<00:36,   22.33it/s]
 19%|#8        |  : 188/999 [00:08<00:36,   22.52it/s]
 19%|#9        |  : 191/999 [00:08<00:33,   24.30it/s]
 19%|#9        |  : 193/999 [00:08<00:32,   24.49it/s]
 20%|#9        |  : 195/999 [00:08<00:31,   25.33it/s]
 20%|#9        |  : 196/999 [00:08<00:31,   25.44it/s]
 20%|#9        |  : 197/999 [00:08<00:32,   24.65it/s]
 20%|#9        |  : 198/999 [00:08<00:32,   24.79it/s]
 20%|##        |  : 200/999 [00:08<00:32,   24.96it/s]
 20%|##        |  : 201/999 [00:08<00:41,   19.31it/s]
 20%|##        |  : 202/999 [00:08<00:41,   18.98it/s]
 20%|##        |  : 203/999 [00:09<00:41,   19.18it/s]
 20%|##        |  : 204/999 [00:09<00:41,   19.37it/s]
 21%|##        |  : 205/999 [00:09<00:40,   19.54it/s]
 21%|##        |  : 206/999 [00:09<00:40,   19.78it/s]
 21%|##        |  : 209/999 [00:09<00:36,   21.50it/s]
 21%|##1       |  : 210/999 [00:09<00:36,   21.62it/s]
 21%|##1       |  : 211/999 [00:09<00:36,   21.78it/s]
 21%|##1       |  : 212/999 [00:09<00:36,   21.34it/s]
 21%|##1       |  : 213/999 [00:09<00:36,   21.47it/s]
 21%|##1       |  : 214/999 [00:09<00:36,   21.68it/s]
 22%|##1       |  : 215/999 [00:09<00:37,   21.06it/s]
 22%|##1       |  : 216/999 [00:09<00:36,   21.29it/s]
 22%|##1       |  : 217/999 [00:09<00:36,   21.43it/s]
 22%|##1       |  : 218/999 [00:09<00:36,   21.67it/s]
 22%|##2       |  : 221/999 [00:09<00:32,   23.61it/s]
 22%|##2       |  : 224/999 [00:09<00:30,   25.53it/s]
 23%|##2       |  : 226/999 [00:09<00:30,   25.66it/s]
 23%|##2       |  : 228/999 [00:09<00:28,   26.66it/s]
 23%|##3       |  : 231/999 [00:10<00:36,   21.05it/s]
 23%|##3       |  : 232/999 [00:10<00:36,   21.17it/s]
 23%|##3       |  : 233/999 [00:10<00:35,   21.37it/s]
 24%|##3       |  : 235/999 [00:10<00:35,   21.69it/s]
 24%|##3       |  : 236/999 [00:10<00:35,   21.72it/s]
 24%|##3       |  : 239/999 [00:10<00:33,   22.64it/s]
 24%|##4       |  : 240/999 [00:10<00:35,   21.50it/s]
 24%|##4       |  : 242/999 [00:10<00:34,   21.80it/s]
 24%|##4       |  : 243/999 [00:10<00:34,   21.91it/s]
 24%|##4       |  : 244/999 [00:10<00:35,   21.49it/s]
 25%|##4       |  : 245/999 [00:10<00:34,   21.69it/s]
 25%|##4       |  : 248/999 [00:10<00:32,   23.37it/s]
 25%|##4       |  : 249/999 [00:10<00:32,   23.43it/s]
 25%|##5       |  : 250/999 [00:10<00:31,   23.59it/s]
 25%|##5       |  : 253/999 [00:10<00:30,   24.49it/s]
 26%|##5       |  : 255/999 [00:10<00:29,   25.41it/s]
 26%|##5       |  : 256/999 [00:11<00:30,   24.64it/s]
 26%|##5       |  : 259/999 [00:11<00:28,   25.58it/s]
 26%|##6       |  : 260/999 [00:11<00:37,   19.55it/s]
 26%|##6       |  : 261/999 [00:11<00:37,   19.76it/s]
 26%|##6       |  : 262/999 [00:11<00:37,   19.90it/s]
 26%|##6       |  : 263/999 [00:11<00:36,   20.11it/s]
 27%|##6       |  : 265/999 [00:11<00:35,   20.46it/s]
 27%|##6       |  : 267/999 [00:11<00:35,   20.73it/s]
 27%|##6       |  : 268/999 [00:11<00:35,   20.40it/s]
 27%|##7       |  : 271/999 [00:11<00:34,   21.40it/s]
 27%|##7       |  : 273/999 [00:12<00:32,   22.26it/s]
 27%|##7       |  : 274/999 [00:12<00:33,   21.77it/s]
 28%|##7       |  : 275/999 [00:12<00:32,   21.96it/s]
 28%|##7       |  : 276/999 [00:12<00:32,   22.06it/s]
 28%|##7       |  : 277/999 [00:12<00:33,   21.55it/s]
 28%|##7       |  : 278/999 [00:12<00:33,   21.75it/s]
 28%|##8       |  : 281/999 [00:12<00:30,   23.44it/s]
 28%|##8       |  : 282/999 [00:12<00:38,   18.72it/s]
 28%|##8       |  : 283/999 [00:12<00:38,   18.50it/s]
 28%|##8       |  : 284/999 [00:12<00:38,   18.67it/s]
 29%|##8       |  : 285/999 [00:12<00:38,   18.45it/s]
 29%|##8       |  : 286/999 [00:12<00:39,   18.19it/s]
 29%|##8       |  : 287/999 [00:12<00:38,   18.43it/s]
 29%|##8       |  : 289/999 [00:13<00:37,   18.80it/s]
 29%|##9       |  : 290/999 [00:13<00:38,   18.51it/s]
 29%|##9       |  : 291/999 [00:13<00:37,   18.76it/s]
 29%|##9       |  : 292/999 [00:13<00:37,   18.94it/s]
 29%|##9       |  : 293/999 [00:13<00:37,   18.65it/s]
 30%|##9       |  : 295/999 [00:13<00:36,   19.09it/s]
 30%|##9       |  : 297/999 [00:13<00:35,   20.04it/s]
 30%|##9       |  : 298/999 [00:13<00:34,   20.19it/s]
 30%|###       |  : 301/999 [00:13<00:32,   21.29it/s]
 30%|###       |  : 302/999 [00:13<00:34,   20.31it/s]
 30%|###       |  : 303/999 [00:13<00:34,   19.98it/s]
 30%|###       |  : 304/999 [00:14<00:43,   16.14it/s]
 31%|###       |  : 305/999 [00:14<00:42,   16.36it/s]
 31%|###       |  : 306/999 [00:14<00:41,   16.62it/s]
 31%|###       |  : 307/999 [00:14<00:41,   16.49it/s]
 31%|###       |  : 308/999 [00:14<00:42,   16.33it/s]
 31%|###       |  : 309/999 [00:14<00:41,   16.60it/s]
 31%|###1      |  : 312/999 [00:14<00:38,   17.74it/s]
 31%|###1      |  : 314/999 [00:14<00:37,   18.19it/s]
 32%|###1      |  : 317/999 [00:14<00:35,   19.26it/s]
 32%|###1      |  : 318/999 [00:14<00:35,   19.43it/s]
 32%|###1      |  : 319/999 [00:14<00:34,   19.66it/s]
 32%|###2      |  : 320/999 [00:14<00:34,   19.82it/s]
 32%|###2      |  : 322/999 [00:14<00:32,   20.76it/s]
 32%|###2      |  : 323/999 [00:14<00:32,   20.90it/s]
 32%|###2      |  : 324/999 [00:14<00:31,   21.12it/s]
 33%|###2      |  : 326/999 [00:14<00:31,   21.46it/s]
 33%|###2      |  : 328/999 [00:15<00:38,   17.33it/s]
 33%|###2      |  : 329/999 [00:15<00:38,   17.53it/s]
 33%|###3      |  : 330/999 [00:15<00:37,   17.78it/s]
 33%|###3      |  : 331/999 [00:15<00:38,   17.55it/s]
 33%|###3      |  : 332/999 [00:15<00:38,   17.33it/s]
 33%|###3      |  : 333/999 [00:15<00:38,   17.17it/s]
 33%|###3      |  : 334/999 [00:15<00:38,   17.38it/s]
 34%|###3      |  : 336/999 [00:15<00:37,   17.86it/s]
 34%|###3      |  : 337/999 [00:15<00:37,   17.61it/s]
 34%|###4      |  : 340/999 [00:15<00:35,   18.73it/s]
 34%|###4      |  : 342/999 [00:15<00:33,   19.64it/s]
 34%|###4      |  : 343/999 [00:15<00:33,   19.33it/s]
 34%|###4      |  : 344/999 [00:16<00:35,   18.57it/s]
 35%|###4      |  : 346/999 [00:16<00:33,   19.49it/s]
 35%|###4      |  : 347/999 [00:16<00:40,   16.19it/s]
 35%|###5      |  : 350/999 [00:16<00:37,   17.23it/s]
 35%|###5      |  : 351/999 [00:16<00:38,   17.04it/s]
 35%|###5      |  : 352/999 [00:16<00:37,   17.29it/s]
 35%|###5      |  : 353/999 [00:16<00:36,   17.48it/s]
 35%|###5      |  : 354/999 [00:16<00:36,   17.74it/s]
 36%|###5      |  : 356/999 [00:16<00:34,   18.60it/s]
 36%|###5      |  : 357/999 [00:16<00:35,   18.33it/s]
 36%|###5      |  : 359/999 [00:16<00:34,   18.76it/s]
 36%|###6      |  : 360/999 [00:16<00:33,   18.94it/s]
 36%|###6      |  : 361/999 [00:16<00:34,   18.63it/s]
 36%|###6      |  : 362/999 [00:17<00:33,   18.89it/s]
 36%|###6      |  : 364/999 [00:17<00:32,   19.32it/s]
 37%|###6      |  : 366/999 [00:17<00:32,   19.72it/s]
 37%|###6      |  : 368/999 [00:17<00:31,   20.11it/s]
 37%|###7      |  : 370/999 [00:17<00:30,   20.48it/s]
 37%|###7      |  : 372/999 [00:17<00:29,   21.40it/s]
 37%|###7      |  : 373/999 [00:17<00:37,   16.85it/s]
 37%|###7      |  : 374/999 [00:17<00:36,   17.10it/s]
 38%|###7      |  : 376/999 [00:17<00:34,   17.94it/s]
 38%|###7      |  : 379/999 [00:17<00:31,   19.42it/s]
 38%|###8      |  : 381/999 [00:17<00:31,   19.78it/s]
 38%|###8      |  : 382/999 [00:18<00:31,   19.51it/s]
 38%|###8      |  : 383/999 [00:18<00:31,   19.67it/s]
 39%|###8      |  : 385/999 [00:18<00:30,   20.03it/s]
 39%|###8      |  : 386/999 [00:18<00:30,   20.18it/s]
 39%|###8      |  : 387/999 [00:18<00:30,   20.39it/s]
 39%|###8      |  : 389/999 [00:18<00:29,   20.75it/s]
 39%|###9      |  : 391/999 [00:18<00:28,   21.08it/s]
 39%|###9      |  : 392/999 [00:18<00:29,   20.72it/s]
 39%|###9      |  : 393/999 [00:18<00:29,   20.38it/s]
 39%|###9      |  : 394/999 [00:18<00:29,   20.53it/s]
 40%|###9      |  : 395/999 [00:18<00:29,   20.74it/s]
 40%|###9      |  : 397/999 [00:18<00:28,   21.10it/s]
 40%|###9      |  : 398/999 [00:19<00:36,   16.34it/s]
 40%|###9      |  : 399/999 [00:19<00:36,   16.60it/s]
 40%|####      |  : 400/999 [00:19<00:35,   16.81it/s]
 40%|####      |  : 401/999 [00:19<00:35,   17.07it/s]
 40%|####      |  : 402/999 [00:19<00:34,   17.28it/s]
 40%|####      |  : 403/999 [00:19<00:33,   17.55it/s]
 41%|####      |  : 406/999 [00:19<00:30,   19.16it/s]
 41%|####      |  : 407/999 [00:19<00:31,   18.90it/s]
 41%|####      |  : 408/999 [00:19<00:31,   18.61it/s]
 41%|####      |  : 409/999 [00:19<00:31,   18.87it/s]
 41%|####1     |  : 410/999 [00:19<00:31,   18.55it/s]
 41%|####1     |  : 413/999 [00:19<00:29,   19.68it/s]
 42%|####1     |  : 415/999 [00:19<00:28,   20.62it/s]
 42%|####1     |  : 417/999 [00:19<00:27,   20.98it/s]
 42%|####1     |  : 418/999 [00:20<00:34,   16.73it/s]
 42%|####1     |  : 419/999 [00:20<00:35,   16.56it/s]
 42%|####2     |  : 420/999 [00:20<00:34,   16.82it/s]
 42%|####2     |  : 422/999 [00:20<00:33,   17.28it/s]
 42%|####2     |  : 423/999 [00:20<00:33,   17.08it/s]
 42%|####2     |  : 424/999 [00:20<00:33,   17.34it/s]
 43%|####2     |  : 426/999 [00:20<00:31,   18.19it/s]
 43%|####2     |  : 427/999 [00:20<00:31,   18.39it/s]
 43%|####2     |  : 429/999 [00:20<00:29,   19.31it/s]
 43%|####3     |  : 431/999 [00:20<00:28,   19.71it/s]
 43%|####3     |  : 432/999 [00:20<00:29,   19.36it/s]
 43%|####3     |  : 433/999 [00:20<00:28,   19.59it/s]
 44%|####3     |  : 435/999 [00:20<00:27,   20.46it/s]
 44%|####3     |  : 436/999 [00:20<00:27,   20.69it/s]
 44%|####3     |  : 437/999 [00:20<00:26,   20.83it/s]
 44%|####3     |  : 438/999 [00:20<00:26,   21.04it/s]
 44%|####3     |  : 439/999 [00:21<00:34,   16.32it/s]
 44%|####4     |  : 442/999 [00:21<00:32,   17.40it/s]
 44%|####4     |  : 443/999 [00:21<00:32,   17.19it/s]
 44%|####4     |  : 444/999 [00:21<00:32,   16.96it/s]
 45%|####4     |  : 446/999 [00:21<00:30,   17.84it/s]
 45%|####4     |  : 447/999 [00:21<00:30,   18.04it/s]
 45%|####4     |  : 448/999 [00:21<00:30,   18.29it/s]
 45%|####4     |  : 449/999 [00:21<00:30,   18.08it/s]
 45%|####5     |  : 450/999 [00:21<00:30,   18.28it/s]
 45%|####5     |  : 451/999 [00:21<00:29,   18.54it/s]
 45%|####5     |  : 453/999 [00:21<00:28,   19.00it/s]
 45%|####5     |  : 454/999 [00:21<00:28,   19.18it/s]
 46%|####5     |  : 455/999 [00:21<00:27,   19.43it/s]
 46%|####5     |  : 456/999 [00:21<00:27,   19.61it/s]
 46%|####5     |  : 457/999 [00:21<00:27,   19.86it/s]
 46%|####5     |  : 459/999 [00:22<00:26,   20.29it/s]
 46%|####6     |  : 460/999 [00:22<00:34,   15.47it/s]
 46%|####6     |  : 462/999 [00:22<00:33,   15.99it/s]
 46%|####6     |  : 463/999 [00:22<00:33,   16.16it/s]
 46%|####6     |  : 464/999 [00:22<00:32,   16.45it/s]
 47%|####6     |  : 465/999 [00:22<00:32,   16.67it/s]
 47%|####6     |  : 466/999 [00:22<00:31,   16.96it/s]
 47%|####6     |  : 467/999 [00:22<00:30,   17.19it/s]
 47%|####6     |  : 468/999 [00:22<00:30,   17.48it/s]
 47%|####6     |  : 469/999 [00:22<00:30,   17.29it/s]
 47%|####7     |  : 470/999 [00:22<00:30,   17.52it/s]
 47%|####7     |  : 471/999 [00:22<00:29,   17.82it/s]
 47%|####7     |  : 473/999 [00:23<00:28,   18.33it/s]
 47%|####7     |  : 474/999 [00:23<00:28,   18.54it/s]
 48%|####7     |  : 475/999 [00:23<00:27,   18.76it/s]
 48%|####7     |  : 477/999 [00:23<00:26,   19.82it/s]
 48%|####7     |  : 478/999 [00:23<00:26,   19.40it/s]
 48%|####7     |  : 479/999 [00:23<00:26,   19.67it/s]
 48%|####8     |  : 480/999 [00:23<00:26,   19.33it/s]
 48%|####8     |  : 483/999 [00:23<00:24,   21.22it/s]
 49%|####8     |  : 485/999 [00:23<00:23,   22.27it/s]
 49%|####8     |  : 488/999 [00:23<00:21,   24.15it/s]
 49%|####8     |  : 489/999 [00:23<00:28,   18.14it/s]
 49%|####9     |  : 490/999 [00:23<00:27,   18.39it/s]
 49%|####9     |  : 491/999 [00:23<00:27,   18.59it/s]
 49%|####9     |  : 492/999 [00:23<00:26,   18.84it/s]
 49%|####9     |  : 494/999 [00:24<00:26,   19.28it/s]
 50%|####9     |  : 497/999 [00:24<00:23,   20.96it/s]
 50%|####9     |  : 498/999 [00:24<00:23,   21.09it/s]
 50%|####9     |  : 499/999 [00:24<00:23,   21.30it/s]
 50%|#####     |  : 500/999 [00:24<00:23,   21.43it/s]
 50%|#####     |  : 501/999 [00:24<00:23,   21.65it/s]
 50%|#####     |  : 502/999 [00:24<00:23,   21.12it/s]
 50%|#####     |  : 503/999 [00:24<00:23,   21.35it/s]
 51%|#####     |  : 505/999 [00:24<00:22,   21.70it/s]
 51%|#####     |  : 506/999 [00:24<00:23,   21.17it/s]
 51%|#####     |  : 507/999 [00:24<00:22,   21.39it/s]
 51%|#####     |  : 509/999 [00:24<00:21,   22.44it/s]
 51%|#####1    |  : 511/999 [00:24<00:27,   17.60it/s]
 51%|#####1    |  : 512/999 [00:25<00:28,   17.35it/s]
 51%|#####1    |  : 513/999 [00:25<00:27,   17.62it/s]
 51%|#####1    |  : 514/999 [00:25<00:27,   17.38it/s]
 52%|#####1    |  : 515/999 [00:25<00:27,   17.60it/s]
 52%|#####1    |  : 516/999 [00:25<00:27,   17.36it/s]
 52%|#####1    |  : 517/999 [00:25<00:28,   17.19it/s]
 52%|#####1    |  : 518/999 [00:25<00:27,   17.41it/s]
 52%|#####1    |  : 519/999 [00:25<00:27,   17.24it/s]
 52%|#####2    |  : 522/999 [00:25<00:25,   18.92it/s]
 52%|#####2    |  : 524/999 [00:25<00:23,   19.90it/s]
 53%|#####2    |  : 526/999 [00:25<00:24,   19.70it/s]
 53%|#####2    |  : 528/999 [00:25<00:24,   19.57it/s]
 53%|#####2    |  : 529/999 [00:25<00:25,   18.80it/s]
 53%|#####3    |  : 531/999 [00:25<00:23,   19.72it/s]
 53%|#####3    |  : 532/999 [00:26<00:24,   18.93it/s]
 53%|#####3    |  : 534/999 [00:26<00:23,   19.86it/s]
 54%|#####3    |  : 535/999 [00:26<00:31,   14.90it/s]
 54%|#####3    |  : 536/999 [00:26<00:30,   15.12it/s]
 54%|#####3    |  : 537/999 [00:26<00:31,   14.72it/s]
 54%|#####3    |  : 539/999 [00:26<00:30,   14.91it/s]
 54%|#####4    |  : 540/999 [00:26<00:30,   15.14it/s]
 54%|#####4    |  : 542/999 [00:27<00:29,   15.31it/s]
 55%|#####4    |  : 545/999 [00:27<00:27,   16.68it/s]
 55%|#####4    |  : 546/999 [00:27<00:28,   16.18it/s]
 55%|#####4    |  : 548/999 [00:27<00:26,   16.99it/s]
 55%|#####4    |  : 549/999 [00:27<00:27,   16.49it/s]
 55%|#####5    |  : 551/999 [00:27<00:25,   17.32it/s]
 55%|#####5    |  : 552/999 [00:27<00:26,   16.78it/s]
 55%|#####5    |  : 553/999 [00:27<00:26,   17.00it/s]
 55%|#####5    |  : 554/999 [00:27<00:26,   16.49it/s]
 56%|#####5    |  : 555/999 [00:27<00:27,   16.02it/s]
 56%|#####5    |  : 556/999 [00:27<00:27,   16.28it/s]
 56%|#####5    |  : 557/999 [00:28<00:33,   13.05it/s]
 56%|#####5    |  : 558/999 [00:28<00:33,   13.05it/s]
 56%|#####6    |  : 560/999 [00:28<00:32,   13.57it/s]
 56%|#####6    |  : 561/999 [00:28<00:32,   13.52it/s]
 56%|#####6    |  : 563/999 [00:28<00:31,   14.03it/s]
 57%|#####6    |  : 565/999 [00:28<00:29,   14.78it/s]
 57%|#####6    |  : 567/999 [00:28<00:28,   15.27it/s]
 57%|#####6    |  : 568/999 [00:28<00:27,   15.49it/s]
 57%|#####6    |  : 569/999 [00:28<00:27,   15.42it/s]
 57%|#####7    |  : 570/999 [00:28<00:27,   15.64it/s]
 57%|#####7    |  : 571/999 [00:28<00:27,   15.54it/s]
 57%|#####7    |  : 572/999 [00:28<00:27,   15.47it/s]
 57%|#####7    |  : 574/999 [00:29<00:27,   15.61it/s]
 58%|#####7    |  : 575/999 [00:29<00:27,   15.53it/s]
 58%|#####7    |  : 576/999 [00:29<00:26,   15.76it/s]
 58%|#####7    |  : 578/999 [00:29<00:25,   16.26it/s]
 58%|#####8    |  : 581/999 [00:29<00:23,   17.75it/s]
 58%|#####8    |  : 583/999 [00:29<00:22,   18.62it/s]
 58%|#####8    |  : 584/999 [00:29<00:27,   15.08it/s]
 59%|#####8    |  : 585/999 [00:29<00:27,   14.99it/s]
 59%|#####8    |  : 586/999 [00:29<00:27,   15.26it/s]
 59%|#####8    |  : 587/999 [00:29<00:27,   15.20it/s]
 59%|#####8    |  : 589/999 [00:30<00:26,   15.37it/s]
 59%|#####9    |  : 590/999 [00:30<00:26,   15.30it/s]
 59%|#####9    |  : 591/999 [00:30<00:26,   15.25it/s]
 59%|#####9    |  : 593/999 [00:30<00:25,   15.74it/s]
 59%|#####9    |  : 594/999 [00:30<00:25,   15.96it/s]
 60%|#####9    |  : 596/999 [00:30<00:24,   16.45it/s]
 60%|#####9    |  : 598/999 [00:30<00:23,   16.92it/s]
 60%|######    |  : 601/999 [00:30<00:21,   18.37it/s]
 60%|######    |  : 602/999 [00:30<00:21,   18.13it/s]
 60%|######    |  : 603/999 [00:30<00:21,   18.31it/s]
 60%|######    |  : 604/999 [00:30<00:21,   18.11it/s]
 61%|######    |  : 605/999 [00:30<00:21,   18.30it/s]
 61%|######    |  : 606/999 [00:31<00:26,   14.74it/s]
 61%|######    |  : 607/999 [00:31<00:26,   14.62it/s]
 61%|######    |  : 608/999 [00:31<00:26,   14.88it/s]
 61%|######1   |  : 610/999 [00:31<00:24,   15.72it/s]
 61%|######1   |  : 612/999 [00:31<00:23,   16.54it/s]
 61%|######1   |  : 613/999 [00:31<00:23,   16.43it/s]
 62%|######1   |  : 615/999 [00:31<00:22,   16.85it/s]
 62%|######1   |  : 617/999 [00:31<00:21,   17.71it/s]
 62%|######1   |  : 619/999 [00:31<00:20,   18.14it/s]
 62%|######2   |  : 621/999 [00:31<00:19,   18.98it/s]
 62%|######2   |  : 622/999 [00:31<00:20,   18.69it/s]
 62%|######2   |  : 623/999 [00:31<00:19,   18.92it/s]
 63%|######2   |  : 625/999 [00:31<00:19,   19.33it/s]
 63%|######2   |  : 626/999 [00:31<00:19,   19.07it/s]
 63%|######2   |  : 627/999 [00:31<00:19,   18.76it/s]
 63%|######2   |  : 629/999 [00:32<00:23,   15.55it/s]
 63%|######3   |  : 631/999 [00:32<00:22,   16.01it/s]
 63%|######3   |  : 633/999 [00:32<00:22,   16.13it/s]
 63%|######3   |  : 634/999 [00:32<00:22,   16.33it/s]
 64%|######3   |  : 636/999 [00:32<00:21,   16.78it/s]
 64%|######3   |  : 637/999 [00:32<00:22,   16.27it/s]
 64%|######3   |  : 638/999 [00:32<00:22,   16.17it/s]
 64%|######4   |  : 640/999 [00:32<00:21,   16.94it/s]
 64%|######4   |  : 641/999 [00:32<00:21,   16.81it/s]
 64%|######4   |  : 643/999 [00:32<00:20,   17.65it/s]
 64%|######4   |  : 644/999 [00:33<00:19,   17.84it/s]
 65%|######4   |  : 645/999 [00:33<00:19,   18.08it/s]
 65%|######4   |  : 647/999 [00:33<00:18,   18.97it/s]
 65%|######4   |  : 648/999 [00:33<00:18,   18.72it/s]
 65%|######5   |  : 650/999 [00:33<00:17,   19.59it/s]
 65%|######5   |  : 651/999 [00:33<00:18,   19.31it/s]
 65%|######5   |  : 652/999 [00:33<00:18,   19.03it/s]
 65%|######5   |  : 653/999 [00:33<00:22,   15.30it/s]
 65%|######5   |  : 654/999 [00:33<00:22,   15.19it/s]
 66%|######5   |  : 655/999 [00:33<00:22,   15.14it/s]
 66%|######5   |  : 657/999 [00:33<00:21,   15.95it/s]
 66%|######5   |  : 658/999 [00:34<00:21,   15.80it/s]
 66%|######6   |  : 660/999 [00:34<00:20,   16.29it/s]
 66%|######6   |  : 661/999 [00:34<00:20,   16.51it/s]
 66%|######6   |  : 662/999 [00:34<00:20,   16.76it/s]
 66%|######6   |  : 663/999 [00:34<00:19,   17.02it/s]
 67%|######6   |  : 665/999 [00:34<00:19,   17.51it/s]
 67%|######6   |  : 666/999 [00:34<00:18,   17.71it/s]
 67%|######6   |  : 667/999 [00:34<00:18,   17.52it/s]
 67%|######6   |  : 669/999 [00:34<00:18,   18.00it/s]
 67%|######7   |  : 670/999 [00:34<00:18,   18.20it/s]
 67%|######7   |  : 672/999 [00:34<00:17,   18.65it/s]
 67%|######7   |  : 674/999 [00:34<00:17,   19.08it/s]
 68%|######7   |  : 675/999 [00:34<00:17,   18.83it/s]
 68%|######7   |  : 676/999 [00:34<00:16,   19.01it/s]
 68%|######7   |  : 679/999 [00:34<00:15,   20.12it/s]
 68%|######8   |  : 680/999 [00:35<00:20,   15.59it/s]
 68%|######8   |  : 682/999 [00:35<00:19,   16.41it/s]
 68%|######8   |  : 684/999 [00:35<00:18,   17.24it/s]
 69%|######8   |  : 686/999 [00:35<00:17,   17.68it/s]
 69%|######8   |  : 687/999 [00:35<00:17,   17.41it/s]
 69%|######8   |  : 688/999 [00:35<00:18,   17.20it/s]
 69%|######8   |  : 689/999 [00:35<00:17,   17.45it/s]
 69%|######9   |  : 690/999 [00:35<00:17,   17.29it/s]
 69%|######9   |  : 691/999 [00:35<00:18,   17.10it/s]
 69%|######9   |  : 692/999 [00:35<00:17,   17.33it/s]
 69%|######9   |  : 693/999 [00:35<00:17,   17.17it/s]
 69%|######9   |  : 694/999 [00:36<00:18,   16.57it/s]
 70%|######9   |  : 695/999 [00:36<00:18,   16.45it/s]
 70%|######9   |  : 697/999 [00:36<00:18,   16.55it/s]
 70%|#######   |  : 700/999 [00:36<00:20,   14.31it/s]
 70%|#######   |  : 701/999 [00:36<00:20,   14.54it/s]
 70%|#######   |  : 702/999 [00:36<00:20,   14.81it/s]
 70%|#######   |  : 703/999 [00:36<00:20,   14.77it/s]
 71%|#######   |  : 705/999 [00:36<00:19,   14.96it/s]
 71%|#######   |  : 708/999 [00:37<00:18,   15.66it/s]
 71%|#######1  |  : 711/999 [00:37<00:16,   17.00it/s]
 71%|#######1  |  : 713/999 [00:37<00:16,   17.42it/s]
 72%|#######1  |  : 715/999 [00:37<00:15,   18.18it/s]
 72%|#######1  |  : 716/999 [00:37<00:15,   17.95it/s]
 72%|#######1  |  : 717/999 [00:37<00:15,   18.18it/s]
 72%|#######1  |  : 718/999 [00:37<00:15,   18.40it/s]
 72%|#######1  |  : 719/999 [00:37<00:15,   18.20it/s]
 72%|#######2  |  : 721/999 [00:37<00:14,   19.07it/s]
 72%|#######2  |  : 723/999 [00:37<00:14,   19.00it/s]
 73%|#######2  |  : 725/999 [00:37<00:14,   18.93it/s]
 73%|#######2  |  : 727/999 [00:37<00:13,   19.78it/s]
 73%|#######2  |  : 728/999 [00:38<00:17,   15.51it/s]
 73%|#######3  |  : 731/999 [00:38<00:16,   16.45it/s]
 73%|#######3  |  : 734/999 [00:38<00:15,   17.37it/s]
 74%|#######3  |  : 736/999 [00:38<00:14,   17.75it/s]
 74%|#######3  |  : 737/999 [00:38<00:14,   17.51it/s]
 74%|#######3  |  : 738/999 [00:38<00:14,   17.73it/s]
 74%|#######4  |  : 740/999 [00:38<00:14,   18.12it/s]
 74%|#######4  |  : 741/999 [00:38<00:14,   18.29it/s]
 74%|#######4  |  : 742/999 [00:38<00:13,   18.51it/s]
 75%|#######4  |  : 745/999 [00:38<00:12,   19.92it/s]
 75%|#######4  |  : 748/999 [00:38<00:11,   21.36it/s]
 75%|#######5  |  : 750/999 [00:38<00:11,   21.64it/s]
 75%|#######5  |  : 752/999 [00:38<00:11,   21.78it/s]
 75%|#######5  |  : 753/999 [00:38<00:11,   21.35it/s]
 75%|#######5  |  : 754/999 [00:38<00:11,   21.52it/s]
 76%|#######5  |  : 755/999 [00:39<00:14,   17.20it/s]
 76%|#######5  |  : 756/999 [00:39<00:13,   17.42it/s]
 76%|#######5  |  : 759/999 [00:39<00:12,   18.76it/s]
 76%|#######6  |  : 760/999 [00:39<00:12,   18.56it/s]
 76%|#######6  |  : 763/999 [00:39<00:11,   19.92it/s]
 77%|#######6  |  : 765/999 [00:39<00:11,   20.67it/s]
 77%|#######6  |  : 768/999 [00:39<00:10,   21.57it/s]
 77%|#######6  |  : 769/999 [00:39<00:10,   21.23it/s]
 77%|#######7  |  : 770/999 [00:39<00:10,   21.34it/s]
 77%|#######7  |  : 772/999 [00:39<00:10,   22.15it/s]
 78%|#######7  |  : 775/999 [00:39<00:09,   23.63it/s]
 78%|#######7  |  : 776/999 [00:39<00:09,   23.69it/s]
 78%|#######7  |  : 777/999 [00:39<00:09,   23.82it/s]
 78%|#######7  |  : 779/999 [00:40<00:09,   24.01it/s]
 78%|#######8  |  : 782/999 [00:40<00:08,   25.57it/s]
 78%|#######8  |  : 783/999 [00:40<00:08,   25.57it/s]
 78%|#######8  |  : 784/999 [00:40<00:08,   25.67it/s]
 79%|#######8  |  : 785/999 [00:40<00:08,   25.04it/s]
 79%|#######8  |  : 786/999 [00:40<00:08,   25.05it/s]
 79%|#######8  |  : 788/999 [00:40<00:08,   25.95it/s]
 79%|#######8  |  : 789/999 [00:40<00:08,   25.27it/s]
 79%|#######9  |  : 792/999 [00:40<00:07,   26.97it/s]
 79%|#######9  |  : 793/999 [00:40<00:09,   20.69it/s]
 80%|#######9  |  : 795/999 [00:40<00:09,   21.52it/s]
 80%|#######9  |  : 797/999 [00:40<00:09,   22.35it/s]
 80%|#######9  |  : 798/999 [00:40<00:09,   21.78it/s]
 80%|########  |  : 800/999 [00:40<00:08,   22.63it/s]
 80%|########  |  : 801/999 [00:41<00:08,   22.71it/s]
 80%|########  |  : 802/999 [00:41<00:08,   22.88it/s]
 80%|########  |  : 803/999 [00:41<00:08,   22.96it/s]
 80%|########  |  : 804/999 [00:41<00:08,   23.12it/s]
 81%|########  |  : 805/999 [00:41<00:08,   22.53it/s]
 81%|########  |  : 806/999 [00:41<00:08,   22.71it/s]
 81%|########  |  : 807/999 [00:41<00:08,   22.80it/s]
 81%|########  |  : 808/999 [00:41<00:08,   22.98it/s]
 81%|########1 |  : 811/999 [00:41<00:07,   24.79it/s]
 81%|########1 |  : 814/999 [00:41<00:06,   26.58it/s]
 82%|########1 |  : 816/999 [00:41<00:06,   26.64it/s]
 82%|########1 |  : 817/999 [00:41<00:07,   25.78it/s]
 82%|########1 |  : 818/999 [00:41<00:06,   25.88it/s]
 82%|########2 |  : 821/999 [00:41<00:06,   27.68it/s]
 82%|########2 |  : 822/999 [00:41<00:08,   21.60it/s]
 82%|########2 |  : 823/999 [00:42<00:08,   21.13it/s]
 82%|########2 |  : 824/999 [00:42<00:08,   21.29it/s]
 83%|########2 |  : 825/999 [00:42<00:08,   21.41it/s]
 83%|########2 |  : 827/999 [00:42<00:07,   22.34it/s]
 83%|########2 |  : 829/999 [00:42<00:07,   23.17it/s]
 83%|########3 |  : 830/999 [00:42<00:07,   23.34it/s]
 83%|########3 |  : 832/999 [00:42<00:06,   24.28it/s]
 83%|########3 |  : 833/999 [00:42<00:06,   24.32it/s]
 84%|########3 |  : 835/999 [00:42<00:06,   25.28it/s]
 84%|########3 |  : 836/999 [00:42<00:06,   25.29it/s]
 84%|########3 |  : 837/999 [00:42<00:06,   25.41it/s]
 84%|########3 |  : 838/999 [00:42<00:06,   24.60it/s]
 84%|########3 |  : 839/999 [00:42<00:06,   24.75it/s]
 84%|########4 |  : 840/999 [00:42<00:06,   24.78it/s]
 84%|########4 |  : 841/999 [00:42<00:06,   24.92it/s]
 84%|########4 |  : 843/999 [00:42<00:06,   25.09it/s]
 84%|########4 |  : 844/999 [00:43<00:08,   19.12it/s]
 85%|########4 |  : 845/999 [00:43<00:08,   18.79it/s]
 85%|########4 |  : 846/999 [00:43<00:08,   19.05it/s]
 85%|########4 |  : 848/999 [00:43<00:07,   19.98it/s]
 85%|########4 |  : 849/999 [00:43<00:07,   19.52it/s]
 85%|########5 |  : 850/999 [00:43<00:07,   19.69it/s]
 85%|########5 |  : 851/999 [00:43<00:07,   19.91it/s]
 85%|########5 |  : 853/999 [00:43<00:06,   20.92it/s]
 85%|########5 |  : 854/999 [00:43<00:06,   21.06it/s]
 86%|########5 |  : 856/999 [00:43<00:06,   22.08it/s]
 86%|########5 |  : 857/999 [00:43<00:06,   21.51it/s]
 86%|########5 |  : 858/999 [00:43<00:06,   21.73it/s]
 86%|########6 |  : 861/999 [00:43<00:05,   23.59it/s]
 86%|########6 |  : 862/999 [00:43<00:05,   23.66it/s]
 86%|########6 |  : 863/999 [00:43<00:05,   23.83it/s]
 87%|########6 |  : 865/999 [00:43<00:05,   24.85it/s]
 87%|########6 |  : 866/999 [00:43<00:05,   24.91it/s]
 87%|########6 |  : 868/999 [00:43<00:05,   25.08it/s]
 87%|########6 |  : 869/999 [00:44<00:06,   19.19it/s]
 87%|########7 |  : 871/999 [00:44<00:06,   20.13it/s]
 87%|########7 |  : 872/999 [00:44<00:06,   20.29it/s]
 87%|########7 |  : 873/999 [00:44<00:06,   20.52it/s]
 87%|########7 |  : 874/999 [00:44<00:06,   20.67it/s]
 88%|########7 |  : 875/999 [00:44<00:05,   20.90it/s]
 88%|########7 |  : 878/999 [00:44<00:05,   22.70it/s]
 88%|########8 |  : 880/999 [00:44<00:05,   23.69it/s]
 88%|########8 |  : 881/999 [00:44<00:04,   23.76it/s]
 88%|########8 |  : 882/999 [00:44<00:04,   23.88it/s]
 88%|########8 |  : 883/999 [00:44<00:04,   23.28it/s]
 89%|########8 |  : 885/999 [00:44<00:04,   23.44it/s]
 89%|########8 |  : 887/999 [00:44<00:04,   24.35it/s]
 89%|########9 |  : 890/999 [00:44<00:04,   24.59it/s]
 89%|########9 |  : 891/999 [00:44<00:04,   23.97it/s]
 89%|########9 |  : 893/999 [00:44<00:04,   24.93it/s]
 90%|########9 |  : 895/999 [00:44<00:04,   24.95it/s]
 90%|########9 |  : 897/999 [00:45<00:04,   25.11it/s]
 90%|########9 |  : 898/999 [00:45<00:04,   24.36it/s]
 90%|########9 |  : 899/999 [00:45<00:04,   24.49it/s]
 90%|######### |  : 901/999 [00:45<00:05,   19.24it/s]
 90%|######### |  : 903/999 [00:45<00:04,   20.11it/s]
 90%|######### |  : 904/999 [00:45<00:04,   19.33it/s]
 91%|######### |  : 905/999 [00:45<00:05,   18.63it/s]
 91%|######### |  : 907/999 [00:45<00:04,   19.03it/s]
 91%|#########1|  : 910/999 [00:45<00:04,   20.53it/s]
 91%|#########1|  : 911/999 [00:46<00:04,   20.66it/s]
 91%|#########1|  : 912/999 [00:46<00:04,   20.85it/s]
 91%|#########1|  : 914/999 [00:46<00:03,   21.74it/s]
 92%|#########1|  : 915/999 [00:46<00:03,   21.77it/s]
 92%|#########1|  : 917/999 [00:46<00:03,   22.68it/s]
 92%|#########1|  : 918/999 [00:46<00:03,   22.13it/s]
 92%|#########2|  : 920/999 [00:46<00:03,   22.42it/s]
 92%|#########2|  : 921/999 [00:46<00:03,   22.51it/s]
 92%|#########2|  : 922/999 [00:46<00:03,   22.69it/s]
 92%|#########2|  : 924/999 [00:46<00:03,   23.58it/s]
 93%|#########2|  : 925/999 [00:46<00:03,   23.66it/s]
 93%|#########2|  : 926/999 [00:46<00:03,   18.25it/s]
 93%|#########2|  : 927/999 [00:46<00:04,   17.99it/s]
 93%|#########2|  : 928/999 [00:46<00:03,   18.24it/s]
 93%|#########3|  : 930/999 [00:47<00:03,   18.64it/s]
 93%|#########3|  : 932/999 [00:47<00:03,   19.00it/s]
 93%|#########3|  : 934/999 [00:47<00:03,   19.39it/s]
 94%|#########3|  : 935/999 [00:47<00:03,   19.62it/s]
 94%|#########3|  : 938/999 [00:47<00:03,   20.15it/s]
 94%|#########3|  : 939/999 [00:47<00:02,   20.29it/s]
 94%|#########4|  : 940/999 [00:47<00:02,   20.50it/s]
 94%|#########4|  : 941/999 [00:47<00:02,   20.64it/s]
 94%|#########4|  : 942/999 [00:47<00:02,   20.86it/s]
 94%|#########4|  : 943/999 [00:47<00:02,   21.00it/s]
 94%|#########4|  : 944/999 [00:47<00:02,   21.22it/s]
 95%|#########4|  : 945/999 [00:47<00:02,   21.35it/s]
 95%|#########4|  : 947/999 [00:47<00:02,   22.35it/s]
 95%|#########4|  : 948/999 [00:48<00:02,   17.33it/s]
 95%|#########4|  : 949/999 [00:48<00:02,   17.55it/s]
 95%|#########5|  : 950/999 [00:48<00:02,   17.76it/s]
 95%|#########5|  : 951/999 [00:48<00:02,   18.03it/s]
 95%|#########5|  : 952/999 [00:48<00:02,   18.23it/s]
 95%|#########5|  : 953/999 [00:48<00:02,   18.50it/s]
 96%|#########5|  : 955/999 [00:48<00:02,   19.50it/s]
 96%|#########5|  : 958/999 [00:48<00:01,   21.23it/s]
 96%|#########6|  : 960/999 [00:48<00:01,   20.95it/s]
 96%|#########6|  : 962/999 [00:48<00:01,   21.30it/s]
 96%|#########6|  : 964/999 [00:48<00:01,   21.04it/s]
 97%|#########6|  : 967/999 [00:48<00:01,   22.68it/s]
 97%|#########6|  : 968/999 [00:48<00:01,   22.76it/s]
 97%|#########6|  : 969/999 [00:48<00:01,   22.91it/s]
 97%|#########7|  : 971/999 [00:48<00:01,   23.17it/s]
 97%|#########7|  : 973/999 [00:48<00:01,   23.40it/s]
 98%|#########7|  : 975/999 [00:48<00:00,   24.32it/s]
 98%|#########7|  : 976/999 [00:48<00:00,   23.74it/s]
 98%|#########7|  : 979/999 [00:48<00:00,   25.45it/s]
 98%|#########8|  : 981/999 [00:49<00:00,   25.57it/s]
 98%|#########8|  : 982/999 [00:49<00:00,   20.28it/s]
 98%|#########8|  : 983/999 [00:49<00:00,   20.43it/s]
 99%|#########8|  : 985/999 [00:49<00:00,   21.30it/s]
 99%|#########8|  : 988/999 [00:49<00:00,   22.26it/s]
 99%|#########9|  : 990/999 [00:49<00:00,   22.52it/s]
 99%|#########9|  : 992/999 [00:49<00:00,   23.36it/s]
100%|#########9|  : 995/999 [00:49<00:00,   24.25it/s]
100%|#########9|  : 997/999 [00:49<00:00,   24.41it/s]
100%|##########|  : 999/999 [00:49<00:00,   25.44it/s]
100%|##########|  : 999/999 [00:49<00:00,   20.04it/s]
Computing cluster p-values
Done.

Finally, we can plot our results. It is difficult to visualize clusters in time-frequency-sensor space; plotting time-frequency spectrograms and plotting topomaps display time-frequency and sensor space respectively but they are difficult to combine. We will plot topomaps with the clustered sensors colored in white adjacent to spectrograms in order to provide a visualization of the results. This is a dimensionally limited view, however. Each sensor has its own significant time-frequencies, but, in order to display a single spectrogram, all the time-frequencies that are significant for any sensor in the cluster are plotted as significant. This is a difficulty inherent to visualizing high-dimensional data and should be taken into consideration when interpreting results.

F_obs, clusters, p_values, _ = cluster_stats
good_cluster_inds = np.where(p_values < p_accept)[0]

for i_clu, clu_idx in enumerate(good_cluster_inds):
    # unpack cluster information, get unique indices
    freq_inds, time_inds, space_inds = clusters[clu_idx]
    ch_inds = np.unique(space_inds)
    time_inds = np.unique(time_inds)
    freq_inds = np.unique(freq_inds)

    # get topography for F stat
    f_map = F_obs[freq_inds].mean(axis=0)
    f_map = f_map[time_inds].mean(axis=0)

    # get signals at the sensors contributing to the cluster
    sig_times = epochs.times[time_inds]

    # initialize figure
    fig, ax_topo = plt.subplots(1, 1, figsize=(10, 3))

    # create spatial mask
    mask = np.zeros((f_map.shape[0], 1), dtype=bool)
    mask[ch_inds, :] = True

    # plot average test statistic and mark significant sensors
    f_evoked = mne.EvokedArray(f_map[:, np.newaxis], epochs.info, tmin=0)
    f_evoked.plot_topomap(times=0, mask=mask, axes=ax_topo, cmap='Reds',
                          vmin=np.min, vmax=np.max, show=False,
                          colorbar=False, mask_params=dict(markersize=10))
    image = ax_topo.images[0]

    # create additional axes (for ERF and colorbar)
    divider = make_axes_locatable(ax_topo)

    # add axes for colorbar
    ax_colorbar = divider.append_axes('right', size='5%', pad=0.05)
    plt.colorbar(image, cax=ax_colorbar)
    ax_topo.set_xlabel(
        'Averaged F-map ({:0.3f} - {:0.3f} s)'.format(*sig_times[[0, -1]]))

    # add new axis for spectrogram
    ax_spec = divider.append_axes('right', size='300%', pad=1.2)
    title = 'Cluster #{0}, {1} spectrogram'.format(i_clu + 1, len(ch_inds))
    if len(ch_inds) > 1:
        title += " (max over channels)"
    F_obs_plot = F_obs[..., ch_inds].max(axis=-1)
    F_obs_plot_sig = np.zeros(F_obs_plot.shape) * np.nan
    F_obs_plot_sig[tuple(np.meshgrid(freq_inds, time_inds))] = \
        F_obs_plot[tuple(np.meshgrid(freq_inds, time_inds))]

    for f_image, cmap in zip([F_obs_plot, F_obs_plot_sig], ['gray', 'autumn']):
        c = ax_spec.imshow(f_image, cmap=cmap, aspect='auto', origin='lower',
                           extent=[epochs.times[0], epochs.times[-1],
                                   freqs[0], freqs[-1]])
    ax_spec.set_xlabel('Time (ms)')
    ax_spec.set_ylabel('Frequency (Hz)')
    ax_spec.set_title(title)

    # add another colorbar
    ax_colorbar2 = divider.append_axes('right', size='5%', pad=0.05)
    plt.colorbar(c, cax=ax_colorbar2)
    ax_colorbar2.set_ylabel('F-stat')

    # clean up viz
    mne.viz.tight_layout(fig=fig)
    fig.subplots_adjust(bottom=.05)
  • 0.000 s, Cluster #1, 5 spectrogram (max over channels)
  • 0.000 s, Cluster #2, 6 spectrogram (max over channels)

Exercises#

  • What is the smallest p-value you can obtain, given the finite number of permutations?

  • use an F distribution to compute the threshold by traditional significance levels. Hint: take a look at scipy.stats.f

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

Estimated memory usage: 129 MB

Gallery generated by Sphinx-Gallery