Hello,
I have an issue with PsychoPy on my new computer (did not have that with the previous one). At test, one of the routines I created is supposed to run only if the participant presses yes (key set to ‘s’) in the previous routine. On my old computer, this worked perfectly fine in numerous experiments. Now, on my new computer, everything works fine except for that.
I usually use the Builder View, but for that purpose, I added a code as a parameter. However, I understand from other questions here that the problem could be solved by modifying something in the Coder View. Here is the code of the two routines I am talking about (Reco_words being the first answer and RKG is the conditional routine). However, I have never used the Python code and I have trouble finding the problem and the modifications I need to make based on other topics on the forum… Could someone help?
I use the version 3.2.4, which I know is not the latest official version, but I can’t upgrade to 3.2.2, for reasons I don’t quite understand.
Thanks!
-------Run Routine “Reco_words”-------
while continueRoutine:
# get current time
t = Reco_wordsClock.getTime()
tThisFlip = win.getFutureFlipTime(clock=Reco_wordsClock)
tThisFlipGlobal = win.getFutureFlipTime(clock=None)
frameN = frameN + 1 # number of completed frames (so 0 is the first frame)
# update/draw components on each frame
# *words* updates
if words.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance:
# keep track of start time/frame for later
words.frameNStart = frameN # exact frame index
words.tStart = t # local t and not account for scr refresh
words.tStartRefresh = tThisFlipGlobal # on global time
win.timeOnFlip(words, 'tStartRefresh') # time at next scr refresh
words.setAutoDraw(True)
# *key_old_new* updates
waitOnFlip = False
if key_old_new.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance:
# keep track of start time/frame for later
key_old_new.frameNStart = frameN # exact frame index
key_old_new.tStart = t # local t and not account for scr refresh
key_old_new.tStartRefresh = tThisFlipGlobal # on global time
win.timeOnFlip(key_old_new, 'tStartRefresh') # time at next scr refresh
key_old_new.status = STARTED
# keyboard checking is just starting
waitOnFlip = True
win.callOnFlip(key_old_new.clock.reset) # t=0 on next screen flip
win.callOnFlip(key_old_new.clearEvents, eventType='keyboard') # clear events on next screen flip
if key_old_new.status == STARTED and not waitOnFlip:
theseKeys = key_old_new.getKeys(keyList=['s', 'l'], waitRelease=False)
if len(theseKeys):
theseKeys = theseKeys[0] # at least one key was pressed
# check for quit:
if "escape" == theseKeys:
endExpNow = True
key_old_new.keys = theseKeys.name # just the last key pressed
key_old_new.rt = theseKeys.rt
# was this 'correct'?
if (key_old_new.keys == str(Key_sl)) or (key_old_new.keys == Key_sl):
key_old_new.corr = 1
else:
key_old_new.corr = 0
# a response ends the routine
continueRoutine = False
# check for quit (typically the Esc key)
if endExpNow or defaultKeyboard.getKeys(keyList=["escape"]):
core.quit()
# check if all components have finished
if not continueRoutine: # a component has requested a forced-end of Routine
break
continueRoutine = False # will revert to True if at least one component still running
for thisComponent in Reco_wordsComponents:
if hasattr(thisComponent, "status") and thisComponent.status != FINISHED:
continueRoutine = True
break # at least one component has not yet finished
# refresh the screen
if continueRoutine: # don't flip if this routine is over or we'll get a blank screen
win.flip()
# -------Ending Routine "Reco_words"-------
for thisComponent in Reco_wordsComponents:
if hasattr(thisComponent, "setAutoDraw"):
thisComponent.setAutoDraw(False)
Reco.addData('words.started', words.tStartRefresh)
Reco.addData('words.stopped', words.tStopRefresh)
# check responses
if key_old_new.keys in ['', [], None]: # No response was made
key_old_new.keys = None
# was no response the correct answer?!
if str(Key_sl).lower() == 'none':
key_old_new.corr = 1; # correct non-response
else:
key_old_new.corr = 0; # failed to respond (incorrectly)
# store data for Reco (TrialHandler)
Reco.addData('key_old_new.keys',key_old_new.keys)
Reco.addData('key_old_new.corr', key_old_new.corr)
if key_old_new.keys != None: # we had a response
Reco.addData('key_old_new.rt', key_old_new.rt)
Reco.addData('key_old_new.started', key_old_new.tStartRefresh)
Reco.addData('key_old_new.stopped', key_old_new.tStopRefresh)
# the Routine "Reco_words" was not non-slip safe, so reset the non-slip timer
routineTimer.reset()
# ------Prepare to start Routine "RKG"-------
# update component parameters for each repeat
if key_old_new.keys.lower() !='s':
continueRoutine = False
rk.setText('Détails ou non ?')
key_rk.keys = []
key_rk.rt = []
# keep track of which components have finished
RKGComponents = [rk, key_rk]
for thisComponent in RKGComponents:
thisComponent.tStart = None
thisComponent.tStop = None
thisComponent.tStartRefresh = None
thisComponent.tStopRefresh = None
if hasattr(thisComponent, 'status'):
thisComponent.status = NOT_STARTED
# reset timers
t = 0
_timeToFirstFrame = win.getFutureFlipTime(clock="now")
RKGClock.reset(-_timeToFirstFrame) # t0 is time of first possible flip
frameN = -1
continueRoutine = True
# -------Run Routine "RKG"-------
while continueRoutine:
# get current time
t = RKGClock.getTime()
tThisFlip = win.getFutureFlipTime(clock=RKGClock)
tThisFlipGlobal = win.getFutureFlipTime(clock=None)
frameN = frameN + 1 # number of completed frames (so 0 is the first frame)
# update/draw components on each frame
# *rk* updates
if rk.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance:
# keep track of start time/frame for later
rk.frameNStart = frameN # exact frame index
rk.tStart = t # local t and not account for scr refresh
rk.tStartRefresh = tThisFlipGlobal # on global time
win.timeOnFlip(rk, 'tStartRefresh') # time at next scr refresh
rk.setAutoDraw(True)
# *key_rk* updates
waitOnFlip = False
if key_rk.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance:
# keep track of start time/frame for later
key_rk.frameNStart = frameN # exact frame index
key_rk.tStart = t # local t and not account for scr refresh
key_rk.tStartRefresh = tThisFlipGlobal # on global time
win.timeOnFlip(key_rk, 'tStartRefresh') # time at next scr refresh
key_rk.status = STARTED
# keyboard checking is just starting
waitOnFlip = True
win.callOnFlip(key_rk.clock.reset) # t=0 on next screen flip
win.callOnFlip(key_rk.clearEvents, eventType='keyboard') # clear events on next screen flip
if key_rk.status == STARTED and not waitOnFlip:
theseKeys = key_rk.getKeys(keyList=['c', 'b'], waitRelease=False)
if len(theseKeys):
theseKeys = theseKeys[0] # at least one key was pressed
# check for quit:
if "escape" == theseKeys:
endExpNow = True
key_rk.keys = theseKeys.name # just the last key pressed
key_rk.rt = theseKeys.rt
# a response ends the routine
continueRoutine = False
# check for quit (typically the Esc key)
if endExpNow or defaultKeyboard.getKeys(keyList=["escape"]):
core.quit()
# check if all components have finished
if not continueRoutine: # a component has requested a forced-end of Routine
break
continueRoutine = False # will revert to True if at least one component still running
for thisComponent in RKGComponents:
if hasattr(thisComponent, "status") and thisComponent.status != FINISHED:
continueRoutine = True
break # at least one component has not yet finished
# refresh the screen
if continueRoutine: # don't flip if this routine is over or we'll get a blank screen
win.flip()
# -------Ending Routine "RKG"-------
for thisComponent in RKGComponents:
if hasattr(thisComponent, "setAutoDraw"):
thisComponent.setAutoDraw(False)
Reco.addData('rk.started', rk.tStartRefresh)
Reco.addData('rk.stopped', rk.tStopRefresh)
# check responses
if key_rk.keys in ['', [], None]: # No response was made
key_rk.keys = None
Reco.addData('key_rk.keys',key_rk.keys)
if key_rk.keys != None: # we had a response
Reco.addData('key_rk.rt', key_rk.rt)
Reco.addData('key_rk.started', key_rk.tStartRefresh)
Reco.addData('key_rk.stopped', key_rk.tStopRefresh)
# the Routine "RKG" was not non-slip safe, so reset the non-slip timer
routineTimer.reset()
thisExp.nextEntry()