Open eort opened 1 year ago
It suggests that
np.array(...)
when we should do np.array(..., int)
np.array(..., int)
, but we'll have to seesomewhere we do np.array(...) when we should do np.array(..., int)
Yes, exactly. I linked the location in the source code above.
this might actually already happen once we np.array(..., int), but we'll have to see
No, it doesn't unfortunately. You get a (different) ValueError instead.
we should catch the empty events
Yes, agreed. Right after the linked location above would be a good place. I haven't checked the entire preprocessing algorithm (eog, etc). Perhaps the same applies there.
I'm gonna take a look and try fixing this. Will keep you guys posted
Description of the problem
Calling
mne.preprocessing.create_ecg_epochs()
on data that contain an ECG channel that is malfunctioning in some way, such that no ecg events can be found, the function returns the somewhat misleading error message:TypeError: events should be a NumPy array of integers, got <class 'numpy.ndarray'>
. This is because here: https://github.com/mne-tools/mne-python/blob/7b3e3c931914ee655486e7b8d5a5a30668ce136f/mne/preprocessing/ecg.py#L283 an empty numpy array without type specification is created in case no ECG events can be found.This behavior is different from when an empty events array is passed to Epochs(), which results in :
ValueError: zero-size array to reduction operation maximum which has no identity
Either way, both are a bit confusing when the error is essentially: "No ECG events can be found."
Steps to reproduce
Expected results
An error message a la "No ECG events can be found."
Actual results
TypeError: events should be a NumPy array of integers, got <class 'numpy.ndarray'>
Additional information