Looking for advice and help writing oddball programs

If this template helps then use it. If not then just delete and start from scratch.

OS mac 13.4 (22F66)
PsychoPy version 2023.2.1
Standard Standalone? (y/n) Y
What are you trying to achieve?:
I want to write a program for an oddball task, divided into four parts.

  1. The first part is an instruction phase, where I want to play an instructional audio.
  2. The second part is the standard stimulus phase, including 60 sound stimuli “ba,” each lasting 500ms, with a variable ISI (Inter-Stimulus Interval) between 200ms to 700ms. This part should have a total duration of 60 seconds.
  3. The third part is the deviant stimulus phase, including 60 sound stimuli, with 80% “ba” and 20% “da,” each lasting 500ms. The ISI should be variable, and this part should also have a total duration of 60 seconds.
  4. The fourth part plays the instructional audio again.

I’m looking for suggestions on how to implement the variable ISI while keeping the entire block duration fixed. Is it possible to achieve this using the PsychoPy Builder?

What did you try to make it work?:
My current approach is to create a routine for the standard stimulus. In this routine, I would create a sound and a text component, and the text component’s duration would be determined by a condition. Then, I would create a loop and import a condition file. This seems like it could achieve variable ISIs, but it may be challenging to ensure the entire block duration is exactly 60 seconds.

I also noticed the “TrialHandlerExt,” which seems helpful for oddball paradigms. Is it possible to use this functionality in the PsychoPy Builder?

I’ve searched the forum for all ISI-related questions but still haven’t found a good solution. Does anyone have any suggestions? I’m open to advice for both the Builder and coder approaches.