diff --git a/CHANGELOG.md b/CHANGELOG.md index 9ba4ccb5c..b5dc7c78f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ - Increase pytest coverage for `common`, `lfp`, and `utils`. #743 - Update docs to reflect new notebooks. #776 - Add overview of Spyglass to docs. #779 +- LFPV1: Fix error for multiple lfp settings on same data #775 ### Pipelines diff --git a/src/spyglass/lfp/v1/lfp.py b/src/spyglass/lfp/v1/lfp.py index 10146e64c..3ef33244c 100644 --- a/src/spyglass/lfp/v1/lfp.py +++ b/src/spyglass/lfp/v1/lfp.py @@ -155,7 +155,7 @@ def make(self, key): # need to censor the valid times to account for the downsampling lfp_valid_times = interval_list_censor(valid_times, timestamp_interval) - # add an interval list for the LFP valid times, skipping duplicates + # add an interval list for the LFP valid times, or check that it matches the existing one key["interval_list_name"] = "_".join( ( "lfp", @@ -164,15 +164,28 @@ def make(self, key): "valid times", ) ) - IntervalList.insert1( - { + + tmp_valid_times = ( + IntervalList + & { "nwb_file_name": key["nwb_file_name"], "interval_list_name": key["interval_list_name"], - "valid_times": lfp_valid_times, - "pipeline": "lfp_v1", - }, - replace=True, - ) + } + ).fetch("valid_times") + if len(tmp_valid_times) == 0: + IntervalList.insert1( + { + "nwb_file_name": key["nwb_file_name"], + "interval_list_name": key["interval_list_name"], + "valid_times": lfp_valid_times, + "pipeline": "lfp_v1", + }, + replace=True, + ) + elif not np.allclose(tmp_valid_times[0], lfp_valid_times): + raise ValueError( + "previously saved lfp times do not match current times" + ) self.insert1(key) # finally, we insert this into the LFP output table.