Skip to content

Commit

Permalink
Make sampling rate for LFP user-defined instead of hard-coded to 1000…
Browse files Browse the repository at this point in the history
… 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 <[email protected]>
Co-authored-by: Eric Denovellis <[email protected]>
Co-authored-by: Chris Brozdowski <[email protected]>
  • Loading branch information
4 people authored Dec 14, 2023
1 parent 06f292e commit 0d66ea9
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/spyglass/lfp/v1/lfp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
"""


Expand All @@ -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"]
Expand Down Expand Up @@ -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 = (
Expand Down

0 comments on commit 0d66ea9

Please sign in to comment.