Skip to content

Commit

Permalink
adapted herman grid to repo-use
Browse files Browse the repository at this point in the history
  • Loading branch information
LynnSchmittwilken committed Jun 30, 2022
1 parent 042dae1 commit f4f6e49
Showing 1 changed file with 38 additions and 13 deletions.
51 changes: 38 additions & 13 deletions stimuli/illusions/hermann.py
@@ -1,19 +1,44 @@
import numpy as np
from stimuli.utils import degrees_to_pixels


def hermann_grid(
ppd=10,
grid_size=(10, 10),
element_size=(1.5, 1.5, 0.2),
vback=0.,
vgrid=1.
):
"""
Hermann grid
Parameters
----------
ppd : int
pixels per degree (visual angle)
grid_shape : (float, float)
height and width of grid in degree visual angle
element_size : (float, float, float)
height, width and thickness of individual elements in degree visual angle
vback : float
value of background
vgrid : float
value of grid
Returns
-------
A stimulus dictionary with the stimulus ['img'] and target mask ['mask']
"""

grid_height, grid_width = degrees_to_pixels(grid_size, ppd)
element_height, element_width, element_thick = degrees_to_pixels(element_size, ppd)

img = np.ones([grid_height, grid_width], dtype=np.float32) * vback
for i in range(element_thick):
img[i::element_height, :] = vgrid
img[:, i::element_width] = vgrid


###################################
# Hermann Grid #
###################################
def hermann_grid(n_grid=100, space=5):
# TODO: the parameters aren't analogous to the other stimuli

grid = np.zeros([n_grid, n_grid], dtype=np.float32)
grid[::space, :] = 1
grid[:, ::space] = 1

img = grid
mask = None # TODO add this

return {"img": img, "mask": mask}


Expand Down

0 comments on commit f4f6e49

Please sign in to comment.