OS (e.g. Win10): Win10
PsychoPy version (e.g. 1.84.x): v2023.3
Standard Standalone? (y/n): y
What are you trying to achieve?: offline
pilot_legacy.psyexp (83.5 KB)
pilot_lastrun.py (80.2 KB)
pilot_legacy.psyexp (83.5 KB)
My experiment was working properly; however, after I added 3 breaks for when a certain this
N was reached using a code component in the end routine of the last routine in the loop (see below), it started crashing after trial 28 (there were 29 trials in total). I had to use code instead of other ways because it was working for assigning the participant to Excel depending on the ExpInfo (5 lists), randomising the stims in that Excel file and retrieving the correct image to display (no repeats).
if Conds.thisN == 12:
break_msg = visual.TextStim(win=win, text=‘Well Done! You are halfway done! Time for a break.’, pos=(0, 0), height=0.05, wrapWidth=None, ori=0.0,
color=[-0.1765, -0.1765, -0.1765], colorSpace=‘rgb’, opacity=None, languageStyle=‘LTR’, depth=0.0)
break_msg.draw()
win.flip()
event.waitKeys()
elif Conds.thisN == 21:
break_msg = visual.TextStim(win=win, text=‘Well Done! You are nearly done! Time for a break.’, pos=(0, 0), height=0.05, wrapWidth=None, ori=0.0,
color=[-0.1765, -0.1765, -0.1765], colorSpace=‘rgb’, opacity=None, languageStyle=‘LTR’, depth=0.0)
break_msg.draw()
win.flip()
event.waitKeys()
if Conds.thisN == 29:
break_msg = visual.TextStim(win=win, text=‘Well Done! You have finished the task. We will now count your coins, you will recieve your gift as soon as possible! Thank you’, pos=(0, 0), height=0.05, wrapWidth=None, ori=0.0,
color=[-0.1765, -0.1765, -0.1765], colorSpace=‘rgb’, opacity=None, languageStyle=‘LTR’, depth=0.0)
break_msg.draw()
win.flip()
event.waitKeys()
What did you try to make it work?:
- I removed code (from break_msg.draw()) to see if that would help. I also tried using this code out of the if statement.
- I also tried removing all the code, just keeping the text and creating a routine ($break_msg). However, this did not work because the routine couldn’t be in the loop, so thisN did not work
- I had one if statement with all the trial breaks, e.g., [6,12, 21]
- I included continueRoutine and then continueRoutine = False for the 29, same problem.
- at the start, I did not have the last code (for 29) and instead had an end routine, so I tried removing that and adding it to the code instead.
I also changed where I put the code, including different routines in and outside the loop and where in the code component, e.g., the start routine, the start of the experiment, and the end routine.
I can’t think of anything else!
What specifically went wrong when you tried that?:
What happens (depending on how I attempt it) is that the breaks work, but then at 28 trials (29 trials in the Exp, then the end screen), it crashes. Then it has the code below, which is the same no matter how I do this.
Conds.saveAsText(filename + ‘Conds.csv’, delim=‘,’,
File “C:\Program Files\PsychoPy\lib\site-packages\psychopy\data\base.py”, line 201, in saveAsText
dataArray = self._createOutputArray(stimOut=stimOut,
File “C:\Program Files\PsychoPy\lib\site-packages\psychopy\data\trial.py”, line 423, in _createOutputArray
strVersion = str(tmpData.tolist())
TypeError: repr returned non-string (type tuple)
pilot_lastrun.py file
It appears this is where it goes wrong, but I don’t even know why this code is here. Btw, it does save all output, but appears, to stop when the crash happens.
get names of stimulus parameters
if Conds.trialList in (, [None], None):
params =
else:
params = Conds.trialList[0].keys()
# save data for this loop
Conds.saveAsText(filename + ‘Conds.csv’, delim=‘,’,
stimOut=params,
dataOut=[‘n’,‘all_mean’,‘all_std’, ‘all_raw’])