Skip to content

Commit

Permalink
Merge pull request LorenFrankLab#512 from LorenFrankLab/rename_firfil…
Browse files Browse the repository at this point in the history
…ter_table

Rename FirFilter to FirFilterParameters
  • Loading branch information
MichaelCoulter authored May 20, 2023
2 parents 011dcaa + 0e983f1 commit 9b732f8
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 29 deletions.
7 changes: 6 additions & 1 deletion notebooks/02_curation.ipynb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"cells": [
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand Down Expand Up @@ -105,7 +106,7 @@
" LFP,\n",
" LFPBandSelection,\n",
" LFPBand,\n",
" FirFilter,\n",
" FirFilterParameters,\n",
" IntervalList,\n",
" Lab,\n",
" LabMember,\n",
Expand Down Expand Up @@ -168,6 +169,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand Down Expand Up @@ -409,13 +411,15 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"### `sortingview` web app"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand All @@ -433,6 +437,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand Down
8 changes: 4 additions & 4 deletions notebooks/03_lfp.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
" Electrode,\n",
" Raw,\n",
" SampleCount,\n",
" FirFilter,\n",
" FirFilterParameters,\n",
" IntervalList,\n",
" Lab,\n",
" LabMember,\n",
Expand Down Expand Up @@ -115,7 +115,7 @@
"metadata": {},
"outputs": [],
"source": [
"FirFilter().create_standard_filters()\n"
"FirFilterParameters().create_standard_filters()\n"
]
},
{
Expand Down Expand Up @@ -181,7 +181,7 @@
"You might need to run<br>\n",
"(IntervalList & {\"nwb_file_name\": nwb_file_name}) <br>\n",
" to see the list of intervals and similarly<br>\n",
"FIRFilter() <br>\n",
"FirFilterParameters() <br>\n",
" to see the list of defined filters"
]
},
Expand Down Expand Up @@ -264,7 +264,7 @@
" \"lfp_sampling_rate\"\n",
")\n",
"filter_name = \"Theta 5-11 Hz\"\n",
"FirFilter().add_filter(\n",
"FirFilterParameters().add_filter(\n",
" filter_name,\n",
" lfp_sampling_rate,\n",
" \"bandpass\",\n",
Expand Down
2 changes: 1 addition & 1 deletion src/spyglass/common/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
Raw,
SampleCount,
)
from .common_filter import FirFilter
from .common_filter import FirFilterParameters
from .common_interval import (
IntervalList,
interval_list_censor,
Expand Down
22 changes: 11 additions & 11 deletions src/spyglass/common/common_ephys.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import pynwb

from .common_device import Probe # noqa: F401
from .common_filter import FirFilter
from .common_filter import FirFilterParameters
from .common_interval import (
IntervalList,
interval_list_censor, # noqa: F401
Expand Down Expand Up @@ -362,7 +362,7 @@ class LFP(dj.Imported):
-> LFPSelection
---
-> IntervalList # the valid intervals for the data
-> FirFilter # the filter used for the data
-> FirFilterParameters # the filter used for the data
-> AnalysisNwbfile # the name of the nwb file with the lfp data
lfp_object_id: varchar(40) # the NWB object ID for loading this object from the file
lfp_sampling_rate: float # the sampling rate, in HZ
Expand Down Expand Up @@ -399,7 +399,7 @@ def make(self, key):

# get the LFP filter that matches the raw data
filter = (
FirFilter()
FirFilterParameters()
& {"filter_name": "LFP 0-400 Hz"}
& {"filter_sampling_rate": sampling_rate}
).fetch(as_dict=True)
Expand All @@ -422,7 +422,7 @@ def make(self, key):
lfp_file_name = AnalysisNwbfile().create(key["nwb_file_name"])

lfp_file_abspath = AnalysisNwbfile().get_abs_path(lfp_file_name)
lfp_object_id, timestamp_interval = FirFilter().filter_data_nwb(
lfp_object_id, timestamp_interval = FirFilterParameters().filter_data_nwb(
lfp_file_abspath,
rawdata,
filter_coeff,
Expand Down Expand Up @@ -481,7 +481,7 @@ def fetch1_dataframe(self, *attrs, **kwargs):
class LFPBandSelection(dj.Manual):
definition = """
-> LFP
-> FirFilter # the filter to use for the data
-> FirFilterParameters # the filter to use for the data
-> IntervalList.proj(target_interval_list_name='interval_list_name') # the original set of times to be filtered
lfp_band_sampling_rate: int # the sampling rate for this band
---
Expand Down Expand Up @@ -512,7 +512,7 @@ def set_lfp_band_electrodes(
in the electrode_list.
:param nwb_file_name: string - the name of the nwb file for the desired session
:param electrode_list: list of LFP electrodes to be filtered
:param filter_name: the name of the filter (from the FirFilter schema)
:param filter_name: the name of the filter (from the FirFilterParameters schema)
:param interval_name: the name of the interval list (from the IntervalList schema)
:param reference_electrode_list: A single electrode id corresponding to the reference to use for all
electrodes or a list with one element per entry in the electrode_list
Expand All @@ -539,13 +539,13 @@ def set_lfp_band_electrodes(
f"samping rate {lfp_sampling_rate}"
)
# filter
query = FirFilter() & {
query = FirFilterParameters() & {
"filter_name": filter_name,
"filter_sampling_rate": lfp_sampling_rate,
}
if not query:
raise ValueError(
f"filter {filter_name}, sampling rate {lfp_sampling_rate} is not in the FirFilter table"
f"filter {filter_name}, sampling rate {lfp_sampling_rate} is not in the FirFilterParameters table"
)
# interval_list
query = IntervalList() & {
Expand Down Expand Up @@ -699,14 +699,14 @@ def make(self, key):

# get the LFP filter that matches the raw data
filter = (
FirFilter()
FirFilterParameters()
& {"filter_name": filter_name}
& {"filter_sampling_rate": filter_sampling_rate}
).fetch(as_dict=True)
if len(filter) == 0:
raise ValueError(
f"Filter {filter_name} and sampling_rate {lfp_band_sampling_rate} does not exit in the "
"FirFilter table"
"FirFilterParameters table"
)

filter_coeff = filter[0]["filter_coeff"]
Expand All @@ -720,7 +720,7 @@ def make(self, key):
lfp_band_file_name = AnalysisNwbfile().create(key["nwb_file_name"])
lfp_band_file_abspath = AnalysisNwbfile().get_abs_path(lfp_band_file_name)
# filter the data and write to an the nwb file
filtered_data, new_timestamps = FirFilter().filter_data(
filtered_data, new_timestamps = FirFilterParameters().filter_data(
timestamps,
lfp_data,
filter_coeff,
Expand Down
2 changes: 1 addition & 1 deletion src/spyglass/common/common_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def _import_ghostipy():


@schema
class FirFilter(dj.Manual):
class FirFilterParameters(dj.Manual):
definition = """
filter_name: varchar(80) # descriptive name of this filter
filter_sampling_rate: int # sampling rate for this filter
Expand Down
22 changes: 11 additions & 11 deletions src/spyglass/lfp/v1/lfp.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import scipy.stats as stats

from spyglass.common.common_ephys import Electrode, Raw
from spyglass.common.common_filter import FirFilter
from spyglass.common.common_filter import FirFilterParameters
from spyglass.common.common_interval import interval_list_censor # noqa: F401
from spyglass.common.common_interval import (
IntervalList,
Expand Down Expand Up @@ -80,7 +80,7 @@ class LFPSelection(dj.Manual):
definition = """
-> LFPElectrodeGroup
-> IntervalList.proj(target_interval_list_name='interval_list_name') # the original set of times to be filtered
-> FirFilter
-> FirFilterParameters
"""


Expand Down Expand Up @@ -131,7 +131,7 @@ def make(self, key):

# get the LFP filter that matches the raw data
filter = (
FirFilter()
FirFilterParameters()
& {"filter_name": key["filter_name"]}
& {"filter_sampling_rate": sampling_rate}
).fetch(as_dict=True)
Expand All @@ -154,7 +154,7 @@ def make(self, key):
lfp_file_name = AnalysisNwbfile().create(key["nwb_file_name"])

lfp_file_abspath = AnalysisNwbfile().get_abs_path(lfp_file_name)
lfp_object_id, timestamp_interval = FirFilter().filter_data_nwb(
lfp_object_id, timestamp_interval = FirFilterParameters().filter_data_nwb(
lfp_file_abspath,
rawdata,
filter_coeff,
Expand Down Expand Up @@ -615,7 +615,7 @@ def _check_artifact_thresholds(
class LFPBandSelection(dj.Manual):
definition = """
-> LFPOutput
-> FirFilter # the filter to use for the data
-> FirFilterParameters # the filter to use for the data
-> IntervalList.proj(target_interval_list_name='interval_list_name') # the original set of times to be filtered
lfp_band_sampling_rate: int # the sampling rate for this band
---
Expand Down Expand Up @@ -647,7 +647,7 @@ def set_lfp_band_electrodes(
:param nwb_file_name: string - the name of the nwb file for the desired session
:param lfp_id: uuid - the uuid for the LFPOutput to use
:param electrode_list: list of LFP electrodes (electrode ids) to be filtered
:param filter_name: the name of the filter (from the FirFilter schema)
:param filter_name: the name of the filter (from the FirFilterParameters schema)
:param interval_name: the name of the interval list (from the IntervalList schema)
:param reference_electrode_list: A single electrode id corresponding to the reference to use for all
electrodes or a list with one element per entry in the electrode_list
Expand Down Expand Up @@ -676,13 +676,13 @@ def set_lfp_band_electrodes(
f"samping rate {lfp_sampling_rate}"
)
# filter
query = FirFilter() & {
query = FirFilterParameters() & {
"filter_name": filter_name,
"filter_sampling_rate": lfp_sampling_rate,
}
if not query:
raise ValueError(
f"filter {filter_name}, sampling rate {lfp_sampling_rate} is not in the FirFilter table"
f"filter {filter_name}, sampling rate {lfp_sampling_rate} is not in the FirFilterParameters table"
)
# interval_list
query = IntervalList() & {
Expand Down Expand Up @@ -840,14 +840,14 @@ def make(self, key):

# get the LFP filter that matches the raw data
filter = (
FirFilter()
FirFilterParameters()
& {"filter_name": filter_name}
& {"filter_sampling_rate": filter_sampling_rate}
).fetch(as_dict=True)
if len(filter) == 0:
raise ValueError(
f"Filter {filter_name} and sampling_rate {lfp_band_sampling_rate} does not exit in the "
"FirFilter table"
"FirFilterParameters table"
)

filter_coeff = filter[0]["filter_coeff"]
Expand All @@ -861,7 +861,7 @@ def make(self, key):
lfp_band_file_name = AnalysisNwbfile().create(key["nwb_file_name"])
lfp_band_file_abspath = AnalysisNwbfile().get_abs_path(lfp_band_file_name)
# filter the data and write to an the nwb file
filtered_data, new_timestamps = FirFilter().filter_data(
filtered_data, new_timestamps = FirFilterParameters().filter_data(
timestamps,
lfp_data,
filter_coeff,
Expand Down

0 comments on commit 9b732f8

Please sign in to comment.