Experiment crashes after the loop ends

OS (e.g. Win10): MacOS Sonoma 14.4
PsychoPy version (e.g. 1.84.x): v2023.2.3
**Standard Standalone? y ** If not then what?:
What are you trying to achieve?:

Hello! I am trying to create an experiment where the task is to tap along to a 30s long rhythm sequence using the spacebar. There are meant to be 6 conditions with 4 repetitions. I am interested in the reaction time of the keypresses and the experiment runs fine until the final trial of the loop. It just crashes.

What did you try to make it work?:

I added this code

Begin Experiment

response_clock = core.Clock() # Create a clock object for measuring response time

Each Frame

keys = event.getKeys([‘space’]) # Check for spacebar press
if ‘space’ in keys: # Assuming ‘space’ is the key for the participant’s response
reaction_time = response_clock.getTime() # Get the reaction time
print(“Reaction Time:”, reaction_time) # Print the reaction time

What specifically went wrong when you tried that?:
Include pasted full error message if possible.

I get these errors:

ioHub Server Process Completed With Code: 0
File “/Users/andreachavez/Documents/PsychoPy/RPE/RPECoded_lastrun.py”, line 1648, in
run(
File “/Users/andreachavez/Documents/PsychoPy/RPE/RPECoded_lastrun.py”, line 1317, in run
trials.saveAsText(filename + ‘trials.csv’, delim=‘,’,
File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.8/psychopy/data/base.py”, line 201, in saveAsText
dataArray = self._createOutputArray(stimOut=stimOut,
File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.8/psychopy/data/trial.py”, line 444, in _createOutputArray
tup = eval(strVersion) # convert back to a tuple
File “”, line 1
[, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ]
^
SyntaxError: invalid syntax
################# Experiment ended with exit code 1 [pid:4581] #################

Can anyone help please?

Hi,
The error may be due to incorrect data formatting or structure during saving. Try to verify your data-saving logic and format variables and strings.
Hope this helps.

I have a similar error - what ways are there to check the data formatting / structure during saving?

Do you have any routines following the loop? If so, and they aren’t reached then I suspect that the error may be in the loop’s spreadsheet (e.g. some blank rows). Is the loop set to sequential? If I’m right and you set it to random, the crash will happen at a random point rather than at the end.

Dear @wakecarter,

thank you for your reply and sorry for the delay in responding. First, I have been able to resolve the error (yet, I don’t understand why this solves the error), that is, if I use psychopy version 2023.1.0 or earlier, it works fine, yet, when I select any later version in the “use psychpy version” settings (2023.1.3 is the next one), it crashes with the following error message:

C:\Users\merzs\AppData\Roaming\psychopy3\versions\psychopy\data\trial.py", line 444, in _createOutputArray
tup = eval(strVersion) # convert back to a tuple
File “”, line 1
[, ]
^
SyntaxError: invalid syntax
################ Experiment ended with exit code 1 [pid:14112] #################

It seems to me that between the two versions some update of handling loop information was introducted, which led to these errors.

Regarding your questions:

Do you have any routines following the loop? If so, and they aren’t reached then I suspect that the error may be in the loop’s spreadsheet (e.g. some blank rows).

Yes, there are routines, yet, I don’t think this is the problem. That is, I have a two loop structure - one inner loop, selecting the exact trial procedure, and then an outer loop structure defining the relevant block information (here, if it is a practice or experimental block, how many trials for each block and so forth). Error occurs after the practice trials are finished, so the inner loop runs as should eight times, but when the next block (experimental block) should start, this routine is not shown (although this is a routine I also presented before practice block, and here it worked fine…). I checked the excel sheets and could not spot any additional / empty / blank row (I saved them in .cvs and then opened the file in editor to see if any additional / empty rows / colums are included).

Is the loop set to sequential? If I’m right and you set it to random, the crash will happen at a random point rather than at the end.

And yes, the outer loop is set to sequential. If random is selected, the error occurs later (yet, i don’t see a systematic in when it crashes…). Is this what you have expected?

I can upload the Exp if someone wants to explore this in detail, but perhaps the information about the working Version was enough to spot the problem?