psychopy.org | Reference | Downloads | Github

Do you need to send stimulus triggers from PsychoPy when running EEG study?

I have a question about running EEG research, which I’m new to. I am working with a few other researchers to set up a new EEG study where we’ll basically show people images and ask them to make keypresses using PsychoPy. We are also going to record EEG data using Emotiv EPOC headsets. I’ve been trying to convince my colleagues that we should try to get 2 computers connected via a parallel or serial port so we can send triggers from PsychoPy to the EEG software automatically when an image is shown, which will be recorded at the exact time the image actually appeared in the EEG data.
However, I’ve now been told that this is not how they normally run things. Instead they present the stimuli and record the EEG on separate computers and do not send any triggers at all. Instead they match the stimuli to the EEG manually, and in some cases time the stimulus presentation using a stopwatch. Is this normal practice?

In my eyes this will lead to inaccurate results as we cannot be 100% sure that the data we analyse belong to the trial we think, as we might be slightly off in matching the stimuli to the EEG. However, I’m not sufficiently experienced in EEG to confidently say that their method is not ok.

Can anyone offer any advice on this?

:scream::face_with_symbols_over_mouth::exploding_head:

This almost seems like a parody post?

No that wouldn’t be normal. Yes, you should send triggers, and they should ideally be timed to exact onset of the stimulus display (this can be done in PsychoPy code by using the .callOnFlip() function of the visual.Window class).

Thanks for the response, Michael. Unfortunately this is not a parody post but a situation I’m dealing with right now.

That was kind of my though as well as I’ve worked with fMRI and know how important stimulus onset timings are in neuroscience research. It’s just difficult to argue with people who have claimed to do this before while I’ve never used EEG in my own research previously.

I guess I’ll have to make a stronger case to invest the necessary time to set this up properly!

Good luck. By comparison, fMRI is MUCH more tolerant timing-wise than EEG, given it’s own much lower time resolution.

Hey, how do we send trigger for each stimuli in the builder view?

Assuming that you are using parallel port triggers, insert a component for one of those with the same onset time as the corresponding stimulus.

1 Like

Hi @Michael Could you please elaborate. I have just begun using PsychoPy.

Look in the component panel on the right side of the Builder window. You might need to click on the “I/O” tab to make the parallel port component visible. Click it to insert like any stimulus component.

I can’t advise on the content of that component: the value that gets sent and the duration of the pulse depends on your particular EEG hardware/software. The manual for that should tell you what the communication protocol. You also need to select what the parallel port address is on your PC (the one running PsychoPy). You’ll need to Google for how to that (I’m a Mac person, I’d need to Google it myself).

Thank you. The device is Cyton biosensing board. Any idea about how to trigger?

Hello, I was reading your post about emotiv EPOC EEG. How do you solve the problem? Thak you.

Dear Micheal,
I am dealing with the I/O component for an EEG study and I am having a problem when sending the triggers with psychopy Builder. They are being pulled from an excel spreadsheet associated and the start time of the trigger is a bit delayed after the onset since the moment I want to get information from is there. Every trial has the same information, though associated to different spread sheets but triggers are sent in some of the trials whereas in other not. Do you know why would this be happening? If I close and open the experiment again and run it again, the triggers will be sent in some other different trials this time. So I do not see it is linked to a problem in a specific trial but that sometunes they are not sent, no matter the trial… I am very confused and I am new to psychopy so I am not sure what to do or how to check. I would very much appreciate your help!
Thank you in advance,
Mar

Hello, please show us screenshots of your experiment timeline and the settings in the parallel port component, and any other relevant information.

In the study we are presenting participants with spoken sentences they have to passively listen to and at some points, they have a task that serves as a means of attentional check. After a number of sounds (always different), a written sentence is displayed and participants have to indicate whether the written sentence matches in meaning with the previous sentence they heard (see the screenshots below for the flow of both, spoken and written sentences respectively). For that, they have to press either ‘F’ (‘yes’) or ‘J’ (‘no’). The spoken sentences are .wav files and every written sentence is a .jpg file. In every loop, images or sounds, respectively, are being pulled from a spreadsheet. (Note that images and sounds are in separate .xlsx files and I have manually set when the written sentences appear because I was not able to find a better and easy solution to randomize the presentation of the images after a random number of sounds and set the button press for image trials only.)

The flow of the experiment goes as follows: a set of instructions are first presented and then a short Training (TR) block starts. Every trial containing spoken sentences has a first interstimulus event of 500 ms because I read that it prevents from cutting the sound files since they are very long and some of them are actually cut.


After that, 3 testing blocks follow (Block 1, 2 and 3). The I/O component is set at the beginning of every sound trial; time set at 500ms + the onset of the interesting point in the sentence. The number of the specific trigger is also pulled from the spreadsheet that contains the list of sound files, from the column ‘portNumber’.


Since the parallel port is not an official cable but bought in Amazon, the bites are sent reversed, so that trigger 1 is 64 in the acquisition screen, 2 is 32, 3 is 96, 4 is 16, etc.

The parallel port is registered under ‘Preferences’ tab as shown here:

in which the address is taken (0x3FB8).
Moreover, two files are included to help send the triggers correctly to the parallel port (‘inpout32.dll’ and ‘inpoutx64.dll’):

The main problem is that when I run an empty EEG as a tryout to check the triggers, in some of the trials are not being sent, last time it was in 3 out of 5 trials of Block 2, and 2 out of 6 in Block 3. I want to make sure the triggers are always being sent when expected.

I hope this was a clear explanation of the experiment and about the problems that I have been encountering. I appreciate very much your time and help.

Ok, so I solved the problem of the triggers adding the I/O component at the very top of each sound trial, so that the trigger was the first to be read in the loop. But the problem with the audio files persist and some sentences, mainly the longer ones, are cut. Audio lengths vary from around 3.6s up to around 6.6s. I have been trying to implement the tricks suggested in another discussion entitled: Some WAV files don’t play in full, but they do not work for me either. The ISI static component is added but I am not able to change libraries to ‘pygame’ or ‘pyo’ because the experiment is not able to run. With the ‘pyo’ lib I was reported some errors in the boot that I do not know how to check and with the ‘pygame’ library does not report any error at all. Do you know what can be causing this problem and what should I do to play the full audio files? Thank you!

Much improved sound performance is now available using the PTB audio library. The best strategy is likely to shift to the latest 64 bit version of PsychoPy, using Python 3, which will provide the PTB library.