Skip to content

Commit cb3ccba

Browse files
authored
Merge branch 'main' into custom-annotation-colors
2 parents b9b4eda + bd1dc9c commit cb3ccba

16 files changed

Lines changed: 147 additions & 21 deletions

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
repos:
22
# Ruff mne
33
- repo: https://github.com/astral-sh/ruff-pre-commit
4-
rev: v0.15.9
4+
rev: v0.15.10
55
hooks:
66
- id: ruff-check
77
name: ruff lint mne
@@ -74,7 +74,7 @@ repos:
7474

7575
# zizmor
7676
- repo: https://github.com/woodruffw/zizmor-pre-commit
77-
rev: v1.23.1
77+
rev: v1.24.1
7878
hooks:
7979
- id: zizmor
8080
args: [--fix]

doc/changes/dev/13825.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Improved colocated OPM topomap handling by recognizing additional OPM coil types (FieldLine and Kernel), by `Pragnya Khandelwal`_.

doc/changes/dev/13842.other.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Added regression coverage for colocated triaxial OPM topomap handling in ``plot_joint()`` and ``ICA.plot_components()``, by `Pragnya Khandelwal`_.

doc/changes/dev/13843.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix bug where logging messages were sometimes errantly printed, by `Eric Larson`_.

doc/conf.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,15 +180,13 @@
180180
"picard": ("https://mind-inria.github.io/picard/", None),
181181
"eeglabio": ("https://eeglabio.readthedocs.io/en/latest", None),
182182
"pybv": ("https://pybv.readthedocs.io/en/latest", None),
183-
# should go back below after https://github.com/dipy/dipy/issues/3870 is fixed
184-
"dipy": ("https://docs.dipy.org/1.12.0", None),
185183
}
186184
intersphinx_mapping.update(
187185
get_intersphinx_mapping(
188186
packages=set(
189187
"""
190188
imageio matplotlib numpy pandas python scipy statsmodels sklearn numba joblib nibabel
191-
seaborn patsy pyvista nilearn pyqtgraph
189+
seaborn patsy pyvista dipy nilearn pyqtgraph
192190
""".strip().split()
193191
),
194192
)

doc/sphinxext/credit_tools.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,9 @@ def generate_credit_rst(app=None, *, verbose=False):
315315
logo/LICENSE doc/credit.rst
316316
""".strip().split():
317317
globs[key] = "null"
318+
# A few remaps
319+
globs["mne/io/edf/_open.py"] = "mne.io"
320+
globs["mne/_edf/open.py"] = "mne.io"
318321
# Now onto the actual module organization
319322
root_path = pathlib.Path(mne.__file__).parent
320323
mod_file_map = dict()
@@ -345,8 +348,6 @@ def generate_credit_rst(app=None, *, verbose=False):
345348
globs["bin/*"] = "mne.commands"
346349
globs["mne/morph_map.py"] = "mne.surface"
347350
globs["mne/baseline.py"] = "mne.epochs"
348-
globs["mne/io/edf/_open.py"] = "mne.io"
349-
globs["mne/_edf/open.py"] = "mne.io"
350351
for key in """
351352
parallel.py rank.py misc.py data/*.* defaults.py fixes.py icons/*.* icons.*
352353
""".strip().split():

examples/preprocessing/plot_epoch_quality.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,14 @@
111111
# :meth:`mne.Epochs.drop` method. Here, we remove the worst scoring epochs (≥ 0.6)
112112
# which contained strong artifact activity. The remaining good epochs can then be used
113113
# for further analysis.
114+
#
115+
# .. admonition:: Repairing and retaining epochs with artifacts
116+
#
117+
# In this case, the large frontal deflections are likely blink artifacts, so
118+
# dropping is not the only option. For artifacts like these, it can be
119+
# preferable to repair the data and keep more epochs, for example with
120+
# :ref:`ICA <tut-artifact-ica>` or
121+
# :ref:`regression-based artifact correction <tut-artifact-regression>`.
114122
epochs.drop(np.where(scores >= 0.6)[0])
115123
print(f"Epochs remaining after dropping scores ≥ 0.6: {len(epochs)}")
116124

mne/_fiff/constants.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1183,6 +1183,7 @@
11831183
FIFF.FIFFV_COIL_QUSPIN_ZFOPM_MAG2,
11841184
FIFF.FIFFV_COIL_FIELDLINE_OPM_MAG_GEN1,
11851185
FIFF.FIFFV_COIL_KERNEL_OPM_MAG_GEN1,
1186+
# If more OPM coil types are added here, update mne/viz/topomap.py too.
11861187
FIFF.FIFFV_COIL_KRISS_GRAD,
11871188
FIFF.FIFFV_COIL_COMPUMEDICS_ADULT_GRAD,
11881189
FIFF.FIFFV_COIL_COMPUMEDICS_PEDIATRIC_GRAD,

mne/conftest.py

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,13 @@
2727

2828
# ruff: noqa: E402
2929
import mne
30-
from mne import Epochs, pick_types, read_events
30+
from mne import Epochs, create_info, make_fixed_length_epochs, pick_types, read_events
31+
from mne._fiff.constants import FIFF
3132
from mne.channels import read_layout
3233
from mne.coreg import create_default_subject
3334
from mne.datasets import testing
3435
from mne.fixes import _compare_version, has_numba
35-
from mne.io import read_raw_ctf, read_raw_fif, read_raw_nirx, read_raw_snirf
36+
from mne.io import RawArray, read_raw_ctf, read_raw_fif, read_raw_nirx, read_raw_snirf
3637
from mne.stats import cluster_level
3738
from mne.utils import (
3839
Bunch,
@@ -546,6 +547,47 @@ def _bias_params(evoked, noise_cov, fwd):
546547
return evoked, fwd, noise_cov, data_cov, want
547548

548549

550+
@pytest.fixture
551+
def triaxial_raw():
552+
"""Create a small triaxial OPM raw for regression tests."""
553+
ch_names = ["OPM001", "OPM002", "OPM003", "OPM004", "OPM005", "OPM006"]
554+
info = create_info(ch_names, 1000.0, ch_types="mag")
555+
positions = np.array(
556+
[
557+
[0.03, 0.00, 0.05],
558+
[0.03, 0.00, 0.05],
559+
[0.03, 0.00, 0.05],
560+
[-0.03, 0.00, 0.05],
561+
[-0.03, 0.00, 0.05],
562+
[-0.03, 0.00, 0.05],
563+
]
564+
)
565+
orientations = np.array(
566+
[
567+
[0.5145, 0.0000, 0.8575],
568+
[0.0000, 1.0000, 0.0000],
569+
[0.0000, 0.0000, 1.0000],
570+
[-0.5145, 0.0000, 0.8575],
571+
[0.0000, 1.0000, 0.0000],
572+
[0.0000, 0.0000, 1.0000],
573+
]
574+
)
575+
with info._unlock():
576+
for idx, ch in enumerate(info["chs"]):
577+
ch["coil_type"] = FIFF.FIFFV_COIL_FIELDLINE_OPM_MAG_GEN1
578+
ch["loc"][:3] = positions[idx]
579+
ch["loc"][9:12] = orientations[idx]
580+
rng = np.random.default_rng(0)
581+
data = rng.standard_normal((len(ch_names), 2000))
582+
return RawArray(data, info, verbose="error")
583+
584+
585+
@pytest.fixture
586+
def triaxial_evoked(triaxial_raw):
587+
"""Create a small triaxial OPM evoked for regression tests."""
588+
return make_fixed_length_epochs(triaxial_raw).average()
589+
590+
549591
@pytest.fixture
550592
def garbage_collect():
551593
"""Garbage collect on exit."""

mne/utils/_logging.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,9 @@ def __init__(self, verbose=None, *, add_frames=None):
166166
self._old_frames = _filter.add_frames
167167

168168
def __enter__(self): # noqa: D105
169+
level = logger.level if self._level is None else self._level
169170
self._old_level = set_log_level(
170-
self._level, return_old_level=True, add_frames=self._add_frames
171+
level, return_old_level=True, add_frames=self._add_frames
171172
)
172173

173174
def __exit__(self, *args): # noqa: D105
@@ -319,10 +320,7 @@ def __init__(self, verbose=None):
319320
self.verbose = verbose
320321

321322
def __enter__(self): # noqa: D105
322-
if self.verbose is not None:
323-
self._ctx = use_log_level(self.verbose)
324-
else:
325-
self._ctx = contextlib.nullcontext()
323+
self._ctx = use_log_level(self.verbose)
326324
self._data = ClosingStringIO()
327325
self._lh = logging.StreamHandler(self._data)
328326
self._lh.setFormatter(logging.Formatter("%(message)s"))

0 commit comments

Comments
 (0)