Skip to content

Commit

Permalink
avoid creating many Annotations objects in for loop
Browse files Browse the repository at this point in the history
  • Loading branch information
agramfort committed Oct 9, 2022
1 parent 79aeaa4 commit ff0aad8
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions mne_bids/read.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit ff0aad8

Please sign in to comment.