Skip to content
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
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ repos:
rev: v6.0.0
hooks:
- id: file-contents-sorter
files: ^doc/changes/names.inc|^.mailmap
files: ^doc/changes/names.inc|^.mailmap|^doc/sphinxext/related_software.txt
args: ["--ignore-case"]

- repo: https://github.com/pappasam/toml-sort
Expand Down
6 changes: 3 additions & 3 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ stages:
- bash: |
set -eo pipefail
python -m pip install --progress-bar off --upgrade pip build
python -m pip install --progress-bar off -ve .[hdf5,test]
python -m pip install --progress-bar off -ve .[hdf5] --group=test
python -m pip uninstall -yq pytest-qt # don't want to set up display, etc. for this
pre-commit install --install-hooks
displayName: Install dependencies
Expand Down Expand Up @@ -116,7 +116,7 @@ stages:
python -m pip install --progress-bar off --upgrade pip
python -m pip install --progress-bar off "mne-qt-browser[opengl] @ git+https://github.com/mne-tools/mne-qt-browser.git" pyvista scikit-learn python-picard qtpy nibabel sphinx-gallery "PySide6!=6.8.0,!=6.8.0.1,!=6.8.1.1,!=6.9.1" pandas neo pymatreader antio defusedxml
python -m pip uninstall -yq mne
python -m pip install --progress-bar off --upgrade -e .[test]
python -m pip install --progress-bar off --upgrade -e . --group=test
displayName: 'Install dependencies with pip'
- bash: |
set -e
Expand Down Expand Up @@ -173,7 +173,7 @@ stages:
python -m pip install --progress-bar off --upgrade pip
python -m pip install --progress-bar off --upgrade --pre --only-binary=\"numpy,scipy,matplotlib,vtk\" numpy scipy matplotlib vtk
python -c "import vtk"
python -m pip install --progress-bar off --upgrade -ve .[full,test_extra]
python -m pip install --progress-bar off --upgrade -ve .[full] --group=test_extra
displayName: 'Install dependencies with pip'
- bash: |
set -e
Expand Down
3 changes: 3 additions & 0 deletions doc/changes/dev/13452.other.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Removed development dependencies from user-visible "extras"; they're now dependency
groups only visible to developers (and can be installed for example via
``pip install --group dev`` with pip version 25.1 or later), by `Richard Höchenberger`_
1 change: 1 addition & 0 deletions doc/changes/dev/13456.newfeature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The ``rename_channels`` method now has an ``on_missing`` parameter to control behavior on channel mismatch, by `Stefan Appelhoff`_.
4 changes: 4 additions & 0 deletions doc/changes/names.inc
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
.. _Asish Panda: https://github.com/kaichogami
.. _Austin Hurst: https://github.com/a-hurst
.. _Ben Beasley: https://github.com/musicinmybrain
.. _Bradley Voytek: https://github.com/voytek
.. _Britta Westner: https://britta-wstnr.github.io
.. _Bruno Aristimunha: https://bruaristimunha.github.io
.. _Bruno Nicenboim: https://bnicenboim.github.io
Expand Down Expand Up @@ -132,6 +133,7 @@
.. _Jan Sedivy: https://github.com/honzaseda
.. _Jan Sosulski: https://jan-sosulski.de
.. _Jan Zerfowski: https://github.com/jzerfowski
.. _Jan-Mathijs Schoeffelen: https://github.com/schoffelen
.. _Jasper van den Bosch: https://github.com/ilogue
.. _Jean-Baptiste Schiratti: https://github.com/jbschiratti
.. _Jean-Rémi King: https://github.com/kingjr
Expand Down Expand Up @@ -202,6 +204,7 @@
.. _Matteo Anelli: https://github.com/matteoanelli
.. _Matthias Dold: https://matthiasdold.de
.. _Matthias Eberlein: https://github.com/MatthiasEb
.. _Matti Hämäläinen: https://research.aalto.fi/en/persons/matti-h%C3%A4m%C3%A4l%C3%A4inen/
.. _Matti Toivonen: https://github.com/mattitoi
.. _Mauricio Cespedes Tenorio: https://github.com/mcespedes99
.. _Michal Žák: https://github.com/michalrzak
Expand Down Expand Up @@ -229,6 +232,7 @@
.. _Noah Markowitz: https://github.com/nmarkowitz
.. _Okba Bekhelifi: https://github.com/okbalefthanded
.. _Olaf Hauk: https://neuroscience.cam.ac.uk/member/olafhauk
.. _Ole Jensen: https://www.psy.ox.ac.uk/people/ole-jensen
.. _Oleh Kozynets: https://github.com/OlehKSS
.. _Pablo Mainar: https://github.com/pablomainar
.. _Pablo-Arias: https://github.com/Pablo-Arias
Expand Down
4 changes: 2 additions & 2 deletions doc/development/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -304,11 +304,11 @@ be reflected the next time you open a Python interpreter and ``import mne``
Finally, we'll add a few dependencies that are not needed for running
MNE-Python, but are needed for locally running our test suite::

$ pip install -e ".[test]"
$ pip install --group=test

And for building our documentation::

$ pip install -e ".[doc]"
$ pip install --group=doc
$ conda install graphviz

.. note::
Expand Down
7 changes: 6 additions & 1 deletion doc/overview/people.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,12 @@ Steering Council
Advisory Board
--------------

The advisory board is currently unfilled.
* `Alex Gramfort`_
* `Bradley Voytek`_
* `Jan-Mathijs Schoeffelen`_
* `Liberty Hamilton`_
* `Matti Hämäläinen`_
* `Ole Jensen`_


