I've been battling this issue for several hours and my attempts to find a solution online have come up blank. Hopefully someone here has some insight.
In the course of an experiment, participants see a series of stimuli followed by masks with no user input. However, on some trials we want to throw in "catch" trials to make sure the participant is still engaged.
So ideally, the flow would look like:
stim->mask->stim->mask...->catch trial->mask (register keypress - "I saw it")->stim->mask...
The problem I'm having is that when I call event.getKeys('space') it invariably returns an empty list.
Here's a snippet of relevant code:
if stimCount >= min(catchTrials)+mod[modCount] and stimCount <= max(catchTrials)+mod[modCount] and beenDisplayed == 0:
print 1
test = random.randint(0,1)
if test == 1 or stimCount % 20 == 0:
print 2
actualStim.setSF(0)
actualStim.setOri(0)
doCatch(catchTimeout) # this displays the "catch" stim
doMask(MaskTimeout,maskNum) # this is the mask
print stimCount+1, 'catch', catchResponse # debug line
beenDisplayed = 1
modCount += 1
inCatch = 1
keys = event.getKeys(["space"]) # should return *something* that was pressed?
print 'keys = ',keys
if len(keys) > 0: # logic given a keypress
print 'pressed'
catchResponse[0] = 1
else:
print 'not pressed'
catchResponse[0] = 0
else:
maskNum = str(1)
doFixate(FixateTimeout)
actualStim.setSF(Circle1[stimCount][1])
actualStim.setOri(Circle1[stimCount][2])
#doMask(MaskTimeout,maskNum)
print stimCount+1, inCatch
if inCatch == 1:
print str(keyMap[response["firstKey"]])
doStimulus(None, StimTimeout, None)
doMask(MaskTimeout,maskNum)
Output:
5 0
1
6 0
1
2
7 catch [0, 1]
keys = []
not pressed
8 0
As I understand it, event.getKeys() returns a list of all keys pressed since the last getKeys was called, or a clearEvent is called.
In this case, I don't understand why keys is always empty. I've tried moving the getKeys event all over the loop and to no avail.
I would greatly appreciate any help, Ben