Skip to content

Commit ab1cd64

Browse files
committed
Fixing issue-13767
1 parent cdbdf92 commit ab1cd64

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

mne/stats/permutations.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import numpy as np
1010

1111
from ..parallel import parallel_func
12-
from ..utils import check_random_state, logger, verbose
12+
from ..utils import _check_if_nan, check_random_state, logger, verbose
1313

1414

1515
def _max_stat(X, X2, perms, dof_scaling):
@@ -77,6 +77,7 @@ def permutation_t_test(
7777
"""
7878
from .cluster_level import _get_1samp_orders
7979

80+
_check_if_nan(X)
8081
n_samples, n_tests = X.shape
8182
X2 = np.mean(X**2, axis=0) # precompute moments
8283
mu0 = np.mean(X, axis=0)

mne/utils/check.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -699,10 +699,13 @@ def _path_like(item):
699699
return False
700700

701701

702-
def _check_if_nan(data, msg=" to be plotted"):
702+
def _check_if_nan(data, on_nan="error", msg=" to be plotted"):
703703
"""Raise if any of the values are NaN."""
704704
if not np.isfinite(data).all():
705-
raise ValueError(f"Some of the values {msg} are NaN.")
705+
if on_nan == "error":
706+
raise ValueError(f"Some of the values {msg} are NaN.")
707+
elif on_nan == "warn":
708+
warn(f"Some of the values {msg} are NaN")
706709

707710

708711
@verbose

0 commit comments

Comments
 (0)