diff --git a/pylossless/pipeline.py b/pylossless/pipeline.py index 1387a0a5..c03c5e5e 100644 --- a/pylossless/pipeline.py +++ b/pylossless/pipeline.py @@ -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) diff --git a/pylossless/tests/test_pipeline.py b/pylossless/tests/test_pipeline.py index cc76d213..4476bdaa 100644 --- a/pylossless/tests/test_pipeline.py +++ b/pylossless/tests/test_pipeline.py @@ -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