Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
CBroz1 committed Jul 28, 2023
2 parents 5d66f25 + f4cc73d commit 15d1369
Show file tree
Hide file tree
Showing 16 changed files with 2,981 additions and 1,586 deletions.
1,699 changes: 1,699 additions & 0 deletions examples/db_alter.ipynb

Large diffs are not rendered by default.

64 changes: 21 additions & 43 deletions notebooks/03_lfp.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,24 @@
"#### First, we select the NWB file, which corresponds to the dataset we want to extract LFP from"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import copy\n",
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"import os\n",
"import pandas as pd\n",
"from spyglass.common import Electrode, BrainRegion, FirFilterParameters, IntervalList, Raw, get_electrode_indices\n",
"from spyglass.lfp import LFPOutput\n",
"from spyglass.lfp.lfp_electrode import LFPElectrodeGroup\n",
"from spyglass.lfp.v1 import LFPV1, LFPSelection\n",
"from spyglass.lfp.analysis.v1.lfp_band import LFPBandV1, LFPBandSelection"
]
},
{
"cell_type": "code",
"execution_count": 1,
Expand All @@ -33,8 +51,6 @@
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"\n",
"os.environ[\"SPYGLASS_BASE_DIR\"] = \"/stelmo/nwb\"\n",
"os.environ[\"DJ_SUPPORT_FILEPATH_MANAGEMENT\"] = \"TRUE\""
]
Expand Down Expand Up @@ -324,8 +340,6 @@
}
],
"source": [
"from spyglass.common import FirFilterParameters\n",
"\n",
"FirFilterParameters().create_standard_filters()\n",
"FirFilterParameters()"
]
Expand Down Expand Up @@ -465,9 +479,6 @@
}
],
"source": [
"from spyglass.common import Electrode, BrainRegion\n",
"import pandas as pd\n",
"\n",
"electrodes_df = (\n",
" pd.DataFrame(\n",
" (Electrode & {\"nwb_file_name\": nwb_file_name, \"probe_electrode\": 0})\n",
Expand All @@ -493,8 +504,6 @@
"metadata": {},
"outputs": [],
"source": [
"from spyglass.lfp.v1 import LFPElectrodeGroup\n",
"\n",
"lfp_electrode_ids = electrodes_df.loc[\n",
" electrodes_df.region_name == \"ca1\"\n",
"].electrode_id\n",
Expand Down Expand Up @@ -815,9 +824,6 @@
}
],
"source": [
"from spyglass.common import IntervalList\n",
"\n",
"\n",
"pd.DataFrame(IntervalList & {\"nwb_file_name\": nwb_file_name})"
]
},
Expand All @@ -827,9 +833,6 @@
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"\n",
"\n",
"orig_interval_list_name = \"02_r1\"\n",
"valid_times = (\n",
" IntervalList\n",
Expand Down Expand Up @@ -963,9 +966,6 @@
"metadata": {},
"outputs": [],
"source": [
"import copy\n",
"from spyglass.lfp.v1 import LFPSelection\n",
"\n",
"filter_name = \"LFP 0-400 Hz\"\n",
"filter_sampling_rate = 30_000\n",
"\n",
Expand Down Expand Up @@ -1121,8 +1121,6 @@
},
"outputs": [],
"source": [
"from spyglass.lfp.v1 import LFPV1\n",
"\n",
"LFPV1().populate(lfp_s_key)"
]
},
Expand Down Expand Up @@ -1238,8 +1236,6 @@
}
],
"source": [
"from spyglass.lfp import LFPOutput\n",
"\n",
"LFPOutput.LFPV1() & lfp_s_key"
]
},
Expand Down Expand Up @@ -1889,8 +1885,6 @@
}
],
"source": [
"from spyglass.common.common_filter import FirFilterParameters\n",
"\n",
"lfp_sampling_rate = LFPOutput.merge_get_parent(lfp_key).fetch1(\n",
" \"lfp_sampling_rate\"\n",
")\n",
Expand Down Expand Up @@ -2024,8 +2018,6 @@
}
],
"source": [
"from spyglass.lfp_band.v1.lfp_band import LFPBandSelection\n",
"\n",
"# assume that we've filtered these electrodes; change this if not\n",
"lfp_band_electrode_ids = [28, 32]\n",
"\n",
Expand Down Expand Up @@ -2366,8 +2358,6 @@
}
],
"source": [
"from spyglass.lfp_band.v1 import LFPBandV1\n",
"\n",
"LFPBandV1().populate(LFPBandSelection() & lfp_band_key)\n",
"LFPBandV1()"
]
Expand All @@ -2382,15 +2372,7 @@
]
},
{
"cell_type": "code",
"execution_count": 24,
"metadata": {},
"outputs": [],
"source": [
"import matplotlib.pyplot as plt"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand Down Expand Up @@ -2428,9 +2410,6 @@
}
],
"source": [
"from spyglass.common import Raw, get_electrode_indices\n",
"\n",
"\n",
"orig_eseries = (Raw() & {\"nwb_file_name\": nwb_file_name}).fetch_nwb()[0][\"raw\"]\n",
"orig_elect_indices = get_electrode_indices(orig_eseries, lfp_band_electrode_ids)\n",
"orig_timestamps = np.asarray(orig_eseries.timestamps)"
Expand All @@ -2453,16 +2432,15 @@
"metadata": {},
"outputs": [],
"source": [
"from spyglass.lfp_band import LFPBandOutput\n",
"\n",
"lfp_band_eseries = LFPBandOutput.fetch_nwb(lfp_band_key)[0][\"lfp_band\"]\n",
"lfp_band_eseries = (LFPBandV1 & lfp_band_key).fetch_nwb()[0][\"lfp_band\"]\n",
"lfp_band_elect_indices = get_electrode_indices(\n",
" lfp_band_eseries, lfp_band_electrode_ids\n",
")\n",
"lfp_band_timestamps = np.asarray(lfp_band_eseries.timestamps)"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand Down
Loading

0 comments on commit 15d1369

Please sign in to comment.