From 33e5ca0bd4d9e4d6357a2e685fff6d3513af2fea Mon Sep 17 00:00:00 2001 From: Kyu Hyun Lee Date: Mon, 11 Dec 2023 15:27:00 -0800 Subject: [PATCH 1/3] Change `CurationV1.insert_metric_curation` to include `metric_curation_id` in `description` field to faciliate provenance checking (#704) * Store metric_curation_id in CurationV1 --- src/spyglass/spikesorting/v1/curation.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/spyglass/spikesorting/v1/curation.py b/src/spyglass/spikesorting/v1/curation.py index 6a334d844..28450e611 100644 --- a/src/spyglass/spikesorting/v1/curation.py +++ b/src/spyglass/spikesorting/v1/curation.py @@ -150,10 +150,7 @@ def insert_metric_curation(cls, key: Dict, apply_merge=False): labels=MetricCuration.get_labels(key) or None, merge_groups=MetricCuration.get_merge_groups(key) or None, apply_merge=apply_merge, - description=( - "metric curation of sorting id " - + f"{sorting_id}, curation id {parent_curation_id}" - ), + description=(f"metric_curation_id: {key['metric_curation_id']}"), ) return curation_key From 06f292e05733e8efb87b02f3e0dab58e5d37b7df Mon Sep 17 00:00:00 2001 From: Samuel Bray Date: Wed, 13 Dec 2023 16:45:51 -0800 Subject: [PATCH 2/3] Lfp band fixes (#706) * skip zero-sized intervals in filter * censor interval list before comparing to existing * update changelog * use isclose for comparison check --- CHANGELOG.md | 1 + src/spyglass/common/common_filter.py | 3 ++- src/spyglass/lfp/analysis/v1/lfp_band.py | 3 +++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 437e27493..4fec14d6e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ - Clean up following pre-commit checks. #688 - Add Mixin class to centralize `fetch_nwb` functionality. #692 - Minor fixes to LinearizedPositionV1 pipeline #695 +- Minor fixes to LFPBandV1 populator #706 ## [0.4.3] (November 7, 2023) diff --git a/src/spyglass/common/common_filter.py b/src/spyglass/common/common_filter.py index 2f3e12fac..0e3c63711 100644 --- a/src/spyglass/common/common_filter.py +++ b/src/spyglass/common/common_filter.py @@ -461,7 +461,8 @@ def filter_data( frm, to = self._time_bound_check( a_start, a_stop, timestamps, n_samples ) - + if np.isclose(frm, to, rtol=0, atol=1e-8): + continue indices.append((frm, to)) shape, _ = gsp.filter_data_fir( diff --git a/src/spyglass/lfp/analysis/v1/lfp_band.py b/src/spyglass/lfp/analysis/v1/lfp_band.py index 1b2596461..68a846667 100644 --- a/src/spyglass/lfp/analysis/v1/lfp_band.py +++ b/src/spyglass/lfp/analysis/v1/lfp_band.py @@ -355,6 +355,9 @@ def make(self, key): } ) else: + lfp_band_valid_times = interval_list_censor( + lfp_band_valid_times, new_timestamps + ) # check that the valid times are the same assert np.isclose( tmp_valid_times[0], lfp_band_valid_times From 0d66ea9f99fe713a626729a92faafd48180195d9 Mon Sep 17 00:00:00 2001 From: sharon-chiang <90107659+sharon-chiang@users.noreply.github.com> Date: Thu, 14 Dec 2023 08:01:07 -0800 Subject: [PATCH 3/3] Make sampling rate for LFP user-defined instead of hard-coded to 1000 Hz (#705) * Make sampling rate for LFP user-defined rather than hard-coded to 1000 Hz * Fixed default lfp_sampling_rate and moved decimation factor line * Update src/spyglass/lfp/v1/lfp.py --------- Co-authored-by: Sharon Chiang Co-authored-by: Eric Denovellis Co-authored-by: Chris Brozdowski --- src/spyglass/lfp/v1/lfp.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/spyglass/lfp/v1/lfp.py b/src/spyglass/lfp/v1/lfp.py index 9f7f709a2..861526116 100644 --- a/src/spyglass/lfp/v1/lfp.py +++ b/src/spyglass/lfp/v1/lfp.py @@ -32,15 +32,17 @@ class LFPSelection(dj.Manual): The interval list is used to select the times from the raw data that will be filtered. The user can also specify the filter to be used. - The LFP data is filtered and downsampled to 1 KHz. The filtered data is stored - in the AnalysisNwbfile table. The valid times for the filtered data are stored - in the IntervalList table. + The LFP data is filtered and downsampled to the user-defined sampling rate, specified + as lfp_sampling_rate. The filtered data is stored in the AnalysisNwbfile table. + The valid times for the filtered data are stored in the IntervalList table. """ definition = """ -> LFPElectrodeGroup # the group of electrodes to be filtered -> IntervalList.proj(target_interval_list_name='interval_list_name') # the original set of times to be filtered -> FirFilterParameters # the filter to be used + --- + target_sampling_rate = 1000 : float # the desired output sampling rate, in HZ """ @@ -58,7 +60,6 @@ class LFPV1(SpyglassMixin, dj.Computed): """ def make(self, key): - DECIMATION_FACTOR = 1000 # get the NWB object with the data nwbf_key = {"nwb_file_name": key["nwb_file_name"]} rawdata = (Raw & nwbf_key).fetch_nwb()[0]["raw"] @@ -94,8 +95,8 @@ def make(self, key): f"LFP: found {len(valid_times)} intervals > {MIN_LFP_INTERVAL_DURATION} sec long." ) - # target 1 KHz sampling rate - decimation = sampling_rate // DECIMATION_FACTOR + # target user-specified sampling rate + decimation = sampling_rate // key["target_sampling_rate"] # get the LFP filter that matches the raw data filter = (