# Permutation statistics

Options for permutation statistics: max-statistic, cluster-mass and TFCE.

This example illustrates different options for null-distirbutions in permutation tests. All are illustrated using a simple t-test. For simulating more complex datasets see other examples in this section.

For the sake of speed, the tests here are based on 1000 permutations of the data (`samples=1000`). For precise p-values, 10000 permutations (the default) are preferable.

```# sphinx_gallery_thumbnail_number = 2
from eelbrain import *
import scipy.stats

data = datasets.simulate_erp()
eeg = data['eeg']
```

## Max statistic

The max statistic is simply the maximum across the entire t-map. The permutation distribution consist of `max(t)` for each permutation. This is the default, and is also the fastest test.

```result = testnd.TTestOneSample(eeg, samples=1000)
```
```Permutation test:   0%|          | 0/1000 [00:00<?, ? permutations/s]
Permutation test:   3%|▎         | 28/1000 [00:00<00:03, 270.60 permutations/s]
Permutation test:   6%|▌         | 62/1000 [00:00<00:03, 301.45 permutations/s]
Permutation test:  10%|▉         | 96/1000 [00:00<00:02, 310.43 permutations/s]
Permutation test:  13%|█▎        | 130/1000 [00:00<00:02, 315.47 permutations/s]
Permutation test:  16%|█▋        | 164/1000 [00:00<00:02, 318.04 permutations/s]
Permutation test:  20%|█▉        | 196/1000 [00:00<00:02, 317.92 permutations/s]
Permutation test:  23%|██▎       | 230/1000 [00:00<00:02, 319.27 permutations/s]
Permutation test:  26%|██▌       | 262/1000 [00:00<00:02, 318.95 permutations/s]
Permutation test:  30%|██▉       | 296/1000 [00:00<00:02, 319.65 permutations/s]
Permutation test:  33%|███▎      | 328/1000 [00:01<00:02, 319.19 permutations/s]
Permutation test:  36%|███▌      | 360/1000 [00:01<00:02, 318.80 permutations/s]
Permutation test:  39%|███▉      | 393/1000 [00:01<00:01, 318.26 permutations/s]
Permutation test:  43%|████▎     | 427/1000 [00:01<00:01, 323.85 permutations/s]
Permutation test:  46%|████▌     | 460/1000 [00:01<00:01, 324.89 permutations/s]
Permutation test:  49%|████▉     | 493/1000 [00:01<00:01, 320.02 permutations/s]
Permutation test:  53%|█████▎    | 526/1000 [00:01<00:01, 322.80 permutations/s]
Permutation test:  56%|█████▌    | 559/1000 [00:01<00:01, 317.79 permutations/s]
Permutation test:  59%|█████▉    | 593/1000 [00:01<00:01, 320.30 permutations/s]
Permutation test:  63%|██████▎   | 627/1000 [00:01<00:01, 322.00 permutations/s]
Permutation test:  66%|██████▌   | 660/1000 [00:02<00:01, 323.51 permutations/s]
Permutation test:  69%|██████▉   | 693/1000 [00:02<00:00, 319.93 permutations/s]
Permutation test:  73%|███████▎  | 727/1000 [00:02<00:00, 320.89 permutations/s]
Permutation test:  76%|███████▌  | 761/1000 [00:02<00:00, 321.74 permutations/s]
Permutation test:  80%|███████▉  | 795/1000 [00:02<00:00, 321.45 permutations/s]
Permutation test:  83%|████████▎ | 828/1000 [00:02<00:00, 322.44 permutations/s]
Permutation test:  86%|████████▌ | 862/1000 [00:02<00:00, 323.45 permutations/s]
Permutation test:  90%|████████▉ | 895/1000 [00:02<00:00, 324.96 permutations/s]
Permutation test:  93%|█████████▎| 928/1000 [00:02<00:00, 320.90 permutations/s]
Permutation test:  96%|█████████▌| 962/1000 [00:03<00:00, 320.73 permutations/s]
Permutation test: 100%|█████████▉| 996/1000 [00:03<00:00, 320.26 permutations/s]
Permutation test: 100%|██████████| 1000/1000 [00:03<00:00, 319.67 permutations/s]
```

