In a loop that sets up variables within a given trial, I have:
t = 0
trialClock.reset() #Resets the trialClock (trial clock was initialized as core.Clock() )
frameN = -1
Then a while loop that follows this ( while continueRoutine:
) contains the following code:
t = trialClock.getTime()
frameN = frameN + 1
score_text.setAutoDraw(False) # removes the last score_text from the screen
score_update = 'this is some text that is generated based upon the score in the last trial, I've taken the code out here to simplify everything'
score_text = visual.TextStim(win=win, name='score_text', text= score_update , font='Arial', pos=(0.6, 0.3), height=0.1, wrapWidth=None, ori=0, color='white', colorSpace='rgb', opacity=1,depth=-2.0);
if t >= 0.0 and audio_stimulus.status == NOT_STARTED:
audio_stimulus.tStart = t
audio_stimulus.frameNStart = frameN
audio_stimulus.play()
if t >= 0.0 and key_resp_2.status == NOT_STARTED:
key_resp_2.tStart = t
key_resp_2.frameNStart = frameN # exact frame index
key_resp_2.status = STARTED
win.callOnFlip(key_resp_2.clock.reset)
event.clearEvents(eventType='keyboard')
if key_resp_2.status == STARTED:
theseKeys = event.getKeys(keyList=key_strings)
if "escape" in theseKeys:
endExpNow = True
In the initial loop:
⢠Why does t need to be set to 0 if in the following loop itâs going to be set to trialClock.getTime()
anyway?
⢠Why set frameN = -1
?
In the while continueRoutine:
frameN is set as:
frameN = frameN + 1
Couldnât it just be set at this point as:
frameN = 0
?
â
The t >= 0.0
part of the if statements doesnât seem to say anything⌠isnât t always >= 0 here? However if I simplify this to e.g. audio_stimulus.status == NOT_STARTED:
then the code wonât run anymore⌠I donât understand why?
I presume that once audio_stimulus
is set to audio_stimulus.play()
, or key_resp_2
is set to key_resp_2.status = STARTED
, that something behind the scenes starts measuring time from the starting point of e.g. audio_stimulus.tStart
, and starts measuring frames from the starting point of e.g. audio_stimulus.frameNStart
? Why couldnât audio_stimulus.frameNStart = frameN
have simply been audio_stimulus.frameNStart = -0
?
â
The following bit of code:
win.callOnFlip(key_resp_2.clock.reset)
event.clearEvents(eventType='keyboard')
seems to clear the set of keys already saved from the previous trial, and set up an instruction for the clock for key_resp_2 to reset when the off screen buffer is flipped to appear on screen - is that correct?
The final bit of code collects the keys punched on this particular trial. One problem I have here is that I only want to allow participants to press one key, but currently they can correct their response at any given time but pressing a new key. How might I change this? Would this have implications upon this issue I have: frameRemains = 1000 + 1.0- win.monitorFramePeriod * 0.75