Note

Go to the end to download the full example code

# 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.

Here, the unit of observation is epochs from a specific study subject. However, the same logic applies when the unit observation is a number of study subject each of whom contribute their own averaged data (i.e., an average of their epochs). This would then be considered an analysis at the “2nd level”.

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

For more information on cluster-based permutation testing in MNE-Python, see also: Non-parametric 1 sample cluster statistic on single trial power

```
# Authors: Denis Engemann <denis.engemann@gmail.com>
# Jona Sassenhagen <jona.sassenhagen@gmail.com>
# Alex Rockhill <aprockhill@mailbox.org>
# Stefan Appelhoff <stefan.appelhoff@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 scipy.stats
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
```

## 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)
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.6s 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)
# Obtain the data as a 3D matrix and transpose it such that
# the dimensions are as expected for the cluster permutation test:
# n_epochs × n_times × n_channels
X = [epochs[event_name].get_data() for event_name in event_id]
X = [np.transpose(x, (0, 2, 1)) for x in X]
```

```
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!
mne.viz.plot_ch_adjacency(epochs.info, adjacency, ch_names)
```

```
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 [1][2].

```
# We are running an F test, so we look at the upper tail
# see also: https://stats.stackexchange.com/a/73993
tail = 1
# We want to set a critical test statistic (here: F), to determine when
# clusters are being formed. Using Scipy's percent point function of the F
# distribution, we can conveniently select a threshold that corresponds to
# some alpha level that we arbitrarily pick.
alpha_cluster_forming = 0.001
# For an F test we need the degrees of freedom for the numerator
# (number of conditions - 1) and the denominator (number of observations
# - number of conditions):
n_conditions = len(event_id)
n_observations = len(X[0])
dfn = n_conditions - 1
dfd = n_observations - n_conditions
# Note: we calculate 1 - alpha_cluster_forming to get the critical value
# on the right tail
f_thresh = scipy.stats.f.ppf(1 - alpha_cluster_forming, dfn=dfn, dfd=dfd)
# run the cluster based permutation analysis
cluster_stats = spatio_temporal_cluster_test(X, n_permutations=1000,
threshold=f_thresh, tail=tail,
n_jobs=None, buffer_size=None,
adjacency=adjacency)
F_obs, clusters, p_values, _ = cluster_stats
```

