Repository: mne-tools/mne-python

Issue:
BUG/API issue with multi_comp.bonferroni_correction
Do people agree that this is a bug, at least a very unexpected output:
https://github.com/mne-tools/mne-python/blob/master/mne/stats/multi_comp.py#L101

`pval_corrected` should instead be used for creating the output mask.

@agramfort @Eric89GXL @mainakjas 

Discussion:

Patch:
diff --git a/doc/source/whats_new.rst b/doc/source/whats_new.rst
index 5ff2f77d1..3c7c0a5fd 100644
--- a/doc/source/whats_new.rst
+++ b/doc/source/whats_new.rst
@@ -14,6 +14,8 @@ BUG
 
     - Fix ``mne.io.add_reference_channels`` not setting ``info[nchan]`` correctly by `Federico Raimondo`_
 
+    - Fix ``mne.stats.bonferroni_correction`` reject mask output to use corrected p-values by `Denis Engemann`_
+
 .. _changes_0_9:
 
 Changelog
diff --git a/mne/stats/multi_comp.py b/mne/stats/multi_comp.py
index 51751ea1a..a26b4a772 100644
--- a/mne/stats/multi_comp.py
+++ b/mne/stats/multi_comp.py
@@ -98,5 +98,5 @@ def bonferroni_correction(pval, alpha=0.05):
     """
     pval = np.asarray(pval)
     pval_corrected = pval * float(pval.size)
-    reject = pval < alpha
+    reject = pval_corrected < alpha
     return reject, pval_corrected


Test patch:
diff --git a/mne/stats/tests/test_multi_comp.py b/mne/stats/tests/test_multi_comp.py
index 4cba14113..76b2c99db 100644
--- a/mne/stats/tests/test_multi_comp.py
+++ b/mne/stats/tests/test_multi_comp.py
@@ -1,5 +1,6 @@
 import numpy as np
-from numpy.testing import assert_almost_equal, assert_allclose, assert_raises
+from numpy.testing import (
+    assert_almost_equal, assert_allclose, assert_raises, assert_array_equal)
 from nose.tools import assert_true
 from scipy import stats
 
@@ -25,6 +26,8 @@ def test_multi_pval_correction():
     assert_true(pval_bonferroni.ndim == 2)
     assert_true(reject_bonferroni.ndim == 2)
     assert_allclose(pval_bonferroni / 10000, pval)
+    reject_expected = pval_bonferroni < alpha
+    assert_array_equal(reject_bonferroni, reject_expected)
 
     fwer = np.mean(reject_bonferroni)
     assert_almost_equal(fwer, alpha, 1)