.. _governance-cpgrl:
Expand Down
37 changes: 37 additions & 0 deletions doc/sphinxext/related_software.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# cross-domain-saliency-maps requirements are onerous (torch and tensorflow)
# so we don't add it here, and install it separately in circleci_dependencies.sh
alphaCSC
autoreject
bycycle
conpy
curryreader
eeg_positions
emd
fooof
meegkit
meggie
mne-ari
mne-bids-pipeline
mne-faster
mne-features
mne-icalabel
mne-lsl
mne-microstates
mne-nirs
mne-rsa
mnelab
neurodsp
neurokit2
niseq
nitime
pactools
plotly
pycrostates
pyprep
pyriemann
python-picard
sesameeg
sleepecg
tensorpac
wfdb
yasa
9 changes: 7 additions & 2 deletions mne/_fiff/meas_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -626,12 +626,17 @@ def set_channel_types(self, mapping, *, on_unit_change="warn", verbose=None):
return self

@verbose
def rename_channels(self, mapping, allow_duplicates=False, *, verbose=None):
def rename_channels(
self, mapping, allow_duplicates=False, *, on_missing="raise", verbose=None
):
"""Rename channels.

Parameters
----------
%(mapping_rename_channels_duplicates)s
%(on_missing_ch_names)s

.. versionadded:: 1.11.0
%(verbose)s

Returns
Expand All @@ -652,7 +657,7 @@ def rename_channels(self, mapping, allow_duplicates=False, *, verbose=None):
info = self if isinstance(self, Info) else self.info

ch_names_orig = list(info["ch_names"])
rename_channels(info, mapping, allow_duplicates)
rename_channels(info, mapping, allow_duplicates, on_missing=on_missing)

# Update self._orig_units for Raw
if isinstance(self, BaseRaw):
Expand Down
27 changes: 24 additions & 3 deletions mne/channels/channels.py
Original file line number Diff line number Diff line change
Expand Up @@ -1126,13 +1126,18 @@ def _check_pos_sphere(pos):


@verbose
def rename_channels(info, mapping, allow_duplicates=False, *, verbose=None):
def rename_channels(
info, mapping, allow_duplicates=False, *, on_missing="raise", verbose=None
):
"""Rename channels.

Parameters
----------
%(info_not_none)s Note: modified in place.
%(mapping_rename_channels_duplicates)s
%(on_missing_ch_names)s

.. versionadded:: 1.11.0
%(verbose)s

See Also
Expand All @@ -1148,14 +1153,30 @@ def rename_channels(info, mapping, allow_duplicates=False, *, verbose=None):

# first check and assemble clean mappings of index and name
if isinstance(mapping, dict):
if on_missing in ["warn", "ignore"]:
new_mapping = {
ch_old: ch_new
for ch_old, ch_new in mapping.items()
if ch_old in ch_names
}
else:
new_mapping = mapping

if new_mapping != mapping and on_missing == "warn":
warn(
"Channel rename map contains keys that are not present in the object "
"to be renamed. These will be ignored."
)

_check_dict_keys(
mapping,
new_mapping,
ch_names,
key_description="channel name(s)",
valid_key_source="info",
)
new_names = [
(ch_names.index(ch_name), new_name) for ch_name, new_name in mapping.items()
(ch_names.index(ch_name), new_name)
for ch_name, new_name in new_mapping.items()
]
elif callable(mapping):
new_names = [(ci, mapping(ch_name)) for ci, ch_name in enumerate(ch_names)]
Expand Down
12 changes: 9 additions & 3 deletions mne/channels/montage.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,13 +379,19 @@ def plot(
axes=axes,
)

@fill_doc
def rename_channels(self, mapping, allow_duplicates=False):
@verbose
def rename_channels(
self, mapping, allow_duplicates=False, *, on_missing="raise", verbose=None
):
"""Rename the channels.

Parameters
----------
%(mapping_rename_channels_duplicates)s
%(on_missing_ch_names)s

.. versionadded:: 1.11.0
%(verbose)s

Returns
-------
Expand All @@ -395,7 +401,7 @@ def rename_channels(self, mapping, allow_duplicates=False):
from .channels import rename_channels

temp_info = create_info(list(self._get_ch_pos()), 1000.0, "eeg")
rename_channels(temp_info, mapping, allow_duplicates)
rename_channels(temp_info, mapping, allow_duplicates, on_missing=on_missing)
self.ch_names = temp_info["ch_names"]
return self

Expand Down
5 changes: 5 additions & 0 deletions mne/channels/tests/test_channels.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,12 @@ def test_rename_channels():
# Error Tests
# Test channel name exists in ch_names
mapping = {"EEG 160": "EEG060"}
ch_names_orig = info.ch_names[::]
pytest.raises(ValueError, rename_channels, info, mapping)
rename_channels(info, mapping, on_missing="ignore")
assert info.ch_names == ch_names_orig
with pytest.warns(RuntimeWarning, match="Channel rename map contains keys that *"):
rename_channels(info, mapping, on_missing="warn")
# Test improper mapping configuration
mapping = {"MEG 2641": 1.0}
pytest.raises(TypeError, rename_channels, info, mapping)
Expand Down
6 changes: 5 additions & 1 deletion mne/utils/tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,11 @@ def test_sys_info_complete():
sys_info(fid=out, check_version=False, dependencies="developer")
out = out.getvalue()
pyproject = tomllib.loads(pyproject.read_text("utf-8"))
deps = pyproject["project"]["optional-dependencies"]["test_extra"]
deps = [
dep
for dep in pyproject["dependency-groups"]["test_extra"]
if not isinstance(dep, dict)
]
for dep in deps:
dep = dep.split("[")[0].split(">")[0].strip()
assert f" {dep}" in out, f"Missing in dev config: {dep}"
Expand Down
Loading
Loading