Hi everyone, I have a strange problem with trying to receive scanner pulses via the Cedrus controller. I first initialise the box using the pyxid package (init_cedrusSync) and then set it up (waitForCedrus).
def init_cedrusSync():
global dev
try:
devices = pyxid.get_xid_devices()
except:
devices = pyxid.get_xid_devices()
dev = devices[0]
print(dev)
print('Open cedrux box')
def waitForCedrus():
event.clearEvents(eventType='keyboard') # remove any keys waiting in the queue
if dev.is_response_device():
dev.reset_base_timer()
dev.reset_rt_timer()
while True:
dev.poll_for_response()
if dev.response_queue_size() > 0:
response = dev.get_next_response()
if response['pressed'] == True:
print('Button press: ' + str(response['key']))
break
After this, I set up the main experiment code, which calls for the ‘waitForCedrus’ function, which should wait for 3 triggers before starting the experiment (set the range as 3).
fmriTimer = core.Clock()
clockOn = fmriTimer.getTime()
scanTime = fmriTimer.getTime()
for dummy in range(3):
waitForCedrus()
if dummy==0:
scanOn = fmriTimer.getTime()
timeFirstTrigger = scanOn - clockOn
trials.addData('firstTrigger', timeFirstTrigger)
print('First scanner pulse received ' + str(timeFirstTrigger) + ' seconds after start of sequence')
else:
print('MRI pulse received ' + str(fmriTimer.getTime()-scanOn) + ' seconds after the first trigger. This is pulse number ' + str(dummy+1))
print('Task starts')
However, the experiment triggers pretty much straight away after the first signal is received from the scanner - and this is what I get in the Output screen:
Hello from the pygame community. https://www.pygame.org/contribute.html
<ResponseDevice “Cedrus Lumina LP-400 Response Pad System”>
Open cedrux box
Button press: 3
First scanner pulse received 0.03183174385549137 seconds after start of sequence
Button press: 3
MRI pulse received 0.06744353395924918 seconds after the first trigger. This is pulse number 2
Button press: 3
MRI pulse received 0.0997588051754974 seconds after the first trigger. This is pulse number 3
Task starts
So it seems that three ‘pulses’ are being received under 0.1 second, setting the experiment off pretty much straight away. I’m not sure why this would be, and was wondering if anyone has had a similar problem, or know why this could be? Any help or pointers would be much appreciated - thanks in advance!