| Reference | Downloads | Github

Onset timing for mouse contingent window

Hey there

URL of experiment: (minimal working example)

Description of the problem: I am trying to implement a mouse contingent window. There is a problem though, and I haven’t been able to nail it down yet. In some trials, the aperture (which is implemented as an ImageStim) briefly flashes at the position where the mouse cursor was when the previous trial ended. Here’s a clip that demonstrates this: This is most likely not related to repetitions of images (this also happens in another task I’ve built that does not have any repetitions).

Is there a way to make stim onsets more reliable through the builder/code components to prevent this brief flashing?

Your experiment looks very nice.

I looked at your .psyexp file and everything seems to be correctly specified there.

  • Does this ever happen when testing locally (i.e. in Python), or does it only happen in the online version? i.e. I can’t see anything wrong on the Python side of things, so I wonder if this something specific to PsychoJS.

As a work-around, perhaps insert a code component and in the “begin routine” tab, centre the location of the aperture (i.e. force it to default to the fixation point location), to counter the seemingly random occasions when it doesn’t update properly on the first frame.

Let us know if that does/doesn’t work, but this should probably also be posted as an issue at

1 Like

Thank you so much, this fixed the flashing problem.
The aperture now consistently appears in the center of the screen.

For anyone stumbling across this: all I had to do to fix this problem was insert a code component (or use an existing one for that routine) and enter the following line in the ‘Begin Routine’ tab:

aperture.pos = [0,0]

where aperture is the name of the ImageStim object containing my mask image.

Again, thank you very much, @Michael!