Skip to content

Commit

Permalink
Revert "Move erp functions and tests"
Browse files Browse the repository at this point in the history
This reverts commit e4e332c.
  • Loading branch information
withmywoessner committed Dec 16, 2024
1 parent 633d644 commit ecd689b
Showing 1 changed file with 1 addition and 65 deletions.
66 changes: 1 addition & 65 deletions mne/stats/tests/test_erp.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,7 @@

from mne import Epochs, read_events
from mne.io import read_raw_fif
from mne.stats.erp import (
compute_sme,
get_peak,
get_area,
get_frac_peak_latency,
get_frac_area_latency,
)
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")
Expand All @@ -25,7 +19,6 @@ def test_compute_sme():
"""Test SME computation."""
epochs = Epochs(raw, events)
sme = compute_sme(epochs, start=0, stop=0.1)
print(sme)
assert sme.shape == (376,)

with pytest.raises(TypeError, match="int or float"):
Expand All @@ -36,60 +29,3 @@ def test_compute_sme():
compute_sme(epochs, -1.2, 0.3)
with pytest.raises(ValueError, match="out of bounds"):
compute_sme(epochs, -0.1, 0.8)


def test_get_peak():
"""Test peak computation."""
epochs = Epochs(raw, events)
evoked = epochs.average()
peak_df = get_peak(evoked, tmin=0, tmax=0.1)
evoked_pos = evoked.copy()
evoked_pos.data = abs(evoked_pos.data)
get_peak(evoked_pos, tmin=0, tmax=0.1, mode="neg", strict=False)

evoked_neg = evoked.copy()
evoked_neg.data = -abs(evoked_neg.data)
get_peak(evoked_neg, tmin=0, tmax=0.1, mode="pos", strict=False)

assert peak_df.shape == (366, 3)

with pytest.raises(ValueError, match="No negative values encountered"):
evoked_pos.data = abs(evoked_pos.data)
get_peak(evoked_pos, tmin=0, tmax=0.1, mode="neg", strict=True)
with pytest.raises(ValueError, match="No positive values encountered"):
get_peak(evoked_neg, tmin=0, tmax=0.1, mode="pos", strict=True)


def test_get_area():
"""Test area computation."""
epochs = Epochs(raw, events)
evoked = epochs.average()
area_df = get_area(evoked, tmin=0, tmax=0.1)
assert area_df.shape == (366, 2)


def test_get_frac_peak_latency():
"""Test fractional peak latency computation."""
epochs = Epochs(raw, events)
evoked = epochs.average()
frac_peak_df = get_frac_peak_latency(evoked, frac=0.5, tmin=0, tmax=0.1)
assert frac_peak_df.shape == (366, 4)

with pytest.raises(ValueError, match="No negative values encountered"):
evoked_pos = evoked.copy()
evoked_pos.data = abs(evoked_pos.data)
get_frac_peak_latency(evoked, frac=0.5, tmin=0,
tmax=0.1, mode="neg", strict=True)
with pytest.raises(ValueError, match="No positive values encountered"):
evoked_neg = evoked.copy()
evoked_neg.data = -abs(evoked_neg.data)
get_frac_peak_latency(evoked, frac=0.5, tmin=0,
tmax=0.1, mode="pos", strict=True)


def test_get_frac_area_latency():
"""Test fractional area latency computation."""
epochs = Epochs(raw, events)
evoked = epochs.average()
frac_area_df = get_frac_area_latency(evoked, frac=0.5, tmin=0, tmax=0.1)
assert frac_area_df.shape == (366, 3)

0 comments on commit ecd689b

Please sign in to comment.