File: test_erp.py

package info (click to toggle)
python-mne 1.9.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 131,492 kB
  • sloc: python: 213,302; javascript: 12,910; sh: 447; makefile: 144
file content (31 lines) | stat: -rw-r--r-- 969 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# Authors: The MNE-Python contributors.
# License: BSD-3-Clause
# Copyright the MNE-Python contributors.

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)