From c34d77dba19084f0a56d07c43b403fff615685c4 Mon Sep 17 00:00:00 2001 From: withmywoessner Date: Tue, 5 Mar 2024 13:25:38 -0600 Subject: [PATCH] Ignore annotations with NaN onset --- mne/io/eeglab/eeglab.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/mne/io/eeglab/eeglab.py b/mne/io/eeglab/eeglab.py index 50cfc39c820..d56ca3e5b6c 100644 --- a/mne/io/eeglab/eeglab.py +++ b/mne/io/eeglab/eeglab.py @@ -799,6 +799,18 @@ def _read_annotations_eeglab(eeg, uint16_codec=None): ) duration[idx] = np.nan if is_empty_array else event.duration + # Drop events with NaN onset see PR #XXXX + valid_indices = [ + idx for idx, onset_idx in enumerate(onset) if not np.isnan(onset_idx) + ] + n_dropped = len(onset) - len(valid_indices) + if len(valid_indices) != len(onset): + warn( + f"{n_dropped} events have an onset that is NaN. These values are " + "usually ignored by EEGLAB and will be dropped from the " + "annotations." + ) + return Annotations( onset=np.array(onset) / eeg.srate, duration=duration / eeg.srate,