Skip to content

Commit dbeea81

Browse files
committed
FIX: early return in find_breaks if no annotations in raw
1 parent 68c1784 commit dbeea81

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

pylossless/pipeline.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -718,6 +718,9 @@ def find_breaks(self):
718718
"""
719719
if "find_breaks" not in self.config or not self.config["find_breaks"]:
720720
return
721+
if not self.raw.annotations:
722+
logger.debug("No annotations found in raw object. Skipping find_breaks.")
723+
return
721724
breaks = annotate_break(self.raw, **self.config["find_breaks"])
722725
self.raw.set_annotations(breaks + self.raw.annotations)
723726

pylossless/tests/test_pipeline.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ def test_find_breaks(logging):
4343
pipeline.find_breaks(message="Looking for break periods between tasks")
4444
else:
4545
pipeline.find_breaks()
46+
# Now explicitly remove annotations and make sure we avoid MNE's error.
47+
pipeline.raw.set_annotations(None)
48+
pipeline.find_breaks()
4649
Path(config_fname).unlink() # delete config file
4750

4851

0 commit comments

Comments
 (0)