Sending triggers to Cyton AUX pins
I am trying to run an experiment on PsychoPy while also recording EEG using the OpenBCI Cyton board. I would like to send triggers from the Psychopy experiment to the EEG recordings.
According to the first comment here (https://openbci.com/forum/index.php?p=/discussion/3101/psychopy-brainflow-and-markers-resolved), the 3 AUX channels of the Cyton board can be used to record trigger and marker. The Cyton documentation (https://docs.openbci.com/Cyton/CytonExternal/) mentions 5 General Purpose Input and Output pins and explains how triggers can be manually sent from a physical push on the board.
I would like these triggers to be sent from Psychopy. I tried to follow this tutorial: https://psychopy.org/hardware/serialPortInstr.html#sending-triggers-via-a-serial-port
But I am not sure which port address I should use, nor how to find the port address for the Cyton AUX pins. More specifically, the port name is dev/ttyUSB1, but I cannot find its address. Running
setserial -g /dev/ttyUSB[01]
yields
/dev/ttyUSB1, UART: unknown, Port: 0x0000, IRQ: 0
And whichever address value I try in “Port” in the “Basic” properties of serialPort in Psychopy yields the following error:
raise SerialException(msg.errno, "could not open port {}: {}".format(self._port, msg))
serial.serialutil.SerialException: [Errno 2] could not open port 0x0000: [Errno 2] No such file or directory: '0x0000'
######## Experiment ended with exit code 1 [pid:215199] ########
My OS is Ubuntu 24.04. Any help is appreciated. Thanks!
Comments
The Cyton external trigger pins are intended to be used with a source of DIGITAL input levels.
https://docs.openbci.com/Cyton/CytonExternal/#adding-trigger-markers-from-external-sources
In the diagram there, the 'External Trigger' 'Signal' and 'GND' are logic levels from a hardware device.
In some experiments, the External Trigger inputs can be derived from photo sensors, placed on your subject monitor screen. Then a small area of the screen, for example lower left corner, can have a photo sensor mounted there and wired through the opto isolator to the trigger pin.
https://docs.openbci.com/Examples/VideoExperiment/
Regards, William
Thanks for your answer @wjcroft. I've indeed seen that external hardware (eg an Arduino) can be interfaced with the Cyton board to send triggers. But I would ideally like to do it without relying on an external hardware. For the moment, I am using LSL: the LabRecorder receives and synchronizes both the EEG signal from the Cyton board and the external triggers. Sorry for the naive question, but can I do it without LSL, i.e. can triggers from an external software be directly sent to the Cyton board (for instance via the USB dongle)? Or do I need a physical connection to the Cyton board (e.g. using the pins you mentioned, or the push button on the board)? Thanks!
The Cyton dongle or mainboard cannot receive 'software triggers' as you describe. I'm glad you found a way to do it with LSL.
The mainboard 'external trigger' is only physical hardware connected. Did you read the photo sensor example? That is one way to use a display monitor to send triggers.
According to this search query, PsychoPy CAN generate external Vdd,GND trigger levels with an additional board.
https://www.google.com/search?q=can+psychopy+send+digital+logic+levels+(Vdd%2C+GND)+to+an+external+trigger%3F
Regards,
https://labjack.com/products/u3
Thanks for the input. Using a photo sensor is indeed a classical solution, but in my case I'm trying not to rely on an additional board nor on any extra hardware.
I actually just realized that the documentation of the Marker widget (https://docs.openbci.com/Software/OpenBCISoftware/GUIWidgets/#marker) mentions
I guess that would actually allow me to send triggers e.g. from Psychopy and have them synchronized with the GUI recording? Although what seems to be the classical solution (ie synchronizing triggers to EEG via LSL) is also perfectly doing the trick.
Apologies, I forgot to mention the GUI Marker widget. I was unclear from your initial post if you were using the GUI. You mentioned both the LSL LabRecorder and Brainflow. The fewer software / hardware components involved, the less the latency. You will have to figure out what is the delay between your Python sending marker and it showing up in the recording. Could be tens of milliseconds. Hard to say which has more latency, using the GUI marker, or the LabJack approach. But I would guess the GUI marker.
It is possible to stream directly into Python from the Brainflow library. Bypassing the GUI. LSL LabRecorder (direct Cyton interface) also bypasses the GUI.
https://brainflow.readthedocs.io/en/stable/Examples.html#python-get-data-from-a-board
https://brainflow.readthedocs.io/en/stable/Examples.html#python-markers