I’m new to PsychoPy and Python in general and am working mostly in the Builder (v1.90.0, Win10). I created a loop that randomly selects one sound out of a set of 12 (each having a unique duration), waits for the participant’s response, and then repeats this process until all sounds have been played.
However, I’ve run into some problems with setting this up properly in the Builder. When I leave the ‘duration’ box of the sound component empty (as the tooltip in PsychoPy suggests), the experiment does not run and I get the following error message:
Traceback (most recent call last):
File “C:\Program Files (x86)\PsychoPy2\lib\site-packages\psychopy\app\builder\builder.py”, line 2039, in runFile
script = self.generateScript(self.exp.expPath)
File “C:\Program Files (x86)\PsychoPy2\lib\site-packages\psychopy\app\builder\builder.py”, line 2247, in generateScript
File “C:\Program Files (x86)\PsychoPy2\lib\site-packages\psychopy\experiment_experiment.py”, line 140, in writeScript
File “C:\Program Files (x86)\PsychoPy2\lib\site-packages\psychopy\experiment\flow.py”, line 241, in writeBody
File “C:\Program Files (x86)\PsychoPy2\lib\site-packages\psychopy\experiment\routine.py”, line 99, in writeInitCode
File “C:\Program Files (x86)\PsychoPy2\lib\site-packages\psychopy\experiment\components\sound_init_.py”, line 65, in writeInitCode
if float(inits[‘stopVal’].val) > 2:
ValueError: could not convert string to float: None
If I do put in a random value (e.g. 10 seconds) in the duration box, it seems to work fine. At least in the sense that all of the files are being played. The problem is, however, that when I set the same fixed duration time for all of the files I’m unable to reliably measure response time, since the onset of the key response component is set to trigger after the sound file has been played (I want to measure how quickly the participants press a key after they’ve heard the sound).
The strange thing is that when I do same in the coder view, the experiment seems to run just fine. I did notice, however, that the response key component is not working as I intended: it seems to start with the onset of the sound file and not after the sound has played. But maybe this is because I did something wrong in the code? This is how I tried to set it up (key_resp_4 is the key response component and warmup_sentence is the sound component):
if t >= 1.0 and key_resp_4.status == NOT_STARTED:
key_resp_4.tStart = warmup_sentence.status == FINISHED
key_resp_4.frameNStart = frameN
key_resp_4.status = STARTED
if key_resp_4.status == STARTED:
theseKeys = event.getKeys(keyList=[‘left’, ‘right’])
I’d appreciate any advice on how to solve these issues. Thanks!