```
stat_fun(H1): min=0.004107 max=196.094418
Running initial clustering …
Found 22 clusters
0%| | Permuting : 0/999 [00:00<?, ?it/s]
0%| | Permuting : 1/999 [00:00<00:34, 29.02it/s]
0%| | Permuting : 3/999 [00:00<00:22, 44.20it/s]
1%| | Permuting : 6/999 [00:00<00:16, 59.71it/s]
1%| | Permuting : 9/999 [00:00<00:14, 67.49it/s]
1%|1 | Permuting : 12/999 [00:00<00:13, 72.18it/s]
2%|1 | Permuting : 15/999 [00:00<00:13, 75.31it/s]
2%|1 | Permuting : 18/999 [00:00<00:12, 77.53it/s]
2%|2 | Permuting : 21/999 [00:00<00:12, 79.20it/s]
2%|2 | Permuting : 24/999 [00:00<00:12, 80.49it/s]
3%|2 | Permuting : 27/999 [00:00<00:11, 81.52it/s]
3%|3 | Permuting : 30/999 [00:00<00:11, 82.36it/s]
3%|3 | Permuting : 33/999 [00:00<00:11, 83.05it/s]
4%|3 | Permuting : 36/999 [00:00<00:11, 83.64it/s]
4%|3 | Permuting : 39/999 [00:00<00:11, 84.14it/s]
4%|4 | Permuting : 41/999 [00:00<00:11, 81.80it/s]
4%|4 | Permuting : 44/999 [00:00<00:11, 82.41it/s]
5%|4 | Permuting : 47/999 [00:00<00:11, 82.96it/s]
5%|4 | Permuting : 49/999 [00:00<00:11, 80.97it/s]
5%|5 | Permuting : 52/999 [00:00<00:11, 81.59it/s]
6%|5 | Permuting : 55/999 [00:00<00:11, 82.13it/s]
6%|5 | Permuting : 58/999 [00:00<00:11, 82.63it/s]
6%|6 | Permuting : 61/999 [00:00<00:11, 83.08it/s]
6%|6 | Permuting : 64/999 [00:00<00:11, 83.50it/s]
7%|6 | Permuting : 66/999 [00:00<00:11, 81.78it/s]
7%|6 | Permuting : 69/999 [00:00<00:11, 82.26it/s]
7%|7 | Permuting : 72/999 [00:00<00:11, 82.70it/s]
8%|7 | Permuting : 75/999 [00:00<00:11, 83.10it/s]
8%|7 | Permuting : 78/999 [00:00<00:11, 83.48it/s]
8%|8 | Permuting : 80/999 [00:00<00:11, 81.91it/s]
8%|8 | Permuting : 83/999 [00:01<00:11, 82.35it/s]
9%|8 | Permuting : 86/999 [00:01<00:11, 82.76it/s]
9%|8 | Permuting : 89/999 [00:01<00:10, 83.13it/s]
9%|9 | Permuting : 92/999 [00:01<00:10, 83.47it/s]
10%|9 | Permuting : 95/999 [00:01<00:10, 83.80it/s]
10%|9 | Permuting : 98/999 [00:01<00:10, 84.11it/s]
10%|# | Permuting : 101/999 [00:01<00:10, 84.39it/s]
10%|# | Permuting : 104/999 [00:01<00:10, 84.65it/s]
11%|# | Permuting : 107/999 [00:01<00:10, 84.89it/s]
11%|#1 | Permuting : 110/999 [00:01<00:10, 85.10it/s]
11%|#1 | Permuting : 113/999 [00:01<00:10, 85.31it/s]
12%|#1 | Permuting : 116/999 [00:01<00:10, 85.51it/s]
12%|#1 | Permuting : 118/999 [00:01<00:10, 84.01it/s]
12%|#2 | Permuting : 121/999 [00:01<00:10, 84.28it/s]
12%|#2 | Permuting : 124/999 [00:01<00:10, 84.54it/s]
13%|#2 | Permuting : 127/999 [00:01<00:10, 84.77it/s]
13%|#3 | Permuting : 130/999 [00:01<00:10, 84.99it/s]
13%|#3 | Permuting : 133/999 [00:01<00:10, 85.19it/s]
14%|#3 | Permuting : 136/999 [00:01<00:10, 85.39it/s]
14%|#3 | Permuting : 139/999 [00:01<00:10, 85.57it/s]
14%|#4 | Permuting : 141/999 [00:01<00:10, 84.14it/s]
14%|#4 | Permuting : 144/999 [00:01<00:10, 84.39it/s]
15%|#4 | Permuting : 147/999 [00:01<00:10, 84.62it/s]
15%|#5 | Permuting : 150/999 [00:01<00:10, 84.85it/s]
15%|#5 | Permuting : 153/999 [00:01<00:09, 85.06it/s]
16%|#5 | Permuting : 156/999 [00:01<00:09, 85.26it/s]
16%|#5 | Permuting : 159/999 [00:01<00:09, 85.45it/s]
16%|#6 | Permuting : 162/999 [00:01<00:09, 85.63it/s]
17%|#6 | Permuting : 165/999 [00:01<00:09, 85.80it/s]
17%|#6 | Permuting : 168/999 [00:01<00:09, 85.95it/s]
17%|#7 | Permuting : 171/999 [00:02<00:09, 86.10it/s]
17%|#7 | Permuting : 174/999 [00:02<00:09, 86.24it/s]
18%|#7 | Permuting : 176/999 [00:02<00:09, 84.78it/s]
18%|#7 | Permuting : 179/999 [00:02<00:09, 84.98it/s]
18%|#8 | Permuting : 182/999 [00:02<00:09, 85.18it/s]
19%|#8 | Permuting : 185/999 [00:02<00:09, 85.36it/s]
19%|#8 | Permuting : 188/999 [00:02<00:09, 85.54it/s]
19%|#9 | Permuting : 191/999 [00:02<00:09, 85.71it/s]
19%|#9 | Permuting : 194/999 [00:02<00:09, 85.87it/s]
20%|#9 | Permuting : 197/999 [00:02<00:09, 86.02it/s]
20%|#9 | Permuting : 199/999 [00:02<00:09, 84.64it/s]
20%|## | Permuting : 202/999 [00:02<00:09, 84.85it/s]
21%|## | Permuting : 205/999 [00:02<00:09, 85.04it/s]
21%|## | Permuting : 208/999 [00:02<00:09, 85.24it/s]
21%|##1 | Permuting : 211/999 [00:02<00:09, 85.42it/s]
21%|##1 | Permuting : 214/999 [00:02<00:09, 85.59it/s]
22%|##1 | Permuting : 217/999 [00:02<00:09, 85.76it/s]
22%|##2 | Permuting : 220/999 [00:02<00:09, 85.91it/s]
22%|##2 | Permuting : 223/999 [00:02<00:09, 86.06it/s]
23%|##2 | Permuting : 225/999 [00:02<00:09, 84.68it/s]
23%|##2 | Permuting : 228/999 [00:02<00:09, 84.89it/s]
23%|##3 | Permuting : 232/999 [00:02<00:08, 86.59it/s]
24%|##3 | Permuting : 235/999 [00:02<00:08, 86.69it/s]
24%|##3 | Permuting : 237/999 [00:02<00:08, 85.30it/s]
24%|##4 | Permuting : 240/999 [00:02<00:08, 85.48it/s]
24%|##4 | Permuting : 243/999 [00:02<00:08, 85.64it/s]
25%|##4 | Permuting : 246/999 [00:02<00:08, 85.80it/s]
25%|##4 | Permuting : 249/999 [00:02<00:08, 85.94it/s]
25%|##5 | Permuting : 252/999 [00:02<00:08, 86.07it/s]
26%|##5 | Permuting : 255/999 [00:03<00:08, 86.20it/s]
26%|##5 | Permuting : 258/999 [00:03<00:08, 86.32it/s]
26%|##6 | Permuting : 261/999 [00:03<00:08, 86.44it/s]
26%|##6 | Permuting : 264/999 [00:03<00:08, 86.56it/s]
27%|##6 | Permuting : 267/999 [00:03<00:08, 86.66it/s]
27%|##7 | Permuting : 270/999 [00:03<00:08, 86.77it/s]
27%|##7 | Permuting : 272/999 [00:03<00:08, 85.38it/s]
28%|##7 | Permuting : 275/999 [00:03<00:08, 85.56it/s]
28%|##7 | Permuting : 278/999 [00:03<00:08, 85.72it/s]
28%|##8 | Permuting : 281/999 [00:03<00:08, 85.87it/s]
28%|##8 | Permuting : 284/999 [00:03<00:08, 86.02it/s]
29%|##8 | Permuting : 287/999 [00:03<00:08, 86.16it/s]
29%|##9 | Permuting : 290/999 [00:03<00:08, 86.30it/s]
29%|##9 | Permuting : 292/999 [00:03<00:08, 84.93it/s]
30%|##9 | Permuting : 295/999 [00:03<00:08, 85.13it/s]
30%|##9 | Permuting : 298/999 [00:03<00:08, 85.31it/s]
30%|### | Permuting : 301/999 [00:03<00:08, 85.49it/s]
30%|### | Permuting : 304/999 [00:03<00:08, 85.66it/s]
31%|### | Permuting : 307/999 [00:03<00:08, 85.81it/s]
31%|###1 | Permuting : 310/999 [00:03<00:08, 85.95it/s]
31%|###1 | Permuting : 312/999 [00:03<00:08, 84.55it/s]
32%|###1 | Permuting : 315/999 [00:03<00:08, 84.76it/s]
32%|###1 | Permuting : 318/999 [00:03<00:08, 84.96it/s]
32%|###2 | Permuting : 321/999 [00:03<00:07, 85.15it/s]
32%|###2 | Permuting : 324/999 [00:03<00:07, 85.33it/s]
33%|###2 | Permuting : 327/999 [00:03<00:07, 85.50it/s]
33%|###3 | Permuting : 330/999 [00:03<00:07, 85.66it/s]
33%|###3 | Permuting : 333/999 [00:03<00:07, 85.82it/s]
34%|###3 | Permuting : 336/999 [00:03<00:07, 85.96it/s]
34%|###3 | Permuting : 339/999 [00:03<00:07, 86.09it/s]
34%|###4 | Permuting : 342/999 [00:04<00:07, 86.23it/s]
34%|###4 | Permuting : 344/999 [00:04<00:07, 84.86it/s]
35%|###4 | Permuting : 347/999 [00:04<00:07, 85.06it/s]
35%|###5 | Permuting : 350/999 [00:04<00:07, 85.24it/s]
35%|###5 | Permuting : 353/999 [00:04<00:07, 85.42it/s]
36%|###5 | Permuting : 356/999 [00:04<00:07, 85.58it/s]
36%|###5 | Permuting : 359/999 [00:04<00:07, 85.74it/s]
36%|###6 | Permuting : 362/999 [00:04<00:07, 85.89it/s]
37%|###6 | Permuting : 365/999 [00:04<00:07, 86.04it/s]
37%|###6 | Permuting : 367/999 [00:04<00:07, 84.70it/s]
37%|###7 | Permuting : 370/999 [00:04<00:07, 84.90it/s]
37%|###7 | Permuting : 372/999 [00:04<00:07, 83.60it/s]
38%|###7 | Permuting : 375/999 [00:04<00:07, 83.86it/s]
38%|###7 | Permuting : 378/999 [00:04<00:07, 84.11it/s]
38%|###8 | Permuting : 381/999 [00:04<00:07, 84.33it/s]
38%|###8 | Permuting : 384/999 [00:04<00:07, 84.55it/s]
39%|###8 | Permuting : 386/999 [00:04<00:07, 83.28it/s]
39%|###8 | Permuting : 389/999 [00:04<00:07, 83.54it/s]
39%|###9 | Permuting : 391/999 [00:04<00:07, 82.30it/s]
39%|###9 | Permuting : 394/999 [00:04<00:07, 82.61it/s]
40%|###9 | Permuting : 397/999 [00:04<00:07, 82.92it/s]
40%|#### | Permuting : 400/999 [00:04<00:07, 83.21it/s]
40%|#### | Permuting : 403/999 [00:04<00:07, 83.49it/s]
41%|#### | Permuting : 406/999 [00:04<00:07, 83.75it/s]
41%|#### | Permuting : 408/999 [00:04<00:07, 82.41it/s]
41%|####1 | Permuting : 411/999 [00:04<00:07, 82.58it/s]
41%|####1 | Permuting : 414/999 [00:04<00:07, 82.88it/s]
42%|####1 | Permuting : 417/999 [00:04<00:06, 83.18it/s]
42%|####2 | Permuting : 420/999 [00:04<00:06, 83.45it/s]
42%|####2 | Permuting : 423/999 [00:05<00:06, 83.70it/s]
43%|####2 | Permuting : 426/999 [00:05<00:06, 83.95it/s]
43%|####2 | Permuting : 428/999 [00:05<00:06, 82.66it/s]
43%|####3 | Permuting : 431/999 [00:05<00:06, 82.95it/s]
43%|####3 | Permuting : 434/999 [00:05<00:06, 83.24it/s]
44%|####3 | Permuting : 437/999 [00:05<00:06, 83.51it/s]
44%|####4 | Permuting : 440/999 [00:05<00:06, 83.77it/s]
44%|####4 | Permuting : 442/999 [00:05<00:06, 82.50it/s]
45%|####4 | Permuting : 445/999 [00:05<00:06, 82.81it/s]
45%|####4 | Permuting : 448/999 [00:05<00:06, 83.11it/s]
45%|####5 | Permuting : 451/999 [00:05<00:06, 83.38it/s]
45%|####5 | Permuting : 454/999 [00:05<00:06, 83.65it/s]
46%|####5 | Permuting : 457/999 [00:05<00:06, 83.91it/s]
46%|####6 | Permuting : 460/999 [00:05<00:06, 84.16it/s]
46%|####6 | Permuting : 462/999 [00:05<00:06, 82.91it/s]
47%|####6 | Permuting : 465/999 [00:05<00:06, 83.20it/s]
47%|####6 | Permuting : 468/999 [00:05<00:06, 83.47it/s]
47%|####7 | Permuting : 471/999 [00:05<00:06, 83.73it/s]
47%|####7 | Permuting : 474/999 [00:05<00:06, 83.98it/s]
48%|####7 | Permuting : 477/999 [00:05<00:06, 84.22it/s]
48%|####8 | Permuting : 480/999 [00:05<00:06, 84.45it/s]
48%|####8 | Permuting : 483/999 [00:05<00:06, 84.67it/s]
49%|####8 | Permuting : 486/999 [00:05<00:06, 84.87it/s]
49%|####8 | Permuting : 489/999 [00:05<00:05, 85.06it/s]
49%|####9 | Permuting : 492/999 [00:05<00:05, 85.25it/s]
50%|####9 | Permuting : 495/999 [00:05<00:05, 85.43it/s]
50%|####9 | Permuting : 498/999 [00:05<00:05, 85.59it/s]
50%|##### | Permuting : 500/999 [00:05<00:05, 84.26it/s]
50%|##### | Permuting : 503/999 [00:05<00:05, 84.48it/s]
51%|##### | Permuting : 506/999 [00:05<00:05, 84.70it/s]
51%|##### | Permuting : 509/999 [00:06<00:05, 84.90it/s]
51%|#####1 | Permuting : 512/999 [00:06<00:05, 85.10it/s]
52%|#####1 | Permuting : 515/999 [00:06<00:05, 85.28it/s]
52%|#####1 | Permuting : 518/999 [00:06<00:05, 85.46it/s]
52%|#####2 | Permuting : 521/999 [00:06<00:05, 85.63it/s]
52%|#####2 | Permuting : 524/999 [00:06<00:05, 85.79it/s]
53%|#####2 | Permuting : 527/999 [00:06<00:05, 85.93it/s]
53%|#####3 | Permuting : 530/999 [00:06<00:05, 86.08it/s]
53%|#####3 | Permuting : 533/999 [00:06<00:05, 86.21it/s]
54%|#####3 | Permuting : 536/999 [00:06<00:05, 86.35it/s]
54%|#####3 | Permuting : 539/999 [00:06<00:05, 86.47it/s]
54%|#####4 | Permuting : 541/999 [00:06<00:05, 85.11it/s]
54%|#####4 | Permuting : 544/999 [00:06<00:05, 85.28it/s]
55%|#####4 | Permuting : 547/999 [00:06<00:05, 85.45it/s]
55%|#####5 | Permuting : 550/999 [00:06<00:05, 85.62it/s]
55%|#####5 | Permuting : 553/999 [00:06<00:05, 85.77it/s]
56%|#####5 | Permuting : 556/999 [00:06<00:05, 85.92it/s]
56%|#####5 | Permuting : 559/999 [00:06<00:05, 86.06it/s]
56%|#####6 | Permuting : 561/999 [00:06<00:05, 84.71it/s]
56%|#####6 | Permuting : 564/999 [00:06<00:05, 84.92it/s]
57%|#####6 | Permuting : 567/999 [00:06<00:05, 85.11it/s]
57%|#####7 | Permuting : 570/999 [00:06<00:05, 85.30it/s]
57%|#####7 | Permuting : 573/999 [00:06<00:04, 85.47it/s]
58%|#####7 | Permuting : 576/999 [00:06<00:04, 85.63it/s]
58%|#####7 | Permuting : 579/999 [00:06<00:04, 85.79it/s]
58%|#####8 | Permuting : 582/999 [00:06<00:04, 85.95it/s]
59%|#####8 | Permuting : 585/999 [00:06<00:04, 86.08it/s]
59%|#####8 | Permuting : 588/999 [00:06<00:04, 86.21it/s]
59%|#####9 | Permuting : 591/999 [00:06<00:04, 86.34it/s]
59%|#####9 | Permuting : 594/999 [00:07<00:04, 86.44it/s]
60%|#####9 | Permuting : 597/999 [00:07<00:04, 86.56it/s]
60%|###### | Permuting : 600/999 [00:07<00:04, 86.66it/s]
60%|###### | Permuting : 603/999 [00:07<00:04, 86.77it/s]
61%|###### | Permuting : 606/999 [00:07<00:04, 86.87it/s]
61%|###### | Permuting : 609/999 [00:07<00:04, 86.96it/s]
61%|######1 | Permuting : 612/999 [00:07<00:04, 87.05it/s]
62%|######1 | Permuting : 615/999 [00:07<00:04, 87.14it/s]
62%|######1 | Permuting : 618/999 [00:07<00:04, 87.22it/s]
62%|######2 | Permuting : 621/999 [00:07<00:04, 87.30it/s]
62%|######2 | Permuting : 624/999 [00:07<00:04, 87.38it/s]
63%|######2 | Permuting : 627/999 [00:07<00:04, 87.44it/s]
63%|######3 | Permuting : 630/999 [00:07<00:04, 87.50it/s]
63%|######3 | Permuting : 633/999 [00:07<00:04, 87.56it/s]
64%|######3 | Permuting : 636/999 [00:07<00:04, 87.63it/s]
64%|######3 | Permuting : 639/999 [00:07<00:04, 87.69it/s]
64%|######4 | Permuting : 642/999 [00:07<00:04, 87.75it/s]
65%|######4 | Permuting : 645/999 [00:07<00:04, 87.80it/s]
65%|######4 | Permuting : 648/999 [00:07<00:03, 87.85it/s]
65%|######5 | Permuting : 651/999 [00:07<00:03, 87.89it/s]
65%|######5 | Permuting : 654/999 [00:07<00:03, 87.92it/s]
66%|######5 | Permuting : 657/999 [00:07<00:03, 87.95it/s]
66%|######6 | Permuting : 660/999 [00:07<00:03, 87.98it/s]
66%|######6 | Permuting : 663/999 [00:07<00:03, 88.01it/s]
67%|######6 | Permuting : 666/999 [00:07<00:03, 88.04it/s]
67%|######6 | Permuting : 669/999 [00:07<00:03, 88.06it/s]
67%|######7 | Permuting : 672/999 [00:07<00:03, 88.09it/s]
68%|######7 | Permuting : 675/999 [00:07<00:03, 88.12it/s]
68%|######7 | Permuting : 678/999 [00:07<00:03, 88.13it/s]
68%|######8 | Permuting : 680/999 [00:07<00:03, 86.60it/s]
68%|######8 | Permuting : 684/999 [00:08<00:03, 88.18it/s]
69%|######8 | Permuting : 686/999 [00:08<00:03, 86.72it/s]
69%|######8 | Permuting : 689/999 [00:08<00:03, 86.83it/s]
69%|######9 | Permuting : 692/999 [00:08<00:03, 86.93it/s]
70%|######9 | Permuting : 695/999 [00:08<00:03, 87.02it/s]
70%|######9 | Permuting : 698/999 [00:08<00:03, 87.11it/s]
70%|####### | Permuting : 701/999 [00:08<00:03, 87.18it/s]
70%|####### | Permuting : 704/999 [00:08<00:03, 87.26it/s]
71%|####### | Permuting : 707/999 [00:08<00:03, 87.33it/s]
71%|#######1 | Permuting : 710/999 [00:08<00:03, 87.40it/s]
71%|#######1 | Permuting : 713/999 [00:08<00:03, 87.48it/s]
72%|#######1 | Permuting : 716/999 [00:08<00:03, 87.55it/s]
72%|#######1 | Permuting : 719/999 [00:08<00:03, 87.61it/s]
72%|#######2 | Permuting : 722/999 [00:08<00:03, 87.67it/s]
73%|#######2 | Permuting : 725/999 [00:08<00:03, 87.72it/s]
73%|#######2 | Permuting : 728/999 [00:08<00:03, 87.77it/s]
73%|#######3 | Permuting : 731/999 [00:08<00:03, 87.83it/s]
73%|#######3 | Permuting : 734/999 [00:08<00:03, 87.87it/s]
74%|#######3 | Permuting : 737/999 [00:08<00:02, 87.91it/s]
74%|#######4 | Permuting : 740/999 [00:08<00:02, 87.95it/s]
74%|#######4 | Permuting : 743/999 [00:08<00:02, 87.99it/s]
75%|#######4 | Permuting : 745/999 [00:08<00:02, 86.56it/s]
75%|#######4 | Permuting : 748/999 [00:08<00:02, 86.66it/s]
75%|#######5 | Permuting : 751/999 [00:08<00:02, 86.77it/s]
75%|#######5 | Permuting : 754/999 [00:08<00:02, 86.86it/s]
76%|#######5 | Permuting : 757/999 [00:08<00:02, 86.95it/s]
76%|#######6 | Permuting : 760/999 [00:08<00:02, 87.05it/s]
76%|#######6 | Permuting : 763/999 [00:08<00:02, 87.13it/s]
77%|#######6 | Permuting : 766/999 [00:08<00:02, 87.22it/s]
77%|#######6 | Permuting : 769/999 [00:08<00:02, 87.30it/s]
77%|#######7 | Permuting : 772/999 [00:09<00:02, 87.37it/s]
78%|#######7 | Permuting : 775/999 [00:09<00:02, 87.43it/s]
78%|#######7 | Permuting : 778/999 [00:09<00:02, 87.50it/s]
78%|#######8 | Permuting : 781/999 [00:09<00:02, 87.56it/s]
78%|#######8 | Permuting : 784/999 [00:09<00:02, 87.63it/s]
79%|#######8 | Permuting : 787/999 [00:09<00:02, 87.67it/s]
79%|#######9 | Permuting : 790/999 [00:09<00:02, 87.73it/s]
79%|#######9 | Permuting : 793/999 [00:09<00:02, 87.78it/s]
80%|#######9 | Permuting : 796/999 [00:09<00:02, 87.82it/s]
80%|#######9 | Permuting : 799/999 [00:09<00:02, 87.87it/s]
80%|######## | Permuting : 802/999 [00:09<00:02, 87.91it/s]
81%|######## | Permuting : 805/999 [00:09<00:02, 87.96it/s]
81%|######## | Permuting : 808/999 [00:09<00:02, 87.99it/s]
81%|########1 | Permuting : 811/999 [00:09<00:02, 88.03it/s]
81%|########1 | Permuting : 814/999 [00:09<00:02, 88.07it/s]
82%|########1 | Permuting : 817/999 [00:09<00:02, 88.11it/s]
82%|########2 | Permuting : 820/999 [00:09<00:02, 88.14it/s]
82%|########2 | Permuting : 823/999 [00:09<00:01, 88.17it/s]
83%|########2 | Permuting : 826/999 [00:09<00:01, 88.20it/s]
83%|########2 | Permuting : 829/999 [00:09<00:01, 88.22it/s]
83%|########3 | Permuting : 832/999 [00:09<00:01, 88.25it/s]
84%|########3 | Permuting : 835/999 [00:09<00:01, 88.28it/s]
84%|########3 | Permuting : 838/999 [00:09<00:01, 88.31it/s]
84%|########4 | Permuting : 840/999 [00:09<00:01, 86.86it/s]
84%|########4 | Permuting : 843/999 [00:09<00:01, 86.96it/s]
85%|########4 | Permuting : 847/999 [00:09<00:01, 88.53it/s]
85%|########4 | Permuting : 849/999 [00:09<00:01, 87.07it/s]
85%|########5 | Permuting : 852/999 [00:09<00:01, 87.16it/s]
86%|########5 | Permuting : 855/999 [00:09<00:01, 87.23it/s]
86%|########5 | Permuting : 858/999 [00:10<00:01, 87.31it/s]
86%|########6 | Permuting : 861/999 [00:10<00:01, 87.38it/s]
86%|########6 | Permuting : 864/999 [00:10<00:01, 87.45it/s]
87%|########6 | Permuting : 867/999 [00:10<00:01, 87.53it/s]
87%|########7 | Permuting : 870/999 [00:10<00:01, 87.60it/s]
87%|########7 | Permuting : 873/999 [00:10<00:01, 87.65it/s]
88%|########7 | Permuting : 876/999 [00:10<00:01, 87.71it/s]
88%|########7 | Permuting : 879/999 [00:10<00:01, 87.76it/s]
88%|########8 | Permuting : 882/999 [00:10<00:01, 87.82it/s]
89%|########8 | Permuting : 885/999 [00:10<00:01, 87.87it/s]
89%|########8 | Permuting : 888/999 [00:10<00:01, 87.91it/s]
89%|########9 | Permuting : 891/999 [00:10<00:01, 87.96it/s]
89%|########9 | Permuting : 894/999 [00:10<00:01, 88.00it/s]
90%|########9 | Permuting : 897/999 [00:10<00:01, 88.05it/s]
90%|######### | Permuting : 900/999 [00:10<00:01, 88.08it/s]
90%|######### | Permuting : 904/999 [00:10<00:01, 89.60it/s]
91%|######### | Permuting : 907/999 [00:10<00:01, 89.56it/s]
91%|#########1| Permuting : 910/999 [00:10<00:00, 89.52it/s]
91%|#########1| Permuting : 913/999 [00:10<00:00, 89.49it/s]
92%|#########1| Permuting : 916/999 [00:10<00:00, 89.45it/s]
92%|#########1| Permuting : 919/999 [00:10<00:00, 89.43it/s]
92%|#########2| Permuting : 922/999 [00:10<00:00, 89.40it/s]
93%|#########2| Permuting : 925/999 [00:10<00:00, 89.37it/s]
93%|#########2| Permuting : 928/999 [00:10<00:00, 89.34it/s]
93%|#########3| Permuting : 931/999 [00:10<00:00, 89.32it/s]
93%|#########3| Permuting : 934/999 [00:10<00:00, 89.29it/s]
94%|#########3| Permuting : 937/999 [00:10<00:00, 89.26it/s]
94%|#########4| Permuting : 940/999 [00:10<00:00, 89.24it/s]
94%|#########4| Permuting : 943/999 [00:10<00:00, 89.22it/s]
95%|#########4| Permuting : 946/999 [00:10<00:00, 89.20it/s]
95%|#########4| Permuting : 949/999 [00:11<00:00, 89.18it/s]
95%|#########5| Permuting : 952/999 [00:11<00:00, 89.16it/s]
96%|#########5| Permuting : 955/999 [00:11<00:00, 89.14it/s]
96%|#########5| Permuting : 958/999 [00:11<00:00, 89.12it/s]
96%|#########6| Permuting : 961/999 [00:11<00:00, 89.10it/s]
96%|#########6| Permuting : 964/999 [00:11<00:00, 89.08it/s]
97%|#########6| Permuting : 967/999 [00:11<00:00, 89.07it/s]
97%|#########7| Permuting : 970/999 [00:11<00:00, 89.05it/s]
97%|#########7| Permuting : 973/999 [00:11<00:00, 89.04it/s]
98%|#########7| Permuting : 976/999 [00:11<00:00, 89.03it/s]
98%|#########7| Permuting : 979/999 [00:11<00:00, 89.02it/s]
98%|#########8| Permuting : 982/999 [00:11<00:00, 89.00it/s]
99%|#########8| Permuting : 985/999 [00:11<00:00, 89.00it/s]
99%|#########8| Permuting : 988/999 [00:11<00:00, 88.98it/s]
99%|#########9| Permuting : 991/999 [00:11<00:00, 88.97it/s]
99%|#########9| Permuting : 994/999 [00:11<00:00, 88.95it/s]
100%|#########9| Permuting : 997/999 [00:11<00:00, 88.94it/s]
100%|##########| Permuting : 999/999 [00:11<00:00, 89.65it/s]
100%|##########| Permuting : 999/999 [00:11<00:00, 86.23it/s]
```

