0

We are trying to recreate a 3x3 grid of simultaneous windows in PsychoPy, each displaying a radial optic flow pattern, as described by Cardin and Smith (2010). When we run the code the stimuli is too slow (taking a while to load). How can this be sped up? Would doing a single flip after drawing each of the windows help?

Cardin & Smith, 2010; Sensitivity of human visual and vestibular cortical regions to egomotion-compatible visual stimulation. Cerebral Cortex

1 Answers1

2

The details in the paper are quite sparse but just to make sure: you probably don't want to draw 9 different Windows but rather 9 different stimuli within the same (full screen) window. So I'd do something like this:

import random
from psychopy import visual
win = visual.Window()

# Create 9 dotstims
stims = []
for xPos in range(-1, 2):
    for yPos in range(-1, 2):
        stims += [visual.DotStim(win, fieldPos=(xPos, yPos), fieldShape='circle', dotLife=30, speed=0.01, fieldSize = 0.2, nDots=50, dir=random.randint(0, 359))]

# Draw for 120 frames
for frame in range(120):
    for stim in stims:
        stim.draw()
    win.flip()

You may want to change the dir values to something more systematic than just random values as the above example and fieldPos as well. Performance-wise this is a bit borderline on my laptop as the maximum duration of the draws are 11.5 ms. This is dangerously close to 16.667 ms but you can test it for yourself on your stimulus computer. Just put

from psychopy import core
timerClock = core.Clock()

in the beginning of the script and then have use the following to loop over frames:

for frame in range(120):
    timerClock.reset()
    for stim in stims:
        stim.draw()
    print timerClock.getTime()  # should be consistently below 0.016 seconds on a 60 Hz monitor.
    win.flip()
Jonas Lindeløv
  • 5,442
  • 6
  • 31
  • 54