I’m having trouble with keyboard response for hits and false alarm.
Description of exp: In my exp, subjects need to respond whenever they see target word, and not when they see non target word. Targets/non targets are presented once per second, but I want to give subjects a couple of second chance to respond. However because the target is presented at random, another target will be presented in this time window sometime. If/when this happens, the time window should (of course) start again for this new target.
Description of problem: The problem I am having is I only wish to accept 1 response as a hit in the response window, and any others should be discarded or considered false alarms. I find that I can’t seem to make this work. I keep running into problem. Either I accept all key responses within this window, which leads to all being accepted as hits, or I only allow to accept one response, which prevents storing additional keys (false alarms or further hits if a new target falls into the same window).
Code:
target = visual.TextStim(win=win, name=‘text’, text=u’HATE’, font=u’Arial’, pos=(0, 0), height=0.1, wrapWidth=None, ori=0, color=u’white’, colorSpace=‘rgb’, opacity=1, depth=-2.0);
non_target = visual.TextStim(win=win, name=‘text’, text=u’HAIE’, font=u’Arial’, pos=(0, 0), height=0.1, >wrapWidth=None, ori=0, color=u’white’, colorSpace=‘rgb’, opacity=1, depth=-2.0);
trial_Clock = core.Clock()time = 0
frameN = 0
continueRoutine = True
while continueRoutine:
time = trial_Clock.getTime()
if time < 60:
win.flip()
frameN = frameN + 1
if frameN == 1:
target_rng = random.randint(1,11)
if frameN >= 42+18:
frameN = 0
if frameN in range(42,42+19,18):
if target_rng in range(1,3): #target
target.draw()
elif target_rng in range(3,11):
non_target.draw()
if time >= 60.0 and trial_Clock >=60:
continueRoutine = False
win.flip()
Using the below, I try and make it so only one key response is accepted as a hit within the time window, and any other are taken as false alarm. No matter what I can’t seem to get it working
theseKeys = event.getKeys(keyList=['enter']) if len(theseKeys) > 0: #this or just the last key if time in range (target_time[-1], (target_time[-1] + 3.5)): target_hit + 1 false_alarm + (len(theseKeys) - 1) event.clearEvents(eventType='keyboard')
I concerned that this may not work due to how I have coded the presentation timing of stimuli (because they are presented based on framerate, which resets every 60 frames i.e. once per second)