Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: early return in find_breaks if no annotations in raw #180

Merged
merged 1 commit into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading