We try to send triggers via the parallel port for our EEG setup. However, we have approximately ten years old Brain Products hardware, and we were unable to use the older functions for parallel ports when we used the newest version of Psychtoolbox and MatLab 2022a.
Then we downgrade Matlab from 2022a to 2014a, and Psychtoolbox from 3.0.17 to 3.0.12. We currently have the following setup: BrainAmp Amplifier (Brain Products), Linux Ubuntu 22.04 “Jammy Jellyfish”, Psychtoolbox 3.0.12, and MatLab 2014a. However, although the trigger command works with the older versions of PTB and Matlab, the code we wrote on newer PTB did not work anymore.
Is there any alternative approach to sending triggers instead of using a Parallel port?
Do you suggest using older software?
I’ve never used the parallel port, so don’t know what current code may control it on Linux. There are many ways to send a trigger. But for many users USB I/O devices work well. In MATLAB there are several ways to control a serial device, including PTB’s IOPort, and comparing performance I found that IOPort is clearly the fastest (~60µs TTL switch time using an Arduino):
What are the parameters of the trigger you need to send? Some hardware require strobed words with a trigger bit, others simple TTLs etc…
There is some more info here:
And some specific details for the LabJack:
And Arduinos:
@xiangrui from this forum made a response button + I/O box with very robust PTB support and high reliability that you can look at here, this would also allow you to compare timings to a photodiode etc:
Thanks for mentioning the RTBox.
I would like to add that we recently made the setup between the stimulus computer and Brain Product system (likely the latest version) for simultaneous EEG/fMRI with RTBox. They provided a multi-function but bulky trigger interface for this purpose, but we chose to replace it with RTBox. The only extra hardware is a cable to connect the corresponding pins between RTBox and BrainAmp USB2 Adapter (BUA).
Don’t hesitate to reach me if you are interested in our solution.
we tried to use ‘IOPort’ for the parallel port (at the address ‘c000’ or 49152) with the intention of sending an 8-bit trigger (we set the 8-bit trigger for 0.004 seconds and then reset the pins to 0, I guess it is a simple TTL?), but we could not figure out how to use this function in this context.
we tried to use ‘IOPort’ for the parallel port (at the address ‘c000’ or 49152) with the intention of sending an 8-bit trigger (we set the 8-bit trigger for 0.004 seconds and then reset the pins to 0, I guess it is a simple TTL?), but we could not figure out how to use this function in this context.
IOPort currently only supports serial ports.
One of the functions that we were not able to use with new versions of MatLab was ‘digitalio’. Following code uses this:
This is from 2008. If I remember correctly digitalio function never was supported in 64 bit MATLAB and discontinued around 2014 and was unsuitable (slow/inaccurate) for EEG triggering. Not sure whether it ever worked on Linux.
Have you tried method 1 from FAQ as already suggested?
Just checked, method 1 still works for sending TTL triggers from parallel port to EEG on both most recent available MATLAB R2022a and Octave 6.4.0 on Ubuntu 22.04.
The initial question was: are there alternative approaches to send triggers to the Brainproducts EEG System? Brainproducts offers the Remote Control Server (for free, Download BrainVision Recorder | Brain Products GmbH) which allows you to drive the Recorder from Matlab on your stimulus computer via TCP/IP. Within the recording you may send annotations to the Recorder which are stored in the .mrk files with a time stamp. At a first glance this seems to be wonderful but testing the timings the annotations appear before a simultaneously sent digital IO trigger via parallel port. The reason behind this: the amplifier stores EEG data and digital signals in real time. The recorded collects buffered data every once in a while but annotations are stored immediately in the .mrk files. As a consequence digital signals appear in the .mrk files 20-30 ms later.
So you have to stay on your digital markers - using parallel port, USB devices or whatever. We wrote a toolbox on using the Remote Control Server in Matlab and we will publish it soon.
Cheers
Andreas
In recent version of PTB3, there is no config_io. What is the solution?
I tried lptwrite also but it seems there is no more this function. Should I downgrade PTB3?
>> lptwrite
Unrecognized function or variable 'lptwrite'.
The numbering has historical reasons. I kept it for backward compatibility when inheriting the code. Users coming from Windows typically try 1 (LPT1) first. Trying 0 would result in a “Port number out of range.” error message.
Have you tried to change port number 1 to 2 as suggested by widmann? I wonder if it works fine. I am intent to use PTB under linux as well and send a trigger through a DSUB25 LPT port.
Your answer would be very helpful to me.