Hey guys, I will try to explain my problem properly. I am using PsychoPy 3.2.4 - I first started building the experiment in the Builder and then configured the code in coding mode. I will have two participants doing the experiment, hence two monitors win0 and win1.
My problem is now: I want to analyze my data from the .csv file. It works fine, except for all values under the function [NAME].stopped: The program will save None
. This applies to all saves .stopped values (other TextStimuli, etc). Thanks a lot! (This is just a code snippet of course, I hope its enough to identify the problem)
rating0 and rating1 are RatingScales
# ------Prepare to start Routine "Rating_Scale"-------
#assigning study items as stimuli (this comes from something that I coded earlier, not important, just so you understand the syntax)
StimulusLeft = list_of_pairs[study_trial][0]
StimulusRight = list_of_pairs[study_trial][1]
#assign next StimuliImages to be shown
LeftStimuli.setImage(StimulusLeft)
RightStimuli.setImage(StimulusRight)
# keep track of which components have finished
Rating_ScaleComponents = [LeftStimuli, RightStimuli,line_rating, text_Stimuli_zero, rating0, rating1]
for thisComponent in Rating_ScaleComponents:
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 = win0.getFutureFlipTime(clock="now")
Rating_ScaleClock.reset(-_timeToFirstFrame) # t0 is time of first possible flip
frameN = -1
continueRoutine = True
# -------Run Routine "Rating_Scale"-------
rating0.reset()
rating1.reset()
while continueRoutine:
# get current time
t = Rating_ScaleClock.getTime()
tThisFlip = win0.getFutureFlipTime(clock=Rating_ScaleClock)
tThisFlipGlobal = win0.getFutureFlipTime(clock=None)
frameN = frameN + 1 # number of completed frames (so 0 is the first frame)
# update/draw components on each frame
# *LeftStimuli* updates
if LeftStimuli.status == NOT_STARTED and tThisFlip >= 0-frameTolerance:
# keep track of start time/frame for later
LeftStimuli.frameNStart = frameN # exact frame index
LeftStimuli.tStart = t # local t and not account for scr refresh
LeftStimuli.tStartRefresh = tThisFlipGlobal # on global time
win0.timeOnFlip(LeftStimuli, 'tStartRefresh') # time at next scr refresh
# *RightStimuli* updates
if RightStimuli.status == NOT_STARTED and tThisFlip >= 0-frameTolerance:
# keep track of start time/frame for later
RightStimuli.frameNStart = frameN # exact frame index
RightStimuli.tStart = t # local t and not account for scr refresh
RightStimuli.tStartRefresh = tThisFlipGlobal # on global time
win0.timeOnFlip(RightStimuli, 'tStartRefresh') # time at next scr refresh
# *rating0* & rating1 update
if rating0.status == NOT_STARTED and t >= 0-frameTolerance:
# keep track of start time/frame for later
rating0.frameNStart = frameN # exact frame index
rating0.tStart = t # local t and not account for scr refresh
rating0.tStartRefresh = tThisFlipGlobal # on global time
win0.timeOnFlip(rating0, 'tStartRefresh') # time at next scr refresh
rating1.frameNStart = frameN # exact frame index
rating1.tStart = t # local t and not account for scr refresh
rating1.tStartRefresh = tThisFlipGlobal # on global time
win1.timeOnFlip(rating1, 'tStartRefresh') # time at next scr refresh
rating0.reset()
rating1.reset()
while rating0.noResponse or rating1.noResponse:
text_Stimuli_zero.draw(win0)
text_Stimuli_zero.draw(win1)
RightStimuli.draw(win0)
RightStimuli.draw(win1)
LeftStimuli.draw(win0)
LeftStimuli.draw(win1)
line_rating.draw(win0)
line_rating.draw(win1)
rating0.draw(win0)
rating1.draw(win1)
win0.flip()
win1.flip()
#check for quit
if defaultKeyboard.getKeys(keyList=["escape"]):
core.quit()
else:
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 Rating_ScaleComponents:
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
win0.flip()
win1.flip()
# -------Ending Routine "Rating_Scale"-------
#my TrialHandler is called "trials_rep"
trials_rep.addData('LeftStimuli.started', LeftStimuli.tStartRefresh)
trials_rep.addData('LeftStimuli.stopped', LeftStimuli.tStopRefresh)
trials_rep.addData('RightStimuli.started', RightStimuli.tStartRefresh)
trials_rep.addData('RightStimuli.stopped', RightStimuli.tStopRefresh)
# store data for trials (TrialHandler)
trials_rep.addData('rating0.response', rating0.getRating())
trials_rep.addData('rating0.rt', rating0.getRT())
trials_rep.addData('rating0.started', rating0.tStartRefresh)
trials_rep.addData('rating0.stopped', rating0.tStop)
trials_rep.addData('rating1.response', rating1.getRating())
trials_rep.addData('rating1.rt', rating1.getRT())
trials_rep.addData('rating1.started', rating1.tStart)
trials_rep.addData('rating1.stopped', rating1.tStop)
The end (final Text message after loops) is coded a bit differently (with .setautodraw()), still its saving None
.
# -------Run Routine "End"-------
while continueRoutine:
# get current time
t = EndClock.getTime()
tThisFlip = win0.getFutureFlipTime(clock=EndClock)
tThisFlipGlobal = win0.getFutureFlipTime(clock=None)
frameN = frameN + 1 # number of completed frames (so 0 is the first frame)
# update/draw components on each frame
# *text* updates
if text_Ende0.status == NOT_STARTED and tThisFlip >= 0.5-frameTolerance:
# keep track of start time/frame for later
text_Ende0.frameNStart = frameN # exact frame index
text_Ende0.tStart = t # local t and not account for scr refresh
text_Ende0.tStartRefresh = tThisFlipGlobal # on global time
win0.timeOnFlip(text_Ende0, 'tStartRefresh') # time at next scr refresh
text_Ende0.setAutoDraw(True)
text_Ende1.frameNStart = frameN # exact frame index
text_Ende1.tStart = t # local t and not account for scr refresh
text_Ende1.tStartRefresh = tThisFlipGlobal # on global time
win0.timeOnFlip(text_Ende1, 'tStartRefresh') # time at next scr refresh
text_Ende1.setAutoDraw(True)
# *keyResp_4* updates
waitOnFlip = False
if keyResp_4.status == NOT_STARTED and tThisFlip >= 0.8-frameTolerance:
# keep track of start time/frame for later
keyResp_4.frameNStart = frameN # exact frame index
keyResp_4.tStart = t # local t and not account for scr refresh
keyResp_4.tStartRefresh = tThisFlipGlobal # on global time
win0.timeOnFlip(keyResp_4, 'tStartRefresh') # time at next scr refresh
keyResp_4.status = STARTED
# keyboard checking is just starting
win0.callOnFlip(keyResp_4.clearEvents, eventType='keyboard') # clear events on next screen flip
if keyResp_4.status == STARTED and not waitOnFlip:
theseKeys = keyResp_4.getKeys(keyList=['space'], waitRelease=False)
if len(theseKeys):
theseKeys = theseKeys[0] # at least one key was pressed
# check for quit:
if "escape" == theseKeys:
endExpNow = True
keyResp_4.keys = theseKeys.name # just the last key pressed
keyResp_4.rt = theseKeys.rt
# *keyResp_3* updates
waitOnFlip = False
if keyResp_3.status == NOT_STARTED and tThisFlip >= 0.8-frameTolerance:
# keep track of start time/frame for later
keyResp_3.frameNStart = frameN # exact frame index
keyResp_3.tStart = t # local t and not account for scr refresh
keyResp_3.tStartRefresh = tThisFlipGlobal # on global time
win0.timeOnFlip(keyResp_3, 'tStartRefresh') # time at next scr refresh
keyResp_3.status = STARTED
# keyboard checking is just starting
waitOnFlip = True
win0.callOnFlip(keyResp_3.clock.reset) # t=0 on next screen flip
win0.callOnFlip(keyResp_3.clearEvents, eventType='keyboard') # clear events on next screen flip
if keyResp_3.status == STARTED and not waitOnFlip:
theseKeys = keyResp_3.getKeys(keyList=['return'], waitRelease=False)
if len(theseKeys):
theseKeys = theseKeys[0] # at least one key was pressed
# check for quit:
if "escape" == theseKeys:
endExpNow = True
keyResp_3.keys = theseKeys.name # just the last key pressed
keyResp_3.rt = theseKeys.rt
# check for quit (typically the Esc key)
if endExpNow or defaultKeyboard.getKeys(keyList=["escape"]):
core.quit()
#wait for both responses
if 'return' in keyResp_3.keys and 'space' in keyResp_4.keys:
#end routine (go to net trial or end)
continueRoutine = False
# 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 EndComponents:
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
win0.flip()
win1.flip()
# -------Ending Routine "End"-------
for thisComponent in EndComponents:
if hasattr(thisComponent, "setAutoDraw"):
thisComponent.setAutoDraw(False)
thisExp.addData('text_Ende0.started', text_Ende0.tStartRefresh)
thisExp.addData('text_Ende0.stopped', text_Ende0.tStopRefresh)
thisExp.addData('text_Ende1.started', text_Ende1.tStartRefresh)
thisExp.addData('text_Ende1.stopped', text_Ende1.tStopRefresh)
# check responses
if keyResp_3.keys in ['', [], None]: # No response was made
keyResp_3.keys = None
thisExp.addData('keyResp_3.keys',keyResp_3.keys)
if keyResp_3.keys != None: # we had a response
thisExp.addData('keyResp_3.rt', keyResp_3.rt)
thisExp.addData('keyResp_3.started', keyResp_3.tStartRefresh)
thisExp.addData('keyResp_3.stopped', keyResp_3.tStopRefresh)