Skip to content

Commit

Permalink
Demo angular grating
Browse files Browse the repository at this point in the history
  • Loading branch information
JorisVincent committed Nov 14, 2022
1 parent a2a6e42 commit c579a06
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions demo/illusions/angular.ipynb
Expand Up @@ -139,6 +139,66 @@
"plot_stim(stim)\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## angular_grating"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from stimuli.components.angular import grating\n",
"\n",
"# Define widgets\n",
"w_length = iw.IntSlider(value=5, min=1, max=10, description=\"heigh/width [deg]\")\n",
"w_ppd = iw.IntSlider(value=40, min=1, max=64, description=\"ppd\")\n",
"\n",
"w_rot = iw.IntSlider(value=45, min=0, max=360, description=\"rotate\")\n",
"w_n_segments = iw.IntSlider(value=4, min=1, max=20, description=\"n segments\")\n",
"\n",
"b_size = iw.HBox([w_length, w_ppd])\n",
"ui = iw.VBox([b_size, w_rot, w_n_segments])\n",
"\n",
"# Function for showing stim\n",
"def show_grating(\n",
" rotation=None,\n",
" length=None,\n",
" ppd=None,\n",
" n_segments=None,\n",
"):\n",
"\n",
" stim = grating(\n",
" rotation=rotation,\n",
" visual_size=(length, length),\n",
" ppd=ppd,\n",
" n_segments=n_segments,\n",
" intensities=[1, 0],\n",
" )\n",
" plot_stim(stim)\n",
"\n",
"\n",
"# Set interactivity\n",
"out = iw.interactive_output(\n",
" show_grating,\n",
" {\n",
" \"rotation\": w_rot,\n",
" \"length\": w_length,\n",
" \"ppd\": w_ppd,\n",
" \"n_segments\": w_n_segments,\n",
" },\n",
")\n",
"\n",
"# Show\n",
"display(ui, out)\n",
"\n",
"\n"
]
}
],
"metadata": {
Expand Down

0 comments on commit c579a06

Please sign in to comment.