Skip to content

Commit

Permalink
Update basics tutorial
Browse files Browse the repository at this point in the history
  • Loading branch information
sitic committed Sep 21, 2023
1 parent abeee96 commit 224b991
Showing 1 changed file with 105 additions and 4 deletions.
109 changes: 105 additions & 4 deletions docs/tutorials/basics.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,12 @@
"source": [
"## Fluorescence wave isolation\n",
"\n",
"```{note}\n",
"The rest of this tutorial is currently work in progress. We will add more information soon.\n",
"```\n",
"\n",
"### Sliding window normalization\n",
"\n",
"To better visualize the action potential propagation we can compute a pixel-wise normalization to [0, 1] using a sliding/rolling window. This is done using the {func}`video.normalize_pixelwise_slidingwindow` function. The `window_size` parameter controls the size of the sliding window, here we use a window size of 60 frames (120 ms)."
]
},
Expand Down Expand Up @@ -420,29 +426,124 @@
},
"outputs": [],
"source": [
"norm_raw = om.video.normalize_pixelwise_slidingwindow(video, window_size=60)\n",
"norm_warped = om.video.normalize_pixelwise_slidingwindow(warped, window_size=60)\n",
"def f():\n",
" norm_raw = om.video.normalize_pixelwise_slidingwindow(video, window_size=60)\n",
" norm_warped = om.video.normalize_pixelwise_slidingwindow(warped, window_size=60)\n",
" return om.video.play2(norm_raw[:500], norm_warped[:500], title1=\"with motion\", title2=\"without motion\", interval=20)\n",
"render_ani_func(f)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The dark waves is the fluorescent signal, they correspond to the action potential propagation."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"mask = om.background_mask(warped[0])\n",
"norm_warped[:, mask] = 0"
"norm_warped[:, mask] = 1.0"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"tags": [
"skip-execution"
]
},
"outputs": [],
"source": [
"om.video.play(norm_warped, interval=20);"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"tags": [
"remove-input"
]
},
"outputs": [],
"source": [
"render_ani_func(lambda: om.video.play(norm_warped, interval=40))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"tags": [
"skip-execution"
]
},
"outputs": [],
"source": [
"alpha = np.clip(-(2*norm_warped - 1), 0, 1)\n",
"om.video.play_with_overlay(warped, 1-norm_warped, alpha=alpha);"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"tags": [
"remove-input"
]
},
"outputs": [],
"source": [
"alpha = np.clip(-(2*norm_warped - 1), 0, 1)\n",
"render_ani_func(lambda: om.video.play_with_overlay(warped, 1-norm_warped, alpha=alpha), interval=20)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Temporal difference"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"tags": [
"skip-execution"
]
},
"outputs": [],
"source": [
"diff = om.video.temporal_difference(warped, 10)\n",
"diff[diff > 0] = 0\n",
"diff[:, mask] = 0\n",
"diff = om.video.normalize_pixelwise_slidingwindow(-diff, window_size=60)\n",
"om.video.play_with_overlay(warped, diff, vmin_overlay=-1, vmax_overlay=1)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"tags": [
"remove-input"
]
},
"outputs": [],
"source": []
"source": [
"diff = om.video.temporal_difference(warped, 10)\n",
"diff[diff > 0] = 0\n",
"diff[:, mask] = 0\n",
"diff = om.video.normalize_pixelwise_slidingwindow(-diff, window_size=60)\n",
"render_ani_func(lambda: om.video.play_with_overlay(warped, diff, vmin_overlay=-1, vmax_overlay=1))"
]
}
],
"metadata": {
Expand Down

0 comments on commit 224b991

Please sign in to comment.