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.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)
# 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, 28.82it/s]
0%| | Permuting : 3/999 [00:00<00:22, 44.01it/s]
1%| | Permuting : 5/999 [00:00<00:20, 49.22it/s]
1%| | Permuting : 8/999 [00:00<00:16, 59.78it/s]
1%|1 | Permuting : 10/999 [00:00<00:16, 59.57it/s]
1%|1 | Permuting : 13/999 [00:00<00:15, 65.04it/s]
2%|1 | Permuting : 15/999 [00:00<00:15, 64.03it/s]
2%|1 | Permuting : 18/999 [00:00<00:14, 67.62it/s]
2%|2 | Permuting : 21/999 [00:00<00:13, 70.43it/s]
2%|2 | Permuting : 24/999 [00:00<00:13, 72.66it/s]
3%|2 | Permuting : 26/999 [00:00<00:13, 71.08it/s]
3%|2 | Permuting : 29/999 [00:00<00:13, 72.96it/s]
3%|3 | Permuting : 31/999 [00:00<00:13, 71.56it/s]
3%|3 | Permuting : 33/999 [00:00<00:13, 70.27it/s]
4%|3 | Permuting : 36/999 [00:00<00:13, 71.99it/s]
4%|3 | Permuting : 38/999 [00:00<00:13, 70.83it/s]
4%|4 | Permuting : 40/999 [00:00<00:13, 69.83it/s]
4%|4 | Permuting : 42/999 [00:00<00:13, 68.77it/s]
5%|4 | Permuting : 45/999 [00:00<00:13, 70.35it/s]
5%|4 | Permuting : 47/999 [00:00<00:13, 69.45it/s]
5%|4 | Permuting : 49/999 [00:00<00:13, 68.66it/s]
5%|5 | Permuting : 51/999 [00:00<00:13, 67.94it/s]
5%|5 | Permuting : 53/999 [00:00<00:14, 67.23it/s]
6%|5 | Permuting : 56/999 [00:00<00:13, 68.71it/s]
6%|5 | Permuting : 58/999 [00:00<00:13, 68.02it/s]
6%|6 | Permuting : 60/999 [00:00<00:13, 67.41it/s]
6%|6 | Permuting : 62/999 [00:00<00:14, 66.83it/s]
6%|6 | Permuting : 64/999 [00:00<00:14, 66.31it/s]
7%|6 | Permuting : 66/999 [00:00<00:14, 65.83it/s]
7%|6 | Permuting : 69/999 [00:01<00:13, 67.25it/s]
7%|7 | Permuting : 71/999 [00:01<00:13, 66.73it/s]
7%|7 | Permuting : 73/999 [00:01<00:13, 66.25it/s]
8%|7 | Permuting : 76/999 [00:01<00:13, 67.59it/s]
8%|7 | Permuting : 78/999 [00:01<00:13, 67.08it/s]
8%|8 | Permuting : 80/999 [00:01<00:13, 66.59it/s]
8%|8 | Permuting : 83/999 [00:01<00:13, 67.90it/s]
9%|8 | Permuting : 85/999 [00:01<00:13, 67.38it/s]
9%|8 | Permuting : 88/999 [00:01<00:13, 68.61it/s]
9%|9 | Permuting : 90/999 [00:01<00:13, 68.07it/s]
9%|9 | Permuting : 93/999 [00:01<00:13, 69.25it/s]
10%|9 | Permuting : 96/999 [00:01<00:12, 70.36it/s]
10%|9 | Permuting : 98/999 [00:01<00:12, 69.73it/s]
10%|# | Permuting : 101/999 [00:01<00:12, 70.79it/s]
10%|# | Permuting : 104/999 [00:01<00:12, 71.79it/s]
11%|# | Permuting : 107/999 [00:01<00:12, 72.72it/s]
11%|#1 | Permuting : 110/999 [00:01<00:12, 73.59it/s]
11%|#1 | Permuting : 112/999 [00:01<00:12, 72.80it/s]
12%|#1 | Permuting : 115/999 [00:01<00:11, 73.67it/s]
12%|#1 | Permuting : 118/999 [00:01<00:11, 74.48it/s]
12%|#2 | Permuting : 120/999 [00:01<00:11, 73.66it/s]
12%|#2 | Permuting : 123/999 [00:01<00:11, 74.46it/s]
13%|#2 | Permuting : 126/999 [00:01<00:11, 75.23it/s]
13%|#2 | Permuting : 129/999 [00:01<00:11, 75.96it/s]
13%|#3 | Permuting : 131/999 [00:01<00:11, 75.07it/s]
13%|#3 | Permuting : 134/999 [00:01<00:11, 75.80it/s]
14%|#3 | Permuting : 137/999 [00:01<00:11, 76.48it/s]
14%|#4 | Permuting : 140/999 [00:01<00:11, 77.12it/s]
14%|#4 | Permuting : 143/999 [00:01<00:11, 77.73it/s]
15%|#4 | Permuting : 145/999 [00:02<00:11, 76.74it/s]
15%|#4 | Permuting : 148/999 [00:02<00:11, 77.35it/s]
15%|#5 | Permuting : 151/999 [00:02<00:10, 77.93it/s]
15%|#5 | Permuting : 154/999 [00:02<00:10, 78.48it/s]
16%|#5 | Permuting : 157/999 [00:02<00:10, 79.02it/s]
16%|#6 | Permuting : 160/999 [00:02<00:10, 79.51it/s]
16%|#6 | Permuting : 163/999 [00:02<00:10, 79.98it/s]
17%|#6 | Permuting : 166/999 [00:02<00:10, 80.44it/s]
17%|#6 | Permuting : 169/999 [00:02<00:10, 80.87it/s]
17%|#7 | Permuting : 172/999 [00:02<00:10, 81.28it/s]
17%|#7 | Permuting : 174/999 [00:02<00:10, 80.11it/s]
18%|#7 | Permuting : 177/999 [00:02<00:10, 80.54it/s]
18%|#8 | Permuting : 180/999 [00:02<00:10, 80.96it/s]
18%|#8 | Permuting : 183/999 [00:02<00:10, 81.34it/s]
19%|#8 | Permuting : 185/999 [00:02<00:10, 80.21it/s]
19%|#8 | Permuting : 188/999 [00:02<00:10, 80.63it/s]
19%|#9 | Permuting : 191/999 [00:02<00:09, 81.04it/s]
19%|#9 | Permuting : 194/999 [00:02<00:09, 81.43it/s]
20%|#9 | Permuting : 197/999 [00:02<00:09, 81.81it/s]
20%|#9 | Permuting : 199/999 [00:02<00:09, 80.66it/s]
20%|## | Permuting : 202/999 [00:02<00:09, 81.07it/s]
21%|## | Permuting : 205/999 [00:02<00:09, 81.45it/s]
21%|## | Permuting : 208/999 [00:02<00:09, 81.81it/s]
21%|##1 | Permuting : 211/999 [00:02<00:09, 82.16it/s]
21%|##1 | Permuting : 213/999 [00:02<00:09, 80.98it/s]
22%|##1 | Permuting : 216/999 [00:02<00:09, 81.37it/s]
22%|##1 | Permuting : 219/999 [00:02<00:09, 81.74it/s]
22%|##2 | Permuting : 221/999 [00:02<00:09, 80.57it/s]
22%|##2 | Permuting : 224/999 [00:02<00:09, 80.98it/s]
23%|##2 | Permuting : 227/999 [00:02<00:09, 81.37it/s]
23%|##3 | Permuting : 230/999 [00:03<00:09, 81.75it/s]
23%|##3 | Permuting : 233/999 [00:03<00:09, 82.10it/s]
24%|##3 | Permuting : 236/999 [00:03<00:09, 82.42it/s]
24%|##3 | Permuting : 238/999 [00:03<00:09, 81.25it/s]
24%|##4 | Permuting : 241/999 [00:03<00:09, 81.63it/s]
24%|##4 | Permuting : 244/999 [00:03<00:09, 81.99it/s]
25%|##4 | Permuting : 247/999 [00:03<00:09, 82.33it/s]
25%|##5 | Permuting : 250/999 [00:03<00:09, 82.64it/s]
25%|##5 | Permuting : 253/999 [00:03<00:08, 82.93it/s]
26%|##5 | Permuting : 256/999 [00:03<00:08, 83.21it/s]
26%|##5 | Permuting : 259/999 [00:03<00:08, 83.49it/s]
26%|##6 | Permuting : 261/999 [00:03<00:08, 82.27it/s]
26%|##6 | Permuting : 264/999 [00:03<00:08, 82.61it/s]
27%|##6 | Permuting : 267/999 [00:03<00:08, 82.91it/s]
27%|##7 | Permuting : 270/999 [00:03<00:08, 83.21it/s]
27%|##7 | Permuting : 273/999 [00:03<00:08, 83.49it/s]
28%|##7 | Permuting : 276/999 [00:03<00:08, 83.76it/s]
28%|##7 | Permuting : 278/999 [00:03<00:08, 82.52it/s]
28%|##8 | Permuting : 281/999 [00:03<00:08, 82.83it/s]
28%|##8 | Permuting : 284/999 [00:03<00:08, 83.12it/s]
29%|##8 | Permuting : 287/999 [00:03<00:08, 83.40it/s]
29%|##9 | Permuting : 290/999 [00:03<00:08, 83.67it/s]
29%|##9 | Permuting : 292/999 [00:03<00:08, 82.44it/s]
30%|##9 | Permuting : 295/999 [00:03<00:08, 82.76it/s]
30%|##9 | Permuting : 298/999 [00:03<00:08, 83.06it/s]
30%|### | Permuting : 301/999 [00:03<00:08, 83.35it/s]
30%|### | Permuting : 304/999 [00:03<00:08, 83.63it/s]
31%|### | Permuting : 307/999 [00:03<00:08, 83.89it/s]
31%|###1 | Permuting : 310/999 [00:03<00:08, 84.13it/s]
31%|###1 | Permuting : 312/999 [00:03<00:08, 82.84it/s]
32%|###1 | Permuting : 315/999 [00:04<00:08, 83.13it/s]
32%|###1 | Permuting : 318/999 [00:04<00:08, 83.40it/s]
32%|###2 | Permuting : 321/999 [00:04<00:08, 83.66it/s]
32%|###2 | Permuting : 324/999 [00:04<00:08, 83.92it/s]
33%|###2 | Permuting : 327/999 [00:04<00:07, 84.15it/s]
33%|###3 | Permuting : 330/999 [00:04<00:07, 84.36it/s]
33%|###3 | Permuting : 333/999 [00:04<00:07, 84.57it/s]
34%|###3 | Permuting : 336/999 [00:04<00:07, 84.76it/s]
34%|###3 | Permuting : 339/999 [00:04<00:07, 84.95it/s]
34%|###4 | Permuting : 342/999 [00:04<00:07, 85.15it/s]
35%|###4 | Permuting : 345/999 [00:04<00:07, 85.33it/s]
35%|###4 | Permuting : 348/999 [00:04<00:07, 85.51it/s]
35%|###5 | Permuting : 351/999 [00:04<00:07, 85.68it/s]
35%|###5 | Permuting : 354/999 [00:04<00:07, 85.83it/s]
36%|###5 | Permuting : 357/999 [00:04<00:07, 85.97it/s]
36%|###6 | Permuting : 360/999 [00:04<00:07, 86.09it/s]
36%|###6 | Permuting : 363/999 [00:04<00:07, 86.21it/s]
37%|###6 | Permuting : 366/999 [00:04<00:07, 86.32it/s]
37%|###6 | Permuting : 369/999 [00:04<00:07, 86.45it/s]
37%|###7 | Permuting : 372/999 [00:04<00:07, 86.56it/s]
37%|###7 | Permuting : 374/999 [00:04<00:07, 85.19it/s]
38%|###7 | Permuting : 377/999 [00:04<00:07, 85.36it/s]
38%|###8 | Permuting : 380/999 [00:04<00:07, 85.54it/s]
38%|###8 | Permuting : 383/999 [00:04<00:07, 85.70it/s]
39%|###8 | Permuting : 386/999 [00:04<00:07, 85.85it/s]
39%|###8 | Permuting : 389/999 [00:04<00:07, 85.99it/s]
39%|###9 | Permuting : 392/999 [00:04<00:07, 86.13it/s]
40%|###9 | Permuting : 395/999 [00:04<00:07, 86.26it/s]
40%|###9 | Permuting : 398/999 [00:04<00:06, 86.39it/s]
40%|#### | Permuting : 401/999 [00:05<00:06, 86.51it/s]
40%|#### | Permuting : 404/999 [00:05<00:06, 86.63it/s]
41%|#### | Permuting : 407/999 [00:05<00:06, 86.74it/s]
41%|####1 | Permuting : 410/999 [00:05<00:06, 86.84it/s]
41%|####1 | Permuting : 413/999 [00:05<00:06, 86.94it/s]
42%|####1 | Permuting : 416/999 [00:05<00:06, 87.04it/s]
42%|####1 | Permuting : 419/999 [00:05<00:06, 87.13it/s]
42%|####2 | Permuting : 422/999 [00:05<00:06, 87.21it/s]
43%|####2 | Permuting : 425/999 [00:05<00:06, 87.27it/s]
43%|####2 | Permuting : 428/999 [00:05<00:06, 87.35it/s]
43%|####3 | Permuting : 430/999 [00:05<00:06, 85.94it/s]
43%|####3 | Permuting : 433/999 [00:05<00:06, 86.09it/s]
44%|####3 | Permuting : 436/999 [00:05<00:06, 86.22it/s]
44%|####3 | Permuting : 439/999 [00:05<00:06, 86.34it/s]
44%|####4 | Permuting : 442/999 [00:05<00:06, 86.46it/s]
45%|####4 | Permuting : 445/999 [00:05<00:06, 86.58it/s]
45%|####4 | Permuting : 447/999 [00:05<00:06, 85.21it/s]
45%|####5 | Permuting : 450/999 [00:05<00:06, 85.38it/s]
45%|####5 | Permuting : 452/999 [00:05<00:06, 84.07it/s]
46%|####5 | Permuting : 455/999 [00:05<00:06, 84.29it/s]
46%|####5 | Permuting : 458/999 [00:05<00:06, 84.52it/s]
46%|####6 | Permuting : 460/999 [00:05<00:06, 83.25it/s]
46%|####6 | Permuting : 463/999 [00:05<00:06, 83.52it/s]
47%|####6 | Permuting : 466/999 [00:05<00:06, 83.77it/s]
47%|####6 | Permuting : 468/999 [00:05<00:06, 82.53it/s]
47%|####7 | Permuting : 472/999 [00:05<00:06, 84.32it/s]
47%|####7 | Permuting : 474/999 [00:05<00:06, 83.05it/s]
48%|####7 | Permuting : 477/999 [00:05<00:06, 83.32it/s]
48%|####8 | Permuting : 480/999 [00:05<00:06, 83.58it/s]
48%|####8 | Permuting : 483/999 [00:05<00:06, 83.83it/s]
49%|####8 | Permuting : 486/999 [00:06<00:06, 84.07it/s]
49%|####8 | Permuting : 489/999 [00:06<00:06, 84.30it/s]
49%|####9 | Permuting : 492/999 [00:06<00:05, 84.52it/s]
49%|####9 | Permuting : 494/999 [00:06<00:06, 83.26it/s]
50%|####9 | Permuting : 497/999 [00:06<00:06, 83.54it/s]
50%|##### | Permuting : 500/999 [00:06<00:05, 83.80it/s]
50%|##### | Permuting : 502/999 [00:06<00:06, 82.56it/s]
51%|##### | Permuting : 505/999 [00:06<00:05, 82.86it/s]
51%|##### | Permuting : 508/999 [00:06<00:05, 83.14it/s]
51%|#####1 | Permuting : 511/999 [00:06<00:05, 83.43it/s]
51%|#####1 | Permuting : 514/999 [00:06<00:05, 83.70it/s]
52%|#####1 | Permuting : 517/999 [00:06<00:05, 83.94it/s]
52%|#####2 | Permuting : 520/999 [00:06<00:05, 84.12it/s]
52%|#####2 | Permuting : 522/999 [00:06<00:05, 82.87it/s]
53%|#####2 | Permuting : 525/999 [00:06<00:05, 83.16it/s]
53%|#####2 | Permuting : 528/999 [00:06<00:05, 83.44it/s]
53%|#####3 | Permuting : 531/999 [00:06<00:05, 83.69it/s]
53%|#####3 | Permuting : 534/999 [00:06<00:05, 83.93it/s]
54%|#####3 | Permuting : 537/999 [00:06<00:05, 84.16it/s]
54%|#####3 | Permuting : 539/999 [00:06<00:05, 82.89it/s]
54%|#####4 | Permuting : 542/999 [00:06<00:05, 83.17it/s]
55%|#####4 | Permuting : 545/999 [00:06<00:05, 83.44it/s]
55%|#####4 | Permuting : 547/999 [00:06<00:05, 82.20it/s]
55%|#####5 | Permuting : 550/999 [00:06<00:05, 82.52it/s]
55%|#####5 | Permuting : 553/999 [00:06<00:05, 82.82it/s]
56%|#####5 | Permuting : 555/999 [00:06<00:05, 81.64it/s]
56%|#####5 | Permuting : 558/999 [00:06<00:05, 82.00it/s]
56%|#####6 | Permuting : 561/999 [00:06<00:05, 82.33it/s]
56%|#####6 | Permuting : 564/999 [00:06<00:05, 82.66it/s]
57%|#####6 | Permuting : 567/999 [00:07<00:05, 82.96it/s]
57%|#####7 | Permuting : 570/999 [00:07<00:05, 83.24it/s]
57%|#####7 | Permuting : 572/999 [00:07<00:05, 82.03it/s]
58%|#####7 | Permuting : 575/999 [00:07<00:05, 82.37it/s]
58%|#####7 | Permuting : 578/999 [00:07<00:05, 82.69it/s]
58%|#####8 | Permuting : 580/999 [00:07<00:05, 81.51it/s]
58%|#####8 | Permuting : 583/999 [00:07<00:05, 81.88it/s]
59%|#####8 | Permuting : 586/999 [00:07<00:05, 82.22it/s]
59%|#####8 | Permuting : 588/999 [00:07<00:05, 81.07it/s]
59%|#####9 | Permuting : 591/999 [00:07<00:05, 81.45it/s]
59%|#####9 | Permuting : 594/999 [00:07<00:04, 81.81it/s]
60%|#####9 | Permuting : 597/999 [00:07<00:04, 82.17it/s]
60%|###### | Permuting : 600/999 [00:07<00:04, 82.49it/s]
60%|###### | Permuting : 603/999 [00:07<00:04, 82.80it/s]
61%|###### | Permuting : 606/999 [00:07<00:04, 83.09it/s]
61%|###### | Permuting : 609/999 [00:07<00:04, 83.37it/s]
61%|######1 | Permuting : 611/999 [00:07<00:04, 82.17it/s]
61%|######1 | Permuting : 614/999 [00:07<00:04, 82.50it/s]
62%|######1 | Permuting : 617/999 [00:07<00:04, 82.80it/s]
62%|######1 | Permuting : 619/999 [00:07<00:04, 81.56it/s]
62%|######2 | Permuting : 622/999 [00:07<00:04, 81.91it/s]
63%|######2 | Permuting : 625/999 [00:07<00:04, 82.24it/s]
63%|######2 | Permuting : 628/999 [00:07<00:04, 82.57it/s]
63%|######3 | Permuting : 630/999 [00:07<00:04, 81.40it/s]
63%|######3 | Permuting : 633/999 [00:07<00:04, 81.77it/s]
64%|######3 | Permuting : 636/999 [00:07<00:04, 82.11it/s]
64%|######3 | Permuting : 639/999 [00:07<00:04, 82.43it/s]
64%|######4 | Permuting : 642/999 [00:07<00:04, 82.74it/s]
65%|######4 | Permuting : 645/999 [00:07<00:04, 83.03it/s]
65%|######4 | Permuting : 649/999 [00:07<00:04, 84.79it/s]
65%|######5 | Permuting : 652/999 [00:08<00:04, 84.99it/s]
66%|######5 | Permuting : 655/999 [00:08<00:04, 85.18it/s]
66%|######5 | Permuting : 658/999 [00:08<00:03, 85.36it/s]
66%|######6 | Permuting : 661/999 [00:08<00:03, 85.53it/s]
66%|######6 | Permuting : 663/999 [00:08<00:03, 84.21it/s]
67%|######6 | Permuting : 666/999 [00:08<00:03, 84.44it/s]
67%|######6 | Permuting : 669/999 [00:08<00:03, 84.64it/s]
67%|######7 | Permuting : 672/999 [00:08<00:03, 84.85it/s]
68%|######7 | Permuting : 675/999 [00:08<00:03, 85.03it/s]
68%|######7 | Permuting : 678/999 [00:08<00:03, 85.21it/s]
68%|######8 | Permuting : 681/999 [00:08<00:03, 85.39it/s]
68%|######8 | Permuting : 684/999 [00:08<00:03, 85.56it/s]
69%|######8 | Permuting : 686/999 [00:08<00:03, 84.24it/s]
69%|######8 | Permuting : 689/999 [00:08<00:03, 84.47it/s]
69%|######9 | Permuting : 692/999 [00:08<00:03, 84.69it/s]
69%|######9 | Permuting : 694/999 [00:08<00:03, 83.41it/s]
70%|######9 | Permuting : 697/999 [00:08<00:03, 83.68it/s]
70%|####### | Permuting : 701/999 [00:08<00:03, 85.42it/s]
70%|####### | Permuting : 704/999 [00:08<00:03, 85.57it/s]
71%|####### | Permuting : 707/999 [00:08<00:03, 85.73it/s]
71%|#######1 | Permuting : 710/999 [00:08<00:03, 85.87it/s]
71%|#######1 | Permuting : 713/999 [00:08<00:03, 86.02it/s]
72%|#######1 | Permuting : 716/999 [00:08<00:03, 86.16it/s]
72%|#######1 | Permuting : 719/999 [00:08<00:03, 86.29it/s]
72%|#######2 | Permuting : 722/999 [00:08<00:03, 86.40it/s]
73%|#######2 | Permuting : 725/999 [00:08<00:03, 86.52it/s]
73%|#######2 | Permuting : 728/999 [00:08<00:03, 86.63it/s]
73%|#######3 | Permuting : 731/999 [00:08<00:03, 86.74it/s]
73%|#######3 | Permuting : 734/999 [00:08<00:03, 86.84it/s]
74%|#######3 | Permuting : 737/999 [00:09<00:03, 86.93it/s]
74%|#######4 | Permuting : 740/999 [00:09<00:02, 87.02it/s]
74%|#######4 | Permuting : 743/999 [00:09<00:02, 87.11it/s]
75%|#######4 | Permuting : 745/999 [00:09<00:02, 85.69it/s]
75%|#######4 | Permuting : 748/999 [00:09<00:02, 85.84it/s]
75%|#######5 | Permuting : 752/999 [00:09<00:02, 87.47it/s]
75%|#######5 | Permuting : 754/999 [00:09<00:02, 86.06it/s]
76%|#######5 | Permuting : 757/999 [00:09<00:02, 86.19it/s]
76%|#######6 | Permuting : 760/999 [00:09<00:02, 86.32it/s]
76%|#######6 | Permuting : 763/999 [00:09<00:02, 86.45it/s]
77%|#######6 | Permuting : 766/999 [00:09<00:02, 86.57it/s]
77%|#######6 | Permuting : 769/999 [00:09<00:02, 86.66it/s]
77%|#######7 | Permuting : 772/999 [00:09<00:02, 86.76it/s]
78%|#######7 | Permuting : 775/999 [00:09<00:02, 86.86it/s]
78%|#######7 | Permuting : 779/999 [00:09<00:02, 88.43it/s]
78%|#######8 | Permuting : 781/999 [00:09<00:02, 86.97it/s]
78%|#######8 | Permuting : 784/999 [00:09<00:02, 87.06it/s]
79%|#######8 | Permuting : 787/999 [00:09<00:02, 87.15it/s]
79%|#######9 | Permuting : 790/999 [00:09<00:02, 87.23it/s]
79%|#######9 | Permuting : 793/999 [00:09<00:02, 87.31it/s]
80%|#######9 | Permuting : 796/999 [00:09<00:02, 87.37it/s]
80%|#######9 | Permuting : 799/999 [00:09<00:02, 87.44it/s]
80%|######## | Permuting : 802/999 [00:09<00:02, 87.50it/s]
81%|######## | Permuting : 805/999 [00:09<00:02, 87.55it/s]
81%|######## | Permuting : 808/999 [00:09<00:02, 87.61it/s]
81%|########1 | Permuting : 810/999 [00:09<00:02, 86.17it/s]
81%|########1 | Permuting : 813/999 [00:09<00:02, 86.31it/s]
82%|########1 | Permuting : 816/999 [00:09<00:02, 86.43it/s]
82%|########1 | Permuting : 819/999 [00:09<00:02, 86.55it/s]
82%|########2 | Permuting : 822/999 [00:09<00:02, 86.67it/s]
83%|########2 | Permuting : 825/999 [00:10<00:02, 86.77it/s]
83%|########2 | Permuting : 828/999 [00:10<00:01, 86.88it/s]
83%|########3 | Permuting : 831/999 [00:10<00:01, 86.97it/s]
83%|########3 | Permuting : 834/999 [00:10<00:01, 87.06it/s]
84%|########3 | Permuting : 837/999 [00:10<00:01, 87.14it/s]
84%|########4 | Permuting : 840/999 [00:10<00:01, 87.23it/s]
84%|########4 | Permuting : 843/999 [00:10<00:01, 87.31it/s]
85%|########4 | Permuting : 846/999 [00:10<00:01, 87.39it/s]
85%|########4 | Permuting : 849/999 [00:10<00:01, 87.46it/s]
85%|########5 | Permuting : 852/999 [00:10<00:01, 87.53it/s]
86%|########5 | Permuting : 855/999 [00:10<00:01, 87.58it/s]
86%|########5 | Permuting : 858/999 [00:10<00:01, 87.64it/s]
86%|########6 | Permuting : 861/999 [00:10<00:01, 87.69it/s]
86%|########6 | Permuting : 864/999 [00:10<00:01, 87.74it/s]
87%|########6 | Permuting : 867/999 [00:10<00:01, 87.80it/s]
87%|########7 | Permuting : 870/999 [00:10<00:01, 87.84it/s]
87%|########7 | Permuting : 873/999 [00:10<00:01, 87.88it/s]
88%|########7 | Permuting : 876/999 [00:10<00:01, 87.91it/s]
88%|########7 | Permuting : 879/999 [00:10<00:01, 87.96it/s]
88%|########8 | Permuting : 882/999 [00:10<00:01, 88.01it/s]
89%|########8 | Permuting : 885/999 [00:10<00:01, 88.05it/s]
89%|########8 | Permuting : 888/999 [00:10<00:01, 88.08it/s]
89%|########9 | Permuting : 891/999 [00:10<00:01, 88.11it/s]
89%|########9 | Permuting : 894/999 [00:10<00:01, 88.13it/s]
90%|########9 | Permuting : 897/999 [00:10<00:01, 88.16it/s]
90%|######### | Permuting : 900/999 [00:10<00:01, 88.18it/s]
90%|######### | Permuting : 903/999 [00:10<00:01, 88.20it/s]
91%|######### | Permuting : 906/999 [00:10<00:01, 88.23it/s]
91%|######### | Permuting : 909/999 [00:10<00:01, 88.24it/s]
91%|#########1| Permuting : 912/999 [00:11<00:00, 88.25it/s]
92%|#########1| Permuting : 915/999 [00:11<00:00, 88.28it/s]
92%|#########1| Permuting : 918/999 [00:11<00:00, 88.30it/s]
92%|#########2| Permuting : 921/999 [00:11<00:00, 88.32it/s]
92%|#########2| Permuting : 924/999 [00:11<00:00, 88.35it/s]
93%|#########2| Permuting : 927/999 [00:11<00:00, 88.37it/s]
93%|#########2| Permuting : 929/999 [00:11<00:00, 86.90it/s]
93%|#########3| Permuting : 932/999 [00:11<00:00, 86.98it/s]
94%|#########3| Permuting : 935/999 [00:11<00:00, 87.06it/s]
94%|#########3| Permuting : 937/999 [00:11<00:00, 85.66it/s]
94%|#########4| Permuting : 940/999 [00:11<00:00, 85.82it/s]
94%|#########4| Permuting : 943/999 [00:11<00:00, 85.96it/s]
95%|#########4| Permuting : 946/999 [00:11<00:00, 86.10it/s]
95%|#########4| Permuting : 949/999 [00:11<00:00, 86.23it/s]
95%|#########5| Permuting : 952/999 [00:11<00:00, 86.36it/s]
96%|#########5| Permuting : 955/999 [00:11<00:00, 86.49it/s]
96%|#########5| Permuting : 958/999 [00:11<00:00, 86.61it/s]
96%|#########6| Permuting : 961/999 [00:11<00:00, 86.70it/s]
96%|#########6| Permuting : 964/999 [00:11<00:00, 86.79it/s]
97%|#########6| Permuting : 967/999 [00:11<00:00, 86.89it/s]
97%|#########7| Permuting : 970/999 [00:11<00:00, 86.98it/s]
97%|#########7| Permuting : 973/999 [00:11<00:00, 87.07it/s]
98%|#########7| Permuting : 976/999 [00:11<00:00, 87.15it/s]
98%|#########7| Permuting : 978/999 [00:11<00:00, 85.61it/s]
98%|#########8| Permuting : 981/999 [00:11<00:00, 85.74it/s]
98%|#########8| Permuting : 984/999 [00:11<00:00, 85.88it/s]
99%|#########8| Permuting : 987/999 [00:11<00:00, 86.02it/s]
99%|#########9| Permuting : 990/999 [00:11<00:00, 86.16it/s]
99%|#########9| Permuting : 993/999 [00:11<00:00, 86.30it/s]
100%|#########9| Permuting : 996/999 [00:11<00:00, 86.42it/s]
100%|#########9| Permuting : 998/999 [00:12<00:00, 85.06it/s]
100%|##########| Permuting : 999/999 [00:12<00:00, 83.12it/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.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.5s 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:46, 9.36it/s]
0%| | Permuting : 2/999 [00:00<06:19, 2.63it/s]
0%| | Permuting : 3/999 [00:00<04:17, 3.86it/s]
0%| | Permuting : 4/999 [00:00<03:18, 5.01it/s]
1%| | Permuting : 5/999 [00:00<02:41, 6.14it/s]
1%| | Permuting : 6/999 [00:00<02:18, 7.19it/s]
1%| | Permuting : 9/999 [00:00<01:35, 10.40it/s]
1%|1 | Permuting : 10/999 [00:01<01:32, 10.64it/s]
1%|1 | Permuting : 12/999 [00:01<01:17, 12.68it/s]
1%|1 | Permuting : 13/999 [00:01<01:17, 12.70it/s]
2%|1 | Permuting : 15/999 [00:01<01:07, 14.58it/s]
2%|1 | Permuting : 16/999 [00:01<01:04, 15.13it/s]
2%|1 | Permuting : 18/999 [00:01<01:00, 16.18it/s]
2%|2 | Permuting : 20/999 [00:01<00:57, 17.11it/s]
2%|2 | Permuting : 22/999 [00:01<00:52, 18.73it/s]
2%|2 | Permuting : 24/999 [00:01<00:48, 20.30it/s]
3%|2 | Permuting : 25/999 [00:01<01:06, 14.66it/s]
3%|2 | Permuting : 27/999 [00:01<01:03, 15.40it/s]
3%|2 | Permuting : 28/999 [00:01<01:01, 15.80it/s]
3%|3 | Permuting : 31/999 [00:01<00:54, 17.90it/s]
3%|3 | Permuting : 33/999 [00:02<00:52, 18.46it/s]
3%|3 | Permuting : 34/999 [00:02<00:51, 18.79it/s]
4%|3 | Permuting : 37/999 [00:02<00:47, 20.18it/s]
4%|3 | Permuting : 38/999 [00:02<00:47, 20.36it/s]
4%|4 | Permuting : 40/999 [00:02<00:44, 21.52it/s]
4%|4 | Permuting : 41/999 [00:02<00:44, 21.67it/s]
4%|4 | Permuting : 43/999 [00:02<00:41, 22.83it/s]
4%|4 | Permuting : 44/999 [00:02<00:43, 22.13it/s]
5%|4 | Permuting : 45/999 [00:02<00:42, 22.26it/s]
5%|4 | Permuting : 47/999 [00:02<00:40, 23.42it/s]
5%|4 | Permuting : 49/999 [00:02<00:52, 18.00it/s]
5%|5 | Permuting : 51/999 [00:02<00:51, 18.48it/s]
5%|5 | Permuting : 54/999 [00:02<00:46, 20.17it/s]
6%|5 | Permuting : 56/999 [00:02<00:44, 21.13it/s]
6%|5 | Permuting : 57/999 [00:03<00:45, 20.75it/s]
6%|5 | Permuting : 58/999 [00:03<00:44, 20.93it/s]
6%|5 | Permuting : 59/999 [00:03<00:45, 20.47it/s]
6%|6 | Permuting : 60/999 [00:03<00:45, 20.70it/s]
6%|6 | Permuting : 61/999 [00:03<00:44, 20.93it/s]
6%|6 | Permuting : 62/999 [00:03<00:44, 21.08it/s]
6%|6 | Permuting : 63/999 [00:03<00:43, 21.31it/s]
6%|6 | Permuting : 64/999 [00:03<00:44, 20.79it/s]
7%|6 | Permuting : 66/999 [00:03<00:42, 21.85it/s]
7%|6 | Permuting : 67/999 [00:03<00:42, 21.98it/s]
7%|6 | Permuting : 68/999 [00:03<00:41, 22.18it/s]
7%|6 | Permuting : 69/999 [00:03<00:41, 22.30it/s]
7%|7 | Permuting : 71/999 [00:03<00:39, 23.41it/s]
7%|7 | Permuting : 74/999 [00:03<00:36, 25.40it/s]
8%|7 | Permuting : 76/999 [00:03<00:36, 25.55it/s]
8%|7 | Permuting : 78/999 [00:04<00:47, 19.53it/s]
8%|7 | Permuting : 79/999 [00:04<00:47, 19.18it/s]
8%|8 | Permuting : 80/999 [00:04<00:47, 19.42it/s]
8%|8 | Permuting : 83/999 [00:04<00:44, 20.51it/s]
9%|8 | Permuting : 85/999 [00:04<00:42, 21.35it/s]
9%|8 | Permuting : 86/999 [00:04<00:42, 21.55it/s]
9%|8 | Permuting : 89/999 [00:04<00:40, 22.58it/s]
9%|9 | Permuting : 90/999 [00:04<00:40, 22.67it/s]
9%|9 | Permuting : 92/999 [00:04<00:38, 23.60it/s]
9%|9 | Permuting : 94/999 [00:04<00:36, 24.51it/s]
10%|9 | Permuting : 95/999 [00:04<00:36, 24.64it/s]
10%|9 | Permuting : 96/999 [00:04<00:37, 23.93it/s]
10%|9 | Permuting : 98/999 [00:04<00:36, 24.88it/s]
10%|9 | Permuting : 99/999 [00:04<00:37, 24.15it/s]
10%|# | Permuting : 100/999 [00:05<00:47, 19.10it/s]
10%|# | Permuting : 101/999 [00:05<00:46, 19.33it/s]
10%|# | Permuting : 102/999 [00:05<00:46, 19.49it/s]
10%|# | Permuting : 104/999 [00:05<00:43, 20.42it/s]
11%|# | Permuting : 107/999 [00:05<00:41, 21.47it/s]
11%|# | Permuting : 109/999 [00:05<00:40, 21.75it/s]
11%|#1 | Permuting : 110/999 [00:05<00:40, 21.93it/s]
11%|#1 | Permuting : 113/999 [00:05<00:38, 22.93it/s]
12%|#1 | Permuting : 116/999 [00:05<00:36, 23.88it/s]
12%|#1 | Permuting : 117/999 [00:05<00:36, 23.93it/s]
12%|#1 | Permuting : 119/999 [00:05<00:35, 24.81it/s]
12%|#2 | Permuting : 120/999 [00:05<00:35, 24.84it/s]
12%|#2 | Permuting : 122/999 [00:05<00:34, 25.74it/s]
12%|#2 | Permuting : 123/999 [00:05<00:34, 25.74it/s]
12%|#2 | Permuting : 124/999 [00:05<00:33, 25.74it/s]
13%|#2 | Permuting : 125/999 [00:05<00:33, 25.79it/s]
13%|#2 | Permuting : 126/999 [00:05<00:33, 25.81it/s]
13%|#2 | Permuting : 127/999 [00:06<00:44, 19.60it/s]
13%|#3 | Permuting : 130/999 [00:06<00:42, 20.63it/s]
13%|#3 | Permuting : 131/999 [00:06<00:42, 20.24it/s]
13%|#3 | Permuting : 133/999 [00:06<00:40, 21.13it/s]
13%|#3 | Permuting : 134/999 [00:06<00:40, 21.25it/s]
14%|#3 | Permuting : 136/999 [00:06<00:38, 22.15it/s]
14%|#3 | Permuting : 139/999 [00:06<00:37, 23.13it/s]
14%|#4 | Permuting : 140/999 [00:06<00:38, 22.58it/s]
14%|#4 | Permuting : 142/999 [00:06<00:37, 22.83it/s]
14%|#4 | Permuting : 143/999 [00:06<00:37, 22.91it/s]
15%|#4 | Permuting : 145/999 [00:06<00:35, 23.81it/s]
15%|#4 | Permuting : 146/999 [00:06<00:35, 23.88it/s]
15%|#4 | Permuting : 147/999 [00:06<00:35, 23.93it/s]
15%|#4 | Permuting : 148/999 [00:06<00:35, 24.08it/s]
15%|#4 | Permuting : 149/999 [00:06<00:35, 24.03it/s]
15%|#5 | Permuting : 152/999 [00:07<00:32, 25.82it/s]
15%|#5 | Permuting : 154/999 [00:07<00:43, 19.61it/s]
16%|#5 | Permuting : 157/999 [00:07<00:39, 21.08it/s]
16%|#5 | Permuting : 159/999 [00:07<00:39, 21.38it/s]
16%|#6 | Permuting : 160/999 [00:07<00:40, 20.96it/s]
16%|#6 | Permuting : 161/999 [00:07<00:40, 20.56it/s]
16%|#6 | Permuting : 162/999 [00:07<00:40, 20.76it/s]
16%|#6 | Permuting : 163/999 [00:07<00:41, 20.36it/s]
16%|#6 | Permuting : 164/999 [00:07<00:40, 20.56it/s]
17%|#6 | Permuting : 165/999 [00:07<00:40, 20.70it/s]
17%|#6 | Permuting : 166/999 [00:07<00:39, 20.91it/s]
17%|#6 | Permuting : 167/999 [00:08<00:40, 20.53it/s]
17%|#6 | Permuting : 168/999 [00:08<00:41, 20.18it/s]
17%|#7 | Permuting : 170/999 [00:08<00:40, 20.56it/s]
17%|#7 | Permuting : 171/999 [00:08<00:40, 20.22it/s]
17%|#7 | Permuting : 173/999 [00:08<00:39, 21.17it/s]
17%|#7 | Permuting : 174/999 [00:08<00:48, 16.86it/s]
18%|#7 | Permuting : 175/999 [00:08<00:49, 16.67it/s]
18%|#7 | Permuting : 176/999 [00:08<00:48, 16.93it/s]
18%|#7 | Permuting : 178/999 [00:08<00:47, 17.37it/s]
18%|#8 | Permuting : 181/999 [00:08<00:44, 18.44it/s]
18%|#8 | Permuting : 183/999 [00:08<00:42, 19.30it/s]
18%|#8 | Permuting : 184/999 [00:09<00:41, 19.47it/s]
19%|#8 | Permuting : 185/999 [00:09<00:41, 19.69it/s]
19%|#8 | Permuting : 188/999 [00:09<00:38, 21.29it/s]
19%|#8 | Permuting : 189/999 [00:09<00:38, 20.91it/s]
19%|#9 | Permuting : 190/999 [00:09<00:39, 20.56it/s]
19%|#9 | Permuting : 191/999 [00:09<00:38, 20.75it/s]
19%|#9 | Permuting : 194/999 [00:09<00:36, 21.80it/s]
20%|#9 | Permuting : 196/999 [00:09<00:36, 22.10it/s]
20%|#9 | Permuting : 199/999 [00:09<00:34, 23.08it/s]
20%|## | Permuting : 200/999 [00:09<00:34, 23.21it/s]
20%|## | Permuting : 201/999 [00:09<00:35, 22.64it/s]
20%|## | Permuting : 202/999 [00:09<00:34, 22.81it/s]
20%|## | Permuting : 204/999 [00:10<00:43, 18.39it/s]
21%|## | Permuting : 207/999 [00:10<00:40, 19.37it/s]
21%|## | Permuting : 209/999 [00:10<00:40, 19.72it/s]
21%|##1 | Permuting : 210/999 [00:10<00:40, 19.43it/s]
21%|##1 | Permuting : 211/999 [00:10<00:40, 19.61it/s]
21%|##1 | Permuting : 213/999 [00:10<00:39, 19.97it/s]
21%|##1 | Permuting : 214/999 [00:10<00:39, 20.11it/s]
22%|##1 | Permuting : 215/999 [00:10<00:38, 20.32it/s]
22%|##1 | Permuting : 218/999 [00:10<00:35, 21.87it/s]
22%|##2 | Permuting : 220/999 [00:10<00:34, 22.73it/s]
22%|##2 | Permuting : 221/999 [00:10<00:34, 22.82it/s]
22%|##2 | Permuting : 222/999 [00:10<00:33, 22.96it/s]
22%|##2 | Permuting : 223/999 [00:10<00:33, 23.04it/s]
23%|##2 | Permuting : 225/999 [00:10<00:33, 23.24it/s]
23%|##2 | Permuting : 226/999 [00:10<00:34, 22.64it/s]
23%|##2 | Permuting : 227/999 [00:10<00:33, 22.77it/s]
23%|##2 | Permuting : 228/999 [00:10<00:35, 21.61it/s]
23%|##2 | Permuting : 229/999 [00:10<00:35, 21.81it/s]
23%|##3 | Permuting : 232/999 [00:11<00:32, 23.52it/s]
23%|##3 | Permuting : 233/999 [00:11<00:42, 17.95it/s]
24%|##3 | Permuting : 235/999 [00:11<00:40, 18.80it/s]
24%|##3 | Permuting : 238/999 [00:11<00:37, 20.28it/s]
24%|##3 | Permuting : 239/999 [00:11<00:38, 19.99it/s]
24%|##4 | Permuting : 241/999 [00:11<00:36, 20.81it/s]
24%|##4 | Permuting : 242/999 [00:11<00:36, 20.99it/s]
24%|##4 | Permuting : 243/999 [00:11<00:35, 21.12it/s]
24%|##4 | Permuting : 244/999 [00:11<00:35, 21.32it/s]
25%|##4 | Permuting : 247/999 [00:11<00:32, 22.96it/s]
25%|##4 | Permuting : 249/999 [00:11<00:31, 23.86it/s]
25%|##5 | Permuting : 250/999 [00:11<00:32, 23.24it/s]
25%|##5 | Permuting : 251/999 [00:11<00:31, 23.40it/s]
25%|##5 | Permuting : 254/999 [00:11<00:29, 25.10it/s]
26%|##5 | Permuting : 256/999 [00:11<00:28, 26.00it/s]
26%|##5 | Permuting : 257/999 [00:12<00:28, 26.06it/s]
26%|##5 | Permuting : 258/999 [00:12<00:29, 25.35it/s]
26%|##5 | Permuting : 259/999 [00:12<00:29, 25.36it/s]
26%|##6 | Permuting : 260/999 [00:12<00:29, 25.47it/s]
26%|##6 | Permuting : 261/999 [00:12<00:28, 25.48it/s]
26%|##6 | Permuting : 262/999 [00:12<00:28, 25.60it/s]
27%|##6 | Permuting : 265/999 [00:12<00:26, 27.49it/s]
27%|##6 | Permuting : 266/999 [00:12<00:27, 26.51it/s]
27%|##6 | Permuting : 267/999 [00:12<00:27, 26.59it/s]
27%|##7 | Permuting : 270/999 [00:12<00:25, 28.49it/s]
27%|##7 | Permuting : 271/999 [00:12<00:35, 20.52it/s]
27%|##7 | Permuting : 272/999 [00:12<00:35, 20.73it/s]
27%|##7 | Permuting : 274/999 [00:12<00:33, 21.63it/s]
28%|##7 | Permuting : 276/999 [00:13<00:32, 21.93it/s]
28%|##7 | Permuting : 277/999 [00:13<00:33, 21.52it/s]
28%|##7 | Permuting : 278/999 [00:13<00:35, 20.49it/s]
28%|##8 | Permuting : 280/999 [00:13<00:34, 20.88it/s]
28%|##8 | Permuting : 282/999 [00:13<00:33, 21.22it/s]
29%|##8 | Permuting : 285/999 [00:13<00:31, 22.81it/s]
29%|##8 | Permuting : 287/999 [00:13<00:30, 23.61it/s]
29%|##8 | Permuting : 289/999 [00:13<00:29, 23.82it/s]
29%|##9 | Permuting : 290/999 [00:13<00:30, 23.30it/s]
29%|##9 | Permuting : 291/999 [00:13<00:31, 22.81it/s]
29%|##9 | Permuting : 294/999 [00:13<00:28, 24.44it/s]
30%|##9 | Permuting : 295/999 [00:13<00:28, 24.47it/s]
30%|##9 | Permuting : 296/999 [00:13<00:29, 23.80it/s]
30%|##9 | Permuting : 297/999 [00:14<00:38, 18.24it/s]
30%|##9 | Permuting : 299/999 [00:14<00:37, 18.64it/s]
30%|### | Permuting : 302/999 [00:14<00:34, 20.07it/s]
31%|### | Permuting : 305/999 [00:14<00:33, 21.00it/s]
31%|### | Permuting : 306/999 [00:14<00:32, 21.12it/s]
31%|### | Permuting : 308/999 [00:14<00:31, 21.94it/s]
31%|### | Permuting : 309/999 [00:14<00:31, 22.04it/s]
31%|###1 | Permuting : 310/999 [00:14<00:31, 22.13it/s]
31%|###1 | Permuting : 311/999 [00:14<00:30, 22.31it/s]
31%|###1 | Permuting : 313/999 [00:14<00:30, 22.48it/s]
31%|###1 | Permuting : 314/999 [00:14<00:30, 22.65it/s]
32%|###1 | Permuting : 315/999 [00:14<00:30, 22.78it/s]
32%|###1 | Permuting : 316/999 [00:14<00:29, 22.86it/s]
32%|###1 | Permuting : 317/999 [00:14<00:29, 23.03it/s]
32%|###1 | Permuting : 318/999 [00:14<00:29, 23.17it/s]
32%|###2 | Permuting : 320/999 [00:14<00:28, 23.41it/s]
32%|###2 | Permuting : 321/999 [00:14<00:28, 23.48it/s]
32%|###2 | Permuting : 322/999 [00:15<00:28, 23.65it/s]
32%|###2 | Permuting : 323/999 [00:15<00:38, 17.55it/s]
33%|###2 | Permuting : 326/999 [00:15<00:36, 18.61it/s]
33%|###2 | Permuting : 327/999 [00:15<00:35, 18.78it/s]
33%|###2 | Permuting : 329/999 [00:15<00:34, 19.19it/s]
33%|###3 | Permuting : 330/999 [00:15<00:35, 18.94it/s]
33%|###3 | Permuting : 331/999 [00:15<00:35, 18.70it/s]
33%|###3 | Permuting : 334/999 [00:15<00:32, 20.25it/s]
34%|###3 | Permuting : 335/999 [00:15<00:32, 20.39it/s]
34%|###3 | Permuting : 337/999 [00:15<00:31, 21.30it/s]
34%|###3 | Permuting : 338/999 [00:15<00:30, 21.42it/s]
34%|###3 | Permuting : 339/999 [00:15<00:30, 21.58it/s]
34%|###4 | Permuting : 340/999 [00:16<00:30, 21.78it/s]
34%|###4 | Permuting : 341/999 [00:16<00:30, 21.89it/s]
34%|###4 | Permuting : 342/999 [00:16<00:29, 22.10it/s]
35%|###4 | Permuting : 345/999 [00:16<00:27, 23.89it/s]
35%|###4 | Permuting : 347/999 [00:16<00:27, 24.11it/s]
35%|###5 | Permuting : 350/999 [00:16<00:25, 25.09it/s]
35%|###5 | Permuting : 353/999 [00:16<00:24, 26.82it/s]
35%|###5 | Permuting : 354/999 [00:16<00:24, 26.78it/s]
36%|###5 | Permuting : 355/999 [00:16<00:30, 20.80it/s]
36%|###5 | Permuting : 356/999 [00:16<00:31, 20.40it/s]
36%|###5 | Permuting : 357/999 [00:16<00:31, 20.61it/s]
36%|###6 | Permuting : 360/999 [00:16<00:28, 22.19it/s]
36%|###6 | Permuting : 362/999 [00:16<00:28, 22.45it/s]
36%|###6 | Permuting : 363/999 [00:16<00:28, 22.54it/s]
36%|###6 | Permuting : 364/999 [00:17<00:27, 22.71it/s]
37%|###6 | Permuting : 366/999 [00:17<00:26, 23.53it/s]
37%|###6 | Permuting : 367/999 [00:17<00:26, 23.69it/s]
37%|###6 | Permuting : 368/999 [00:17<00:26, 23.75it/s]
37%|###7 | Permuting : 370/999 [00:17<00:25, 24.70it/s]
37%|###7 | Permuting : 371/999 [00:17<00:26, 23.98it/s]
37%|###7 | Permuting : 372/999 [00:17<00:26, 24.03it/s]
37%|###7 | Permuting : 373/999 [00:17<00:25, 24.18it/s]
38%|###7 | Permuting : 376/999 [00:17<00:23, 26.00it/s]
38%|###7 | Permuting : 377/999 [00:17<00:24, 25.16it/s]
38%|###7 | Permuting : 378/999 [00:17<00:24, 25.29it/s]
38%|###8 | Permuting : 380/999 [00:17<00:24, 25.43it/s]
38%|###8 | Permuting : 383/999 [00:17<00:22, 27.25it/s]
38%|###8 | Permuting : 384/999 [00:17<00:29, 20.85it/s]
39%|###8 | Permuting : 385/999 [00:17<00:29, 21.04it/s]
39%|###8 | Permuting : 387/999 [00:18<00:27, 21.94it/s]
39%|###8 | Permuting : 388/999 [00:18<00:27, 22.05it/s]
39%|###9 | Permuting : 390/999 [00:18<00:26, 22.97it/s]
39%|###9 | Permuting : 391/999 [00:18<00:27, 22.40it/s]
39%|###9 | Permuting : 393/999 [00:18<00:25, 23.33it/s]
39%|###9 | Permuting : 394/999 [00:18<00:25, 23.40it/s]
40%|###9 | Permuting : 396/999 [00:18<00:24, 24.35it/s]
40%|###9 | Permuting : 397/999 [00:18<00:24, 24.39it/s]
40%|###9 | Permuting : 398/999 [00:18<00:24, 24.43it/s]
40%|###9 | Permuting : 399/999 [00:18<00:24, 24.58it/s]
40%|#### | Permuting : 400/999 [00:18<00:24, 24.65it/s]
40%|#### | Permuting : 401/999 [00:18<00:25, 23.88it/s]
40%|#### | Permuting : 402/999 [00:18<00:24, 24.05it/s]
40%|#### | Permuting : 403/999 [00:18<00:24, 24.10it/s]
41%|#### | Permuting : 405/999 [00:18<00:23, 25.15it/s]
41%|#### | Permuting : 407/999 [00:18<00:23, 25.23it/s]
41%|#### | Permuting : 408/999 [00:19<00:31, 18.74it/s]
41%|####1 | Permuting : 411/999 [00:19<00:29, 19.82it/s]
41%|####1 | Permuting : 412/999 [00:19<00:29, 19.98it/s]
41%|####1 | Permuting : 413/999 [00:19<00:29, 20.20it/s]
41%|####1 | Permuting : 414/999 [00:19<00:28, 20.36it/s]
42%|####1 | Permuting : 415/999 [00:19<00:28, 20.58it/s]
42%|####1 | Permuting : 416/999 [00:19<00:28, 20.73it/s]
42%|####1 | Permuting : 418/999 [00:19<00:27, 21.02it/s]
42%|####2 | Permuting : 420/999 [00:19<00:27, 21.30it/s]
42%|####2 | Permuting : 421/999 [00:19<00:27, 20.82it/s]
42%|####2 | Permuting : 422/999 [00:19<00:27, 21.05it/s]
42%|####2 | Permuting : 423/999 [00:19<00:27, 21.18it/s]
43%|####2 | Permuting : 425/999 [00:19<00:25, 22.19it/s]
43%|####2 | Permuting : 427/999 [00:19<00:25, 22.50it/s]
43%|####3 | Permuting : 430/999 [00:19<00:23, 24.27it/s]
43%|####3 | Permuting : 431/999 [00:19<00:23, 24.32it/s]
43%|####3 | Permuting : 433/999 [00:19<00:22, 25.30it/s]
43%|####3 | Permuting : 434/999 [00:19<00:22, 25.31it/s]
44%|####3 | Permuting : 435/999 [00:20<00:28, 19.77it/s]
44%|####3 | Permuting : 436/999 [00:20<00:28, 20.00it/s]
44%|####3 | Permuting : 439/999 [00:20<00:25, 21.65it/s]
44%|####4 | Permuting : 441/999 [00:20<00:24, 22.58it/s]
44%|####4 | Permuting : 442/999 [00:20<00:24, 22.73it/s]
44%|####4 | Permuting : 444/999 [00:20<00:24, 22.99it/s]
45%|####4 | Permuting : 447/999 [00:20<00:22, 24.07it/s]
45%|####4 | Permuting : 448/999 [00:20<00:22, 24.12it/s]
45%|####5 | Permuting : 450/999 [00:20<00:21, 25.04it/s]
45%|####5 | Permuting : 452/999 [00:20<00:21, 25.86it/s]
45%|####5 | Permuting : 454/999 [00:20<00:20, 26.77it/s]
46%|####5 | Permuting : 455/999 [00:20<00:20, 26.74it/s]
46%|####5 | Permuting : 456/999 [00:20<00:20, 26.82it/s]
46%|####5 | Permuting : 458/999 [00:20<00:19, 27.64it/s]
46%|####5 | Permuting : 459/999 [00:20<00:19, 27.70it/s]
46%|####6 | Permuting : 461/999 [00:20<00:18, 28.66it/s]
46%|####6 | Permuting : 464/999 [00:20<00:18, 29.45it/s]
47%|####6 | Permuting : 465/999 [00:21<00:18, 29.31it/s]
47%|####6 | Permuting : 467/999 [00:21<00:17, 30.24it/s]
47%|####6 | Permuting : 468/999 [00:21<00:17, 30.07it/s]
47%|####6 | Permuting : 469/999 [00:21<00:17, 30.05it/s]
47%|####7 | Permuting : 472/999 [00:21<00:16, 31.96it/s]
47%|####7 | Permuting : 473/999 [00:21<00:23, 22.79it/s]
47%|####7 | Permuting : 474/999 [00:21<00:23, 22.29it/s]
48%|####7 | Permuting : 476/999 [00:21<00:22, 23.19it/s]
48%|####7 | Permuting : 477/999 [00:21<00:22, 23.26it/s]
48%|####7 | Permuting : 479/999 [00:21<00:21, 24.17it/s]
48%|####8 | Permuting : 480/999 [00:21<00:21, 24.22it/s]
48%|####8 | Permuting : 481/999 [00:21<00:21, 24.32it/s]
48%|####8 | Permuting : 482/999 [00:21<00:21, 24.44it/s]
48%|####8 | Permuting : 484/999 [00:21<00:20, 25.41it/s]
49%|####8 | Permuting : 486/999 [00:21<00:19, 26.35it/s]
49%|####8 | Permuting : 487/999 [00:21<00:19, 26.44it/s]
49%|####9 | Permuting : 490/999 [00:22<00:17, 28.29it/s]
49%|####9 | Permuting : 493/999 [00:22<00:17, 29.12it/s]
50%|####9 | Permuting : 495/999 [00:22<00:16, 30.02it/s]
50%|####9 | Permuting : 496/999 [00:22<00:16, 29.92it/s]
50%|####9 | Permuting : 498/999 [00:22<00:16, 29.77it/s]
50%|####9 | Permuting : 499/999 [00:22<00:16, 29.63it/s]
50%|##### | Permuting : 500/999 [00:22<00:16, 29.63it/s]
50%|##### | Permuting : 501/999 [00:22<00:17, 28.59it/s]
50%|##### | Permuting : 503/999 [00:22<00:16, 29.41it/s]
50%|##### | Permuting : 504/999 [00:22<00:16, 29.41it/s]
51%|##### | Permuting : 505/999 [00:22<00:22, 22.06it/s]
51%|##### | Permuting : 507/999 [00:22<00:21, 22.98it/s]
51%|##### | Permuting : 508/999 [00:22<00:21, 23.11it/s]
51%|#####1 | Permuting : 511/999 [00:22<00:20, 24.11it/s]
51%|#####1 | Permuting : 514/999 [00:23<00:18, 25.78it/s]
52%|#####1 | Permuting : 516/999 [00:23<00:18, 26.64it/s]
52%|#####1 | Permuting : 517/999 [00:23<00:18, 26.72it/s]
52%|#####2 | Permuting : 520/999 [00:23<00:17, 27.58it/s]
52%|#####2 | Permuting : 523/999 [00:23<00:16, 28.37it/s]
53%|#####2 | Permuting : 526/999 [00:23<00:16, 29.11it/s]
53%|#####2 | Permuting : 527/999 [00:23<00:16, 29.00it/s]
53%|#####2 | Permuting : 529/999 [00:23<00:15, 29.84it/s]
53%|#####3 | Permuting : 530/999 [00:23<00:15, 29.72it/s]
53%|#####3 | Permuting : 533/999 [00:23<00:15, 30.42it/s]
53%|#####3 | Permuting : 534/999 [00:23<00:15, 29.32it/s]
54%|#####3 | Permuting : 536/999 [00:23<00:15, 30.16it/s]
54%|#####3 | Permuting : 538/999 [00:23<00:19, 24.12it/s]
54%|#####3 | Permuting : 539/999 [00:23<00:18, 24.25it/s]
54%|#####4 | Permuting : 540/999 [00:24<00:18, 24.29it/s]
54%|#####4 | Permuting : 542/999 [00:24<00:18, 25.13it/s]
54%|#####4 | Permuting : 543/999 [00:24<00:18, 25.15it/s]
55%|#####4 | Permuting : 545/999 [00:24<00:17, 26.02it/s]
55%|#####4 | Permuting : 546/999 [00:24<00:17, 26.01it/s]
55%|#####4 | Permuting : 548/999 [00:24<00:16, 26.89it/s]
55%|#####4 | Permuting : 549/999 [00:24<00:16, 26.96it/s]
55%|#####5 | Permuting : 552/999 [00:24<00:15, 28.69it/s]
55%|#####5 | Permuting : 554/999 [00:24<00:15, 28.48it/s]
56%|#####5 | Permuting : 555/999 [00:24<00:15, 28.51it/s]
56%|#####5 | Permuting : 556/999 [00:24<00:15, 28.42it/s]
56%|#####5 | Permuting : 557/999 [00:24<00:15, 28.32it/s]
56%|#####5 | Permuting : 559/999 [00:24<00:15, 29.24it/s]
56%|#####6 | Permuting : 562/999 [00:24<00:14, 30.01it/s]
56%|#####6 | Permuting : 564/999 [00:24<00:14, 30.85it/s]
57%|#####6 | Permuting : 565/999 [00:24<00:14, 30.81it/s]
57%|#####6 | Permuting : 568/999 [00:24<00:13, 31.49it/s]
57%|#####6 | Permuting : 569/999 [00:25<00:17, 24.13it/s]
57%|#####7 | Permuting : 570/999 [00:25<00:17, 24.26it/s]
57%|#####7 | Permuting : 572/999 [00:25<00:17, 25.07it/s]
57%|#####7 | Permuting : 573/999 [00:25<00:16, 25.19it/s]
58%|#####7 | Permuting : 576/999 [00:25<00:15, 26.84it/s]
58%|#####7 | Permuting : 577/999 [00:25<00:16, 26.01it/s]
58%|#####7 | Permuting : 578/999 [00:25<00:16, 26.07it/s]
58%|#####7 | Permuting : 579/999 [00:25<00:16, 26.16it/s]
58%|#####8 | Permuting : 581/999 [00:25<00:15, 27.01it/s]
58%|#####8 | Permuting : 582/999 [00:25<00:15, 27.08it/s]
58%|#####8 | Permuting : 583/999 [00:25<00:15, 27.04it/s]
58%|#####8 | Permuting : 584/999 [00:25<00:15, 27.11it/s]
59%|#####8 | Permuting : 586/999 [00:25<00:14, 27.94it/s]
59%|#####8 | Permuting : 587/999 [00:25<00:14, 27.99it/s]
59%|#####9 | Permuting : 590/999 [00:25<00:13, 29.88it/s]
59%|#####9 | Permuting : 592/999 [00:25<00:13, 29.73it/s]
60%|#####9 | Permuting : 595/999 [00:25<00:12, 31.57it/s]
60%|#####9 | Permuting : 596/999 [00:25<00:12, 31.40it/s]
60%|#####9 | Permuting : 598/999 [00:25<00:12, 32.29it/s]
60%|#####9 | Permuting : 599/999 [00:25<00:12, 32.12it/s]
60%|###### | Permuting : 601/999 [00:25<00:12, 31.80it/s]
60%|###### | Permuting : 603/999 [00:26<00:16, 23.65it/s]
60%|###### | Permuting : 604/999 [00:26<00:16, 23.79it/s]
61%|###### | Permuting : 606/999 [00:26<00:15, 24.58it/s]
61%|###### | Permuting : 607/999 [00:26<00:15, 24.71it/s]
61%|######1 | Permuting : 610/999 [00:26<00:15, 25.61it/s]
61%|######1 | Permuting : 613/999 [00:26<00:14, 27.25it/s]
61%|######1 | Permuting : 614/999 [00:26<00:14, 27.20it/s]
62%|######1 | Permuting : 616/999 [00:26<00:13, 28.07it/s]
62%|######1 | Permuting : 619/999 [00:26<00:13, 28.84it/s]
62%|######2 | Permuting : 621/999 [00:26<00:13, 28.66it/s]
62%|######2 | Permuting : 622/999 [00:26<00:13, 28.68it/s]
62%|######2 | Permuting : 623/999 [00:26<00:13, 28.63it/s]
62%|######2 | Permuting : 624/999 [00:26<00:13, 27.64it/s]
63%|######2 | Permuting : 625/999 [00:26<00:13, 27.68it/s]
63%|######2 | Permuting : 626/999 [00:26<00:13, 27.73it/s]
63%|######2 | Permuting : 627/999 [00:27<00:17, 21.35it/s]
63%|######2 | Permuting : 628/999 [00:27<00:17, 21.47it/s]
63%|######2 | Permuting : 629/999 [00:27<00:17, 21.58it/s]
63%|######3 | Permuting : 630/999 [00:27<00:16, 21.78it/s]
63%|######3 | Permuting : 631/999 [00:27<00:16, 21.94it/s]
63%|######3 | Permuting : 632/999 [00:27<00:17, 21.43it/s]
63%|######3 | Permuting : 634/999 [00:27<00:16, 22.38it/s]
64%|######3 | Permuting : 637/999 [00:27<00:15, 24.10it/s]
64%|######3 | Permuting : 639/999 [00:27<00:14, 24.21it/s]
64%|######4 | Permuting : 641/999 [00:27<00:14, 25.13it/s]
64%|######4 | Permuting : 644/999 [00:27<00:13, 26.85it/s]
65%|######4 | Permuting : 645/999 [00:27<00:13, 26.81it/s]
65%|######4 | Permuting : 647/999 [00:27<00:12, 27.72it/s]
65%|######4 | Permuting : 648/999 [00:27<00:12, 27.66it/s]
65%|######5 | Permuting : 650/999 [00:27<00:12, 28.58it/s]
65%|######5 | Permuting : 651/999 [00:27<00:12, 28.48it/s]
65%|######5 | Permuting : 653/999 [00:28<00:11, 29.42it/s]
65%|######5 | Permuting : 654/999 [00:28<00:12, 28.42it/s]
66%|######5 | Permuting : 655/999 [00:28<00:15, 21.73it/s]
66%|######5 | Permuting : 658/999 [00:28<00:15, 22.72it/s]
66%|######6 | Permuting : 660/999 [00:28<00:14, 23.51it/s]
66%|######6 | Permuting : 661/999 [00:28<00:14, 23.66it/s]
66%|######6 | Permuting : 662/999 [00:28<00:14, 23.71it/s]
67%|######6 | Permuting : 665/999 [00:28<00:13, 25.39it/s]
67%|######6 | Permuting : 668/999 [00:28<00:12, 26.27it/s]
67%|######7 | Permuting : 671/999 [00:28<00:11, 27.91it/s]
67%|######7 | Permuting : 673/999 [00:28<00:11, 27.76it/s]
68%|######7 | Permuting : 675/999 [00:28<00:11, 28.59it/s]
68%|######7 | Permuting : 677/999 [00:28<00:11, 28.43it/s]
68%|######7 | Permuting : 678/999 [00:29<00:11, 28.46it/s]
68%|######8 | Permuting : 681/999 [00:29<00:10, 30.12it/s]
68%|######8 | Permuting : 684/999 [00:29<00:09, 31.77it/s]
69%|######8 | Permuting : 685/999 [00:29<00:09, 31.57it/s]
69%|######8 | Permuting : 688/999 [00:29<00:09, 33.25it/s]
69%|######8 | Permuting : 689/999 [00:29<00:09, 31.91it/s]
69%|######9 | Permuting : 691/999 [00:29<00:09, 32.71it/s]
69%|######9 | Permuting : 693/999 [00:29<00:12, 24.78it/s]
69%|######9 | Permuting : 694/999 [00:29<00:12, 24.89it/s]
70%|######9 | Permuting : 695/999 [00:29<00:12, 24.91it/s]
70%|######9 | Permuting : 697/999 [00:29<00:11, 25.74it/s]
70%|######9 | Permuting : 699/999 [00:29<00:11, 25.74it/s]
70%|####### | Permuting : 700/999 [00:29<00:11, 25.84it/s]
70%|####### | Permuting : 701/999 [00:29<00:11, 25.87it/s]
70%|####### | Permuting : 703/999 [00:29<00:11, 26.73it/s]
71%|####### | Permuting : 705/999 [00:30<00:10, 27.47it/s]
71%|####### | Permuting : 706/999 [00:30<00:10, 27.35it/s]
71%|####### | Permuting : 707/999 [00:30<00:10, 27.41it/s]
71%|####### | Permuting : 708/999 [00:30<00:10, 27.36it/s]
71%|#######1 | Permuting : 711/999 [00:30<00:09, 29.11it/s]
71%|#######1 | Permuting : 712/999 [00:30<00:10, 28.06it/s]
71%|#######1 | Permuting : 714/999 [00:30<00:09, 28.95it/s]
72%|#######1 | Permuting : 715/999 [00:30<00:12, 21.97it/s]
72%|#######1 | Permuting : 716/999 [00:30<00:12, 22.14it/s]
72%|#######1 | Permuting : 719/999 [00:30<00:11, 23.71it/s]
72%|#######2 | Permuting : 721/999 [00:30<00:11, 24.57it/s]
72%|#######2 | Permuting : 724/999 [00:30<00:10, 26.17it/s]
73%|#######2 | Permuting : 725/999 [00:30<00:10, 26.20it/s]
73%|#######2 | Permuting : 726/999 [00:30<00:10, 26.18it/s]
73%|#######2 | Permuting : 728/999 [00:30<00:10, 27.06it/s]
73%|#######2 | Permuting : 729/999 [00:30<00:09, 27.02it/s]
73%|#######3 | Permuting : 731/999 [00:31<00:09, 26.97it/s]
73%|#######3 | Permuting : 732/999 [00:31<00:09, 27.04it/s]
73%|#######3 | Permuting : 733/999 [00:31<00:09, 27.00it/s]
74%|#######3 | Permuting : 735/999 [00:31<00:09, 27.92it/s]
74%|#######3 | Permuting : 736/999 [00:31<00:09, 26.95it/s]
74%|#######3 | Permuting : 737/999 [00:31<00:09, 27.02it/s]
74%|#######3 | Permuting : 739/999 [00:31<00:09, 26.92it/s]
74%|#######4 | Permuting : 740/999 [00:31<00:09, 26.99it/s]
74%|#######4 | Permuting : 741/999 [00:31<00:09, 26.95it/s]
74%|#######4 | Permuting : 742/999 [00:31<00:09, 26.90it/s]
74%|#######4 | Permuting : 743/999 [00:31<00:09, 26.99it/s]
74%|#######4 | Permuting : 744/999 [00:31<00:12, 20.29it/s]
75%|#######4 | Permuting : 746/999 [00:31<00:12, 20.66it/s]
75%|#######4 | Permuting : 747/999 [00:32<00:12, 20.79it/s]
75%|#######4 | Permuting : 749/999 [00:32<00:11, 21.73it/s]
75%|#######5 | Permuting : 750/999 [00:32<00:11, 21.84it/s]
75%|#######5 | Permuting : 752/999 [00:32<00:11, 22.15it/s]
75%|#######5 | Permuting : 753/999 [00:32<00:11, 21.68it/s]
75%|#######5 | Permuting : 754/999 [00:32<00:11, 21.79it/s]
76%|#######5 | Permuting : 756/999 [00:32<00:10, 22.77it/s]
76%|#######5 | Permuting : 757/999 [00:32<00:10, 22.76it/s]
76%|#######5 | Permuting : 758/999 [00:32<00:10, 22.90it/s]
76%|#######5 | Permuting : 759/999 [00:32<00:10, 23.09it/s]
76%|#######6 | Permuting : 762/999 [00:32<00:09, 24.94it/s]
76%|#######6 | Permuting : 763/999 [00:32<00:09, 24.17it/s]
77%|#######6 | Permuting : 765/999 [00:32<00:09, 25.17it/s]
77%|#######6 | Permuting : 768/999 [00:32<00:08, 27.02it/s]
77%|#######7 | Permuting : 770/999 [00:32<00:08, 27.98it/s]
77%|#######7 | Permuting : 773/999 [00:32<00:07, 29.82it/s]
78%|#######7 | Permuting : 776/999 [00:32<00:07, 30.57it/s]
78%|#######7 | Permuting : 777/999 [00:33<00:09, 23.31it/s]
78%|#######7 | Permuting : 779/999 [00:33<00:09, 24.17it/s]
78%|#######8 | Permuting : 781/999 [00:33<00:08, 24.94it/s]
78%|#######8 | Permuting : 782/999 [00:33<00:08, 25.06it/s]
78%|#######8 | Permuting : 783/999 [00:33<00:08, 25.07it/s]
78%|#######8 | Permuting : 784/999 [00:33<00:08, 25.09it/s]
79%|#######8 | Permuting : 786/999 [00:33<00:08, 26.01it/s]
79%|#######8 | Permuting : 788/999 [00:33<00:08, 26.10it/s]
79%|#######9 | Permuting : 791/999 [00:33<00:07, 26.95it/s]
79%|#######9 | Permuting : 792/999 [00:33<00:07, 26.91it/s]
79%|#######9 | Permuting : 794/999 [00:33<00:07, 27.81it/s]
80%|#######9 | Permuting : 795/999 [00:33<00:07, 27.75it/s]
80%|#######9 | Permuting : 796/999 [00:33<00:07, 26.80it/s]
80%|#######9 | Permuting : 798/999 [00:33<00:07, 27.72it/s]
80%|######## | Permuting : 801/999 [00:33<00:06, 28.54it/s]
80%|######## | Permuting : 802/999 [00:34<00:08, 22.18it/s]
80%|######## | Permuting : 803/999 [00:34<00:08, 22.35it/s]
80%|######## | Permuting : 804/999 [00:34<00:08, 22.44it/s]
81%|######## | Permuting : 806/999 [00:34<00:08, 23.32it/s]
81%|######## | Permuting : 808/999 [00:34<00:08, 23.54it/s]
81%|######## | Permuting : 809/999 [00:34<00:08, 23.60it/s]
81%|########1 | Permuting : 811/999 [00:34<00:07, 24.50it/s]
81%|########1 | Permuting : 812/999 [00:34<00:07, 24.55it/s]
81%|########1 | Permuting : 813/999 [00:34<00:07, 23.86it/s]
81%|########1 | Permuting : 814/999 [00:34<00:07, 23.98it/s]
82%|########1 | Permuting : 815/999 [00:34<00:07, 24.13it/s]
82%|########1 | Permuting : 816/999 [00:34<00:07, 23.45it/s]
82%|########1 | Permuting : 817/999 [00:34<00:07, 23.61it/s]
82%|########1 | Permuting : 818/999 [00:34<00:07, 23.75it/s]
82%|########1 | Permuting : 819/999 [00:34<00:07, 23.81it/s]
82%|########2 | Permuting : 820/999 [00:34<00:07, 23.97it/s]
82%|########2 | Permuting : 821/999 [00:35<00:09, 18.45it/s]
82%|########2 | Permuting : 822/999 [00:35<00:09, 18.71it/s]
82%|########2 | Permuting : 824/999 [00:35<00:09, 19.14it/s]
83%|########2 | Permuting : 825/999 [00:35<00:08, 19.39it/s]
83%|########2 | Permuting : 826/999 [00:35<00:08, 19.56it/s]
83%|########2 | Permuting : 828/999 [00:35<00:08, 20.55it/s]
83%|########2 | Permuting : 829/999 [00:35<00:08, 20.71it/s]
83%|########3 | Permuting : 830/999 [00:35<00:08, 20.89it/s]
83%|########3 | Permuting : 831/999 [00:35<00:08, 20.40it/s]
83%|########3 | Permuting : 832/999 [00:35<00:08, 20.56it/s]
83%|########3 | Permuting : 833/999 [00:35<00:07, 20.80it/s]
83%|########3 | Permuting : 834/999 [00:35<00:07, 20.95it/s]
84%|########3 | Permuting : 835/999 [00:35<00:07, 21.19it/s]
84%|########3 | Permuting : 836/999 [00:35<00:07, 20.64it/s]
84%|########3 | Permuting : 837/999 [00:35<00:07, 20.80it/s]
84%|########3 | Permuting : 838/999 [00:35<00:07, 21.06it/s]
84%|########3 | Permuting : 839/999 [00:36<00:09, 16.61it/s]
84%|########4 | Permuting : 841/999 [00:36<00:09, 17.15it/s]
84%|########4 | Permuting : 842/999 [00:36<00:09, 16.93it/s]
84%|########4 | Permuting : 843/999 [00:36<00:09, 17.23it/s]
85%|########4 | Permuting : 845/999 [00:36<00:08, 18.17it/s]
85%|########4 | Permuting : 846/999 [00:36<00:08, 18.46it/s]
85%|########4 | Permuting : 848/999 [00:36<00:07, 18.94it/s]
85%|########5 | Permuting : 851/999 [00:36<00:07, 20.71it/s]
85%|########5 | Permuting : 853/999 [00:36<00:06, 21.71it/s]
85%|########5 | Permuting : 854/999 [00:36<00:06, 21.92it/s]
86%|########5 | Permuting : 857/999 [00:36<00:06, 23.02it/s]
86%|########5 | Permuting : 858/999 [00:36<00:06, 22.41it/s]
86%|########6 | Permuting : 860/999 [00:36<00:05, 23.40it/s]
86%|########6 | Permuting : 862/999 [00:36<00:05, 24.38it/s]
86%|########6 | Permuting : 863/999 [00:36<00:05, 23.66it/s]
87%|########6 | Permuting : 865/999 [00:36<00:05, 24.65it/s]
87%|########6 | Permuting : 868/999 [00:37<00:05, 25.63it/s]
87%|########7 | Permuting : 871/999 [00:37<00:04, 27.40it/s]
87%|########7 | Permuting : 872/999 [00:37<00:06, 20.89it/s]
87%|########7 | Permuting : 873/999 [00:37<00:05, 21.01it/s]
88%|########7 | Permuting : 875/999 [00:37<00:05, 21.89it/s]
88%|########7 | Permuting : 876/999 [00:37<00:05, 21.99it/s]
88%|########7 | Permuting : 877/999 [00:37<00:05, 22.17it/s]
88%|########7 | Permuting : 878/999 [00:37<00:05, 22.33it/s]
88%|########7 | Permuting : 879/999 [00:37<00:05, 22.43it/s]
88%|########8 | Permuting : 880/999 [00:37<00:05, 22.62it/s]
88%|########8 | Permuting : 881/999 [00:37<00:05, 22.04it/s]
88%|########8 | Permuting : 882/999 [00:37<00:05, 22.24it/s]
88%|########8 | Permuting : 883/999 [00:37<00:05, 21.68it/s]
88%|########8 | Permuting : 884/999 [00:37<00:05, 21.81it/s]
89%|########8 | Permuting : 885/999 [00:37<00:05, 22.02it/s]
89%|########8 | Permuting : 886/999 [00:38<00:05, 22.14it/s]
89%|########8 | Permuting : 887/999 [00:38<00:05, 22.35it/s]
89%|########8 | Permuting : 888/999 [00:38<00:04, 22.46it/s]
89%|########8 | Permuting : 889/999 [00:38<00:06, 16.75it/s]
89%|########9 | Permuting : 890/999 [00:38<00:06, 16.56it/s]
89%|########9 | Permuting : 892/999 [00:38<00:06, 17.52it/s]
90%|########9 | Permuting : 895/999 [00:38<00:05, 18.67it/s]
90%|########9 | Permuting : 896/999 [00:38<00:05, 18.38it/s]
90%|########9 | Permuting : 898/999 [00:38<00:05, 19.32it/s]
90%|######### | Permuting : 901/999 [00:38<00:04, 20.97it/s]
90%|######### | Permuting : 903/999 [00:38<00:04, 21.23it/s]
90%|######### | Permuting : 904/999 [00:38<00:04, 21.43it/s]
91%|######### | Permuting : 905/999 [00:39<00:04, 21.57it/s]
91%|######### | Permuting : 907/999 [00:39<00:04, 22.52it/s]
91%|######### | Permuting : 908/999 [00:39<00:04, 22.62it/s]
91%|######### | Permuting : 909/999 [00:39<00:03, 22.71it/s]
91%|#########1| Permuting : 911/999 [00:39<00:03, 23.70it/s]
91%|#########1| Permuting : 912/999 [00:39<00:03, 23.13it/s]
91%|#########1| Permuting : 913/999 [00:39<00:04, 17.50it/s]
91%|#########1| Permuting : 914/999 [00:39<00:04, 17.75it/s]
92%|#########1| Permuting : 915/999 [00:39<00:04, 17.95it/s]
92%|#########1| Permuting : 916/999 [00:39<00:04, 18.21it/s]
92%|#########1| Permuting : 917/999 [00:39<00:04, 18.41it/s]
92%|#########1| Permuting : 919/999 [00:39<00:04, 18.87it/s]
92%|#########2| Permuting : 920/999 [00:39<00:04, 19.10it/s]
92%|#########2| Permuting : 921/999 [00:39<00:04, 19.28it/s]
92%|#########2| Permuting : 923/999 [00:40<00:03, 20.27it/s]
93%|#########2| Permuting : 925/999 [00:40<00:03, 21.27it/s]
93%|#########2| Permuting : 926/999 [00:40<00:03, 21.42it/s]
93%|#########2| Permuting : 928/999 [00:40<00:03, 22.43it/s]
93%|#########2| Permuting : 929/999 [00:40<00:03, 22.55it/s]
93%|#########3| Permuting : 930/999 [00:40<00:03, 22.65it/s]
93%|#########3| Permuting : 931/999 [00:40<00:02, 22.81it/s]
93%|#########3| Permuting : 933/999 [00:40<00:02, 23.10it/s]
94%|#########3| Permuting : 936/999 [00:40<00:02, 24.99it/s]
94%|#########3| Permuting : 937/999 [00:40<00:02, 24.17it/s]
94%|#########3| Permuting : 938/999 [00:40<00:03, 18.79it/s]
94%|#########3| Permuting : 939/999 [00:40<00:03, 19.04it/s]
94%|#########4| Permuting : 940/999 [00:40<00:03, 19.22it/s]
94%|#########4| Permuting : 942/999 [00:40<00:02, 20.18it/s]
94%|#########4| Permuting : 943/999 [00:40<00:02, 19.78it/s]
94%|#########4| Permuting : 944/999 [00:41<00:02, 20.00it/s]
95%|#########4| Permuting : 945/999 [00:41<00:02, 20.24it/s]
95%|#########4| Permuting : 948/999 [00:41<00:02, 21.38it/s]
95%|#########4| Permuting : 949/999 [00:41<00:02, 21.51it/s]
95%|#########5| Permuting : 951/999 [00:41<00:02, 22.50it/s]
95%|#########5| Permuting : 954/999 [00:41<00:01, 24.28it/s]
96%|#########5| Permuting : 957/999 [00:41<00:01, 25.27it/s]
96%|#########5| Permuting : 959/999 [00:41<00:01, 26.19it/s]
96%|#########6| Permuting : 960/999 [00:41<00:01, 26.29it/s]
96%|#########6| Permuting : 961/999 [00:41<00:01, 26.27it/s]
96%|#########6| Permuting : 963/999 [00:41<00:01, 27.23it/s]
96%|#########6| Permuting : 964/999 [00:41<00:01, 26.29it/s]
97%|#########6| Permuting : 965/999 [00:41<00:01, 26.38it/s]
97%|#########6| Permuting : 966/999 [00:41<00:01, 20.27it/s]
97%|#########6| Permuting : 968/999 [00:41<00:01, 21.01it/s]
97%|#########6| Permuting : 969/999 [00:42<00:01, 21.17it/s]
97%|#########7| Permuting : 970/999 [00:42<00:01, 21.38it/s]
97%|#########7| Permuting : 971/999 [00:42<00:01, 21.50it/s]
97%|#########7| Permuting : 973/999 [00:42<00:01, 22.47it/s]
97%|#########7| Permuting : 974/999 [00:42<00:01, 22.57it/s]
98%|#########7| Permuting : 976/999 [00:42<00:00, 23.55it/s]
98%|#########7| Permuting : 979/999 [00:42<00:00, 25.35it/s]
98%|#########8| Permuting : 980/999 [00:42<00:00, 25.37it/s]
98%|#########8| Permuting : 982/999 [00:42<00:00, 25.47it/s]
98%|#########8| Permuting : 983/999 [00:42<00:00, 25.58it/s]
99%|#########8| Permuting : 986/999 [00:42<00:00, 27.42it/s]
99%|#########8| Permuting : 987/999 [00:42<00:00, 26.47it/s]
99%|#########8| Permuting : 989/999 [00:42<00:00, 27.42it/s]
99%|#########9| Permuting : 992/999 [00:42<00:00, 28.38it/s]
99%|#########9| Permuting : 993/999 [00:42<00:00, 28.37it/s]
100%|#########9| Permuting : 996/999 [00:42<00:00, 30.19it/s]
100%|#########9| Permuting : 998/999 [00:42<00:00, 31.08it/s]
100%|##########| Permuting : 999/999 [00:43<00:00, 23.67it/s]
100%|##########| Permuting : 999/999 [00:43<00:00, 23.20it/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 11.090 seconds)

**Estimated memory usage:** 9 MB