How to use PTB and preschedule sounds in builder


I’m running an experiment where I’m flashing face stimuli at 5.88Hz. At the onset of the stimulus, I have to send tones which will later get read by an EEG machine as markers. So I need really low latencies to be accurate.

I’m using the PTB sound engine and I’m working in the builder.
I’ve created a code component and put in this:

This fixes my latency problem and the experiment runs but now my image stimulus won’t appear. I’m not sure how to fix this, I’m relatively new to psychopy.

I’ve also attached my psychopy (9.5 KB)

Any help will be appreciated. Thanks

  • Please post the .psyexp file rather than the generated .py script.
  • You really shouldn’t be attempting to over-write the window (called win) that Builder creates. What is the intention there? By deleting it and replacing it with your own window with the same name, you’ve broken the link to the destination window that stimuli were created to use (very likely why you can’t see any stimuli).
  • You’re also duplicating imports that Builder already does for you. Open the .py file: you’ll see for example that Builder necessarily imports the visual and sound modules, so you don’t need to do that again in your own custom code. Inspecting the .py file will also show you when the built-in window is created, and when the associated stimuli are created and linked to it. This should help understand why your current custom code is wreaking havoc.

Just out of interest, does your display support that frequency (e.g. by running at 100 Hz)?