Note

Note how we only specified an adjacency for sensors! However,
because we used `mne.stats.spatio_temporal_cluster_test()`

,
an adjacency for time points was automatically taken into
account. That is, at time point N, the time points N - 1 and
N + 1 were considered as adjacent (this is also called “lattice
adjacency”). This is only possible because we ran the analysis on
2D data (times × channels) per observation … for 3D data per
observation (e.g., times × frequencies × channels), we will need
to use `mne.stats.combine_adjacency()`

, as shown further
below.

Note also that the same functions work with source estimates. 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#

```
# We subselect clusters that we consider significant at an arbitrarily
# picked alpha level: "p_accept".
# NOTE: remember the caveats with respect to "significant" clusters that
# we mentioned in the introduction of this tutorial!
p_accept = 0.01
good_cluster_inds = np.where(p_values < p_accept)[0]
# 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',
vlim=(np.min, 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()
```

```
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"
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 vs. Hilbert) 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, channels)
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.7s 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.6s finished
Not setting metadata
Applying baseline correction (mode: ratio)
```

Remember the note on the adjacency matrix from above: For 3D data, as here,
we must use `mne.stats.combine_adjacency()`

to extend the
sensor-based adjacency to incorporate the time-frequency plane as well.

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.

```
# our data at each observation is of shape frequencies × times × channels
tfr_adjacency = combine_adjacency(
len(freqs), len(this_tfr.times), adjacency)
```

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. See Statistical inference for a discussion.

