Skip to content

Commit

Permalink
closes #15; updated plot_stim(uli) and all scripts that use them; add…
Browse files Browse the repository at this point in the history
…ed to_img()
  • Loading branch information
LynnSchmittwilken committed Dec 9, 2022
1 parent 3056654 commit 78e400e
Show file tree
Hide file tree
Showing 23 changed files with 194 additions and 104 deletions.
35 changes: 32 additions & 3 deletions demo/noises/narrowband.ipynb
Expand Up @@ -55,7 +55,7 @@
"}\n",
"\n",
"stim = narrowband(**params)\n",
"plot_stim(stim)\n",
"plot_stim(stim, vmin=stim[\"intensity_range\"][0], vmax=stim[\"intensity_range\"][1])\n",
"plt.show()"
]
},
Expand Down Expand Up @@ -101,7 +101,7 @@
" bandwidth=bandwidth,\n",
" rms_contrast=rms_contrast\n",
" )\n",
" plot_stim(stim)\n",
" plot_stim(stim, vmin=-3, vmax=3)\n",
"\n",
"\n",
"out = iw.interactive_output(show_noise,\n",
Expand Down Expand Up @@ -222,7 +222,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.13"
"version": "3.10.6"
},
"toc": {
"base_numbering": 1,
Expand All @@ -237,6 +237,35 @@
"toc_section_display": true,
"toc_window_display": false
},
"varInspector": {
"cols": {
"lenName": 16,
"lenType": 16,
"lenVar": 40
},
"kernels_config": {
"python": {
"delete_cmd_postfix": "",
"delete_cmd_prefix": "del ",
"library": "var_list.py",
"varRefreshCmd": "print(var_dic_list())"
},
"r": {
"delete_cmd_postfix": ") ",
"delete_cmd_prefix": "rm(",
"library": "var_list.r",
"varRefreshCmd": "cat(var_dic_list()) "
}
},
"types_to_exclude": [
"module",
"function",
"builtin_function_or_method",
"instance",
"_Feature"
],
"window_display": false
},
"vscode": {
"interpreter": {
"hash": "d79f930315d22092267204fc095ece7b80c939bb23fde6f7397d8c6352112825"
Expand Down
8 changes: 4 additions & 4 deletions demo/noises/one_over_frequency.ipynb
Expand Up @@ -54,7 +54,7 @@
"}\n",
"\n",
"stim = one_over_f(**params)\n",
"plot_stim(stim)\n",
"plot_stim(stim, vmin=stim[\"intensity_range\"][0], vmax=stim[\"intensity_range\"][1])\n",
"plt.show()"
]
},
Expand Down Expand Up @@ -97,7 +97,7 @@
" exponent=exponent,\n",
" rms_contrast=rms_contrast\n",
" )\n",
" plot_stim(stim)\n",
" plot_stim(stim, vmin=-3, vmax=3)\n",
"\n",
"\n",
"out = iw.interactive_output(show_noise,\n",
Expand Down Expand Up @@ -192,7 +192,7 @@
"}\n",
"\n",
"stim = pink(**params)\n",
"plot_stim(stim)\n",
"plot_stim(stim, vmin=stim[\"intensity_range\"][0], vmax=stim[\"intensity_range\"][1])\n",
"plt.show()"
]
},
Expand Down Expand Up @@ -235,7 +235,7 @@
"}\n",
"\n",
"stim = brown(**params)\n",
"plot_stim(stim)\n",
"plot_stim(stim, vmin=stim[\"intensity_range\"][0], vmax=stim[\"intensity_range\"][1])\n",
"plt.show()"
]
}
Expand Down
35 changes: 32 additions & 3 deletions demo/noises/white.ipynb
Expand Up @@ -53,7 +53,7 @@
"}\n",
"\n",
"stim = white(**params)\n",
"plot_stim(stim)\n",
"plot_stim(stim, vmin=stim[\"intensity_range\"][0], vmax=stim[\"intensity_range\"][1])\n",
"plt.show()"
]
},
Expand Down Expand Up @@ -91,7 +91,7 @@
" ppd=ppd,\n",
" rms_contrast=rms_contrast\n",
" )\n",
" plot_stim(stim)\n",
" plot_stim(stim, vmin=-2, vmax=2)\n",
"\n",
"\n",
"out = iw.interactive_output(show_noise,\n",
Expand Down Expand Up @@ -170,7 +170,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.13"
"version": "3.10.6"
},
"toc": {
"base_numbering": 1,
Expand All @@ -185,6 +185,35 @@
"toc_section_display": true,
"toc_window_display": false
},
"varInspector": {
"cols": {
"lenName": 16,
"lenType": 16,
"lenVar": 40
},
"kernels_config": {
"python": {
"delete_cmd_postfix": "",
"delete_cmd_prefix": "del ",
"library": "var_list.py",
"varRefreshCmd": "print(var_dic_list())"
},
"r": {
"delete_cmd_postfix": ") ",
"delete_cmd_prefix": "rm(",
"library": "var_list.r",
"varRefreshCmd": "cat(var_dic_list()) "
}
},
"types_to_exclude": [
"module",
"function",
"builtin_function_or_method",
"instance",
"_Feature"
],
"window_display": false
},
"vscode": {
"interpreter": {
"hash": "d79f930315d22092267204fc095ece7b80c939bb23fde6f7397d8c6352112825"
Expand Down
5 changes: 1 addition & 4 deletions stimuli/illusions/angular.py
Expand Up @@ -135,13 +135,10 @@ def radial_white(


if __name__ == "__main__":
import matplotlib.pyplot as plt

from stimuli.utils import plot_stimuli

stims = {
"Radial white": radial_white(visual_size=(8, 8), ppd=32, n_segments=8),
}

plot_stimuli(stims, mask=False)
plt.show()
plot_stimuli(stims, mask=True, save=None)
4 changes: 1 addition & 3 deletions stimuli/illusions/benary_cross.py
Expand Up @@ -614,7 +614,6 @@ def todorovic_benary_triangles(


if __name__ == "__main__":
import matplotlib.pyplot as plt
from stimuli.utils import plot_stimuli

stims = {
Expand All @@ -625,5 +624,4 @@ def todorovic_benary_triangles(
"Todorovic' Benary - rectangles": todorovic_benary_rectangles(),
"Todorovic' Benary - triangles": todorovic_benary_triangles(),
}
ax = plot_stimuli(stims)
plt.show()
plot_stimuli(stims, mask=True, save=None)
6 changes: 1 addition & 5 deletions stimuli/illusions/checkerboards.py
Expand Up @@ -307,11 +307,8 @@ def contrast_contrast(


if __name__ == "__main__":
import matplotlib.pyplot as plt
from stimuli.utils import plot_stimuli

DEFAULT_PPD = 32

stims = {
"Checkerboard (brightness)": checkerboard(
ppd=32,
Expand All @@ -323,5 +320,4 @@ def contrast_contrast(
ppd=32, board_shape=(8, 8), check_visual_size=(2, 2), target_shape=(4, 4)
),
}
ax = plot_stimuli(stims, mask=False)
plt.show()
plot_stimuli(stims, mask=True, save=None)
5 changes: 1 addition & 4 deletions stimuli/illusions/circular.py
Expand Up @@ -207,14 +207,11 @@ def circular_bullseye(


if __name__ == "__main__":
import matplotlib.pyplot as plt

from stimuli.utils import plot_stimuli

stims = {
"Circular Whites": circular_white(visual_size=(8, 8), ppd=32, frequency=1.0),
"Circular Bullseye": circular_bullseye(visual_size=(8, 8), ppd=32, frequency=1.0),
}

plot_stimuli(stims, mask=False)
plt.show()
plot_stimuli(stims, mask=True, save=None)
4 changes: 1 addition & 3 deletions stimuli/illusions/cornsweet.py
Expand Up @@ -88,9 +88,7 @@ def cornsweet(


if __name__ == "__main__":
import matplotlib.pyplot as plt
from stimuli.utils import plot_stim

stim = cornsweet()
plot_stim(stim, stim_name="Cornsweet illusion")
plt.show()
plot_stim(stim, stim_name="Cornsweet illusion", mask=True, save=None)
4 changes: 1 addition & 3 deletions stimuli/illusions/cube.py
Expand Up @@ -170,9 +170,7 @@ def cube_illusion(


if __name__ == "__main__":
import matplotlib.pyplot as plt
from stimuli.utils import plot_stim

stim = cube_illusion()
plot_stim(stim, stim_name="Cube illusion")
plt.show()
plot_stim(stim, stim_name="Cube illusion", mask=True, save=None)
4 changes: 1 addition & 3 deletions stimuli/illusions/dungeon.py
Expand Up @@ -69,9 +69,7 @@ def dungeon_illusion(


if __name__ == "__main__":
import matplotlib.pyplot as plt
from stimuli.utils import plot_stim

stim = dungeon_illusion()
plot_stim(stim, stim_name="Dungeon illusion")
plt.show()
plot_stim(stim, stim_name="Dungeon illusion", mask=True, save=None)
10 changes: 10 additions & 0 deletions stimuli/illusions/frames.py
Expand Up @@ -160,3 +160,13 @@ def bullseye(
)

return stim


if __name__ == "__main__":
from stimuli.utils import plot_stimuli

stims = {
"Frames": frames(visual_size=10, ppd=10, frequency=0.5, target_indices=(1, 3)),
"Bullseye": bullseye(visual_size=10, ppd=10, frequency=0.5),
}
plot_stimuli(stims, mask=True, save=None)
5 changes: 1 addition & 4 deletions stimuli/illusions/grating.py
Expand Up @@ -447,8 +447,6 @@ def grating_induction(


if __name__ == "__main__":
import matplotlib.pyplot as plt

from stimuli.utils import plot_stimuli

ppd = 36
Expand Down Expand Up @@ -496,5 +494,4 @@ def grating_induction(
),
}

plot_stimuli(stims, mask=False)
plt.show()
plot_stimuli(stims, mask=True, save=None)
4 changes: 1 addition & 3 deletions stimuli/illusions/hermann.py
Expand Up @@ -64,9 +64,7 @@ def hermann_grid(


if __name__ == "__main__":
import matplotlib.pyplot as plt
from stimuli.utils import plot_stim

stim = hermann_grid()
plot_stim(stim, stim_name="Hermann Grid")
plt.show()
plot_stim(stim, stim_name="Hermann Grid", mask=True, save=None)
5 changes: 1 addition & 4 deletions stimuli/illusions/mondrians.py
Expand Up @@ -125,10 +125,7 @@ def corrugated_mondrians(


if __name__ == "__main__":
import matplotlib.pyplot as plt
from stimuli.utils import plot_stim

stim = corrugated_mondrians()

plot_stim(stim)
plt.show()
plot_stim(stim, stim_name="Corrugated mondrians", mask=True, save=None)
9 changes: 3 additions & 6 deletions stimuli/illusions/sbc.py
Expand Up @@ -13,7 +13,7 @@
]

def simultaneous_contrast_generalized(
visual_size=(2.0, 2.0),
visual_size=(4.0, 6.0),
ppd=10,
target_size=(2.0, 2.0),
target_position=(1.0, 1.0),
Expand Down Expand Up @@ -335,15 +335,12 @@ def dotted_sbc(


if __name__ == "__main__":
import matplotlib.pyplot as plt

from stimuli.utils import plot_stimuli

stims = {
"SBC - generalized": simultaneous_contrast_generalized(),
"SBC": simultaneous_contrast(),
"SBC with dots": sbc_with_dots(),
"Dotted SBC": dotted_sbc(),
}

plot_stimuli(stims, mask=True)
plt.show()
plot_stimuli(stims, mask=True, save=None)
5 changes: 1 addition & 4 deletions stimuli/illusions/todorovic.py
Expand Up @@ -351,8 +351,6 @@ def todorovic_cross(


if __name__ == "__main__":
import matplotlib.pyplot as plt

from stimuli.utils import plot_stimuli

stims = {
Expand All @@ -361,5 +359,4 @@ def todorovic_cross(
"Todorovic cross": todorovic_cross(),
"Todorovic cross, flex": todorovic_cross_generalized(),
}
plot_stimuli(stims)
plt.show()
plot_stimuli(stims, mask=True, save=None)
4 changes: 1 addition & 3 deletions stimuli/illusions/wedding_cake.py
Expand Up @@ -156,12 +156,10 @@ def wedding_cake_stimulus(


if __name__ == "__main__":
import matplotlib.pyplot as plt
from stimuli.utils import plot_stimuli

stims = {
"Wedding cake new": wedding_cake_stimulus(),
}

plot_stimuli(stims, mask=False)
plt.show()
plot_stimuli(stims, mask=False, save=None)
7 changes: 2 additions & 5 deletions stimuli/illusions/whites.py
Expand Up @@ -22,7 +22,7 @@ def white_generalized(
target_indices=(2, 5, 8, 11, 14),
target_center_offsets=(3, 1.5, 0, -1.5, -3),
target_sizes=(0.1, 0.2, 0.4, 0.8, 1),
period="full",
period="ignore",
):
"""
White's stimulus
Expand Down Expand Up @@ -598,8 +598,6 @@ def white_yazdanbakhsh(


if __name__ == "__main__":
import matplotlib.pyplot as plt

from stimuli.utils import plot_stimuli

stims = {
Expand All @@ -611,5 +609,4 @@ def white_yazdanbakhsh(
"Howe's variation": white_howe(),
}

plot_stimuli(stims, mask=False)
plt.show()
plot_stimuli(stims, mask=False, save=None)

0 comments on commit 78e400e

Please sign in to comment.