Introducing random length delays into an experiment

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

OS (e.g. Win10): W11
PsychoPy version (e.g. 1.84.x): 2.03
Standard Standalone? (y/n) Standalone
What are you trying to achieve?: I’m trying to create a task with random sounds interspersed with random delays

What did you try to make it work?:
I created silent WAV files of different durations that were selected randomly from a conditions spreadsheet as the sounds were
What specifically went wrong when you tried that?: The delays were not of the durations hoped for

Hi again folks. I’m trying to create an experiment where random sounds are replayed to a participant, with random delays of between thirty and sixty seconds between each sound. Can anyone give me a pointer to a way of creating these random delays? I tried alternating the sounds with wav files of silence of different lengths but although this seemed to work as required during testing when I had built the WAVs between one and ten seconds in length, on scaling up the experiment to the specification I have been given, the delays don’t seem to be being reproduced accurately. I hope this isn’t a stupid question, I’m rather a beginner with Psychopy and don’t know Python, though I have done a lot of coding with other languages and IDEs. I’ve done some searches on the forum here and elsewhere and checked the “Building Experiments in Psychopy” book, but not found anything suitable about creating random delays, so I was wondering if anyone had any advice? I’m grateful for any pointers, thanks in advance.

For a random delay I would insert a routine containing a blank text component of duration 30 + 30 * random()

Alternatively you could set the value in a code component and then set the duration of the text component to the variable name.

1 Like

Thanks again Wakefield, I’ll give that a try. :smiley:
Cheers
Rob

Hi again Wakefield, just wanted to let you know that the second method seemed to work best, really grateful for the advice, again. Thanks! :smiley:

1 Like