Hi Somi,
Thanks for your question - we’re working on making some materials to help people with this - so your questions are really helpful thankyou! In answer to your third question, yes I do think a component for serial port communication would be helpful.
I think this should work. Add a code component and in the “Begin Experiment” tab use:
import serial
port = serial.Serial('COM1')
In your Begin Routine tab use:
pulse_started = False
pulse_ended = False
in the Each frame tab use:
if mything.status == STARTED and not pulse_started:# where "mything" refers to a visual thing you are trying to sync the trigger to (so you could have one of these for different component's in the same routine
win.callOnFlip(port.write([0x01])) # send the trigger but only when the window flips to ensure syncronisation
pulse_started = True
pulse_ended = False
pulse_start_time = globalClock.getTime()
if pulse_started and not pulse_ended:
if globalClock.getTime() - pulse_start_time >= 0.005:
pulse_ended = True
Oh and in terms of setting the trigger value through a conditions file. If you have a column with the header “trigger_value” and write what you want the trigger value to be on each trial, you should in theory be able to use this in the port.write()
command. So instead of port.write([0x01])
it would be port.write([trigger_value])
- please let me know if that works!
I think that should do the trick - but please do let me know if not!!
Hope this helps
Becca
PS. to check the frame timing is write here we also highly recommend checking with a photodiode for visual stimuli if you can.