Skip to content

Commit

Permalink
relate window_length to the input data in savgol_filter
Browse files Browse the repository at this point in the history
  • Loading branch information
ZoeLi0525 committed Jul 9, 2024
1 parent 122197b commit b130f68
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions docs/notebooks/path_and_velocity.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@
" timestamps = concatenate(timestamps, group.to_center_timestamps.iloc[i])\n",
" velocity = get_velocity(timestamps, positions)\n",
" ax.plot(timestamps[:-1], velocity, color=color)\n",
" positions[:, 1] = savgol_filter(positions[:, 1], len(positions[:, 0]), 8)\n",
" positions[:, 1] = savgol_filter(positions[:, 1], len(positions[:, 1]), 8)\n",
" velocity_with_filtered_positions = get_velocity(timestamps, positions)\n",
" ax.plot(\n",
" timestamps[:-1],\n",
Expand Down Expand Up @@ -417,9 +417,7 @@
" positions = concatenate(positions, group.to_center_mouse_positions.iloc[i])\n",
" timestamps = concatenate(timestamps, group.to_center_timestamps.iloc[i])\n",
" velocity = get_velocity(timestamps, positions)\n",
" filtered_velocity = savgol_filter(\n",
" velocity, len(timestamps[:-1]), len(timestamps[:-1]) - 1\n",
" )\n",
" filtered_velocity = savgol_filter(velocity, len(velocity), len(velocity) - 1)\n",
" ax.plot(timestamps[:-1], filtered_velocity, color=\"black\", linestyle=\"dashed\")\n",
" ax.plot(timestamps[:-1], velocity, color=color)\n",
"\n",
Expand All @@ -431,6 +429,13 @@
"warnings.filterwarnings(\"ignore\")\n",
"plt.show()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down

0 comments on commit b130f68

Please sign in to comment.