TriggerBox – Marker triggering via USB port

by Carlos Cruz Pérez
Scientific Consultant (Brain Products)

Nearly every EEG research lab needs to send triggers from the experimental setup to the EEG system. Of course, the solution should be precise, reliable and easy to use. By using the USB port and the Brain Products TriggerBox, one can send triggers to the EEG amplifier with a precision of less than 1 ms. If you are using E-Prime® 3.0 or Presentation® 20.0 and have a USB port available, you have a plug & play solution for triggers.

Abstract

The parallel port was used for sending triggers to EEG recordings. However, it becomes increasingly problematic to find a computer with such a port. Luckily, we have a product that is able to address this problem: the TriggerBox. By emulating your old parallel port by means of a virtual serial port, the TriggerBox allows you to send accurate triggers via a USB port. In this article, we show you how to use the TriggerBox to send triggers via USB with E-Prime 3.0 (Psychological Software Tools, Inc.) and Presentation 20.0 (Neurobehavioral Systems, Inc.). We provide source code examples for each software package so that you can follow our step by step instructions yourself.

Introduction

In most EEG experiments we would like to co-register events with our EEG data. For example, we might need markers that indicate the timing of stimuli and responses. The standard approach to send markers to the EEG recording is via TTL pulses. Until recently, the only reliable way to send TTL triggers to the EEG amplifier was using the parallel port or an I/O card. However, in most modern computers, specifically laptops, a parallel port is not available, and using extension cards bears the risk of chipset, BIOS, or operating system incompatibilities. Also, recent operating systems and programming environments do not support parallel port communication. Therefore, we have developed the USB based TriggerBox that emulates the parallel port by means of a virtual serial port. By emulating your old parallel port, it permits the USB port of your computer to be used as an 8-bit trigger source.

Including the TriggerBox in your setup is very easy and intuitive

We also have a small tool that will send USB triggers to your amplifier so that you can test the setup before running your own experiments. Follow the steps below to set up the TriggerBox and test the USB triggers:

(1) Connect the TriggerBox between the USB output of your computer and the trigger input of your EEG amplifier. A simple setup diagram integrating the TriggerBox is shown in Figure 1.
(2) Download and install the TriggerBox Test IO. This application installs the TriggerBox driver and can be used to send USB triggers to your EEG amplifier.
(3) You should now have a new COM port called “TriggerBox VirtualSerial Port” in your Windows device manager. Please check this.
(4) Set the digital port settings in your EEG recording software (e.g. BrainVision Recorder) to enable markers.
(5) Start recording some test data so that you can check whether the markers are received.
(6) Open the TriggerBox Test IO application and click “start”. If everything is working correctly, you should see markers in your EEG recording.

TriggerBox – Marker triggering via USB port

TriggerBox

Performing these steps will allow you to check whether the setup is functioning correctly before trying to implement your own experiments. If you do not see any markers after following the previous steps, please contact the Brain Products Technical Support team .

TriggerBox – Marker triggering via USB port

Figure 1: Standard setup to record EEG and USB generated markers. TriggerBox links the USB output of your PC with the trigger input of your amplifier.

The TriggerBox is a versatile product, able to receive triggers from different sources, combine them, and then forward them to an EEG amplifier. For those interested in further details, you can find them in this newsletter article.

How to send triggers via USB from E-Prime 3.0 and Presentation 20.0

We have described what the TriggerBox can do and also walked you through the setup and testing procedure. Now let us guide you through some practical examples using E-Prime 3.0 and Presentation 20.0. In just three basic steps you will have your system ready to send triggers using the USB port. Below you will find detailed instructions for these three steps.

Send triggers using E-Prime® 3.0

If you are using the example code, before following the steps below you will need to open E-Prime and open the experiments “OutputTriggerScript” and “EventRelatedTrigger” in E-Prime 3.0.

1. Create a new Serial object for the experiment

To establish a USB communication between E-Prime and the TriggerBox, a new Serial device must be added to your E-Prime experiment. Right-click on your experiment and select “properties”. Click on “Add” and choose a new Serial device (see Figure 2A).

2. Set COM port

Double-click on the new serial object, set a name, and select the corresponding TriggerBox COM port number. In our example, the object is called “UsbTriggerBox” (see Figure 2B). The COM port number can be obtained from the Windows device manager. The other numerical values are not relevant since we are not using a serial port but a virtual one.

TriggerBox – Marker triggering via USB port

Figure 2: Configuration of virtual serial port in E-Prime 3.0. A) Add a new serial port object from the experiment properties. B) Set a name and the port number to your new virtual serial port object.

3. Send triggers

