Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0717e85
commit 18b6a5b
Showing
1 changed file
with
364 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,364 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import itertools\n", | ||
"import pandas as pd\n", | ||
"import matplotlib.pyplot as plt\n", | ||
"import numpy as np\n", | ||
"\n", | ||
"import IPython\n", | ||
"import ipywidgets as iw\n", | ||
"from stimuli.utils import plot_stimuli, plot_stim" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# circular_white" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from stimuli.illusions.circular import circular_white" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Parameterization" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"params = {\n", | ||
" \"visual_size\": (10., 10.),\n", | ||
" \"ppd\": 40.0,\n", | ||
" \"frequency\": 1.,\n", | ||
" \"intensity_discs\": (0., 1.),\n", | ||
" \"intensity_background\": 0.5,\n", | ||
" \"intensity_target\": 0.5,\n", | ||
" \"target_indices\": 3,\n", | ||
"}\n", | ||
"\n", | ||
"stim = circular_white(**params)\n", | ||
"plot_stim(stim)\n", | ||
"plt.show()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"It is possible to place as many targets as there are rings by providing a list of `target_indices`.\n", | ||
"The indices refer to the number of the respective ring going from inside to outside." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"params = {\n", | ||
" \"visual_size\": (10., 10.),\n", | ||
" \"ppd\": 40.0,\n", | ||
" \"frequency\": 1.5,\n", | ||
" \"intensity_discs\": (0., 1.),\n", | ||
" \"intensity_background\": 0.5,\n", | ||
" \"intensity_target\": 0.5\n", | ||
"}\n", | ||
"\n", | ||
"stim1 = circular_white(**params, target_indices=(4, 6, 8, 10))\n", | ||
"stim2 = circular_white(**params, target_indices=(3, 5, 7, 9))\n", | ||
"\n", | ||
"plot_stimuli({\"Example 1\": stim1, \"Example 2\": stim2})\n", | ||
"plt.show()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Interactive" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# Define widgets\n", | ||
"w_height = iw.IntSlider(value=10, min=10, max=30, description=\"height [deg]\")\n", | ||
"w_width = iw.IntSlider(value=10, min=10, max=30, description=\"width [deg]\")\n", | ||
"w_ppd = iw.IntSlider(value=40, min=1, max=64, description=\"ppd\")\n", | ||
"w_size = iw.HBox([w_height, w_width, w_ppd])\n", | ||
"w_freq = iw.FloatSlider(value=1., min=0.1, max=2.0, description=\"Frequency\")\n", | ||
"w_idisc1 = iw.FloatSlider(value=0.0, min=0., max=1.0, description=\"intensity disc 1\")\n", | ||
"w_idisc2 = iw.FloatSlider(value=1.0, min=0., max=1.0, description=\"intensity disc 2\")\n", | ||
"w_iback = iw.FloatSlider(value=0.5, min=0., max=1.0, description=\"intensity background\")\n", | ||
"w_itarget = iw.FloatSlider(value=0.5, min=0., max=1.0, description=\"intensity target\")\n", | ||
"w_intensities = iw.HBox([w_idisc1, w_idisc2, w_iback, w_itarget])\n", | ||
"\n", | ||
"ui = iw.VBox([w_size, w_freq, w_intensities])\n", | ||
"\n", | ||
"def show_circular(\n", | ||
" height=None,\n", | ||
" width=None,\n", | ||
" ppd=None,\n", | ||
" frequency=None,\n", | ||
" intensity_disc1=None,\n", | ||
" intensity_disc2=None,\n", | ||
" intensity_background=None,\n", | ||
" intensity_target=None, \n", | ||
"):\n", | ||
"\n", | ||
" stim = circular_white(\n", | ||
" visual_size=(height, width),\n", | ||
" ppd=ppd,\n", | ||
" frequency=frequency,\n", | ||
" intensity_background=intensity_background,\n", | ||
" intensity_discs=(intensity_disc1, intensity_disc2),\n", | ||
" intensity_target=intensity_target,\n", | ||
" target_indices=(1)\n", | ||
" )\n", | ||
" plot_stim(stim)\n", | ||
"\n", | ||
"\n", | ||
"out = iw.interactive_output(show_circular,\n", | ||
" {\n", | ||
" \"height\": w_height,\n", | ||
" \"width\": w_width,\n", | ||
" \"ppd\": w_ppd,\n", | ||
" \"frequency\": w_freq,\n", | ||
" \"intensity_background\": w_iback,\n", | ||
" \"intensity_disc1\": w_idisc1,\n", | ||
" \"intensity_disc2\": w_idisc2,\n", | ||
" \"intensity_target\": w_itarget,\n", | ||
" })\n", | ||
"\n", | ||
"display(ui, out)\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# radial_white" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from stimuli.illusions.circular import radial_white" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Parameterization" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"params = {\n", | ||
" \"visual_size\": (10., 10.),\n", | ||
" \"ppd\": 40.0,\n", | ||
" \"n_segments\": 6,\n", | ||
" \"rotate\": 0*np.pi,\n", | ||
" \"target_width\": 2.,\n", | ||
" \"target_center\": 2.5,\n", | ||
" \"intensity_slices\": (0., 1.),\n", | ||
" \"intensity_background\": 0.5,\n", | ||
" \"intensity_target\": 0.5,\n", | ||
" \"target_indices\": (0, 3),\n", | ||
"}\n", | ||
"\n", | ||
"stim = radial_white(**params)\n", | ||
"plot_stim(stim)\n", | ||
"plt.show()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"It is possible to place as many targets as there are segments by providing a list of `target_indices`.\n", | ||
"The indices refer to the segments starting at the top and then going counter-clockwise." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"params = {\n", | ||
" \"visual_size\": (10., 10.),\n", | ||
" \"ppd\": 40.0,\n", | ||
" \"n_segments\": 10,\n", | ||
" \"rotate\": 0*np.pi,\n", | ||
" \"target_width\": 2.,\n", | ||
" \"target_center\": 2.5,\n", | ||
" \"intensity_slices\": (0., 1.),\n", | ||
" \"intensity_background\": 0.5,\n", | ||
" \"intensity_target\": 0.5,\n", | ||
"}\n", | ||
"\n", | ||
"stim1 = radial_white(**params, target_indices=(0, 2, 4, 6, 8))\n", | ||
"stim2 = radial_white(**params, target_indices=(1, 3, 5, 7, 9))\n", | ||
"\n", | ||
"plot_stimuli({\"Example 1\": stim1, \"Example 2\": stim2})\n", | ||
"plt.show()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Interactive" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# Define widgets\n", | ||
"w_height = iw.IntSlider(value=10, min=10, max=30, description=\"height [deg]\")\n", | ||
"w_width = iw.IntSlider(value=10, min=10, max=30, description=\"width [deg]\")\n", | ||
"w_ppd = iw.IntSlider(value=40, min=1, max=60, description=\"ppd\")\n", | ||
"w_size = iw.HBox([w_height, w_width, w_ppd])\n", | ||
"w_segments = iw.IntSlider(value=8, min=2, max=20, step=2, description=\"No segments\")\n", | ||
"w_rotate = iw.FloatSlider(value=0, min=0, max=360, description=\"rotation [deg]\")\n", | ||
"w_seg = iw.HBox([w_segments, w_rotate])\n", | ||
"w_twidth = iw.FloatSlider(value=2, min=0, max=4, description=\"target width [deg]\")\n", | ||
"w_tcenter = iw.FloatSlider(value=2.5, min=0, max=4, description=\"target center [deg]\")\n", | ||
"w_tplace = iw.HBox([w_twidth, w_tcenter])\n", | ||
"w_islice1 = iw.FloatSlider(value=0.0, min=0., max=1.0, description=\"intensity slice 1\")\n", | ||
"w_islice2 = iw.FloatSlider(value=1.0, min=0., max=1.0, description=\"intensity slice 2\")\n", | ||
"w_iback = iw.FloatSlider(value=0.5, min=0., max=1.0, description=\"intensity background\")\n", | ||
"w_itarget = iw.FloatSlider(value=0.5, min=0., max=1.0, description=\"intensity target\")\n", | ||
"w_intensities = iw.HBox([w_islice1, w_islice2, w_iback, w_itarget])\n", | ||
"\n", | ||
"ui = iw.VBox([w_size, w_seg, w_tplace, w_intensities])\n", | ||
"\n", | ||
"def show_radial(\n", | ||
" height=None,\n", | ||
" width=None,\n", | ||
" ppd=None,\n", | ||
" n_segments=None,\n", | ||
" rotate=None,\n", | ||
" target_width=None,\n", | ||
" target_center=None,\n", | ||
" intensity_slice1=None,\n", | ||
" intensity_slice2=None,\n", | ||
" intensity_background=None,\n", | ||
" intensity_target=None, \n", | ||
"):\n", | ||
"\n", | ||
" stim = radial_white(\n", | ||
" visual_size=(height, width),\n", | ||
" ppd=ppd,\n", | ||
" n_segments=n_segments,\n", | ||
" rotate=rotate / 180 * np.pi,\n", | ||
" target_width=target_width,\n", | ||
" target_center=target_center,\n", | ||
" intensity_background=intensity_background,\n", | ||
" intensity_slices=(intensity_slice1, intensity_slice2),\n", | ||
" intensity_target=intensity_target,\n", | ||
" target_indices=(0)\n", | ||
" )\n", | ||
" plot_stim(stim)\n", | ||
"\n", | ||
"\n", | ||
"out = iw.interactive_output(show_radial,\n", | ||
" {\n", | ||
" \"height\": w_height,\n", | ||
" \"width\": w_width,\n", | ||
" \"ppd\": w_ppd,\n", | ||
" \"n_segments\": w_segments,\n", | ||
" \"rotate\": w_rotate,\n", | ||
" \"target_width\": w_twidth,\n", | ||
" \"target_center\": w_tcenter,\n", | ||
" \"intensity_background\": w_iback,\n", | ||
" \"intensity_slice1\": w_islice1,\n", | ||
" \"intensity_slice2\": w_islice2,\n", | ||
" \"intensity_target\": w_itarget,\n", | ||
" })\n", | ||
"\n", | ||
"display(ui, out)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3 (ipykernel)", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.7.13" | ||
}, | ||
"toc": { | ||
"base_numbering": 1, | ||
"nav_menu": {}, | ||
"number_sections": true, | ||
"sideBar": true, | ||
"skip_h1_title": false, | ||
"title_cell": "Table of Contents", | ||
"title_sidebar": "Contents", | ||
"toc_cell": false, | ||
"toc_position": {}, | ||
"toc_section_display": true, | ||
"toc_window_display": false | ||
}, | ||
"vscode": { | ||
"interpreter": { | ||
"hash": "d79f930315d22092267204fc095ece7b80c939bb23fde6f7397d8c6352112825" | ||
} | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |