Skip to content

Commit

Permalink
Ignore annotations with NaN onset
Browse files Browse the repository at this point in the history
  • Loading branch information
withmywoessner committed Mar 5, 2024
1 parent ae69b03 commit c34d77d
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions mne/io/eeglab/eeglab.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit c34d77d

Please sign in to comment.