Now that the port is configured, we can send triggers using the USB port and the TriggerBox. We present two methods for doing this:

3.1. Send triggers from a script

Open a new InLine script in E-Prime and send triggers using the functions given by the object “UsbTriggerBox”, illustrated in Figure 2. To get a better overview of the code open the example “OutputTriggerScript”.

TriggerBox – Marker triggering via USB port

Figure 3: E-Prime 3.0 script example to send triggers via the USB port.

3.2. Send triggers assigned to an event

An alternative method to send triggers is to set the “TimingMode” property of an E-Prime stimulus object to “Event”. In this way, a trigger can be associated to a certain event i.e. a new visual stimulus.

We provide an E-Prime 3.0 example called “EventRelatedTrigger” where two display E-Objects are included in the experiment, “CheckBoard” and “CheckBoard2”. We want to send a trigger when the image “CheckBoard” is displayed on the screen. To do that, we have paired the onset time of the image (OnsetTime) with the task “WriteByte” provided by the object “UsbTriggerBox” (see Figure 2). In our example, a trigger to generate marker number 10 is sent via USB when the image “CheckBoard” appears on the screen. This is illustrated in Figure 4.

TriggerBox – Marker triggering via USB port

Figure 4: Steps to assign an output trigger to an object in E-Prime 3.0.

To send consecutive triggers you must initialize the port by sending 0 after every trigger. In the provided E-Prime 3.0 example, we have implemented one possible solution by assigning an “OffsetTime” event to “CheckBoard” (see Figure 5). In this way, every time the image “CheckBoard” is removed from your screen, a 0 is sent and the port is initialized for the next event. It is important to mention that one must find a customized solution for each paradigm. You might find another solution that is more suitable for your own experiment.

TriggerBox – Marker triggering via USB port

Figure 5: Initialize USB port before sending next trigger in E-Prime 3.0.

Send triggers using Presentation® 20.0

1. Add a new port

To establish a communication between Presentation and the TriggerBox, a new output port must be added to the experiment. Set the corresponding COM port as an output port in the Port section in the Settings tab (see Figure 6A). Enable the checkbox “Emulate parallel” to use the USB port as if it were your old parallel port. Thanks to this “Emulate parallel” feature, the port is automatically initialized after every trigger and there is no need to send 0 between triggers. This special setting was specifically designed in collaboration with Neurobehavioral Systems as a user-friendly tool to combine Presentation 20.0 stimulation with the TriggerBox.

2. Set COM port

Click on the “Properties” button, a new window opens. By default, the properties are empty for your port. Although they are not significant because the port is virtual, you need to set some values to run the program. It does not matter which values you choose, select any from the available options (see Figure 6B).

TriggerBox – Marker triggering via USB port

Figure 6: Steps to configure an output virtual serial port in Presentation 20.0. A) New output is selected for the TriggerBox COM port B) Properties of the created output. Do not leave empty properties.

3. Send triggers

First, click on the “Editor” tab in Presentation 20.0 and at the beginning of your script enable port communication by adding the following lines:

Copy to Clipboard

Now that the port is configured, we present two methods to send triggers using the USB port and the TriggerBox.

3.1. Send triggers from a script

In Figure 7 we present an easy example to send triggers. The functions get_port and send_code in Presentation 20.0 are used to send output triggers. For a better understanding of the code, feel free to open the Presentation 20.0 “TriggerBox” experiment we have provided. If you open this experiment, refer to the scenario “OutputTriggerScript”.

TriggerBox – Marker triggering via USB port

Figure 7: Presentation 20.0 code example to send triggers via USB port.

3.2. Send triggers assigned to an event

An alternative method to send triggers is to set the command “port_code” inside your Presentation “trial” (see Figure 8). In this way, every time the trial is presented, a trigger is sent via the USB port. This code is part of the scenario “EventRelatedTrigger” contained in the “TriggerBox” Presentation 20.0 experiment example.

TriggerBox – Marker triggering via USB port

Figure 8: Assign an output trigger to a trial in Presentation 20.0.

Conclusion

The TriggerBox allows you to use the USB port of your PC to send accurate markers to your EEG recordings. In this article, we have provided step by step instructions for sending triggers via USB using the TriggerBox in combination with E-Prime 3.0 and Presentation 20.0. For each software package we have provided source code examples so that you can follow the step by step instructions yourself. This will enable you to become familiar with the concepts involved, so that you can go ahead and implement your own USB triggers with the TriggerBox.

Forget your old parallel ports and adapters! Use the TriggerBox to send USB trigger events to your EEG recordings using E-Prime 3.0 or Presentation 20.0.