```
# This time we don't calculate a threshold based on the F distribution.
# We might as well select an arbitrary threshold for cluster forming
tfr_threshold = 15.0
# run cluster based permutation analysis
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
0%| | Permuting : 0/999 [00:00<?, ?it/s]
0%| | Permuting : 1/999 [00:00<01:11, 14.02it/s]
0%| | Permuting : 2/999 [00:00<05:32, 3.00it/s]
0%| | Permuting : 3/999 [00:00<03:47, 4.38it/s]
0%| | Permuting : 4/999 [00:00<02:56, 5.65it/s]
1%| | Permuting : 5/999 [00:00<02:24, 6.87it/s]
1%| | Permuting : 6/999 [00:00<02:10, 7.59it/s]
1%| | Permuting : 9/999 [00:00<01:25, 11.52it/s]
1%|1 | Permuting : 10/999 [00:00<01:24, 11.66it/s]
1%|1 | Permuting : 12/999 [00:00<01:11, 13.84it/s]
1%|1 | Permuting : 13/999 [00:01<01:11, 13.75it/s]
1%|1 | Permuting : 14/999 [00:01<01:08, 14.44it/s]
2%|1 | Permuting : 15/999 [00:01<01:05, 15.00it/s]
2%|1 | Permuting : 16/999 [00:01<01:03, 15.54it/s]
2%|1 | Permuting : 17/999 [00:01<01:00, 16.16it/s]
2%|1 | Permuting : 18/999 [00:01<00:58, 16.64it/s]
2%|2 | Permuting : 20/999 [00:01<00:52, 18.52it/s]
2%|2 | Permuting : 23/999 [00:01<00:47, 20.60it/s]
2%|2 | Permuting : 24/999 [00:01<01:06, 14.75it/s]
3%|2 | Permuting : 25/999 [00:01<01:04, 15.21it/s]
3%|2 | Permuting : 27/999 [00:01<01:00, 16.01it/s]
3%|2 | Permuting : 28/999 [00:01<00:59, 16.37it/s]
3%|3 | Permuting : 30/999 [00:01<00:54, 17.71it/s]
3%|3 | Permuting : 31/999 [00:01<00:53, 18.00it/s]
3%|3 | Permuting : 33/999 [00:01<00:49, 19.33it/s]
3%|3 | Permuting : 34/999 [00:02<00:51, 18.87it/s]
4%|3 | Permuting : 36/999 [00:02<00:47, 20.16it/s]
4%|3 | Permuting : 38/999 [00:02<00:44, 21.43it/s]
4%|3 | Permuting : 39/999 [00:02<00:44, 21.67it/s]
4%|4 | Permuting : 41/999 [00:02<00:41, 22.94it/s]
4%|4 | Permuting : 43/999 [00:02<00:41, 23.14it/s]
4%|4 | Permuting : 44/999 [00:02<00:40, 23.36it/s]
5%|4 | Permuting : 45/999 [00:02<00:42, 22.57it/s]
5%|4 | Permuting : 47/999 [00:02<00:40, 23.78it/s]
5%|4 | Permuting : 48/999 [00:02<00:39, 23.87it/s]
5%|4 | Permuting : 49/999 [00:02<00:53, 17.92it/s]
5%|5 | Permuting : 50/999 [00:02<00:52, 18.23it/s]
5%|5 | Permuting : 52/999 [00:02<00:49, 19.32it/s]
6%|5 | Permuting : 55/999 [00:02<00:44, 21.22it/s]
6%|5 | Permuting : 56/999 [00:02<00:44, 21.36it/s]
6%|5 | Permuting : 57/999 [00:02<00:43, 21.50it/s]
6%|5 | Permuting : 58/999 [00:03<00:43, 21.73it/s]
6%|5 | Permuting : 59/999 [00:03<00:42, 21.88it/s]
6%|6 | Permuting : 60/999 [00:03<00:44, 21.28it/s]
6%|6 | Permuting : 62/999 [00:03<00:41, 22.40it/s]
6%|6 | Permuting : 63/999 [00:03<00:42, 21.77it/s]
6%|6 | Permuting : 64/999 [00:03<00:42, 21.99it/s]
7%|6 | Permuting : 65/999 [00:03<00:42, 22.22it/s]
7%|6 | Permuting : 67/999 [00:03<00:39, 23.36it/s]
7%|6 | Permuting : 68/999 [00:03<00:39, 23.52it/s]
7%|6 | Permuting : 69/999 [00:03<00:39, 23.60it/s]
7%|7 | Permuting : 71/999 [00:03<00:37, 24.76it/s]
7%|7 | Permuting : 73/999 [00:03<00:35, 25.89it/s]
7%|7 | Permuting : 74/999 [00:03<00:35, 25.88it/s]
8%|7 | Permuting : 76/999 [00:03<00:34, 27.01it/s]
8%|7 | Permuting : 77/999 [00:03<00:46, 19.97it/s]
8%|7 | Permuting : 78/999 [00:03<00:45, 20.14it/s]
8%|7 | Permuting : 79/999 [00:04<00:45, 20.39it/s]
8%|8 | Permuting : 80/999 [00:04<00:46, 19.94it/s]
8%|8 | Permuting : 82/999 [00:04<00:43, 21.00it/s]
9%|8 | Permuting : 85/999 [00:04<00:39, 22.87it/s]
9%|8 | Permuting : 86/999 [00:04<00:41, 22.25it/s]
9%|8 | Permuting : 88/999 [00:04<00:39, 23.28it/s]
9%|9 | Permuting : 90/999 [00:04<00:37, 24.30it/s]
9%|9 | Permuting : 91/999 [00:04<00:37, 24.37it/s]
9%|9 | Permuting : 93/999 [00:04<00:35, 25.40it/s]
9%|9 | Permuting : 94/999 [00:04<00:35, 25.42it/s]
10%|9 | Permuting : 95/999 [00:04<00:35, 25.54it/s]
10%|9 | Permuting : 96/999 [00:04<00:35, 25.61it/s]
10%|9 | Permuting : 97/999 [00:04<00:36, 24.83it/s]
10%|9 | Permuting : 98/999 [00:04<00:36, 24.86it/s]
10%|9 | Permuting : 99/999 [00:04<00:35, 25.01it/s]
10%|# | Permuting : 100/999 [00:04<00:35, 25.11it/s]
10%|# | Permuting : 101/999 [00:05<00:48, 18.60it/s]
10%|# | Permuting : 102/999 [00:05<00:47, 18.80it/s]
10%|# | Permuting : 103/999 [00:05<00:46, 19.08it/s]
10%|# | Permuting : 104/999 [00:05<00:46, 19.28it/s]
11%|# | Permuting : 106/999 [00:05<00:43, 20.34it/s]
11%|# | Permuting : 107/999 [00:05<00:43, 20.50it/s]
11%|# | Permuting : 109/999 [00:05<00:41, 21.58it/s]
11%|#1 | Permuting : 110/999 [00:05<00:40, 21.72it/s]
11%|#1 | Permuting : 112/999 [00:05<00:40, 22.07it/s]
11%|#1 | Permuting : 113/999 [00:05<00:39, 22.19it/s]
12%|#1 | Permuting : 115/999 [00:05<00:37, 23.27it/s]
12%|#1 | Permuting : 117/999 [00:05<00:36, 24.22it/s]
12%|#1 | Permuting : 118/999 [00:05<00:36, 24.39it/s]
12%|#2 | Permuting : 120/999 [00:05<00:34, 25.45it/s]
12%|#2 | Permuting : 121/999 [00:05<00:34, 25.58it/s]
12%|#2 | Permuting : 123/999 [00:05<00:32, 26.65it/s]
12%|#2 | Permuting : 124/999 [00:05<00:32, 26.64it/s]
13%|#2 | Permuting : 125/999 [00:05<00:34, 25.64it/s]
13%|#2 | Permuting : 126/999 [00:05<00:33, 25.77it/s]
13%|#2 | Permuting : 127/999 [00:06<00:45, 19.18it/s]
13%|#2 | Permuting : 129/999 [00:06<00:44, 19.62it/s]
13%|#3 | Permuting : 130/999 [00:06<00:43, 19.79it/s]
13%|#3 | Permuting : 131/999 [00:06<00:43, 19.96it/s]
13%|#3 | Permuting : 132/999 [00:06<00:42, 20.21it/s]
13%|#3 | Permuting : 134/999 [00:06<00:40, 21.17it/s]
14%|#3 | Permuting : 135/999 [00:06<00:40, 21.39it/s]
14%|#3 | Permuting : 136/999 [00:06<00:40, 21.53it/s]
14%|#3 | Permuting : 138/999 [00:06<00:38, 22.60it/s]
14%|#3 | Permuting : 139/999 [00:06<00:37, 22.70it/s]
14%|#4 | Permuting : 140/999 [00:06<00:37, 22.80it/s]
14%|#4 | Permuting : 141/999 [00:06<00:37, 23.00it/s]
14%|#4 | Permuting : 143/999 [00:06<00:35, 24.10it/s]
14%|#4 | Permuting : 144/999 [00:06<00:35, 24.27it/s]
15%|#4 | Permuting : 145/999 [00:06<00:35, 24.32it/s]
15%|#4 | Permuting : 147/999 [00:06<00:33, 25.44it/s]
15%|#4 | Permuting : 149/999 [00:06<00:33, 25.59it/s]
15%|#5 | Permuting : 152/999 [00:06<00:31, 26.64it/s]
15%|#5 | Permuting : 153/999 [00:07<00:42, 20.01it/s]
16%|#5 | Permuting : 156/999 [00:07<00:38, 21.69it/s]
16%|#5 | Permuting : 157/999 [00:07<00:38, 21.80it/s]
16%|#5 | Permuting : 159/999 [00:07<00:36, 22.76it/s]
16%|#6 | Permuting : 160/999 [00:07<00:37, 22.18it/s]
16%|#6 | Permuting : 161/999 [00:07<00:37, 22.29it/s]
16%|#6 | Permuting : 162/999 [00:07<00:37, 22.48it/s]
16%|#6 | Permuting : 163/999 [00:07<00:36, 22.62it/s]
17%|#6 | Permuting : 165/999 [00:07<00:36, 22.77it/s]
17%|#6 | Permuting : 166/999 [00:07<00:36, 22.96it/s]
17%|#6 | Permuting : 167/999 [00:07<00:36, 23.05it/s]
17%|#6 | Permuting : 168/999 [00:07<00:37, 22.41it/s]
17%|#7 | Permuting : 170/999 [00:07<00:35, 23.44it/s]
17%|#7 | Permuting : 173/999 [00:07<00:33, 24.52it/s]
17%|#7 | Permuting : 174/999 [00:08<00:42, 19.44it/s]
18%|#7 | Permuting : 175/999 [00:08<00:41, 19.67it/s]
18%|#7 | Permuting : 176/999 [00:08<00:42, 19.31it/s]
18%|#7 | Permuting : 178/999 [00:08<00:40, 20.26it/s]
18%|#8 | Permuting : 182/999 [00:08<00:37, 22.01it/s]
18%|#8 | Permuting : 184/999 [00:08<00:35, 22.91it/s]
19%|#8 | Permuting : 185/999 [00:08<00:35, 23.05it/s]
19%|#8 | Permuting : 188/999 [00:08<00:32, 24.73it/s]
19%|#8 | Permuting : 189/999 [00:08<00:33, 24.04it/s]
19%|#9 | Permuting : 191/999 [00:08<00:32, 24.95it/s]
19%|#9 | Permuting : 194/999 [00:08<00:31, 25.84it/s]
20%|#9 | Permuting : 195/999 [00:08<00:31, 25.87it/s]
20%|#9 | Permuting : 196/999 [00:08<00:31, 25.86it/s]
20%|#9 | Permuting : 198/999 [00:08<00:29, 26.78it/s]
20%|## | Permuting : 200/999 [00:08<00:29, 27.51it/s]
20%|## | Permuting : 201/999 [00:08<00:28, 27.57it/s]
20%|## | Permuting : 202/999 [00:09<00:28, 27.52it/s]
20%|## | Permuting : 204/999 [00:09<00:27, 28.47it/s]
21%|## | Permuting : 205/999 [00:09<00:36, 21.90it/s]
21%|## | Permuting : 207/999 [00:09<00:34, 22.79it/s]
21%|## | Permuting : 208/999 [00:09<00:34, 22.93it/s]
21%|## | Permuting : 209/999 [00:09<00:34, 23.01it/s]
21%|##1 | Permuting : 210/999 [00:09<00:34, 23.18it/s]
21%|##1 | Permuting : 211/999 [00:09<00:33, 23.33it/s]
21%|##1 | Permuting : 214/999 [00:09<00:32, 24.34it/s]
22%|##1 | Permuting : 217/999 [00:09<00:30, 25.30it/s]
22%|##2 | Permuting : 220/999 [00:09<00:28, 26.99it/s]
22%|##2 | Permuting : 221/999 [00:09<00:28, 26.95it/s]
22%|##2 | Permuting : 223/999 [00:09<00:27, 27.84it/s]
22%|##2 | Permuting : 224/999 [00:09<00:27, 27.81it/s]
23%|##2 | Permuting : 225/999 [00:09<00:27, 27.75it/s]
23%|##2 | Permuting : 226/999 [00:09<00:27, 27.80it/s]
23%|##2 | Permuting : 227/999 [00:10<00:27, 27.85it/s]
23%|##2 | Permuting : 228/999 [00:10<00:28, 26.83it/s]
23%|##3 | Permuting : 230/999 [00:10<00:27, 27.81it/s]
23%|##3 | Permuting : 232/999 [00:10<00:34, 22.04it/s]
23%|##3 | Permuting : 233/999 [00:10<00:34, 22.22it/s]
24%|##3 | Permuting : 236/999 [00:10<00:31, 23.87it/s]
24%|##3 | Permuting : 238/999 [00:10<00:30, 24.77it/s]
24%|##3 | Permuting : 239/999 [00:10<00:30, 24.90it/s]
24%|##4 | Permuting : 241/999 [00:10<00:29, 25.67it/s]
24%|##4 | Permuting : 242/999 [00:10<00:29, 25.78it/s]
24%|##4 | Permuting : 243/999 [00:10<00:29, 25.77it/s]
25%|##4 | Permuting : 245/999 [00:10<00:28, 26.72it/s]
25%|##4 | Permuting : 249/999 [00:10<00:25, 29.38it/s]
25%|##5 | Permuting : 250/999 [00:10<00:26, 28.30it/s]
25%|##5 | Permuting : 252/999 [00:10<00:25, 29.20it/s]
26%|##5 | Permuting : 255/999 [00:10<00:24, 30.98it/s]
26%|##5 | Permuting : 256/999 [00:10<00:24, 30.79it/s]
26%|##5 | Permuting : 257/999 [00:11<00:24, 30.61it/s]
26%|##5 | Permuting : 259/999 [00:11<00:23, 31.51it/s]
26%|##6 | Permuting : 261/999 [00:11<00:23, 31.03it/s]
26%|##6 | Permuting : 262/999 [00:11<00:23, 30.98it/s]
27%|##6 | Permuting : 265/999 [00:11<00:22, 32.82it/s]
27%|##6 | Permuting : 266/999 [00:11<00:22, 32.56it/s]
27%|##6 | Permuting : 269/999 [00:11<00:22, 33.16it/s]
27%|##7 | Permuting : 270/999 [00:11<00:28, 25.24it/s]
27%|##7 | Permuting : 271/999 [00:11<00:28, 25.35it/s]
27%|##7 | Permuting : 274/999 [00:11<00:27, 26.22it/s]
28%|##7 | Permuting : 276/999 [00:11<00:27, 26.29it/s]
28%|##7 | Permuting : 277/999 [00:11<00:27, 26.37it/s]
28%|##7 | Permuting : 278/999 [00:11<00:28, 25.59it/s]
28%|##7 | Permuting : 279/999 [00:12<00:28, 25.69it/s]
28%|##8 | Permuting : 280/999 [00:12<00:27, 25.69it/s]
28%|##8 | Permuting : 282/999 [00:12<00:26, 26.61it/s]
29%|##8 | Permuting : 285/999 [00:12<00:25, 28.34it/s]
29%|##8 | Permuting : 287/999 [00:12<00:24, 29.10it/s]
29%|##8 | Permuting : 289/999 [00:12<00:23, 29.97it/s]
29%|##9 | Permuting : 290/999 [00:12<00:24, 28.85it/s]
29%|##9 | Permuting : 292/999 [00:12<00:23, 29.74it/s]
30%|##9 | Permuting : 295/999 [00:12<00:22, 31.50it/s]
30%|##9 | Permuting : 296/999 [00:12<00:23, 30.21it/s]
30%|##9 | Permuting : 297/999 [00:12<00:30, 23.21it/s]
30%|##9 | Permuting : 298/999 [00:12<00:30, 23.36it/s]
30%|### | Permuting : 301/999 [00:12<00:27, 24.95it/s]
30%|### | Permuting : 302/999 [00:12<00:27, 24.97it/s]
30%|### | Permuting : 304/999 [00:12<00:26, 25.84it/s]
31%|### | Permuting : 306/999 [00:12<00:26, 26.63it/s]
31%|### | Permuting : 307/999 [00:12<00:25, 26.71it/s]
31%|### | Permuting : 309/999 [00:13<00:25, 27.43it/s]
31%|###1 | Permuting : 310/999 [00:13<00:25, 27.49it/s]
31%|###1 | Permuting : 311/999 [00:13<00:25, 26.57it/s]
31%|###1 | Permuting : 313/999 [00:13<00:24, 27.48it/s]
31%|###1 | Permuting : 314/999 [00:13<00:24, 27.52it/s]
32%|###1 | Permuting : 316/999 [00:13<00:24, 27.35it/s]
32%|###1 | Permuting : 317/999 [00:13<00:24, 27.41it/s]
32%|###1 | Permuting : 318/999 [00:13<00:25, 26.46it/s]
32%|###2 | Permuting : 321/999 [00:13<00:23, 28.26it/s]
32%|###2 | Permuting : 322/999 [00:13<00:31, 21.53it/s]
32%|###2 | Permuting : 323/999 [00:13<00:31, 21.72it/s]
33%|###2 | Permuting : 326/999 [00:13<00:29, 22.69it/s]
33%|###2 | Permuting : 327/999 [00:13<00:29, 22.78it/s]
33%|###2 | Permuting : 329/999 [00:14<00:28, 23.66it/s]
33%|###3 | Permuting : 330/999 [00:14<00:28, 23.73it/s]
33%|###3 | Permuting : 333/999 [00:14<00:27, 24.67it/s]
34%|###3 | Permuting : 335/999 [00:14<00:26, 25.51it/s]
34%|###3 | Permuting : 336/999 [00:14<00:25, 25.62it/s]
34%|###3 | Permuting : 338/999 [00:14<00:25, 26.36it/s]
34%|###3 | Permuting : 339/999 [00:14<00:24, 26.44it/s]
34%|###4 | Permuting : 340/999 [00:14<00:24, 26.43it/s]
34%|###4 | Permuting : 341/999 [00:14<00:24, 26.40it/s]
34%|###4 | Permuting : 343/999 [00:14<00:23, 27.35it/s]
35%|###4 | Permuting : 345/999 [00:14<00:23, 28.22it/s]
35%|###4 | Permuting : 346/999 [00:14<00:23, 28.26it/s]
35%|###4 | Permuting : 347/999 [00:14<00:23, 28.17it/s]
35%|###4 | Permuting : 349/999 [00:14<00:22, 29.14it/s]
35%|###5 | Permuting : 352/999 [00:14<00:20, 31.02it/s]
35%|###5 | Permuting : 354/999 [00:14<00:20, 31.78it/s]
36%|###5 | Permuting : 355/999 [00:14<00:20, 31.71it/s]
36%|###5 | Permuting : 356/999 [00:15<00:27, 23.69it/s]
36%|###5 | Permuting : 359/999 [00:15<00:25, 24.63it/s]
36%|###6 | Permuting : 360/999 [00:15<00:25, 24.67it/s]
36%|###6 | Permuting : 362/999 [00:15<00:24, 25.56it/s]
36%|###6 | Permuting : 363/999 [00:15<00:24, 25.57it/s]
37%|###6 | Permuting : 366/999 [00:15<00:23, 27.28it/s]
37%|###6 | Permuting : 368/999 [00:15<00:23, 27.29it/s]
37%|###6 | Permuting : 369/999 [00:15<00:23, 27.36it/s]
37%|###7 | Permuting : 370/999 [00:15<00:23, 27.30it/s]
37%|###7 | Permuting : 371/999 [00:15<00:22, 27.35it/s]
37%|###7 | Permuting : 372/999 [00:15<00:22, 27.42it/s]
38%|###7 | Permuting : 375/999 [00:15<00:22, 28.28it/s]
38%|###7 | Permuting : 376/999 [00:15<00:22, 28.19it/s]
38%|###7 | Permuting : 377/999 [00:15<00:22, 28.10it/s]
38%|###7 | Permuting : 378/999 [00:15<00:22, 28.15it/s]
38%|###7 | Permuting : 379/999 [00:15<00:22, 28.13it/s]
38%|###8 | Permuting : 382/999 [00:15<00:20, 30.04it/s]
38%|###8 | Permuting : 384/999 [00:15<00:19, 30.98it/s]
39%|###8 | Permuting : 385/999 [00:15<00:19, 30.89it/s]
39%|###8 | Permuting : 388/999 [00:15<00:18, 32.82it/s]
39%|###8 | Permuting : 389/999 [00:16<00:25, 23.91it/s]
39%|###9 | Permuting : 390/999 [00:16<00:25, 23.96it/s]
39%|###9 | Permuting : 391/999 [00:16<00:25, 23.95it/s]
39%|###9 | Permuting : 392/999 [00:16<00:25, 24.10it/s]
39%|###9 | Permuting : 394/999 [00:16<00:24, 24.95it/s]
40%|###9 | Permuting : 396/999 [00:16<00:23, 25.89it/s]
40%|###9 | Permuting : 397/999 [00:16<00:23, 25.89it/s]
40%|###9 | Permuting : 398/999 [00:16<00:23, 25.95it/s]
40%|###9 | Permuting : 399/999 [00:16<00:23, 26.06it/s]
40%|#### | Permuting : 400/999 [00:16<00:23, 25.19it/s]
40%|#### | Permuting : 401/999 [00:16<00:23, 25.21it/s]
40%|#### | Permuting : 403/999 [00:16<00:22, 26.22it/s]
41%|#### | Permuting : 405/999 [00:16<00:22, 26.27it/s]
41%|#### | Permuting : 406/999 [00:16<00:22, 26.37it/s]
41%|#### | Permuting : 407/999 [00:17<00:28, 20.53it/s]
41%|#### | Permuting : 408/999 [00:17<00:28, 20.76it/s]
41%|####1 | Permuting : 411/999 [00:17<00:26, 21.84it/s]
41%|####1 | Permuting : 412/999 [00:17<00:26, 21.95it/s]
41%|####1 | Permuting : 414/999 [00:17<00:25, 22.90it/s]
42%|####1 | Permuting : 415/999 [00:17<00:25, 23.00it/s]
42%|####1 | Permuting : 416/999 [00:17<00:25, 23.09it/s]
42%|####1 | Permuting : 418/999 [00:17<00:24, 24.07it/s]
42%|####2 | Permuting : 420/999 [00:17<00:23, 24.18it/s]
42%|####2 | Permuting : 421/999 [00:17<00:23, 24.33it/s]
42%|####2 | Permuting : 422/999 [00:17<00:23, 24.40it/s]
42%|####2 | Permuting : 423/999 [00:17<00:23, 24.45it/s]
43%|####2 | Permuting : 425/999 [00:17<00:22, 25.46it/s]
43%|####2 | Permuting : 428/999 [00:17<00:21, 26.45it/s]
43%|####3 | Permuting : 431/999 [00:17<00:20, 28.29it/s]
43%|####3 | Permuting : 433/999 [00:17<00:20, 28.20it/s]
44%|####3 | Permuting : 435/999 [00:18<00:25, 22.03it/s]
44%|####3 | Permuting : 436/999 [00:18<00:25, 22.20it/s]
44%|####3 | Permuting : 438/999 [00:18<00:24, 23.08it/s]
44%|####4 | Permuting : 441/999 [00:18<00:22, 24.69it/s]
44%|####4 | Permuting : 442/999 [00:18<00:23, 24.03it/s]
44%|####4 | Permuting : 444/999 [00:18<00:22, 24.90it/s]
45%|####4 | Permuting : 447/999 [00:18<00:21, 25.78it/s]
45%|####4 | Permuting : 448/999 [00:18<00:21, 25.78it/s]
45%|####5 | Permuting : 450/999 [00:18<00:20, 26.65it/s]
45%|####5 | Permuting : 452/999 [00:18<00:19, 27.40it/s]
45%|####5 | Permuting : 453/999 [00:18<00:19, 27.46it/s]
46%|####5 | Permuting : 455/999 [00:18<00:19, 28.23it/s]
46%|####5 | Permuting : 456/999 [00:18<00:19, 28.26it/s]
46%|####5 | Permuting : 458/999 [00:18<00:18, 29.03it/s]
46%|####6 | Permuting : 460/999 [00:18<00:18, 29.92it/s]
46%|####6 | Permuting : 461/999 [00:18<00:18, 29.77it/s]
46%|####6 | Permuting : 463/999 [00:18<00:17, 30.67it/s]
47%|####6 | Permuting : 465/999 [00:18<00:17, 31.41it/s]
47%|####6 | Permuting : 466/999 [00:18<00:17, 31.35it/s]
47%|####6 | Permuting : 468/999 [00:18<00:16, 32.09it/s]
47%|####7 | Permuting : 470/999 [00:18<00:16, 32.97it/s]
47%|####7 | Permuting : 472/999 [00:19<00:15, 33.84it/s]
47%|####7 | Permuting : 473/999 [00:19<00:15, 33.66it/s]
47%|####7 | Permuting : 474/999 [00:19<00:21, 24.87it/s]
48%|####7 | Permuting : 477/999 [00:19<00:20, 25.76it/s]
48%|####8 | Permuting : 480/999 [00:19<00:19, 26.61it/s]
48%|####8 | Permuting : 481/999 [00:19<00:19, 26.60it/s]
48%|####8 | Permuting : 484/999 [00:19<00:18, 27.41it/s]
49%|####8 | Permuting : 486/999 [00:19<00:18, 28.24it/s]
49%|####8 | Permuting : 487/999 [00:19<00:18, 28.27it/s]
49%|####9 | Permuting : 490/999 [00:19<00:17, 29.94it/s]
49%|####9 | Permuting : 493/999 [00:19<00:16, 30.61it/s]
50%|####9 | Permuting : 495/999 [00:19<00:16, 31.28it/s]
50%|####9 | Permuting : 496/999 [00:19<00:16, 31.23it/s]
50%|####9 | Permuting : 497/999 [00:19<00:16, 31.16it/s]
50%|####9 | Permuting : 499/999 [00:20<00:15, 31.99it/s]
50%|##### | Permuting : 500/999 [00:20<00:15, 31.87it/s]
50%|##### | Permuting : 503/999 [00:20<00:15, 32.48it/s]
50%|##### | Permuting : 504/999 [00:20<00:20, 24.56it/s]
51%|##### | Permuting : 505/999 [00:20<00:20, 24.68it/s]
51%|##### | Permuting : 507/999 [00:20<00:19, 25.48it/s]
51%|##### | Permuting : 508/999 [00:20<00:19, 25.59it/s]
51%|#####1 | Permuting : 511/999 [00:20<00:18, 26.43it/s]
51%|#####1 | Permuting : 514/999 [00:20<00:17, 28.02it/s]
52%|#####1 | Permuting : 516/999 [00:20<00:16, 28.72it/s]
52%|#####1 | Permuting : 517/999 [00:20<00:16, 28.74it/s]
52%|#####1 | Permuting : 518/999 [00:20<00:16, 28.74it/s]
52%|#####2 | Permuting : 520/999 [00:20<00:16, 29.59it/s]
52%|#####2 | Permuting : 521/999 [00:20<00:16, 29.58it/s]
52%|#####2 | Permuting : 523/999 [00:20<00:15, 30.44it/s]
52%|#####2 | Permuting : 524/999 [00:20<00:15, 30.37it/s]
53%|#####2 | Permuting : 527/999 [00:20<00:14, 32.15it/s]
53%|#####2 | Permuting : 529/999 [00:21<00:14, 31.83it/s]
53%|#####3 | Permuting : 530/999 [00:21<00:14, 31.76it/s]
53%|#####3 | Permuting : 533/999 [00:21<00:14, 32.38it/s]
53%|#####3 | Permuting : 534/999 [00:21<00:14, 31.06it/s]
54%|#####3 | Permuting : 537/999 [00:21<00:14, 32.79it/s]
54%|#####3 | Permuting : 538/999 [00:21<00:18, 25.34it/s]
54%|#####3 | Permuting : 539/999 [00:21<00:18, 25.44it/s]
54%|#####4 | Permuting : 540/999 [00:21<00:18, 25.45it/s]
54%|#####4 | Permuting : 542/999 [00:21<00:17, 26.31it/s]
54%|#####4 | Permuting : 543/999 [00:21<00:17, 26.30it/s]
55%|#####4 | Permuting : 545/999 [00:21<00:16, 27.18it/s]
55%|#####4 | Permuting : 546/999 [00:21<00:16, 27.13it/s]
55%|#####4 | Permuting : 548/999 [00:21<00:16, 28.03it/s]
55%|#####4 | Permuting : 549/999 [00:21<00:16, 28.04it/s]
55%|#####5 | Permuting : 552/999 [00:21<00:14, 29.81it/s]
55%|#####5 | Permuting : 554/999 [00:22<00:15, 29.62it/s]
56%|#####5 | Permuting : 555/999 [00:22<00:14, 29.62it/s]
56%|#####5 | Permuting : 556/999 [00:22<00:15, 29.48it/s]
56%|#####5 | Permuting : 557/999 [00:22<00:14, 29.48it/s]
56%|#####5 | Permuting : 558/999 [00:22<00:14, 29.49it/s]
56%|#####5 | Permuting : 559/999 [00:22<00:14, 29.35it/s]
56%|#####6 | Permuting : 561/999 [00:22<00:14, 30.31it/s]
56%|#####6 | Permuting : 564/999 [00:22<00:13, 32.22it/s]
57%|#####6 | Permuting : 565/999 [00:22<00:14, 30.80it/s]
57%|#####6 | Permuting : 568/999 [00:22<00:13, 32.68it/s]
57%|#####6 | Permuting : 569/999 [00:22<00:17, 24.86it/s]
57%|#####7 | Permuting : 570/999 [00:22<00:17, 24.98it/s]
57%|#####7 | Permuting : 572/999 [00:22<00:16, 25.85it/s]
57%|#####7 | Permuting : 573/999 [00:22<00:16, 25.95it/s]
58%|#####7 | Permuting : 576/999 [00:22<00:15, 27.69it/s]
58%|#####7 | Permuting : 577/999 [00:22<00:15, 26.76it/s]
58%|#####7 | Permuting : 578/999 [00:22<00:15, 26.73it/s]
58%|#####8 | Permuting : 580/999 [00:23<00:15, 27.65it/s]
58%|#####8 | Permuting : 581/999 [00:23<00:15, 27.59it/s]
58%|#####8 | Permuting : 583/999 [00:23<00:14, 28.52it/s]
59%|#####8 | Permuting : 586/999 [00:23<00:14, 29.33it/s]
59%|#####9 | Permuting : 590/999 [00:23<00:13, 30.91it/s]
59%|#####9 | Permuting : 593/999 [00:23<00:12, 31.56it/s]
60%|#####9 | Permuting : 595/999 [00:23<00:12, 32.28it/s]
60%|#####9 | Permuting : 596/999 [00:23<00:12, 32.20it/s]
60%|#####9 | Permuting : 598/999 [00:23<00:12, 32.80it/s]
60%|#####9 | Permuting : 599/999 [00:23<00:12, 32.70it/s]
60%|###### | Permuting : 600/999 [00:23<00:12, 32.47it/s]
60%|###### | Permuting : 601/999 [00:23<00:16, 24.84it/s]
60%|###### | Permuting : 602/999 [00:23<00:15, 24.96it/s]
60%|###### | Permuting : 603/999 [00:23<00:15, 24.98it/s]
60%|###### | Permuting : 604/999 [00:23<00:15, 25.10it/s]
61%|###### | Permuting : 606/999 [00:24<00:15, 25.91it/s]
61%|###### | Permuting : 607/999 [00:24<00:15, 26.01it/s]
61%|######1 | Permuting : 610/999 [00:24<00:14, 26.88it/s]
61%|######1 | Permuting : 614/999 [00:24<00:13, 29.42it/s]
62%|######1 | Permuting : 616/999 [00:24<00:13, 29.29it/s]
62%|######1 | Permuting : 617/999 [00:24<00:13, 29.30it/s]
62%|######1 | Permuting : 619/999 [00:24<00:12, 30.16it/s]
62%|######2 | Permuting : 621/999 [00:24<00:12, 29.87it/s]
62%|######2 | Permuting : 622/999 [00:24<00:12, 29.86it/s]
62%|######2 | Permuting : 623/999 [00:24<00:13, 28.75it/s]
62%|######2 | Permuting : 624/999 [00:24<00:13, 28.75it/s]
63%|######2 | Permuting : 625/999 [00:24<00:13, 28.71it/s]
63%|######2 | Permuting : 626/999 [00:24<00:17, 21.14it/s]
63%|######2 | Permuting : 627/999 [00:25<00:17, 21.33it/s]
63%|######2 | Permuting : 628/999 [00:25<00:17, 21.45it/s]
63%|######2 | Permuting : 629/999 [00:25<00:17, 21.56it/s]
63%|######3 | Permuting : 630/999 [00:25<00:16, 21.76it/s]
63%|######3 | Permuting : 631/999 [00:25<00:16, 21.88it/s]
63%|######3 | Permuting : 632/999 [00:25<00:17, 21.37it/s]
63%|######3 | Permuting : 634/999 [00:25<00:16, 22.34it/s]
64%|######3 | Permuting : 637/999 [00:25<00:15, 24.08it/s]
64%|######3 | Permuting : 639/999 [00:25<00:14, 24.17it/s]
64%|######4 | Permuting : 641/999 [00:25<00:14, 25.10it/s]
64%|######4 | Permuting : 644/999 [00:25<00:13, 26.84it/s]
65%|######4 | Permuting : 645/999 [00:25<00:13, 26.80it/s]
65%|######4 | Permuting : 647/999 [00:25<00:12, 27.72it/s]
65%|######4 | Permuting : 648/999 [00:25<00:12, 27.65it/s]
65%|######5 | Permuting : 651/999 [00:25<00:11, 29.46it/s]
65%|######5 | Permuting : 653/999 [00:25<00:11, 29.29it/s]
65%|######5 | Permuting : 654/999 [00:25<00:11, 29.30it/s]
66%|######5 | Permuting : 655/999 [00:26<00:15, 22.45it/s]
66%|######5 | Permuting : 658/999 [00:26<00:14, 23.39it/s]
66%|######6 | Permuting : 660/999 [00:26<00:14, 24.15it/s]
66%|######6 | Permuting : 661/999 [00:26<00:13, 24.29it/s]
66%|######6 | Permuting : 662/999 [00:26<00:13, 24.32it/s]
67%|######6 | Permuting : 665/999 [00:26<00:12, 25.97it/s]
67%|######6 | Permuting : 668/999 [00:26<00:12, 26.81it/s]
67%|######7 | Permuting : 671/999 [00:26<00:11, 28.43it/s]
67%|######7 | Permuting : 673/999 [00:26<00:11, 28.27it/s]
68%|######7 | Permuting : 675/999 [00:26<00:11, 29.08it/s]
68%|######7 | Permuting : 677/999 [00:26<00:11, 28.99it/s]
68%|######7 | Permuting : 678/999 [00:26<00:11, 29.01it/s]
68%|######8 | Permuting : 681/999 [00:26<00:10, 30.65it/s]
68%|######8 | Permuting : 684/999 [00:26<00:09, 32.29it/s]
69%|######8 | Permuting : 685/999 [00:26<00:09, 32.07it/s]
69%|######8 | Permuting : 687/999 [00:26<00:09, 32.86it/s]
69%|######8 | Permuting : 688/999 [00:26<00:09, 32.61it/s]
69%|######8 | Permuting : 689/999 [00:26<00:09, 32.37it/s]
69%|######9 | Permuting : 691/999 [00:26<00:09, 33.19it/s]
69%|######9 | Permuting : 692/999 [00:27<00:12, 25.13it/s]
69%|######9 | Permuting : 693/999 [00:27<00:12, 25.14it/s]
70%|######9 | Permuting : 695/999 [00:27<00:11, 25.99it/s]
70%|######9 | Permuting : 697/999 [00:27<00:11, 25.98it/s]
70%|######9 | Permuting : 698/999 [00:27<00:11, 26.07it/s]
70%|######9 | Permuting : 699/999 [00:27<00:11, 26.06it/s]
70%|####### | Permuting : 700/999 [00:27<00:11, 26.04it/s]
70%|####### | Permuting : 701/999 [00:27<00:11, 26.14it/s]
70%|####### | Permuting : 704/999 [00:27<00:10, 27.89it/s]
71%|####### | Permuting : 705/999 [00:27<00:10, 27.82it/s]
71%|####### | Permuting : 706/999 [00:27<00:10, 27.75it/s]
71%|####### | Permuting : 708/999 [00:27<00:10, 28.68it/s]
71%|#######1 | Permuting : 710/999 [00:27<00:10, 28.61it/s]
71%|#######1 | Permuting : 711/999 [00:27<00:10, 28.51it/s]
71%|#######1 | Permuting : 712/999 [00:27<00:10, 28.41it/s]
71%|#######1 | Permuting : 714/999 [00:27<00:09, 29.36it/s]
72%|#######1 | Permuting : 715/999 [00:28<00:13, 21.78it/s]
72%|#######1 | Permuting : 716/999 [00:28<00:12, 21.97it/s]
72%|#######1 | Permuting : 719/999 [00:28<00:11, 23.61it/s]
72%|#######2 | Permuting : 722/999 [00:28<00:10, 25.25it/s]
72%|#######2 | Permuting : 724/999 [00:28<00:10, 26.12it/s]
73%|#######2 | Permuting : 725/999 [00:28<00:10, 26.21it/s]
73%|#######2 | Permuting : 726/999 [00:28<00:10, 26.19it/s]
73%|#######2 | Permuting : 727/999 [00:28<00:10, 26.29it/s]
73%|#######2 | Permuting : 729/999 [00:28<00:09, 27.10it/s]
73%|#######3 | Permuting : 731/999 [00:28<00:09, 28.02it/s]
73%|#######3 | Permuting : 733/999 [00:28<00:09, 28.00it/s]
73%|#######3 | Permuting : 734/999 [00:28<00:09, 28.04it/s]
74%|#######3 | Permuting : 735/999 [00:28<00:09, 27.96it/s]
74%|#######3 | Permuting : 736/999 [00:28<00:09, 28.01it/s]
74%|#######3 | Permuting : 737/999 [00:28<00:09, 26.95it/s]
74%|#######3 | Permuting : 739/999 [00:28<00:09, 27.92it/s]
74%|#######4 | Permuting : 740/999 [00:28<00:09, 27.87it/s]
74%|#######4 | Permuting : 741/999 [00:28<00:09, 27.79it/s]
74%|#######4 | Permuting : 742/999 [00:29<00:09, 27.85it/s]
74%|#######4 | Permuting : 743/999 [00:29<00:09, 27.82it/s]
74%|#######4 | Permuting : 744/999 [00:29<00:12, 20.67it/s]
75%|#######4 | Permuting : 745/999 [00:29<00:12, 20.89it/s]
75%|#######4 | Permuting : 747/999 [00:29<00:11, 21.86it/s]
75%|#######4 | Permuting : 749/999 [00:29<00:11, 22.09it/s]
75%|#######5 | Permuting : 750/999 [00:29<00:11, 22.29it/s]
75%|#######5 | Permuting : 752/999 [00:29<00:10, 22.50it/s]
75%|#######5 | Permuting : 753/999 [00:29<00:10, 22.68it/s]
75%|#######5 | Permuting : 754/999 [00:29<00:11, 22.09it/s]
76%|#######5 | Permuting : 757/999 [00:29<00:10, 23.88it/s]
76%|#######5 | Permuting : 758/999 [00:29<00:10, 23.21it/s]
76%|#######6 | Permuting : 760/999 [00:29<00:09, 24.18it/s]
76%|#######6 | Permuting : 762/999 [00:29<00:09, 25.05it/s]
76%|#######6 | Permuting : 763/999 [00:30<00:09, 25.18it/s]
76%|#######6 | Permuting : 764/999 [00:30<00:09, 25.24it/s]
77%|#######6 | Permuting : 767/999 [00:30<00:08, 27.11it/s]
77%|#######7 | Permuting : 770/999 [00:30<00:07, 28.96it/s]
77%|#######7 | Permuting : 773/999 [00:30<00:07, 30.79it/s]
77%|#######7 | Permuting : 774/999 [00:30<00:09, 23.41it/s]
78%|#######7 | Permuting : 776/999 [00:30<00:09, 24.29it/s]
78%|#######7 | Permuting : 779/999 [00:30<00:08, 25.18it/s]
78%|#######8 | Permuting : 781/999 [00:30<00:08, 26.03it/s]
78%|#######8 | Permuting : 782/999 [00:30<00:08, 26.04it/s]
78%|#######8 | Permuting : 783/999 [00:30<00:08, 26.03it/s]
78%|#######8 | Permuting : 784/999 [00:30<00:08, 26.12it/s]
79%|#######8 | Permuting : 785/999 [00:30<00:08, 26.18it/s]
79%|#######8 | Permuting : 786/999 [00:30<00:08, 26.16it/s]
79%|#######8 | Permuting : 788/999 [00:30<00:07, 27.10it/s]
79%|#######9 | Permuting : 790/999 [00:30<00:07, 27.14it/s]
79%|#######9 | Permuting : 791/999 [00:31<00:07, 27.09it/s]
79%|#######9 | Permuting : 793/999 [00:31<00:07, 28.03it/s]
79%|#######9 | Permuting : 794/999 [00:31<00:07, 27.94it/s]
80%|#######9 | Permuting : 795/999 [00:31<00:07, 27.87it/s]
80%|#######9 | Permuting : 796/999 [00:31<00:07, 27.92it/s]
80%|#######9 | Permuting : 797/999 [00:31<00:07, 27.96it/s]
80%|#######9 | Permuting : 798/999 [00:31<00:07, 27.88it/s]
80%|######## | Permuting : 800/999 [00:31<00:06, 28.90it/s]
80%|######## | Permuting : 802/999 [00:31<00:08, 22.46it/s]
80%|######## | Permuting : 803/999 [00:31<00:08, 22.64it/s]
80%|######## | Permuting : 804/999 [00:31<00:08, 22.74it/s]
81%|######## | Permuting : 806/999 [00:31<00:08, 23.71it/s]
81%|######## | Permuting : 809/999 [00:31<00:07, 24.71it/s]
81%|########1 | Permuting : 811/999 [00:31<00:07, 24.78it/s]
81%|########1 | Permuting : 812/999 [00:31<00:07, 24.91it/s]
81%|########1 | Permuting : 813/999 [00:31<00:07, 24.94it/s]
81%|########1 | Permuting : 814/999 [00:32<00:07, 24.19it/s]
82%|########1 | Permuting : 815/999 [00:32<00:07, 24.34it/s]
82%|########1 | Permuting : 816/999 [00:32<00:07, 23.63it/s]
82%|########1 | Permuting : 817/999 [00:32<00:07, 23.69it/s]
82%|########1 | Permuting : 818/999 [00:32<00:07, 23.86it/s]
82%|########1 | Permuting : 819/999 [00:32<00:07, 23.92it/s]
82%|########2 | Permuting : 821/999 [00:32<00:07, 24.96it/s]
82%|########2 | Permuting : 822/999 [00:32<00:09, 19.29it/s]
82%|########2 | Permuting : 824/999 [00:32<00:08, 19.67it/s]
83%|########2 | Permuting : 825/999 [00:32<00:08, 19.91it/s]
83%|########2 | Permuting : 826/999 [00:32<00:08, 20.07it/s]
83%|########2 | Permuting : 828/999 [00:32<00:08, 21.05it/s]
83%|########2 | Permuting : 829/999 [00:32<00:08, 21.19it/s]
83%|########3 | Permuting : 830/999 [00:32<00:07, 21.39it/s]
83%|########3 | Permuting : 831/999 [00:32<00:07, 21.61it/s]
83%|########3 | Permuting : 832/999 [00:33<00:07, 21.08it/s]
83%|########3 | Permuting : 834/999 [00:33<00:07, 22.11it/s]
84%|########3 | Permuting : 835/999 [00:33<00:07, 22.24it/s]
84%|########3 | Permuting : 836/999 [00:33<00:07, 21.66it/s]
84%|########3 | Permuting : 837/999 [00:33<00:07, 21.75it/s]
84%|########3 | Permuting : 838/999 [00:33<00:07, 21.97it/s]
84%|########3 | Permuting : 839/999 [00:33<00:09, 17.39it/s]
84%|########4 | Permuting : 841/999 [00:33<00:08, 17.88it/s]
84%|########4 | Permuting : 842/999 [00:33<00:08, 18.16it/s]
85%|########4 | Permuting : 845/999 [00:33<00:07, 19.34it/s]
85%|########4 | Permuting : 846/999 [00:33<00:07, 19.55it/s]
85%|########4 | Permuting : 849/999 [00:33<00:07, 20.67it/s]
85%|########5 | Permuting : 852/999 [00:33<00:06, 22.35it/s]
85%|########5 | Permuting : 853/999 [00:33<00:06, 22.44it/s]
85%|########5 | Permuting : 854/999 [00:34<00:06, 22.54it/s]
86%|########5 | Permuting : 855/999 [00:34<00:06, 22.72it/s]
86%|########5 | Permuting : 857/999 [00:34<00:06, 23.61it/s]
86%|########5 | Permuting : 858/999 [00:34<00:05, 23.62it/s]
86%|########5 | Permuting : 859/999 [00:34<00:05, 23.79it/s]
86%|########6 | Permuting : 862/999 [00:34<00:05, 25.65it/s]
86%|########6 | Permuting : 863/999 [00:34<00:05, 25.71it/s]
87%|########6 | Permuting : 865/999 [00:34<00:05, 25.77it/s]
87%|########6 | Permuting : 866/999 [00:34<00:05, 25.88it/s]
87%|########6 | Permuting : 869/999 [00:34<00:04, 27.76it/s]
87%|########7 | Permuting : 871/999 [00:34<00:05, 22.16it/s]
87%|########7 | Permuting : 872/999 [00:34<00:05, 22.34it/s]
87%|########7 | Permuting : 873/999 [00:34<00:05, 22.44it/s]
88%|########7 | Permuting : 875/999 [00:34<00:05, 23.37it/s]
88%|########7 | Permuting : 876/999 [00:34<00:05, 23.44it/s]
88%|########7 | Permuting : 877/999 [00:34<00:05, 23.51it/s]
88%|########7 | Permuting : 879/999 [00:34<00:04, 24.48it/s]
88%|########8 | Permuting : 880/999 [00:35<00:05, 23.77it/s]
88%|########8 | Permuting : 881/999 [00:35<00:04, 23.83it/s]
88%|########8 | Permuting : 882/999 [00:35<00:04, 23.99it/s]
88%|########8 | Permuting : 883/999 [00:35<00:04, 24.13it/s]
88%|########8 | Permuting : 884/999 [00:35<00:04, 23.41it/s]
89%|########8 | Permuting : 886/999 [00:35<00:04, 24.44it/s]
89%|########8 | Permuting : 887/999 [00:35<00:04, 23.69it/s]
89%|########8 | Permuting : 888/999 [00:35<00:05, 18.66it/s]
89%|########8 | Permuting : 889/999 [00:35<00:05, 18.92it/s]
89%|########9 | Permuting : 890/999 [00:35<00:05, 18.60it/s]
89%|########9 | Permuting : 892/999 [00:35<00:05, 19.57it/s]
89%|########9 | Permuting : 893/999 [00:35<00:05, 19.76it/s]
90%|########9 | Permuting : 895/999 [00:35<00:05, 20.74it/s]
90%|########9 | Permuting : 896/999 [00:35<00:05, 20.36it/s]
90%|########9 | Permuting : 899/999 [00:36<00:04, 22.11it/s]
90%|######### | Permuting : 901/999 [00:36<00:04, 23.07it/s]
90%|######### | Permuting : 902/999 [00:36<00:04, 23.18it/s]
90%|######### | Permuting : 903/999 [00:36<00:04, 23.26it/s]
90%|######### | Permuting : 904/999 [00:36<00:04, 23.44it/s]
91%|######### | Permuting : 908/999 [00:36<00:03, 25.29it/s]
91%|######### | Permuting : 909/999 [00:36<00:03, 24.52it/s]
91%|#########1| Permuting : 911/999 [00:36<00:03, 25.48it/s]
91%|#########1| Permuting : 913/999 [00:36<00:04, 19.86it/s]
91%|#########1| Permuting : 914/999 [00:36<00:04, 20.08it/s]
92%|#########1| Permuting : 915/999 [00:36<00:04, 20.23it/s]
92%|#########1| Permuting : 916/999 [00:36<00:04, 20.44it/s]
92%|#########1| Permuting : 917/999 [00:36<00:03, 20.64it/s]
92%|#########1| Permuting : 919/999 [00:36<00:03, 20.88it/s]
92%|#########2| Permuting : 920/999 [00:37<00:03, 21.09it/s]
92%|#########2| Permuting : 921/999 [00:37<00:03, 21.22it/s]
92%|#########2| Permuting : 923/999 [00:37<00:03, 22.19it/s]
93%|#########2| Permuting : 925/999 [00:37<00:03, 23.04it/s]
93%|#########2| Permuting : 927/999 [00:37<00:03, 23.30it/s]
93%|#########2| Permuting : 928/999 [00:37<00:03, 23.37it/s]
93%|#########3| Permuting : 930/999 [00:37<00:02, 24.34it/s]
93%|#########3| Permuting : 931/999 [00:37<00:02, 24.44it/s]
93%|#########3| Permuting : 934/999 [00:37<00:02, 25.43it/s]
94%|#########3| Permuting : 936/999 [00:37<00:02, 26.36it/s]
94%|#########3| Permuting : 937/999 [00:37<00:02, 26.45it/s]
94%|#########3| Permuting : 938/999 [00:37<00:02, 20.36it/s]
94%|#########3| Permuting : 939/999 [00:37<00:02, 20.57it/s]
94%|#########4| Permuting : 940/999 [00:37<00:02, 20.71it/s]
94%|#########4| Permuting : 942/999 [00:37<00:02, 21.64it/s]
94%|#########4| Permuting : 943/999 [00:38<00:02, 21.15it/s]
94%|#########4| Permuting : 944/999 [00:38<00:02, 21.28it/s]
95%|#########4| Permuting : 945/999 [00:38<00:02, 21.49it/s]
95%|#########4| Permuting : 946/999 [00:38<00:02, 21.70it/s]
95%|#########4| Permuting : 949/999 [00:38<00:02, 23.47it/s]
95%|#########5| Permuting : 952/999 [00:38<00:01, 24.49it/s]
95%|#########5| Permuting : 954/999 [00:38<00:01, 25.32it/s]
96%|#########5| Permuting : 956/999 [00:38<00:01, 26.25it/s]
96%|#########5| Permuting : 959/999 [00:38<00:01, 28.01it/s]
96%|#########6| Permuting : 961/999 [00:38<00:01, 27.87it/s]
96%|#########6| Permuting : 962/999 [00:38<00:01, 27.92it/s]
96%|#########6| Permuting : 963/999 [00:38<00:01, 27.85it/s]
96%|#########6| Permuting : 964/999 [00:38<00:01, 27.78it/s]
97%|#########6| Permuting : 965/999 [00:38<00:01, 21.59it/s]
97%|#########6| Permuting : 966/999 [00:38<00:01, 21.78it/s]
97%|#########6| Permuting : 968/999 [00:38<00:01, 22.68it/s]
97%|#########6| Permuting : 969/999 [00:38<00:01, 22.85it/s]
97%|#########7| Permuting : 971/999 [00:39<00:01, 23.02it/s]
97%|#########7| Permuting : 973/999 [00:39<00:01, 23.95it/s]
97%|#########7| Permuting : 974/999 [00:39<00:01, 24.00it/s]
98%|#########7| Permuting : 976/999 [00:39<00:00, 24.95it/s]
98%|#########7| Permuting : 979/999 [00:39<00:00, 26.70it/s]
98%|#########8| Permuting : 980/999 [00:39<00:00, 25.81it/s]
98%|#########8| Permuting : 982/999 [00:39<00:00, 26.57it/s]
98%|#########8| Permuting : 983/999 [00:39<00:00, 26.65it/s]
99%|#########8| Permuting : 986/999 [00:39<00:00, 28.44it/s]
99%|#########8| Permuting : 987/999 [00:39<00:00, 28.40it/s]
99%|#########8| Permuting : 989/999 [00:39<00:00, 28.33it/s]
99%|#########9| Permuting : 990/999 [00:39<00:00, 28.37it/s]
99%|#########9| Permuting : 992/999 [00:39<00:00, 29.26it/s]
99%|#########9| Permuting : 993/999 [00:39<00:00, 29.27it/s]
100%|#########9| Permuting : 996/999 [00:39<00:00, 31.14it/s]
100%|#########9| Permuting : 998/999 [00:40<00:00, 23.88it/s]
100%|##########| Permuting : 999/999 [00:40<00:00, 24.06it/s]
100%|##########| Permuting : 999/999 [00:40<00:00, 24.93it/s]
```

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',
vlim=(np.min, 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]]))
# remove the title that would otherwise say "0.000 s"
ax_topo.set_title("")
# 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)
plt.show()
```

## Exercises#

## References#

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

**Estimated memory usage:** 128 MB