Visualize the permutation distribution. We consider values significant if they are larger than 95% of the permutation distribution, so we look for the 95th percentile:

```significance_threshold = scipy.stats.scoreatpercentile(result.permutation_distribution, 95)
p = plot.Histogram(
result.permutation_distribution, title='Distribution of \$max(t)\$',
xlabel='max(t)', ylabel='Number of permutations')
_ = p.axes[0].text(significance_threshold, 40, ' 95%', color='red')
```

In the actual comparison, any data point with a t-value that is more extreme than 95% of the permutation distribution is considered signifiacant:

```p = plot.TopoButterfly(result, t=0.13, head_radius=0.35)
```

Significant regions can be retrieved as `Dataset` of `NDVar` for further analysis (e.g., for defining ROIs). This function will find all contiguous regions in which p ≤ .05:

```significan_regions = result.find_clusters(0.05, maps=True)
significan_regions
```

```p = plot.TopoButterfly(significan_regions[0, 'cluster'], t=0.13, head_radius=0.35)
```

## Cluster-based tests

In cluster-based tests, a first steps consists in finding contiguous regions of “meaningful” effect, so-called clusters. “Meaningful” can be defined based on a value of the statistic (e.g., a t-value). It is commonly set to a t value equivalent to uncorrected p = .05. This is specified with the `pmin=.05` argument.

A summary statistic is then computed for each cluster. In Eelbrain this is the cluster-mass statistic: the sum of all values in the cluster (i.e., the sum of the t values at all datapoints that are part of the cluster). The clustering procedure is repeated in each permutation, and the largest cluster-mass value is retained, to derive a permutation distribution for cluster-mass values expected under the null hypothesis. Each cluster in the actual data can then be evaluated against this distribution.

```result = testnd.TTestOneSample(eeg, samples=1000, pmin=.05)
```
```Permutation test:   0%|          | 0/1000 [00:00<?, ? permutations/s]
Permutation test:   2%|▎         | 25/1000 [00:00<00:04, 236.22 permutations/s]
Permutation test:   5%|▌         | 53/1000 [00:00<00:03, 257.03 permutations/s]
Permutation test:   8%|▊         | 81/1000 [00:00<00:03, 264.78 permutations/s]
Permutation test:  11%|█         | 109/1000 [00:00<00:03, 269.70 permutations/s]
Permutation test:  14%|█▎        | 137/1000 [00:00<00:03, 270.68 permutations/s]
Permutation test:  16%|█▋        | 165/1000 [00:00<00:03, 270.91 permutations/s]
Permutation test:  19%|█▉        | 193/1000 [00:00<00:02, 272.40 permutations/s]
Permutation test:  22%|██▏       | 221/1000 [00:00<00:02, 273.62 permutations/s]
Permutation test:  25%|██▍       | 249/1000 [00:00<00:02, 274.31 permutations/s]
Permutation test:  28%|██▊       | 277/1000 [00:01<00:02, 274.87 permutations/s]
Permutation test:  30%|███       | 305/1000 [00:01<00:02, 273.72 permutations/s]
Permutation test:  33%|███▎      | 333/1000 [00:01<00:02, 273.88 permutations/s]
Permutation test:  36%|███▌      | 361/1000 [00:01<00:02, 274.86 permutations/s]
Permutation test:  39%|███▉      | 389/1000 [00:01<00:02, 274.19 permutations/s]
Permutation test:  42%|████▏     | 417/1000 [00:01<00:02, 273.07 permutations/s]
Permutation test:  44%|████▍     | 445/1000 [00:01<00:02, 274.79 permutations/s]
Permutation test:  47%|████▋     | 474/1000 [00:01<00:01, 276.50 permutations/s]
Permutation test:  50%|█████     | 504/1000 [00:01<00:01, 277.60 permutations/s]
Permutation test:  53%|█████▎    | 532/1000 [00:01<00:01, 277.39 permutations/s]
Permutation test:  56%|█████▌    | 560/1000 [00:02<00:01, 277.50 permutations/s]
Permutation test:  59%|█████▉    | 588/1000 [00:02<00:01, 277.73 permutations/s]
Permutation test:  62%|██████▏   | 616/1000 [00:02<00:01, 277.44 permutations/s]
Permutation test:  64%|██████▍   | 644/1000 [00:02<00:01, 277.03 permutations/s]
Permutation test:  67%|██████▋   | 672/1000 [00:02<00:01, 277.39 permutations/s]
Permutation test:  70%|███████   | 700/1000 [00:02<00:01, 277.14 permutations/s]
Permutation test:  73%|███████▎  | 728/1000 [00:02<00:00, 276.75 permutations/s]
Permutation test:  76%|███████▌  | 756/1000 [00:02<00:00, 276.28 permutations/s]
Permutation test:  78%|███████▊  | 784/1000 [00:02<00:00, 276.68 permutations/s]
Permutation test:  81%|████████  | 812/1000 [00:02<00:00, 277.21 permutations/s]
Permutation test:  84%|████████▍ | 840/1000 [00:03<00:00, 277.72 permutations/s]
Permutation test:  87%|████████▋ | 868/1000 [00:03<00:00, 277.49 permutations/s]
Permutation test:  90%|████████▉ | 896/1000 [00:03<00:00, 277.97 permutations/s]
Permutation test:  92%|█████████▏| 924/1000 [00:03<00:00, 278.57 permutations/s]
Permutation test:  95%|█████████▌| 953/1000 [00:03<00:00, 279.47 permutations/s]
Permutation test:  98%|█████████▊| 981/1000 [00:03<00:00, 279.39 permutations/s]
Permutation test: 100%|██████████| 1000/1000 [00:03<00:00, 275.58 permutations/s]
```

