Hi Michael,
thanks for your rapid and in-depth reply. Unfortunately, there was no other error output from PsychoPy, but I’m attaching the relevant bits of code below.
Here is where I set up the instruction screen components:
ReminderOfInstructions = visual.ImageStim(
win=win, name='ReminderOfInstructions',units='norm',
image='sin', mask=None,
ori=0, pos=(0, 0), size=(2,2),
color=[1,1,1], colorSpace='rgb', opacity=1,
flipHoriz=False, flipVert=False,
texRes=128, interpolate=True, depth=-1.0)
ReminderOfInstructions2 = visual.ImageStim(
win=win, name='ReminderOfInstructions2',units='norm',
image='sin', mask=None,
ori=0, pos=(0, 0), size=(2,2),
color=[1,1,1], colorSpace='rgb', opacity=1,
flipHoriz=False, flipVert=False,
texRes=128, interpolate=True, depth=-1.0)
ReminderOfInstructions3 = visual.ImageStim(
win=win, name='ReminderOfInstructions3',units='norm',
image='sin', mask=None,
ori=0, pos=(0, 0), size=(2,2),
color=[1,1,1], colorSpace='rgb', opacity=1,
flipHoriz=False, flipVert=False,
texRes=128, interpolate=True, depth=-1.0)
Here is the code that executes the routine which includes the instructions:
# ------Prepare to start Routine "Block_Intro"-------
starttime = core.getAbsTime()
t = 0
Block_IntroClock.reset() # clock
frameN = -1
continueRoutine = True
# update component parameters for each repeat
BlockNumber.setText('Welcome to ' + number + '.\n\n' + 'Please press space to begin the review of the instructions.')
key_resp_3 = event.BuilderKeyResponse()
key_resp_4 = event.BuilderKeyResponse()
key_resp_5 = event.BuilderKeyResponse()
key_resp_6 = event.BuilderKeyResponse()
key_resp_7 = event.BuilderKeyResponse()
# keep track of which components have finished
Block_IntroComponents = [BlockNumber, key_resp_3, ReminderOfInstructions, key_resp_5, ReminderOfInstructions2, key_resp_6, ReminderOfInstructions3, key_resp_7, scan_start, key_resp_4, p_port_2]
for thisComponent in Block_IntroComponents:
if hasattr(thisComponent, 'status'):
thisComponent.status = NOT_STARTED
# -------Start Routine "Block_Intro"-------
while continueRoutine:
# get current time
t = Block_IntroClock.getTime()
frameN = frameN + 1 # number of completed frames (so 0 is the first frame)
# update/draw components on each frame
# *p_port_2* updates
if t >= 0.0 and p_port_2.status == NOT_STARTED:
# keep track of start time/frame for later
p_port_2.tStart = t
p_port_2.frameNStart = frameN # exact frame index
p_port_2.status = STARTED
win.callOnFlip(p_port_2.setData, int(189))
frameRemains = 0.0 + 1.0- win.monitorFramePeriod * 0.75 # most of one frame period left
if p_port_2.status == STARTED and t >= frameRemains:
p_port_2.status = STOPPED
win.callOnFlip(p_port_2.setData, int(0))
# *BlockNumber* updates
if t >= 0.5 and BlockNumber.status == NOT_STARTED:
# keep track of start time/frame for later
BlockNumber.tStart = t
BlockNumber.frameNStart = frameN # exact frame index
BlockNumber.setAutoDraw(True)
if BlockNumber.status == STARTED and bool(key_resp_3.keys):
BlockNumber.setAutoDraw(False)
# *key_resp_3* updates
if t >= 0.5 and key_resp_3.status == NOT_STARTED:
# keep track of start time/frame for later
key_resp_3.tStart = t
key_resp_3.frameNStart = frameN # exact frame index
key_resp_3.status = STARTED
# keyboard checking is just starting
win.callOnFlip(key_resp_3.clock.reset) # t=0 on next screen flip
event.clearEvents(eventType='keyboard')
#if key_resp_3.status == STARTED and bool(ReminderOfInstructions.status==FINISHED):
#key_resp_3.status = STOPPED
if key_resp_3.status == STARTED:
theseKeys = event.getKeys(keyList=['space'])
# check for quit:
if "escape" in theseKeys:
endExpNow = True
if len(theseKeys) > 0: # at least one key was pressed
key_resp_3.keys = theseKeys[-1] # just the last key pressed
key_resp_3.rt = key_resp_3.clock.getTime()
win.flip()
event.clearEvents(eventType='keyboard')
key_resp_3.status = STOPPED
# *ReminderOfInstructions* updates
if (key_resp_3.keys) and ReminderOfInstructions.status == NOT_STARTED:
# keep track of start time/frame for later
ReminderOfInstructions.setImage("Reminder_Slides_1.png")
ReminderOfInstructions.tStart = t
ReminderOfInstructions.frameNStart = frameN # exact frame index
ReminderOfInstructions.setAutoDraw(True)
if ReminderOfInstructions.status == STARTED and bool(key_resp_5.keys):
ReminderOfInstructions.setAutoDraw(False)
# *key_resp_5* updates
if ReminderOfInstructions.status == STARTED and key_resp_5.status == NOT_STARTED:
# keep track of start time/frame for later
key_resp_5.tStart = t
key_resp_5.frameNStart = frameN # exact frame index
key_resp_5.status = STARTED
# keyboard checking is just starting
win.callOnFlip(key_resp_5.clock.reset) # t=0 on next screen flip
event.clearEvents(eventType='keyboard')
#if key_resp_5.status == STARTED and bool(ReminderOfInstructions.status==FINISHED):
#key_resp_5.status = STOPPED
if key_resp_5.status == STARTED:
theseKeys = event.getKeys(keyList=['space'])
# check for quit:
if "escape" in theseKeys:
endExpNow = True
if len(theseKeys) > 0: # at least one key was pressed
key_resp_5.keys = theseKeys[-1] # just the last key pressed
key_resp_5.rt = key_resp_5.clock.getTime()
win.flip()
event.clearEvents(eventType='keyboard')
key_resp_5.status = STOPPED
# *ReminderOfInstructions2* updates
if (key_resp_5.keys) and ReminderOfInstructions2.status == NOT_STARTED:
# keep track of start time/frame for later
ReminderOfInstructions2.setImage("Reminder_Slides_2.png")
ReminderOfInstructions2.tStart = t
ReminderOfInstructions2.frameNStart = frameN # exact frame index
ReminderOfInstructions2.setAutoDraw(True)
if ReminderOfInstructions2.status == STARTED and bool(key_resp_6.keys):
ReminderOfInstructions2.setAutoDraw(False)
# *key_resp_6* updates
if ReminderOfInstructions2.status == STARTED and key_resp_6.status == NOT_STARTED:
# keep track of start time/frame for later
key_resp_6.tStart = t
key_resp_6.frameNStart = frameN # exact frame index
key_resp_6.status = STARTED
# keyboard checking is just starting
win.callOnFlip(key_resp_6.clock.reset) # t=0 on next screen flip
event.clearEvents(eventType='keyboard')
#if key_resp_6.status == STARTED and bool(ReminderOfInstructions2.status==FINISHED):
#key_resp_6.status = STOPPED
if key_resp_6.status == STARTED:
theseKeys = event.getKeys(keyList=['space'])
# check for quit:
if "escape" in theseKeys:
endExpNow = True
if len(theseKeys) > 0: # at least one key was pressed
key_resp_6.keys = theseKeys[-1] # just the last key pressed
key_resp_6.rt = key_resp_6.clock.getTime()
win.flip()
event.clearEvents(eventType='keyboard')
key_resp_6.status = STOPPED
# *ReminderOfInstructions3* updates
if (key_resp_6.keys) and ReminderOfInstructions3.status == NOT_STARTED:
# keep track of start time/frame for later
ReminderOfInstructions3.setImage("Reminder_Slides_3.png")
ReminderOfInstructions3.tStart = t
ReminderOfInstructions3.frameNStart = frameN # exact frame index
ReminderOfInstructions3.setAutoDraw(True)
if ReminderOfInstructions3.status == STARTED and bool(key_resp_7.keys):
ReminderOfInstructions3.setAutoDraw(False)
# *key_resp_7* updates
if ReminderOfInstructions3.status == STARTED and key_resp_7.status == NOT_STARTED:
# keep track of start time/frame for later
key_resp_7.tStart = t
key_resp_7.frameNStart = frameN # exact frame index
key_resp_7.status = STARTED
# keyboard checking is just starting
win.callOnFlip(key_resp_7.clock.reset) # t=0 on next screen flip
event.clearEvents(eventType='keyboard')
#if key_resp_7.status == STARTED and bool(ReminderOfInstructions3.status==FINISHED):
#key_resp_7.status = STOPPED
if key_resp_7.status == STARTED:
theseKeys = event.getKeys(keyList=['space'])
# check for quit:
if "escape" in theseKeys:
endExpNow = True
if len(theseKeys) > 0: # at least one key was pressed
key_resp_7.keys = theseKeys[-1] # just the last key pressed
key_resp_7.rt = key_resp_7.clock.getTime()
win.flip()
event.clearEvents(eventType='keyboard')
key_resp_7.status = STOPPED
# *scan_start* updates
if (key_resp_7.keys) and scan_start.status == NOT_STARTED:
# keep track of start time/frame for later
scan_start.tStart = t
scan_start.frameNStart = frameN # exact frame index
scan_start.setAutoDraw(True)
if scan_start.status == STARTED and bool(key_resp_4.keys):
scan_start.setAutoDraw(False)
# *key_resp_4* updates
if t >= scan_start.status == STARTED and key_resp_4.status == NOT_STARTED:
# keep track of start time/frame for later
key_resp_4.tStart = t
key_resp_4.frameNStart = frameN # exact frame index
key_resp_4.status = STARTED
# keyboard checking is just starting
win.callOnFlip(key_resp_4.clock.reset) # t=0 on next screen flip
event.clearEvents(eventType='keyboard')
if key_resp_4.status == STARTED and bool(scan_start.status==FINISHED):
key_resp_4.status = STOPPED
if key_resp_4.status == STARTED:
theseKeys = event.getKeys(keyList=['space'])
# check for quit:
if "escape" in theseKeys:
endExpNow = True
if len(theseKeys) > 0: # at least one key was pressed
key_resp_4.keys = theseKeys[-1] # just the last key pressed
key_resp_4.rt = key_resp_4.clock.getTime()
# 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 Block_IntroComponents:
if hasattr(thisComponent, "status") and thisComponent.status != FINISHED:
continueRoutine = True
break # at least one component has not yet finished
# check for quit (the Esc key)
if endExpNow or event.getKeys(keyList=["escape"]):
core.quit()
# refresh the screen
if continueRoutine: # don't flip if this routine is over or we'll get a blank screen
win.flip()
# -------Ending Routine "Block_Intro"-------
for thisComponent in Block_IntroComponents:
if hasattr(thisComponent, "setAutoDraw"):
thisComponent.setAutoDraw(False)
# check responses
if key_resp_3.keys in ['', [], None]: # No response was made
key_resp_3.keys=None
trials_2.addData('key_resp_3.keys',key_resp_3.keys)
if key_resp_3.keys != None: # we had a response
trials_2.addData('key_resp_3.rt', key_resp_3.rt)
if key_resp_4.keys in ['', [], None]: # No response was made
key_resp_4.keys=None
trials_2.addData('key_resp_4.keys',key_resp_4.keys)
if key_resp_4.keys != None: # we had a response
trials_2.addData('key_resp_4.rt', key_resp_4.rt)
trials_2.addData('Block_start_time',starttime)
if p_port_2.status == STARTED:
win.callOnFlip(p_port_2.setData, int(0))
# the Routine "Block_Intro" was not non-slip safe, so reset the non-slip timer
routineTimer.reset()
# set up handler to look after randomisation of conditions etc
trials = data.TrialHandler(nReps=1, method='random',
extraInfo=expInfo, originPath=-1,
trialList=data.importConditions(csv),
seed=None, name='trials')
thisExp.addLoop(trials) # add the loop to the experiment
thisTrial = trials.trialList[0] # so we can initialise stimuli with some values
# abbreviate parameter names if possible (e.g. rgb = thisTrial.rgb)
if thisTrial != None:
for paramName in thisTrial.keys():
exec(paramName + '= thisTrial.' + paramName)
for thisTrial in trials:
currentLoop = trials
# abbreviate parameter names if possible (e.g. rgb = thisTrial.rgb)
if thisTrial != None:
for paramName in thisTrial.keys():
exec(paramName + '= thisTrial.' + paramName)
Please let me know if you need more details or an explanation of what is else is going on in the routine, etc.
Thanks again for your help with this!
Best,
Craig.