Skip to content

Commit

Permalink
reduce demo data size, insert parameter sets into new database
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelbray32 committed Mar 20, 2024
1 parent 440601f commit d7578d7
Show file tree
Hide file tree
Showing 2 changed files with 114 additions and 12 deletions.
63 changes: 57 additions & 6 deletions notebooks/32_Ripple_Detection.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -239,15 +239,29 @@
" pd.DataFrame(\n",
" (\n",
" sgc.Electrode\n",
" & {\n",
" \"nwb_file_name\": nwb_file_name,\n",
" }\n",
" & {\"nwb_file_name\": nwb_file_name, \"bad_channel\": \"False\"}\n",
" )\n",
" * (sgc.BrainRegion & {\"region_name\": \"hippocampus\"})\n",
" )\n",
" .loc[:, [\"nwb_file_name\", \"electrode_id\", \"region_name\"]]\n",
" .loc[\n",
" :,\n",
" [\n",
" \"nwb_file_name\",\n",
" \"electrode_id\",\n",
" \"region_name\",\n",
" \"electrode_group_name\",\n",
" ],\n",
" ]\n",
" .sort_values(by=\"electrode_id\")\n",
")\n",
"# for the purpose of the demo, we will only use one electrode per electrode group\n",
"electrodes_df = pd.DataFrame(\n",
" [\n",
" electrodes_df[electrodes_df.electrode_group_name == str(i)].iloc[0]\n",
" for i in np.unique(electrodes_df.electrode_group_name.values)\n",
" ]\n",
")\n",
"\n",
"# create lfp_electrode_group\n",
"lfp_eg_key = {\n",
" \"nwb_file_name\": nwb_file_name,\n",
Expand Down Expand Up @@ -3038,7 +3052,25 @@
}
],
"source": [
"sgr.RippleParameters().insert_default"
"sgr.RippleParameters().insert_default()\n",
"sgr.RippleParameters.insert1(\n",
" {\n",
" \"ripple_param_name\": \"default_trodes\",\n",
" \"ripple_param_dict\": {\n",
" \"speed_name\": \"speed\", # name of the speed field in the position data\n",
" \"ripple_detection_algorithm\": \"Kay_ripple_detector\",\n",
" \"ripple_detection_params\": {\n",
" \"speed_threshold\": 4.0,\n",
" \"minimum_duration\": 0.015,\n",
" \"zscore_threshold\": 2.0,\n",
" \"smoothing_sigma\": 0.004,\n",
" \"close_ripple_threshold\": 0.0,\n",
" },\n",
" },\n",
" },\n",
" skip_duplicates=True,\n",
")\n",
"sgr.RippleParameters()"
]
},
{
Expand Down Expand Up @@ -3220,6 +3252,25 @@
}
],
"source": [
"# insert the position parameter set\n",
"sgp.TrodesPosParams().insert1(\n",
" {\n",
" \"trodes_pos_params_name\": \"single_led\",\n",
" \"params\": {\n",
" \"max_separation\": 10000.0,\n",
" \"max_speed\": 300.0,\n",
" \"position_smoothing_duration\": 0.125,\n",
" \"speed_smoothing_std_dev\": 0.1,\n",
" \"orient_smoothing_std_dev\": 0.001,\n",
" \"led1_is_front\": 1,\n",
" \"is_upsampled\": 0,\n",
" \"upsampling_sampling_rate\": None,\n",
" \"upsampling_interpolation_method\": \"linear\",\n",
" },\n",
" },\n",
" skip_duplicates=True,\n",
")\n",
"# populate the position if not done already\n",
"pos_key = {\n",
" \"nwb_file_name\": nwb_file_name,\n",
" \"trodes_pos_params_name\": \"single_led\",\n",
Expand Down Expand Up @@ -3842,7 +3893,7 @@
"source": [
"## Up Next\n",
"\n",
"Next, we'll [extract mark indicator](./31_Extract_Mark_Indicators.ipynb).\n"
"We will learn how to [extract spike waveform features](./40_Extracting_Clusterless_Waveform_Features.ipynb) to decode neural data.\n"
]
}
],
Expand Down
63 changes: 57 additions & 6 deletions notebooks/py_scripts/32_Ripple_Detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,29 @@
pd.DataFrame(
(
sgc.Electrode
& {
"nwb_file_name": nwb_file_name,
}
& {"nwb_file_name": nwb_file_name, "bad_channel": "False"}
)
* (sgc.BrainRegion & {"region_name": "hippocampus"})
)
.loc[:, ["nwb_file_name", "electrode_id", "region_name"]]
.loc[
:,
[
"nwb_file_name",
"electrode_id",
"region_name",
"electrode_group_name",
],
]
.sort_values(by="electrode_id")
)
# for the purpose of the demo, we will only use one electrode per electrode group
electrodes_df = pd.DataFrame(
[
electrodes_df[electrodes_df.electrode_group_name == str(i)].iloc[0]
for i in np.unique(electrodes_df.electrode_group_name.values)
]
)

# create lfp_electrode_group
lfp_eg_key = {
"nwb_file_name": nwb_file_name,
Expand Down Expand Up @@ -274,7 +288,25 @@
# ## Setting Ripple Parameters
#

sgr.RippleParameters().insert_default
sgr.RippleParameters().insert_default()
sgr.RippleParameters.insert1(
{
"ripple_param_name": "default_trodes",
"ripple_param_dict": {
"speed_name": "speed", # name of the speed field in the position data
"ripple_detection_algorithm": "Kay_ripple_detector",
"ripple_detection_params": {
"speed_threshold": 4.0,
"minimum_duration": 0.015,
"zscore_threshold": 2.0,
"smoothing_sigma": 0.004,
"close_ripple_threshold": 0.0,
},
},
},
skip_duplicates=True,
)
sgr.RippleParameters()

# Here are the default ripple parameters:
#
Expand All @@ -300,6 +332,25 @@
# set and for a given interval. We can quickly populate this here
#

# insert the position parameter set
sgp.TrodesPosParams().insert1(
{
"trodes_pos_params_name": "single_led",
"params": {
"max_separation": 10000.0,
"max_speed": 300.0,
"position_smoothing_duration": 0.125,
"speed_smoothing_std_dev": 0.1,
"orient_smoothing_std_dev": 0.001,
"led1_is_front": 1,
"is_upsampled": 0,
"upsampling_sampling_rate": None,
"upsampling_interpolation_method": "linear",
},
},
skip_duplicates=True,
)
# populate the position if not done already
pos_key = {
"nwb_file_name": nwb_file_name,
"trodes_pos_params_name": "single_led",
Expand Down Expand Up @@ -366,5 +417,5 @@

# ## Up Next
#
# Next, we'll [extract mark indicator](./31_Extract_Mark_Indicators.ipynb).
# We will learn how to [extract spike waveform features](./40_Extracting_Clusterless_Waveform_Features.ipynb) to decode neural data.
#

0 comments on commit d7578d7

Please sign in to comment.