Skip to content

Commit

Permalink
Create separate mne.stats.erp namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
cbrnr committed Jul 11, 2024
1 parent 638b7d7 commit 98b02fc
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 22 deletions.
2 changes: 1 addition & 1 deletion doc/api/statistics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ ERP-related statistics:
.. autosummary::
:toctree: ../generated/

compute_sme
erp.compute_sme

Compute ``adjacency`` matrices for cluster-level statistics:

Expand Down
2 changes: 1 addition & 1 deletion doc/changes/devel/12707.newfeature.rst
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Add :func:`~mne.stats.compute_sme` to compute the analytical standardized measurement error (SME) as a data quality measure for ERP studies, by `Clemens Brunner`_.
Add :func:`~mne.stats.erp.compute_sme` to compute the analytical standardized measurement error (SME) as a data quality measure for ERP studies, by `Clemens Brunner`_.
4 changes: 2 additions & 2 deletions mne/stats/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ __all__ = [
"bonferroni_correction",
"bootstrap_confidence_interval",
"combine_adjacency",
"compute_sme",
"erp",
"f_mway_rm",
"f_oneway",
"f_threshold_mway_rm",
Expand All @@ -21,6 +21,7 @@ __all__ = [
"ttest_1samp_no_p",
"ttest_ind_no_p",
]
from . import erp
from ._adjacency import combine_adjacency
from .cluster_level import (
_st_mask_from_s_inds,
Expand All @@ -30,7 +31,6 @@ from .cluster_level import (
spatio_temporal_cluster_test,
summarize_clusters_stc,
)
from .erp import compute_sme
from .multi_comp import bonferroni_correction, fdr_correction
from .parametric import (
_parametric_ci,
Expand Down
27 changes: 27 additions & 0 deletions mne/stats/tests/test_erp.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
from pathlib import Path

import pytest

from mne import Epochs, read_events
from mne.io import read_raw_fif
from mne.stats.erp import compute_sme

base_dir = Path(__file__).parents[2] / "io" / "tests" / "data"
raw = read_raw_fif(base_dir / "test_raw.fif")
events = read_events(base_dir / "test-eve.fif")


def test_compute_sme():
"""Test SME computation."""
epochs = Epochs(raw, events)
sme = compute_sme(epochs, start=0, stop=0.1)
assert sme.shape == (376,)

with pytest.raises(TypeError, match="int or float"):
compute_sme(epochs, "0", 0.1)
with pytest.raises(TypeError, match="int or float"):
compute_sme(epochs, 0, "0.1")
with pytest.raises(ValueError, match="out of bounds"):
compute_sme(epochs, -1.2, 0.3)
with pytest.raises(ValueError, match="out of bounds"):
compute_sme(epochs, -0.1, 0.8)
18 changes: 0 additions & 18 deletions mne/tests/test_epochs.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@
from mne.event import merge_events
from mne.io import RawArray, read_raw_fif
from mne.preprocessing import maxwell_filter
from mne.stats.erp import compute_sme
from mne.utils import (
_dt_to_stamp,
_record_warnings,
Expand Down Expand Up @@ -5264,20 +5263,3 @@ def test_empty_error(method, epochs_empty):
pytest.importorskip("pandas")
with pytest.raises(RuntimeError, match="is empty."):
getattr(epochs_empty.copy(), method[0])(**method[1])


def test_epochs_sme():
"""Test SME computation."""
raw, events, _ = _get_data()
epochs = Epochs(raw, events)
sme = compute_sme(epochs, start=0, stop=0.1)
assert sme.shape == (376,)

with pytest.raises(TypeError, match="int or float"):
compute_sme(epochs, "0", 0.1)
with pytest.raises(TypeError, match="int or float"):
compute_sme(epochs, 0, "0.1")
with pytest.raises(ValueError, match="out of bounds"):
compute_sme(epochs, -1.2, 0.3)
with pytest.raises(ValueError, match="out of bounds"):
compute_sme(epochs, -0.1, 0.8)

0 comments on commit 98b02fc

Please sign in to comment.