Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport PR #13070 on branch maint/1.9 (BUGFIX: return events if provided when current = desired sfreq) #13081

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/changes/devel/13070.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Return events when requested even when current matches the desired sfreq in :meth:`mne.io.Raw.resample` by :newcontrib:`Roy Eric Wieske`.
1 change: 1 addition & 0 deletions doc/changes/names.inc
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@
.. _Roman Goj: https://romanmne.blogspot.co.uk
.. _Ross Maddox: https://www.urmc.rochester.edu/labs/maddox-lab.aspx
.. _Rotem Falach: https://github.com/Falach
.. _Roy Eric Wieske: https://github.com/Randomidous
.. _Sammi Chekroud: https://github.com/schekroud
.. _Samu Taulu: https://phys.washington.edu/people/samu-taulu
.. _Samuel Deslauriers-Gauthier: https://github.com/sdeslauriers
Expand Down
5 changes: 4 additions & 1 deletion mne/io/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1387,7 +1387,10 @@ def resample(
sfreq = float(sfreq)
o_sfreq = float(self.info["sfreq"])
if _check_resamp_noop(sfreq, o_sfreq):
return self
if events is not None:
return self, events.copy()
else:
return self

# When no event object is supplied, some basic detection of dropped
# events is performed to generate a warning. Finding events can fail
Expand Down
10 changes: 10 additions & 0 deletions mne/io/fiff/tests/test_raw_fiff.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
concatenate_events,
create_info,
equalize_channels,
events_from_annotations,
find_events,
make_fixed_length_epochs,
pick_channels,
Expand Down Expand Up @@ -1326,6 +1327,15 @@ def test_crop():
assert raw.n_times - 1 == raw3.n_times


@testing.requires_testing_data
def test_resample_with_events():
"""Test resampling raws with events."""
raw = read_raw_fif(fif_fname)
raw.resample(250) # pretend raw is recorded at 250 Hz
events, _ = events_from_annotations(raw)
raw, events = raw.resample(250, events=events)


@testing.requires_testing_data
def test_resample_equiv():
"""Test resample (with I/O and multiple files)."""
Expand Down
Loading