Skip to content

Commit

Permalink
Raise error if target(s) fit in board
Browse files Browse the repository at this point in the history
  • Loading branch information
JorisVincent committed Oct 7, 2022
1 parent ba64cda commit 6e898c3
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions stimuli/illusions/checkerboards.py
Expand Up @@ -4,13 +4,24 @@


def mask_from_idx(checkerboard_stim, check_idc):
board_shape = checkerboard_stim["board_shape"]

check_size = checkerboard_stim["check_visual_size"]
ppd = checkerboard_stim["ppd"]

check_size_px = resolution.shape_from_visual_size_ppd(check_size, ppd)

mask = np.zeros(checkerboard_stim["shape"])
for coords in check_idc:
if (
coords[0] < 0
or coords[0] > coords[0]
or coords[1] < 0
or coords[1] > board_shape[1]
):
raise ValueError(
f"Cannot provide mask for check {coords} outside board {board_shape}"
)
ypos = int(coords[0] * check_size_px.height)
xpos = int(coords[1] * check_size_px.width)
mask[
Expand Down

0 comments on commit 6e898c3

Please sign in to comment.