Description of the problem
Hi all,
I ma facing this error for which exporting epochs using mne.export_epochs() will fail if epochs were concatenated using mne.concatenate_epochs.
I understand from previous issues (e.g. #11131) that this is because mne.concatenate_epochs has no support for annotations, however either the concatenate function should generate empty annotations, or the export function should handle missing annotations.
I tried to solve it myself using the second approach as I needed it rapidly, by editing the file mne-python/mne/export/_eeglab.py. See https://github.com/Gabrock94/mne-python
The workaround I used is to edit Line 45 from:
if len(epochs.annotations) > 0:
to:
if (type(epochs.annotations)!=None.__class__):
if (len(epochs.annotations) > 0):
however probably fixing the concatenation function would be a better approach.
Steps to reproduce
import mne
mne.datasets.sample.data_path(verbose=True)
raw = mne.io.read_raw_fif('~/mne_data/MNE-sample-data/MEG/sample/sample_audvis_raw.fif', verbose=False).load_data()
events = mne.find_events(raw, shortest_event=1)
epochs = mne.Epochs(raw, events, tmin=-1, tmax = 1, detrend = 0, event_id={'LA':1, 'RA':2})
epochsCombined = mne.concatenate_epochs([epochs['LA'], epochs['RA']])
mne.export.export_epochs('~/mne_data/MNE-sample-data/MEG/sample/test.set', epochsCombined, fmt='auto')
Link to data
No response
Expected results
Epochs should be exported with no annotations.
Actual results
Traceback (most recent call last):
File "/usr/local/lib/python3.8/dist-packages/spyder_kernels/py3compat.py", line 356, in compat_exec
exec(code, globals, locals)
File "/home/giulio/Repositories/spinrec_giulio/Scripts/untitled4.py", line 16, in
mne.export.export_epochs('~/mne_data/MNE-sample-data/MEG/sample/test.set', epochsCombined, fmt='auto')
File "", line 12, in export_epochs
File "/usr/local/lib/python3.8/dist-packages/mne/export/_export.py", line 105, in export_epochs
_export_epochs(fname, epochs)
File "/usr/local/lib/python3.8/dist-packages/mne/export/_eeglab.py", line 45, in _export_epochs
if len(epochs.annotations) > 0:
TypeError: object of type 'NoneType' has no len()
Additional information
mne.sys_info()
Platform: Linux-5.15.0-58-generic-x86_64-with-glibc2.29
Python: 3.8.10 (default, Nov 14 2022, 12:59:47) [GCC 9.4.0]
Executable: /usr/bin/python3
CPU: x86_64: 20 cores
Memory: 31.1 GB
mne: 1.3.0
numpy: 1.22.3 {OpenBLAS 0.3.18 with 20 threads}
scipy: 1.8.0
matplotlib: 3.5.1 {backend=Qt5Agg}
sklearn: 1.0.2
numba: Not found
nibabel: Not found
nilearn: Not found
dipy: Not found
openmeeg: Not found
cupy: 10.3.0
pandas: 1.4.2
pyvista: Not found
pyvistaqt: Not found
ipyvtklink: Not found
vtk: Not found
qtpy: 2.0.1 {PyQt5=5.15.2}
ipympl: Not found
pyqtgraph: Not found
pooch: v1.6.0
mne_bids: Not found
mne_nirs: Not found
mne_features: Not found
mne_qt_browser: Not found
mne_connectivity: Not found
mne_icalabel: Not found
Description of the problem
Hi all,
I ma facing this error for which exporting epochs using mne.export_epochs() will fail if epochs were concatenated using mne.concatenate_epochs.
I understand from previous issues (e.g. #11131) that this is because mne.concatenate_epochs has no support for annotations, however either the concatenate function should generate empty annotations, or the export function should handle missing annotations.
I tried to solve it myself using the second approach as I needed it rapidly, by editing the file mne-python/mne/export/_eeglab.py. See https://github.com/Gabrock94/mne-python
The workaround I used is to edit Line 45 from:
if len(epochs.annotations) > 0:to:
however probably fixing the concatenation function would be a better approach.
Steps to reproduce
Link to data
No response
Expected results
Epochs should be exported with no annotations.
Actual results
Traceback (most recent call last):
File "/usr/local/lib/python3.8/dist-packages/spyder_kernels/py3compat.py", line 356, in compat_exec
exec(code, globals, locals)
File "/home/giulio/Repositories/spinrec_giulio/Scripts/untitled4.py", line 16, in
mne.export.export_epochs('~/mne_data/MNE-sample-data/MEG/sample/test.set', epochsCombined, fmt='auto')
File "", line 12, in export_epochs
File "/usr/local/lib/python3.8/dist-packages/mne/export/_export.py", line 105, in export_epochs
_export_epochs(fname, epochs)
File "/usr/local/lib/python3.8/dist-packages/mne/export/_eeglab.py", line 45, in _export_epochs
if len(epochs.annotations) > 0:
TypeError: object of type 'NoneType' has no len()
Additional information
mne.sys_info()
Platform: Linux-5.15.0-58-generic-x86_64-with-glibc2.29
Python: 3.8.10 (default, Nov 14 2022, 12:59:47) [GCC 9.4.0]
Executable: /usr/bin/python3
CPU: x86_64: 20 cores
Memory: 31.1 GB
mne: 1.3.0
numpy: 1.22.3 {OpenBLAS 0.3.18 with 20 threads}
scipy: 1.8.0
matplotlib: 3.5.1 {backend=Qt5Agg}
sklearn: 1.0.2
numba: Not found
nibabel: Not found
nilearn: Not found
dipy: Not found
openmeeg: Not found
cupy: 10.3.0
pandas: 1.4.2
pyvista: Not found
pyvistaqt: Not found
ipyvtklink: Not found
vtk: Not found
qtpy: 2.0.1 {PyQt5=5.15.2}
ipympl: Not found
pyqtgraph: Not found
pooch: v1.6.0
mne_bids: Not found
mne_nirs: Not found
mne_features: Not found
mne_qt_browser: Not found
mne_connectivity: Not found
mne_icalabel: Not found