Triggers via PsychoPy Mislabeling in ActiView for BIOSEMI EEG System

I am trying to get my experiment in PsychoPy to work with BioSemi’s ActiView for EEG using coding in Python. I am using a serial port for the triggers. Using coding I was able to get the triggers to send to ActiView.

While I’ve been able to effectively send triggers to the system, every few trials I get a random number that replaces actual condition labels. There doesn’t appear to be any pattern to them (they don’t appear at specific time points or for specific trigger values/conditions).

These incorrect numbers are 242 and 192. They are replacing any one of the trigger codes I specified for each condition (1, 2, or 3).

Anyone have any experience with this or ideas on how to keep these errors from occurring in the first place? Are there certain values that would be better for the BIOSEMI system when coding triggers?

I’m hoping I don’t have to change them manually during preprocessing of the EEG data for every participant. I can share my experiment file if that helps. Below is my code in PsychoPy for triggers

“Begin experiment”
import serial
port = serial.Serial(“COM4”, baudrate = 115200)

“Begin routine”
port.write(trigger)
if trigger == 1:
port.write(1)
elif trigger == 2:
port.write(2)
elif trigger == 3:
port.write(3)
port.write(str.encode(chr(trigger)))
port.flush()

“End experiment”
port.close()

Thanks!

There are two issues. First you need to convert your codes to bytes notation, e.g., using xxx.to_bytes(1,‘little’)) where xxx is the variable containing your desired value. Second you also need to send a zero (again, in bytes, so 0x00) > 5ms after each trigger. This is because the trigger cable simulates a parallel port, which does not auto-reset after a value is transmitted. See my code demo here if you want some hints:

https://github.com/drmarcj/psychopy_biosemi_serial

Hi Marc,

Thank you! It looks like that link is broken for me. Is there a different one I could use?

Best,
Ashley

Oopsie, it should work now.