I have a code for presenting an image and getting a response. I am going to use this with TMS, triggering the TMS via parallel port after a specific time (different for each trial) in between the participant seeing the image and responding.
Previously I used event.waitKeys() but have switched the event.getKeys() to allow the code to run while getting the response. I still only want the image to appear for a maximum of 3 seconds so have included the while loop.
I want the image to appear and then after a certain time to send the parallel port signal while simultaneously allowing participants to respond (and not only after the signal has been sent - as it is likely on some trials they will respond before as I am basing the timing of the TMS pulse on their average RT).
I was wondering how I can do this without using core.wait() as this also pauses the code. I am currently trying timer but this seems to be repeating the parallel port section of the code several times for each image.
This is the code I currently have:
image[i].draw() win.flip() presentationTime = clock.getTime() t_end=time.time()+3 while time.time() < t_end: keys = event.getKeys(keyList = validResponse.values()) if keys is None: keys= keys.append("no key") response = 'no key' if len(keys) >0: resp=keys responseTime = clock.getTime() break TrialValue=np.random.choice(jitter, replace=False) t = Timer(TrialValue, trigger) t.start() pulse_time = clock.getTime() windll.inpout32.Out32(portaddress, 0)