Flashing checkerboard with overlying/drifting window

having spent a few days searching for this and coming up empty, can i emplore someone far more capable than i to help me create a full screen checkerboard pattern. i would then like to have an overlying window that reveals only a portion of the underlying checkerboard pattern (for example a rectangle). and then move that rectangle across the screen. this is a standard intrinsic signal imaging visual stimulus. i am a biologist. not a coder. but i’m trying to learn. many, many thanks!

Hi @jtrex, are you after something like below, or something more like a chess board?

hi david, thank you for your reply.
here’s some code that makes a vertical rectangle drift across the screen.
i would like that the rectangle was transparent, revealing an underlying chess board layer.

import os
from psychopy import visual, event, core

win = visual.Window(size=(960,600), units = ‘pix’, color = ‘black’) # Set the window

x = -480 # initial positions
y = 0

create rectangle

square = visual.Rect(win, height=500, width=40, fillColor=‘white’)
while True: # draw moving stimulus

x += 2 # drift right; should take 8 seconds to move across screen
square.pos = [x, y] #  update x, y
square.draw()
win.flip() # make the drawn things visible
if x == 480: x=-480

win.close()
core.quit()

Thanks, I understand the need for the moving window, but first I wanted to make sure that the checkerboard above is the type of stimuli you require

hi David, a simple black and white chessboard would be perfect.

Great, then try the following. In the attached Builder file, there is a grating stim which draws the checker board. Then, to get the window over the board, add a code component with the following in the mentioned tab:

##### Begin Experiment #####

# Overwrite Builders aperture stim, so you can redefine the shape, size etc
# but leave the drawing and timing to Builder
apertureSize = [.25, .25]
aperture = visual.Aperture(win, size=apertureSize, shape='square', units='height')

The positioning of the aperture is defined in the Builder Aperture component. You could also define it in the code component in the Each Frame tab, e.g., to control with a mouse aperture.pos = mouse.getPos().

I have not included the code component because I am using the pre-release version of PsychoPy, and it has features that will not work on your version (unless you are also using the pre-release version). Position the code component after the other components in the routine. For PsychoPy Builder fundamentals, see Stroop tutorial.

checkerBoard.psyexp (6.6 KB)

1 Like

many thanks. I was not aware of the Aperture option. this simplifies things quite a bit.