Skip to content

Commit

Permalink
Merge branch 'main' into cola5
Browse files Browse the repository at this point in the history
  • Loading branch information
larsoner authored Jan 31, 2025
2 parents 6d65b33 + 715540a commit 8cfd708
Show file tree
Hide file tree
Showing 15 changed files with 37 additions and 21 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
repos:
# Ruff mne
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.9.2
rev: v0.9.3
hooks:
- id: ruff
name: ruff lint mne
Expand All @@ -23,7 +23,7 @@ repos:

# Codespell
- repo: https://github.com/codespell-project/codespell
rev: v2.3.0
rev: v2.4.0
hooks:
- id: codespell
additional_dependencies:
Expand Down
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/devel/13082.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix bug with automated Mesa 3D detection for proper 3D option setting on systems with software rendering, by `Eric Larson`_.
1 change: 1 addition & 0 deletions doc/changes/names.inc
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,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
1 change: 1 addition & 0 deletions examples/preprocessing/movement_detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
##############################################################################
# After checking the annotated movement artifacts, calculate the new transform
# and plot it:

new_dev_head_t = compute_average_dev_head_t(raw, head_pos)
raw.info["dev_head_t"] = new_dev_head_t
fig = mne.viz.plot_alignment(
Expand Down
2 changes: 1 addition & 1 deletion mne/_fiff/proj.py
Original file line number Diff line number Diff line change
Expand Up @@ -1100,7 +1100,7 @@ def _has_eeg_average_ref_proj(


def _needs_eeg_average_ref_proj(info):
"""Determine if the EEG needs an averge EEG reference.
"""Determine if the EEG needs an average EEG reference.
This returns True if no custom reference has been applied and no average
reference projection is present in the list of projections.
Expand Down
1 change: 1 addition & 0 deletions mne/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ def pytest_configure(config: pytest.Config):
# pandas
ignore:\n*Pyarrow will become a required dependency of pandas.*:DeprecationWarning
ignore:np\.find_common_type is deprecated.*:DeprecationWarning
ignore:Python binding for RankQuantileOptions.*:
# pyvista <-> NumPy 2.0
ignore:__array_wrap__ must accept context and return_scalar arguments.*:DeprecationWarning
# nibabel <-> NumPy 2.0
Expand Down
5 changes: 4 additions & 1 deletion mne/io/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1386,7 +1386,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 @@ -1318,6 +1319,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
2 changes: 1 addition & 1 deletion mne/viz/_figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ def _redraw(self, update_data=True, annotations=False):
if annotations and not self.mne.is_epochs:
self._draw_annotations()

def _close(self, event):
def _close(self, event=None):
"""Handle close events (via keypress or window [x])."""
from matplotlib.pyplot import close

Expand Down
4 changes: 2 additions & 2 deletions mne/viz/_mpl_figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ def _inch_to_rel(self, dim_inches, horiz=True):
class MNEAnnotationFigure(MNEFigure):
"""Interactive dialog figure for annotations."""

def _close(self, event):
def _close(self, event=None):
"""Handle close events (via keypress or window [x])."""
parent = self.mne.parent_fig
# disable span selector
Expand Down Expand Up @@ -275,7 +275,7 @@ def _set_active_button(self, idx, *, draw=True):
class MNESelectionFigure(MNEFigure):
"""Interactive dialog figure for channel selections."""

def _close(self, event):
def _close(self, event=None):
"""Handle close events."""
self.mne.parent_fig.mne.child_figs.remove(self)
self.mne.fig_selection = None
Expand Down
2 changes: 1 addition & 1 deletion mne/viz/backends/_pyvista.py
Original file line number Diff line number Diff line change
Expand Up @@ -1344,7 +1344,7 @@ def _is_osmesa(plotter):
"surface rendering, consider upgrading to 18.3.6 or "
"later."
)
is_osmesa = "via llvmpipe" in gpu_info
is_osmesa = "llvmpipe" in gpu_info
return is_osmesa


Expand Down
2 changes: 1 addition & 1 deletion mne/viz/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1185,7 +1185,7 @@ def _onpick_sensor(event, fig, ax, pos, ch_names, show_names):
fig.canvas.draw()


def _close_event(event, fig):
def _close_event(event=None, fig=None):
"""Listen for sensor plotter close event."""
if getattr(fig, "lasso", None) is not None:
fig.lasso.disconnect()
Expand Down
11 changes: 5 additions & 6 deletions tutorials/epochs/60_make_fixed_length_epochs.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@
=================================================
This tutorial shows how to segment continuous data into a set of epochs spaced
equidistantly in time. The epochs will not be created based on experimental
events; instead, the continuous data will be "chunked" into consecutive epochs
(which may be temporally overlapping, adjacent, or separated).
We will also briefly demonstrate how to use these epochs in connectivity
analysis.
equidistantly in time. The epochs will not be created based on experimental events;
instead, the continuous data will be "chunked" into consecutive epochs (which may be
temporally overlapping, adjacent, or separated). We will also briefly demonstrate how
to use these epochs in connectivity analysis.
First, we import necessary modules and read in a sample raw data set.
First, we import the necessary modules and read in a sample raw data set.
This data set contains brain activity that is event-related, i.e.,
synchronized to the onset of auditory stimuli. However, rather than creating
epochs by segmenting the data around the onset of each stimulus, we will
Expand Down
11 changes: 5 additions & 6 deletions tutorials/evoked/10_evoked_overview.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@
The Evoked data structure: evoked/averaged data
===============================================
This tutorial covers the basics of creating and working with :term:`evoked`
data. It introduces the :class:`~mne.Evoked` data structure in detail,
including how to load, query, subset, export, and plot data from an
:class:`~mne.Evoked` object. For details on creating an :class:`~mne.Evoked`
object from (possibly simulated) data in a :class:`NumPy array
<numpy.ndarray>`, see :ref:`tut-creating-data-structures`.
This tutorial covers the basics of creating and working with :term:`evoked` data. It
introduces the :class:`~mne.Evoked` data structure in detail, including how to load,
query, subset, export, and plot data from an :class:`~mne.Evoked` object. For details
on creating an :class:`~mne.Evoked` object from (possibly simulated) data in a
:class:`NumPy array <numpy.ndarray>`, see :ref:`tut-creating-data-structures`.
As usual, we start by importing the modules we need:
"""
Expand Down

0 comments on commit 8cfd708

Please sign in to comment.