Hello,
I have recently got a response box to work with pyxid. However there is very limited information on the functions for pyxid and how to code using it. Before I was using event.getKeys() and it would listen for a key press and not do anything if nothing was pressed. Now using the 2nd bit of code I have written out, it now waits for a button to be pressed and doesn’t move on through the experiment and once a button is pressed it exits the experiment. I think this could be because of the while True part, but I’m really not sure. Any help or links to materials or examples is appreciated!
previously my code was like this and worked:
for l in range(0,(int(numFrames*1.5))):
myFix.draw()
myWin.flip
allKeys=event.getKeys()
for thisKey in allKeys:
if thisKey in ['space']:
buttonTime = time.time()
buttonPressed = 1
print 'space'
respTime = buttonTime - stimTime
print 'respTime is:'
print respTime
this_response = (respTime, cat_repeat)
responses.append(this_response)
totalResponse += respTime
rowCounter += 1
if cat_repeat == "correct":
correct += 1
with open(info['Participant'], 'ab') as csvfile:
wr = csv.writer(csvfile, delimiter=',')
wr.writerow(this_response)
print "cat_repeat"
print cat_repeat
if thisKey in ['q', 'escape']:
core.quit()
Now I have changed my code to:
for l in range(0,(int(numFrames*1.5))):
myFix.draw()
myWin.flip()
if myBox.is_response_device():
while True:
myBox.poll_for_response()
if myBox.response_queue_size()>0:
boxResponse = myBox.get_next_response()
buttonTime = time.time()
buttonPressed = 1
print "box pressed"
respTime = buttonTime - stimTime
print "respTime is:"
print respTime
this_response = (respTime, cat_repeat)
responses.append(this_response)
totalResponse += respTime
rowCounter += 1
if cat_repeat == "correct":
correct += 1
with open(info['Participant'], 'ab') as csvfile:
wr = csv.writer(csvfile, delimiter=',')
wr.writerow(this_response)
print "cat_repeat"
print cat_repeat
if thisKey in ['q', 'escape']:
core.quit()