Skip to content

Commit 7daecee

Browse files
Randomidouslarsonerpre-commit-ci[bot]drammock
authored
BUGFIX: return events if provided when current = desired sfreq (#13070)
Co-authored-by: Eric Larson <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Daniel McCloy <[email protected]>
1 parent aca4965 commit 7daecee

File tree

4 files changed

+16
-1
lines changed

4 files changed

+16
-1
lines changed

doc/changes/devel/13070.bugfix.rst

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Return events when requested even when current matches the desired sfreq in :meth:`mne.io.Raw.resample` by :newcontrib:`Roy Eric Wieske`.

doc/changes/names.inc

+1
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@
258258
.. _Roman Goj: https://romanmne.blogspot.co.uk
259259
.. _Ross Maddox: https://www.urmc.rochester.edu/labs/maddox-lab.aspx
260260
.. _Rotem Falach: https://github.com/Falach
261+
.. _Roy Eric Wieske: https://github.com/Randomidous
261262
.. _Sammi Chekroud: https://github.com/schekroud
262263
.. _Samu Taulu: https://phys.washington.edu/people/samu-taulu
263264
.. _Samuel Deslauriers-Gauthier: https://github.com/sdeslauriers

mne/io/base.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -1386,7 +1386,10 @@ def resample(
13861386
sfreq = float(sfreq)
13871387
o_sfreq = float(self.info["sfreq"])
13881388
if _check_resamp_noop(sfreq, o_sfreq):
1389-
return self
1389+
if events is not None:
1390+
return self, events.copy()
1391+
else:
1392+
return self
13901393

13911394
# When no event object is supplied, some basic detection of dropped
13921395
# events is performed to generate a warning. Finding events can fail

mne/io/fiff/tests/test_raw_fiff.py

+10
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
concatenate_events,
2424
create_info,
2525
equalize_channels,
26+
events_from_annotations,
2627
find_events,
2728
make_fixed_length_epochs,
2829
pick_channels,
@@ -1318,6 +1319,15 @@ def test_crop():
13181319
assert raw.n_times - 1 == raw3.n_times
13191320

13201321

1322+
@testing.requires_testing_data
1323+
def test_resample_with_events():
1324+
"""Test resampling raws with events."""
1325+
raw = read_raw_fif(fif_fname)
1326+
raw.resample(250) # pretend raw is recorded at 250 Hz
1327+
events, _ = events_from_annotations(raw)
1328+
raw, events = raw.resample(250, events=events)
1329+
1330+
13211331
@testing.requires_testing_data
13221332
def test_resample_equiv():
13231333
"""Test resample (with I/O and multiple files)."""

0 commit comments

Comments
 (0)