Skip to content

Commit

Permalink
FIX: early return in find_breaks if no annotations in raw
Browse files Browse the repository at this point in the history
  • Loading branch information
scott-huberty committed Nov 13, 2024
1 parent 68c1784 commit dbeea81
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pylossless/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,9 @@ def find_breaks(self):
"""
if "find_breaks" not in self.config or not self.config["find_breaks"]:
return
if not self.raw.annotations:
logger.debug("No annotations found in raw object. Skipping find_breaks.")
return
breaks = annotate_break(self.raw, **self.config["find_breaks"])
self.raw.set_annotations(breaks + self.raw.annotations)

Expand Down
3 changes: 3 additions & 0 deletions pylossless/tests/test_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ def test_find_breaks(logging):
pipeline.find_breaks(message="Looking for break periods between tasks")
else:
pipeline.find_breaks()
# Now explicitly remove annotations and make sure we avoid MNE's error.
pipeline.raw.set_annotations(None)
pipeline.find_breaks()
Path(config_fname).unlink() # delete config file


Expand Down

0 comments on commit dbeea81

Please sign in to comment.