Missing EEG triggers

Hi everyone,

I am new to PsychoPy and running EEG studies. I am currently setting up a recognition visual working memory task using EEG in Builder. Participants will first view an initial image, then, after a delay period, will see a new image. They will be asked to respond whether the new image is the ‘same’ or ‘different’ to the initial image, using the keyboard (4s timeout period if no response given).

We are recording EEG data (serial port) to send triggers from PsychoPy to the EEG software at four phases in each trial: encoding (when the initial image is shown); delay (when the delay period begins); retrieval (when the new image is shown); and response (when the keyboard response is given). The stimuli differ in load and semantic availability, which will be represented via the trigger numbers. Since different trigger numbers are being sent depending on the stimulus type, I am sending the triggers via code components, with ‘load’ and ‘semantics’ for each stimulus defined in my conditions Excel file.

I have tried various different versions of the code to send the triggers and every time I have been finding that there are around 10–15 triggers missing throughout the task. This occurs in different phases (encoding, delay, retrieval, response) and trials.

Here is the code I have at the moment in the encoding, delay, and retrieval phase:

Begin Routine
if semantics == 'low' and load = 'low':
win.callOnFlip(send_trigger, 1)

elif semantics == 'low' and load = 'medium':
win.callOnFlip(send_trigger, 2)

This is repeated for the rest of the load and semantic combinations.

Here is the code I have at the moment for the keyboard response (separate triggers for correct vs incorrect, defined with a variable called correct_key as the correct response is counterbalanced)

End Routine
if keypress2.keys:
    if keypress2.keys == correct_key:
        send_trigger(1)
    else:
        send_trigger(2)

else:
    send_trigger(2) # Send incorrect trigger for no response within allowed time

How can I reliably send triggers for each trial and phase? As I am only missing a few triggers randomly across the experiment I presume that this could be a timing issue? I would really appreciate any advice or guidance.

Thanks,

Rebecca

Based on what you have shared, it is not clear to me what is going wrong. Intermittent errors are trickiest, and I hope that they are not truly happening at random, because that likely will be hard to catch.

There are a couple thoughts that come to mind:

  1. If sending a trigger is a thing that can fail, it would be good to wrap send_trigger() in a try … except construct. Although, if that were the case, I guess you would be getting some kind of an error from the function, so there may not be anything to catch here. If it were me, I would have a close look at the send_trigger function and check if there is any way to get confirmation that the signal was sent successfully, that would be awesome. I don’t work with serial ports much, so I don’t know what to expect in this context, but maybe you can have the EEG system send a “received!” signal back to Psychopy, and if you don’t get it in an acceptable amount of time, you can do something about that.
  2. It would be a good idea to have Psychopy logging when a trigger is being sent. That could serve as a fallback to mark up the EEG data post-hoc in case things fail, but it will also confirm that the problem is that the signal is not reaching the EEG software, rather than there being something off in the logic of your Psychopy code such that the signal is literally not being sent at all.

Hope that helps. This sounds frustrating!

Hi Chris, thanks for your reply. After extensive testing and investigation, we discovered that the issue was not related to PsychoPy. Instead, it originated from a hardware problem involving our amplifier and the recording software. Fortunately, we have now resolved this. I did however use your idea of logging the triggers being sent within PsychoPy and this helped me determine that PsychoPy was not the problem, so thanks again.