Time lag between triggers and stimuli

Hi all,

I’m doing an audiovisual detection task with electrophysiological recordings. The auditory and visual stimuli are set to be displayed at the exact same time and the trigger is set to be sent at the same time as the stimulus appears.

However, we observe some discrepancy both between the visual and the auditory stimuli and between the trigger and the stimulus. Any idea where this could come from?

This is the discrepancy we observe:

This is the code we use to send our triggers:

Begin experiment:

import serial.tools.list_ports

ports = serial.tools.list_ports.comports()

for port, desc, hwid in sorted(ports):

    print("{}: {} [{}]".format(port, desc, hwid))

import serial

trigger_stim = "2"

baud_rate = 9600

trigger_duration = 0.01

_parity = serial.PARITY_NONE

_port = expInfo['port_trigger']

port = serial.Serial(port = _port, baudrate=baud_rate, parity=_parity, bytesize=serial.EIGHTBITS)

Begin routine:

stim_state = 0

Each frame:

if stim_visual_2.status == STARTED and stim_state == 0:

    port.write(str.encode(trigger_stim))

    core.wait(0.01)

    port.write(str.encode('0'))

    stim_state = 1

NB: We used a photodiode to record the visual stimulus.