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
1e1da01
commit b2653bd
Showing
1 changed file
with
134 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,134 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# Grating parameters" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import IPython\n", | ||
"import ipywidgets as iw\n", | ||
"from stimuli.utils import plot_stimuli" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from stimuli.components.components import resolve_grating_params\n", | ||
"help(resolve_grating_params)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# Define widgets\n", | ||
"w_length = iw.IntSlider(value=8.0, min=1, max=10, description=\"heigh/width [deg]\")\n", | ||
"w_ppd = iw.IntSlider(value=32, min=1, max=64, description=\"ppd\")\n", | ||
"\n", | ||
"w_frequency = iw.FloatSlider(value=2.0, min=0.1, max=3.0, description=\"frequency\")\n", | ||
"w_phases = iw.IntSlider(value=4, min=0, max=10, description=\"N phases\")\n", | ||
"w_phase_width = iw.FloatSlider(value=1.0, min=0., max=4.0, description=\"phase_width\")\n", | ||
"w_use_which = iw.SelectMultiple(options=['frequency', 'n_phases', 'phase_width'], value=['n_phases'], description='use param(s):')\n", | ||
"\n", | ||
"w_period = iw.ToggleButtons(options=[\"ignore\", \"full\", \"half\"], value=\"ignore\", button_style=\"\", description=\"ensure period\")\n", | ||
"\n", | ||
"# Layout\n", | ||
"b_resolution = iw.HBox([w_length, w_ppd])\n", | ||
"b_grating_params = iw.VBox([iw.HBox([w_use_which, iw.VBox([w_frequency, w_phases, w_phase_width])]),w_period])\n", | ||
"ui = iw.VBox([b_resolution, b_grating_params])\n", | ||
"\n", | ||
"# Function for resolving\n", | ||
"def resolve_params(\n", | ||
" length=None,\n", | ||
" visual_angle=None,\n", | ||
" ppd=None,\n", | ||
" frequency=None,\n", | ||
" n_phases=None,\n", | ||
" phase_width=None,\n", | ||
" period=\"ignore\",\n", | ||
" use_params=None,\n", | ||
"):\n", | ||
" params = resolve_grating_params(\n", | ||
" length=length,\n", | ||
" visual_angle=visual_angle,\n", | ||
" ppd=ppd,\n", | ||
" frequency=frequency if \"frequency\" in use_params else None,\n", | ||
" n_phases=n_phases if \"n_phases\" in use_params else None,\n", | ||
" phase_width=phase_width if \"phase_width\" in use_params else None,\n", | ||
" period=period,\n", | ||
" )\n", | ||
" print(params)\n", | ||
"\n", | ||
"\n", | ||
"# Set interactivity\n", | ||
"out = iw.interactive_output(\n", | ||
" resolve_params,\n", | ||
" {\n", | ||
" \"visual_angle\": w_length,\n", | ||
" \"ppd\": w_ppd,\n", | ||
" \"frequency\": w_frequency,\n", | ||
" \"n_phases\": w_phases,\n", | ||
" \"phase_width\": w_phase_width,\n", | ||
" \"period\": w_period,\n", | ||
" \"use_params\": w_use_which,\n", | ||
" },\n", | ||
")\n", | ||
"\n", | ||
"# Show\n", | ||
"display(ui, out)" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3.10.5 64-bit ('stimuli-dev')", | ||
"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.10.5" | ||
}, | ||
"toc": { | ||
"base_numbering": 1, | ||
"nav_menu": {}, | ||
"number_sections": true, | ||
"sideBar": true, | ||
"skip_h1_title": true, | ||
"title_cell": "Contents", | ||
"title_sidebar": "Contents", | ||
"toc_cell": true, | ||
"toc_position": {}, | ||
"toc_section_display": true, | ||
"toc_window_display": true | ||
}, | ||
"vscode": { | ||
"interpreter": { | ||
"hash": "d79f930315d22092267204fc095ece7b80c939bb23fde6f7397d8c6352112825" | ||
} | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |