MNE version : 1.6.1
Ubuntu : 22.04
I am trying to create ecg based epochs using following lines of code :
self.epochs = mne.preprocessing.create_ecg_epochs(self.raw, ch_name = 'EKG', verbose = False)
There is a channel in raw named “EKG” of type ECG. The above code occasionally throws error for some raw objects (from a large no. of files).
Below is the error :
Traceback (most recent call last):
File "/home/bala/Desktop/sri_krishna/.HMS/HMS-BrainActivity/Preprocessing/eeg_preprocessing.py", line 165, in <module>
eeg_processing.create_and_save(eeg_df)
File "/home/bala/Desktop/sri_krishna/.HMS/HMS-BrainActivity/Preprocessing/eeg_preprocessing.py", line 130, in create_and_save
self.create_epochs()
File "/home/bala/Desktop/sri_krishna/.HMS/HMS-BrainActivity/Preprocessing/eeg_preprocessing.py", line 98, in create_epochs
self.epochs = mne.preprocessing.create_ecg_epochs(self.raw, ch_name = 'EKG', verbose = False)
File "<decorator-gen-240>", line 10, in create_ecg_epochs
File "/home/bala/Desktop/BTP/venv/lib/python3.10/site-packages/mne/preprocessing/ecg.py", line 441, in create_ecg_epochs
ecg_epochs = Epochs(
File "<decorator-gen-228>", line 12, in __init__
File "/home/bala/Desktop/BTP/venv/lib/python3.10/site-packages/mne/epochs.py", line 3253, in __init__
super(Epochs, self).__init__(
File "<decorator-gen-213>", line 12, in __init__
File "/home/bala/Desktop/BTP/venv/lib/python3.10/site-packages/mne/epochs.py", line 470, in __init__
events = _ensure_events(events)
File "/home/bala/Desktop/BTP/venv/lib/python3.10/site-packages/mne/utils/check.py", line 1199, in _ensure_events
raise TypeError(err_msg)
TypeError: events should be a NumPy array of integers, got <class 'numpy.ndarray'>
Pls tell ,what could be the reason behind this error for few raw objects when all else raw objects are getting epoched correctly…
Thanks in advance