Hi,
As I am not 100 % sure exactly what part of the code does what, it has been a little difficult to find those exact places, but I think these are the parts regulating the fixation cross, which is what I want to be shown for between 20 and 25 seconds.
Initialize components for Routine “FixationCross”
FixationCrossClock = core.Clock()
import random
durre = random.randint(20,25)
thisExp.addData(‘random_duration’, durre)
fixationcross = visual.TextStim(win=win, name=‘fixationcross’,
text=’+’,
font=‘Arial’,
pos=(0, 0), height=0.05, wrapWidth=None, ori=0,
color=‘black’, colorSpace=‘rgb’, opacity=1,
languageStyle=‘LTR’,
depth=-1.0);
Initialize components for Routine “FixationCross”
FixationCrossClock = core.Clock()
import random
durre = random.randint(20,25)
thisExp.addData(‘random_duration’, durre)
fixationcross = visual.TextStim(win=win, name=‘fixationcross’,
text=’+’,
font=‘Arial’,
pos=(0, 0), height=0.05, wrapWidth=None, ori=0,
color=‘black’, colorSpace=‘rgb’, opacity=1,
languageStyle=‘LTR’,
depth=-1.0);
# ------Prepare to start Routine "FixationCross"-------
continueRoutine = True
# update component parameters for each repeat
# keep track of which components have finished
FixationCrossComponents = [fixationcross]
for thisComponent in FixationCrossComponents:
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")
FixationCrossClock.reset(-_timeToFirstFrame) # t0 is time of first possible flip
frameN = -1
# -------Run Routine "FixationCross"-------
while continueRoutine:
# get current time
t = FixationCrossClock.getTime()
tThisFlip = win.getFutureFlipTime(clock=FixationCrossClock)
tThisFlipGlobal = win.getFutureFlipTime(clock=None)
frameN = frameN + 1 # number of completed frames (so 0 is the first frame)
# update/draw components on each frame
# *fixationcross* updates
if fixationcross.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance:
# keep track of start time/frame for later
fixationcross.frameNStart = frameN # exact frame index
fixationcross.tStart = t # local t and not account for scr refresh
fixationcross.tStartRefresh = tThisFlipGlobal # on global time
win.timeOnFlip(fixationcross, 'tStartRefresh') # time at next scr refresh
fixationcross.setAutoDraw(True)
if fixationcross.status == STARTED:
# is it time to stop? (based on global clock, using actual start)
if tThisFlipGlobal > fixationcross.tStartRefresh + durre-frameTolerance:
# keep track of stop time/frame for later
fixationcross.tStop = t # not accounting for scr refresh
fixationcross.frameNStop = frameN # exact frame index
win.timeOnFlip(fixationcross, 'tStopRefresh') # time at next scr refresh
fixationcross.setAutoDraw(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 FixationCrossComponents:
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 "FixationCross"-------
for thisComponent in FixationCrossComponents:
if hasattr(thisComponent, "setAutoDraw"):
thisComponent.setAutoDraw(False)
trials.addData('fixationcross.started', fixationcross.tStartRefresh)
trials.addData('fixationcross.stopped', fixationcross.tStopRefresh)
# the Routine "FixationCross" was not non-slip safe, so reset the non-slip timer
routineTimer.reset()
------Prepare to start Routine “FixationCross”-------
continueRoutine = True
# update component parameters for each repeat
# keep track of which components have finished
FixationCrossComponents = [fixationcross]
for thisComponent in FixationCrossComponents:
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")
FixationCrossClock.reset(-_timeToFirstFrame) # t0 is time of first possible flip
frameN = -1
# -------Run Routine "FixationCross"-------
while continueRoutine:
# get current time
t = FixationCrossClock.getTime()
tThisFlip = win.getFutureFlipTime(clock=FixationCrossClock)
tThisFlipGlobal = win.getFutureFlipTime(clock=None)
frameN = frameN + 1 # number of completed frames (so 0 is the first frame)
# update/draw components on each frame
# *fixationcross* updates
if fixationcross.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance:
# keep track of start time/frame for later
fixationcross.frameNStart = frameN # exact frame index
fixationcross.tStart = t # local t and not account for scr refresh
fixationcross.tStartRefresh = tThisFlipGlobal # on global time
win.timeOnFlip(fixationcross, 'tStartRefresh') # time at next scr refresh
fixationcross.setAutoDraw(True)
if fixationcross.status == STARTED:
# is it time to stop? (based on global clock, using actual start)
if tThisFlipGlobal > fixationcross.tStartRefresh + durre-frameTolerance:
# keep track of stop time/frame for later
fixationcross.tStop = t # not accounting for scr refresh
fixationcross.frameNStop = frameN # exact frame index
win.timeOnFlip(fixationcross, 'tStopRefresh') # time at next scr refresh
fixationcross.setAutoDraw(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 FixationCrossComponents:
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 "FixationCross"-------
for thisComponent in FixationCrossComponents:
if hasattr(thisComponent, "setAutoDraw"):
thisComponent.setAutoDraw(False)
Final2.addData('fixationcross.started', fixationcross.tStartRefresh)
Final2.addData('fixationcross.stopped', fixationcross.tStopRefresh)
# the Routine "FixationCross" was not non-slip safe, so reset the non-slip timer
routineTimer.reset()
If anyone can figure out the issue, I’d be very very grateful!
//
Per