From ff0aad8ae2ef25988f34cf7dbf3a30afb1e7dc44 Mon Sep 17 00:00:00 2001 From: Alexandre Gramfort Date: Sun, 9 Oct 2022 17:34:21 +0200 Subject: [PATCH] avoid creating many Annotations objects in for loop --- mne_bids/read.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mne_bids/read.py b/mne_bids/read.py index 976102b27..b95323b73 100644 --- a/mne_bids/read.py +++ b/mne_bids/read.py @@ -491,8 +491,8 @@ def _handle_events_reading(events_fname, raw): description=descriptions) raw.set_annotations(annot_from_events) - annot_idx_to_keep = [idx for idx, annot in enumerate(annot_from_raw) - if annot['description'] in ANNOTATIONS_TO_KEEP] + annot_idx_to_keep = [idx for idx, descr in enumerate(annot_from_raw.description) + if descr in ANNOTATIONS_TO_KEEP] annot_to_keep = annot_from_raw[annot_idx_to_keep] if len(annot_to_keep):