Compared to the `max(t)` approach above:

1. Clusters tend to be larger, because an uncorrected p = .05 (the cluster forming threshold) usually corresponds to a lower t-value than a corrected p = .05.

2. A second, later cluster emerged, showing that this test can be more powerful when effects are temporally and spatially extended.

Because clusters are formed before computing the permutation distribution, there are usually many non-significant clusters (we don not want to list them all here):

```result.find_clusters().head()
```

List only significant clusters

```result.find_clusters(pmin=0.05)
```

## Threshold-free cluster enhancement (TFCE)

TFCE is an image processing algorithm that enhances cluster-like features, but without setting an arbitrary threshold. It thus combines the advantage the max statistic approach (not having to set an arbitrary threshold) with the advantage of the cluster-based test of increased sensitivity for effects that are extended in space and time.

```result = testnd.TTestOneSample(eeg, samples=1000, tfce=True)
```
```Permutation test:   0%|          | 0/1000 [00:00<?, ? permutations/s]
Permutation test:   0%|          | 5/1000 [00:00<00:24, 40.17 permutations/s]
Permutation test:   1%|          | 11/1000 [00:00<00:20, 47.17 permutations/s]
Permutation test:   2%|▏         | 17/1000 [00:00<00:19, 50.14 permutations/s]
Permutation test:   2%|▏         | 23/1000 [00:00<00:18, 51.78 permutations/s]
Permutation test:   3%|▎         | 29/1000 [00:00<00:18, 51.98 permutations/s]
Permutation test:   4%|▎         | 35/1000 [00:00<00:18, 52.10 permutations/s]
Permutation test:   4%|▍         | 41/1000 [00:00<00:18, 52.26 permutations/s]
Permutation test:   5%|▍         | 47/1000 [00:00<00:18, 51.99 permutations/s]
Permutation test:   5%|▌         | 53/1000 [00:01<00:18, 52.21 permutations/s]
Permutation test:   6%|▌         | 59/1000 [00:01<00:17, 52.59 permutations/s]
Permutation test:   6%|▋         | 65/1000 [00:01<00:17, 52.47 permutations/s]
Permutation test:   7%|▋         | 71/1000 [00:01<00:17, 52.39 permutations/s]
Permutation test:   8%|▊         | 77/1000 [00:01<00:17, 51.75 permutations/s]
Permutation test:   8%|▊         | 83/1000 [00:01<00:17, 52.51 permutations/s]
Permutation test:   9%|▉         | 89/1000 [00:01<00:17, 52.28 permutations/s]
Permutation test:  10%|▉         | 95/1000 [00:01<00:17, 52.29 permutations/s]
Permutation test:  10%|█         | 101/1000 [00:01<00:17, 51.94 permutations/s]
Permutation test:  11%|█         | 107/1000 [00:02<00:17, 51.93 permutations/s]
Permutation test:  11%|█▏        | 113/1000 [00:02<00:17, 51.70 permutations/s]
Permutation test:  12%|█▏        | 119/1000 [00:02<00:17, 49.87 permutations/s]
Permutation test:  12%|█▎        | 125/1000 [00:02<00:17, 50.14 permutations/s]
Permutation test:  13%|█▎        | 131/1000 [00:02<00:17, 50.71 permutations/s]
Permutation test:  14%|█▎        | 137/1000 [00:02<00:16, 51.23 permutations/s]
Permutation test:  14%|█▍        | 143/1000 [00:02<00:16, 50.80 permutations/s]
Permutation test:  15%|█▍        | 149/1000 [00:02<00:16, 51.68 permutations/s]
Permutation test:  16%|█▌        | 155/1000 [00:03<00:16, 52.19 permutations/s]
Permutation test:  16%|█▌        | 161/1000 [00:03<00:16, 51.92 permutations/s]
Permutation test:  17%|█▋        | 167/1000 [00:03<00:16, 51.88 permutations/s]
Permutation test:  17%|█▋        | 173/1000 [00:03<00:15, 51.95 permutations/s]
Permutation test:  18%|█▊        | 179/1000 [00:03<00:15, 52.49 permutations/s]
Permutation test:  18%|█▊        | 185/1000 [00:03<00:15, 52.58 permutations/s]
Permutation test:  19%|█▉        | 191/1000 [00:03<00:15, 51.95 permutations/s]
Permutation test:  20%|█▉        | 197/1000 [00:03<00:15, 52.66 permutations/s]
Permutation test:  20%|██        | 203/1000 [00:03<00:15, 51.78 permutations/s]
Permutation test:  21%|██        | 209/1000 [00:04<00:15, 51.94 permutations/s]
Permutation test:  22%|██▏       | 215/1000 [00:04<00:15, 51.94 permutations/s]
Permutation test:  22%|██▏       | 221/1000 [00:04<00:14, 52.14 permutations/s]
Permutation test:  23%|██▎       | 227/1000 [00:04<00:14, 52.70 permutations/s]
Permutation test:  23%|██▎       | 233/1000 [00:04<00:14, 52.51 permutations/s]
Permutation test:  24%|██▍       | 239/1000 [00:04<00:14, 52.67 permutations/s]
Permutation test:  24%|██▍       | 245/1000 [00:04<00:14, 52.71 permutations/s]
Permutation test:  25%|██▌       | 251/1000 [00:04<00:14, 52.57 permutations/s]
Permutation test:  26%|██▌       | 257/1000 [00:04<00:14, 52.27 permutations/s]
Permutation test:  26%|██▋       | 263/1000 [00:05<00:14, 52.10 permutations/s]
Permutation test:  27%|██▋       | 269/1000 [00:05<00:13, 52.67 permutations/s]
Permutation test:  28%|██▊       | 275/1000 [00:05<00:13, 52.24 permutations/s]
Permutation test:  28%|██▊       | 281/1000 [00:05<00:13, 52.18 permutations/s]
Permutation test:  29%|██▊       | 287/1000 [00:05<00:13, 52.40 permutations/s]
Permutation test:  29%|██▉       | 293/1000 [00:05<00:13, 52.08 permutations/s]
Permutation test:  30%|██▉       | 299/1000 [00:05<00:13, 52.22 permutations/s]
Permutation test:  30%|███       | 305/1000 [00:05<00:13, 50.36 permutations/s]
Permutation test:  31%|███       | 311/1000 [00:06<00:14, 49.08 permutations/s]
Permutation test:  32%|███▏      | 317/1000 [00:06<00:13, 49.47 permutations/s]
Permutation test:  32%|███▏      | 323/1000 [00:06<00:13, 49.98 permutations/s]
Permutation test:  33%|███▎      | 329/1000 [00:06<00:13, 51.07 permutations/s]
Permutation test:  34%|███▎      | 335/1000 [00:06<00:12, 51.66 permutations/s]
Permutation test:  34%|███▍      | 341/1000 [00:06<00:12, 51.09 permutations/s]
Permutation test:  35%|███▍      | 347/1000 [00:06<00:12, 51.69 permutations/s]
Permutation test:  35%|███▌      | 353/1000 [00:06<00:12, 52.16 permutations/s]
Permutation test:  36%|███▌      | 359/1000 [00:06<00:12, 52.01 permutations/s]
Permutation test:  36%|███▋      | 365/1000 [00:07<00:12, 52.48 permutations/s]
Permutation test:  37%|███▋      | 371/1000 [00:07<00:11, 52.81 permutations/s]
Permutation test:  38%|███▊      | 377/1000 [00:07<00:11, 53.01 permutations/s]
Permutation test:  38%|███▊      | 383/1000 [00:07<00:11, 52.46 permutations/s]
Permutation test:  39%|███▉      | 389/1000 [00:07<00:11, 52.80 permutations/s]
Permutation test:  40%|███▉      | 395/1000 [00:07<00:11, 52.67 permutations/s]
Permutation test:  40%|████      | 401/1000 [00:07<00:11, 52.94 permutations/s]
Permutation test:  41%|████      | 407/1000 [00:07<00:11, 52.94 permutations/s]
Permutation test:  41%|████▏     | 413/1000 [00:07<00:11, 53.35 permutations/s]
Permutation test:  42%|████▏     | 419/1000 [00:08<00:10, 53.40 permutations/s]
Permutation test:  42%|████▎     | 425/1000 [00:08<00:10, 53.75 permutations/s]
Permutation test:  43%|████▎     | 431/1000 [00:08<00:10, 52.95 permutations/s]
Permutation test:  44%|████▎     | 437/1000 [00:08<00:10, 52.31 permutations/s]
Permutation test:  44%|████▍     | 443/1000 [00:08<00:10, 51.62 permutations/s]
Permutation test:  45%|████▍     | 449/1000 [00:08<00:10, 51.35 permutations/s]
Permutation test:  46%|████▌     | 455/1000 [00:08<00:10, 51.67 permutations/s]
Permutation test:  46%|████▌     | 461/1000 [00:08<00:10, 52.00 permutations/s]
Permutation test:  47%|████▋     | 467/1000 [00:08<00:10, 52.38 permutations/s]
Permutation test:  47%|████▋     | 473/1000 [00:09<00:10, 52.06 permutations/s]
Permutation test:  48%|████▊     | 479/1000 [00:09<00:09, 52.49 permutations/s]
Permutation test:  48%|████▊     | 485/1000 [00:09<00:09, 52.93 permutations/s]
Permutation test:  49%|████▉     | 491/1000 [00:09<00:09, 53.41 permutations/s]
Permutation test:  50%|████▉     | 497/1000 [00:09<00:09, 53.34 permutations/s]
Permutation test:  50%|█████     | 503/1000 [00:09<00:09, 52.47 permutations/s]
Permutation test:  51%|█████     | 509/1000 [00:09<00:09, 52.34 permutations/s]
Permutation test:  52%|█████▏    | 515/1000 [00:09<00:09, 52.31 permutations/s]
Permutation test:  52%|█████▏    | 521/1000 [00:10<00:09, 52.06 permutations/s]
Permutation test:  53%|█████▎    | 527/1000 [00:10<00:09, 52.03 permutations/s]
Permutation test:  53%|█████▎    | 533/1000 [00:10<00:09, 51.48 permutations/s]
Permutation test:  54%|█████▍    | 539/1000 [00:10<00:09, 50.33 permutations/s]
Permutation test:  55%|█████▍    | 545/1000 [00:10<00:08, 51.00 permutations/s]
Permutation test:  55%|█████▌    | 551/1000 [00:10<00:08, 51.44 permutations/s]
Permutation test:  56%|█████▌    | 557/1000 [00:10<00:08, 52.10 permutations/s]
Permutation test:  56%|█████▋    | 563/1000 [00:10<00:08, 52.06 permutations/s]
Permutation test:  57%|█████▋    | 569/1000 [00:10<00:08, 52.38 permutations/s]
Permutation test:  57%|█████▊    | 575/1000 [00:11<00:08, 52.78 permutations/s]
Permutation test:  58%|█████▊    | 581/1000 [00:11<00:08, 50.25 permutations/s]
Permutation test:  59%|█████▊    | 587/1000 [00:11<00:08, 50.93 permutations/s]
Permutation test:  59%|█████▉    | 593/1000 [00:11<00:07, 51.34 permutations/s]
Permutation test:  60%|█████▉    | 599/1000 [00:11<00:07, 51.58 permutations/s]
Permutation test:  60%|██████    | 605/1000 [00:11<00:07, 51.86 permutations/s]
Permutation test:  61%|██████    | 611/1000 [00:11<00:07, 52.24 permutations/s]
Permutation test:  62%|██████▏   | 617/1000 [00:11<00:07, 51.66 permutations/s]
Permutation test:  62%|██████▏   | 623/1000 [00:12<00:07, 51.85 permutations/s]
Permutation test:  63%|██████▎   | 629/1000 [00:12<00:07, 51.82 permutations/s]
Permutation test:  64%|██████▎   | 635/1000 [00:12<00:06, 52.54 permutations/s]
Permutation test:  64%|██████▍   | 641/1000 [00:12<00:06, 52.08 permutations/s]
Permutation test:  65%|██████▍   | 647/1000 [00:12<00:06, 52.67 permutations/s]
Permutation test:  65%|██████▌   | 653/1000 [00:12<00:06, 53.00 permutations/s]
Permutation test:  66%|██████▌   | 659/1000 [00:12<00:06, 52.87 permutations/s]
Permutation test:  66%|██████▋   | 665/1000 [00:12<00:06, 52.26 permutations/s]
Permutation test:  67%|██████▋   | 671/1000 [00:12<00:06, 51.96 permutations/s]
Permutation test:  68%|██████▊   | 677/1000 [00:13<00:06, 51.47 permutations/s]
Permutation test:  68%|██████▊   | 683/1000 [00:13<00:06, 52.20 permutations/s]
Permutation test:  69%|██████▉   | 689/1000 [00:13<00:05, 51.99 permutations/s]
Permutation test:  70%|██████▉   | 695/1000 [00:13<00:05, 52.55 permutations/s]
Permutation test:  70%|███████   | 701/1000 [00:13<00:05, 52.83 permutations/s]
Permutation test:  71%|███████   | 707/1000 [00:13<00:05, 52.56 permutations/s]
Permutation test:  71%|███████▏  | 713/1000 [00:13<00:05, 51.42 permutations/s]
Permutation test:  72%|███████▏  | 719/1000 [00:13<00:05, 51.74 permutations/s]
Permutation test:  72%|███████▎  | 725/1000 [00:13<00:05, 51.96 permutations/s]
Permutation test:  73%|███████▎  | 731/1000 [00:14<00:05, 51.69 permutations/s]
Permutation test:  74%|███████▎  | 737/1000 [00:14<00:05, 51.97 permutations/s]
Permutation test:  74%|███████▍  | 743/1000 [00:14<00:04, 52.08 permutations/s]
Permutation test:  75%|███████▍  | 749/1000 [00:14<00:04, 52.51 permutations/s]
Permutation test:  76%|███████▌  | 755/1000 [00:14<00:04, 52.59 permutations/s]
Permutation test:  76%|███████▌  | 761/1000 [00:14<00:04, 52.65 permutations/s]
Permutation test:  77%|███████▋  | 767/1000 [00:14<00:04, 53.17 permutations/s]
Permutation test:  77%|███████▋  | 773/1000 [00:14<00:04, 53.10 permutations/s]
Permutation test:  78%|███████▊  | 779/1000 [00:14<00:04, 52.56 permutations/s]
Permutation test:  78%|███████▊  | 785/1000 [00:15<00:04, 52.27 permutations/s]
Permutation test:  79%|███████▉  | 791/1000 [00:15<00:03, 53.09 permutations/s]
Permutation test:  80%|███████▉  | 797/1000 [00:15<00:03, 53.11 permutations/s]
Permutation test:  80%|████████  | 803/1000 [00:15<00:03, 52.67 permutations/s]
Permutation test:  81%|████████  | 809/1000 [00:15<00:03, 52.44 permutations/s]
Permutation test:  82%|████████▏ | 815/1000 [00:15<00:03, 51.77 permutations/s]
Permutation test:  82%|████████▏ | 821/1000 [00:15<00:03, 51.70 permutations/s]
Permutation test:  83%|████████▎ | 827/1000 [00:15<00:03, 51.69 permutations/s]
Permutation test:  83%|████████▎ | 833/1000 [00:16<00:03, 50.14 permutations/s]
Permutation test:  84%|████████▍ | 839/1000 [00:16<00:03, 50.36 permutations/s]
Permutation test:  84%|████████▍ | 845/1000 [00:16<00:03, 51.35 permutations/s]
Permutation test:  85%|████████▌ | 851/1000 [00:16<00:02, 51.46 permutations/s]
Permutation test:  86%|████████▌ | 857/1000 [00:16<00:02, 51.61 permutations/s]
Permutation test:  86%|████████▋ | 863/1000 [00:16<00:02, 52.41 permutations/s]
Permutation test:  87%|████████▋ | 869/1000 [00:16<00:02, 52.56 permutations/s]
Permutation test:  88%|████████▊ | 875/1000 [00:16<00:02, 52.57 permutations/s]
Permutation test:  88%|████████▊ | 881/1000 [00:16<00:02, 53.01 permutations/s]
Permutation test:  89%|████████▊ | 887/1000 [00:17<00:02, 52.75 permutations/s]
Permutation test:  89%|████████▉ | 893/1000 [00:17<00:02, 52.55 permutations/s]
Permutation test:  90%|████████▉ | 899/1000 [00:17<00:01, 52.85 permutations/s]
Permutation test:  90%|█████████ | 905/1000 [00:17<00:01, 52.76 permutations/s]
Permutation test:  91%|█████████ | 911/1000 [00:17<00:01, 52.70 permutations/s]
Permutation test:  92%|█████████▏| 917/1000 [00:17<00:01, 52.49 permutations/s]
Permutation test:  92%|█████████▏| 923/1000 [00:17<00:01, 52.37 permutations/s]
Permutation test:  93%|█████████▎| 929/1000 [00:17<00:01, 52.39 permutations/s]
Permutation test:  94%|█████████▎| 935/1000 [00:17<00:01, 52.18 permutations/s]
Permutation test:  94%|█████████▍| 941/1000 [00:18<00:01, 52.26 permutations/s]
Permutation test:  95%|█████████▍| 947/1000 [00:18<00:00, 53.05 permutations/s]
Permutation test:  95%|█████████▌| 953/1000 [00:18<00:00, 51.63 permutations/s]
Permutation test:  96%|█████████▌| 959/1000 [00:18<00:00, 50.92 permutations/s]
Permutation test:  96%|█████████▋| 965/1000 [00:18<00:00, 50.95 permutations/s]
Permutation test:  97%|█████████▋| 971/1000 [00:18<00:00, 51.79 permutations/s]
Permutation test:  98%|█████████▊| 977/1000 [00:18<00:00, 52.24 permutations/s]
Permutation test:  98%|█████████▊| 983/1000 [00:18<00:00, 51.80 permutations/s]
Permutation test:  99%|█████████▉| 989/1000 [00:19<00:00, 52.68 permutations/s]
Permutation test: 100%|█████████▉| 995/1000 [00:19<00:00, 52.41 permutations/s]
Permutation test: 100%|██████████| 1000/1000 [00:19<00:00, 52.04 permutations/s]
```

Result representation is analogous to the max statistic approach, with the addition that the TFCE map can be visualized:

```p = plot.TopoButterfly(result.tfce_map, t=0.13, head_radius=0.35)
```

Total running time of the script: (0 minutes 30.025 seconds)

Gallery generated by Sphinx-Gallery