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

No on_missing in mne.channels.combine_channels #12591

Open
toddrjen opened this issue Apr 30, 2024 · 1 comment
Open

No on_missing in mne.channels.combine_channels #12591

toddrjen opened this issue Apr 30, 2024 · 1 comment
Labels

Comments

@toddrjen
Copy link

Description of the problem

When using mne.channels.combine_channels on mne.Epochs or mne.EpochsArray objects with missing channels where the user had previously used on_missing='ignore' or on_missing='warn' it will raise an exception. There does not appear to be a way within mne.channels.combine_channels to avoid the exception.

Steps to reproduce

import mne

sample_data_folder = mne.datasets.sample.data_path()
sample_data_raw_file = sample_data_folder / "MEG" / "sample" / "sample_audvis_raw.fif"
raw = mne.io.read_raw_fif(sample_data_raw_file, verbose=False).crop(tmax=60)

events = mne.find_events(raw, stim_channel="STI 014")

# event ID 1000 does not exist
event_id = [5, 1000]

epochs = mne.Epochs(raw, events=events, event_id=event_id, on_missing='warn')

mne.channels.combine_channels(inst=epochs, groups={'test': [0, 1]})

Link to data

No response

Expected results

Ideally the previous use of on_missing='ignore' or on_missing='warn' would be stored and used again for constructing the new mne.EpochsArray object, but at least having an on_missing argument in mne.channels.combine_channels would allow this problem to be avoided.

Actual results

The following exception is raised, with apparently no way to avoid it other than manually removing the unused events:

ValueError: No matching events found for 1000 (event id 1000)

Additional information

Platform Linux-5.15.0-105-generic-x86_64-with-glibc2.31
Python 3.10.11 (main, May 16 2023, 00:28:57) [GCC 11.2.0]
Executable /home/toddrjen/bin/anaconda3/envs/mne/bin/python3
CPU x86_64 (16 cores)
Memory 31.2 GB

Core
├☑ mne 1.7.0 (latest release)
├☑ numpy 1.26.4 (OpenBLAS 0.3.23.dev with 16 threads)
├☑ scipy 1.13.0
└☑ matplotlib 3.8.4 (backend=TkAgg)

Numerical (optional)
├☑ sklearn 1.4.2
├☑ numba 0.59.1
├☑ nibabel 5.2.1
├☑ pandas 2.2.1
└☐ unavailable nilearn, dipy, openmeeg, cupy, h5io, h5py

Visualization (optional)
├☑ ipympl 0.9.4
├☑ ipywidgets 8.1.2
└☐ unavailable pyvista, pyvistaqt, vtk, qtpy, pyqtgraph, mne-qt-browser, trame_client, trame_server, trame_vtk, trame_vuetify

Ecosystem (optional)
└☐ unavailable mne-bids, mne-nirs, mne-features, mne-connectivity, mne-icalabel, mne-bids-pipeline, neo, eeglabio, edfio, mffpy, pybv

@toddrjen toddrjen added the BUG label Apr 30, 2024
Copy link

welcome bot commented Apr 30, 2024

Hello! 👋 Thanks for opening your first issue here! ❤️ We will try to get back to you soon. 🚴

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant