Sending trigger via parallel port

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:

https://lobes.osu.edu/rt-box.php

we were unable to use the older functions for parallel ports when we used the newest version of Psychtoolbox and MatLab 2022a

Which "older functions“ you refer to? Could you please specify „unable“? Any error message?

Method 1 here

is still maintained and confirmed to work with recent versions of Psychtoolbox on Ubuntu with Octave. Possibly not recently tested on MATLAB though.

Best,
Andreas

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.

One of the functions that we were not able to use with new versions of MatLab was ‘digitalio’. Following code uses this:

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?

Best,
Andreas

Possibly not recently tested on MATLAB though.

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.

Best,
Andreas

Hi,
lptwrite works great on Linux, IOport on Windows using parallel port (onboard or PCI card). Furthermore we have good experiences with USB-Devices (e.g. NI USB-6008/9, NeuroSpec MMBT Box [MMBT-S Trigger Interface Box | NEUROSPEC AG Research Neurosciences], IO-Warrior [I/O Interface | IO-Warrior, less expensive]).

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

1 Like

Hi,
I need to send the TTL via parallel port.
I have installed the newest version of Matlb and PTB3, under unix. Before I used this line under windows

config_io;
ioObj = io64;
status = io64(ioObj);
port1 = 888;
outp(port1,i)

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'.

Best

I have installed the newest version of Matlb and PTB3, under unix.

What flavor of “unix”? Linux? Distribution?

Have you tested method 1 described in the FAQ as suggested previously in this thread?

My linux version :


ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.5 LTS"

I downloaded ppdev-mex-master.zip and put in my Matlab path. But When I run in Matlab

>> ppdev_mex('Open', 1);
>> lptwrite(1, 255)
>> WaitSecs(1)

Nothing happend, in python I can send the TTL by port : PORT1 = '/dev/parport1'
Best

/dev/parport1 is port number 2 in ppdev_mex.

Try:

ppdev_mex('Open', 2);
lptwrite(2, 255)
ppdev_mex('Close', 2);

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.

Hi Leila,

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.

Best