forked from LorenFrankLab/spyglass
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into spikesorting_v1
- Loading branch information
Showing
9 changed files
with
93 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,7 +34,6 @@ dependencies: | |
- bottleneck | ||
- ipympl | ||
- tqdm | ||
- nb_conda | ||
- ffmpeg | ||
- pytorch<1.12.0 | ||
- torchvision | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
from spyglass.lfp.lfp_merge import LFPOutput | ||
from spyglass.lfp.lfp_electrode import LFPElectrodeGroup | ||
from spyglass.lfp.lfp_imported import ImportedLFP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import datajoint as dj | ||
|
||
from spyglass.common.common_ephys import Electrode | ||
from spyglass.common.common_session import Session | ||
|
||
schema = dj.schema("lfp_electrode") | ||
|
||
|
||
@schema | ||
class LFPElectrodeGroup(dj.Manual): | ||
definition = """ | ||
-> Session # the session to which this LFP belongs | ||
lfp_electrode_group_name: varchar(200) # the name of this group of electrodes | ||
""" | ||
|
||
class LFPElectrode(dj.Part): | ||
definition = """ | ||
-> LFPElectrodeGroup # the group of electrodes to be filtered | ||
-> Electrode # the electrode to be filtered | ||
""" | ||
|
||
@staticmethod | ||
def create_lfp_electrode_group( | ||
nwb_file_name: str, group_name: str, electrode_list: list[int] | ||
): | ||
"""Adds an LFPElectrodeGroup and the individual electrodes | ||
Parameters | ||
---------- | ||
nwb_file_name : str | ||
The name of the nwb file (e.g. the session) | ||
group_name : str | ||
The name of this group (< 200 char) | ||
electrode_list : list | ||
A list of the electrode ids to include in this group. | ||
""" | ||
# remove the session and then recreate the session and Electrode list | ||
# check to see if the user allowed the deletion | ||
key = { | ||
"nwb_file_name": nwb_file_name, | ||
"lfp_electrode_group_name": group_name, | ||
} | ||
LFPElectrodeGroup().insert1(key, skip_duplicates=True) | ||
|
||
# TODO: do this in a better way | ||
all_electrodes = (Electrode() & {"nwb_file_name": nwb_file_name}).fetch( | ||
as_dict=True | ||
) | ||
primary_key = Electrode.primary_key | ||
for e in all_electrodes: | ||
# create a dictionary so we can insert the electrodes | ||
if e["electrode_id"] in electrode_list: | ||
lfpelectdict = {k: v for k, v in e.items() if k in primary_key} | ||
lfpelectdict["lfp_electrode_group_name"] = group_name | ||
LFPElectrodeGroup().LFPElectrode.insert1( | ||
lfpelectdict, skip_duplicates=True | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import datajoint as dj | ||
|
||
from spyglass.common.common_interval import IntervalList | ||
from spyglass.common.common_nwbfile import AnalysisNwbfile | ||
from spyglass.common.common_session import Session | ||
from spyglass.lfp.lfp_electrode import LFPElectrodeGroup | ||
|
||
schema = dj.schema("lfp_imported") | ||
|
||
|
||
@schema | ||
class ImportedLFP(dj.Imported): | ||
definition = """ | ||
-> Session # the session to which this LFP belongs | ||
-> LFPElectrodeGroup # the group of electrodes to be filtered | ||
-> IntervalList # the original set of times to be filtered | ||
lfp_object_id: varchar(40) # the NWB object ID for loading this object from the file | ||
--- | ||
lfp_sampling_rate: float # the sampling rate, in samples/sec | ||
-> AnalysisNwbfile | ||
""" | ||
|
||
def make(self, key): | ||
raise NotImplementedError( | ||
"For `insert`, use `allow_direct_insert=True`" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
# flake8: noqa | ||
from spyglass.lfp.v1.lfp import ( | ||
LFPV1, | ||
ImportedLFPV1, | ||
LFPElectrodeGroup, | ||
LFPSelection, | ||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters