From 89598a8cce31e5fbc3942a4021d0eda42bd79a64 Mon Sep 17 00:00:00 2001 From: Sam Bray Date: Thu, 18 Jan 2024 09:37:29 -0800 Subject: [PATCH 1/4] only insert interval in lfp make if non-existent, compare against existing if not --- src/spyglass/lfp/v1/lfp.py | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/src/spyglass/lfp/v1/lfp.py b/src/spyglass/lfp/v1/lfp.py index 10146e64c..f4ac87a25 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,30 @@ 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, + ) + else: + assert np.isclose( + tmp_valid_times[0], lfp_valid_times + ).all(), ( + "previously saved lfp band times do not match current times" + ) self.insert1(key) # finally, we insert this into the LFP output table. From 7c270a1424e4dfff5f34456e71645098d6043a6e Mon Sep 17 00:00:00 2001 From: Sam Bray Date: Thu, 18 Jan 2024 11:38:57 -0800 Subject: [PATCH 2/4] avoid assert statement --- src/spyglass/lfp/v1/lfp.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/spyglass/lfp/v1/lfp.py b/src/spyglass/lfp/v1/lfp.py index f4ac87a25..dc1736253 100644 --- a/src/spyglass/lfp/v1/lfp.py +++ b/src/spyglass/lfp/v1/lfp.py @@ -182,11 +182,9 @@ def make(self, key): }, replace=True, ) - else: - assert np.isclose( - tmp_valid_times[0], lfp_valid_times - ).all(), ( - "previously saved lfp band times do not match current times" + elif not np.isclose(tmp_valid_times[0], lfp_valid_times).all(): + raise ValueError( + "previously saved lfp times do not match current times" ) self.insert1(key) From 80f4001dc4fdb5b52c2994e6dd32a58be88a28ae Mon Sep 17 00:00:00 2001 From: Eric Denovellis Date: Sat, 20 Jan 2024 10:15:38 -0800 Subject: [PATCH 3/4] Update src/spyglass/lfp/v1/lfp.py --- src/spyglass/lfp/v1/lfp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/spyglass/lfp/v1/lfp.py b/src/spyglass/lfp/v1/lfp.py index dc1736253..3ef33244c 100644 --- a/src/spyglass/lfp/v1/lfp.py +++ b/src/spyglass/lfp/v1/lfp.py @@ -182,7 +182,7 @@ def make(self, key): }, replace=True, ) - elif not np.isclose(tmp_valid_times[0], lfp_valid_times).all(): + elif not np.allclose(tmp_valid_times[0], lfp_valid_times): raise ValueError( "previously saved lfp times do not match current times" ) From 3d70a942176c0efe053cf971de2910b16901ab01 Mon Sep 17 00:00:00 2001 From: Sam Bray Date: Mon, 22 Jan 2024 12:28:54 -0800 Subject: [PATCH 4/4] update changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 895702b43..6503f26b5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ - Add `deprecation_factory` to facilitate table migration. #717 - Add Spyglass logger. #730 - IntervalList: Add secondary key `pipeline` #742 +- LFPV1: Fix error for multiple lfp settings on same data #775 ### Pipelines @@ -31,7 +32,6 @@ - Allow multiple spike waveform features for clusterelss decoding #731 - Reorder notebooks #731 - ## [0.4.3] (November 7, 2023) - Migrate `config` helper scripts to Spyglass codebase. #662