From 938faaff10bc3967a499c61409c0bebcc8ef25c2 Mon Sep 17 00:00:00 2001 From: lynnschmittwilken Date: Thu, 30 Jun 2022 17:54:26 +0200 Subject: [PATCH] added checkerboard component --- stimuli/components/components.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/stimuli/components/components.py b/stimuli/components/components.py index 195665b9..dc6b88db 100644 --- a/stimuli/components/components.py +++ b/stimuli/components/components.py @@ -215,3 +215,23 @@ def square_wave( ] stim[:, index] = low if start == "low" else high return (stim, pixels_per_cycle) + + +def checkerboard( + ppd=10, + board_shape=(8, 8), + check_size=1.0, + vcheck1=0.0, + vcheck2=1.0, + ): + + check_size_px = degrees_to_pixels(check_size, ppd) + nchecks_height, nchecks_width = board_shape + + img = np.ndarray((nchecks_height, nchecks_width)) + + for i, j in np.ndindex((nchecks_height, nchecks_width)): + img[i, j] = vcheck1 if i % 2 == j % 2 else vcheck2 + + img = img.repeat(check_size_px, axis=0).repeat(check_size_px, axis=1) + return img