so there is an extra number there which is 230. I realize that is in some Spanish words and only happened with 3 words. what do you think this can be?
Also, is it a serial port thing that recognizes 1 as 49 and 2 as 50? Can that make any trouble at the moment of a amazing the data with EEGLAB? because when I used a p.port, it recognized the triggers like in the excel file.
But if you use integers does it appear in the data as expected?
I am less sure on what the stray trigger is - does the total number of triggers correspond to the total number of stimuli you expect? or are these extra?
Hi Becca,
So, to sum up, the new code
port.write(1) does not work.
I ended up adding this port.write(str.encode(chr(trigger))) codeand all of the 80 words are recorded. but still, sometimes i get 204 as a trigger. with this script my triggers are the same as in the excell file.
port.write(trigger)
if trigger ==1:
port.write(1)
elif trigger ==2:
port.write(2)
elif trigger ==3:
port.write(3)
port.write(str.encode(chr(trigger)))
Hi Becca,
So sometimes it happens 3 times during the whole experiment, sometimes more.
All my trials are recorded. When the 224 appears, this replaces one of the other triggers, so instead of 1, 2 or 3 is 224. This number because is replacing one of the other triggers, does not add other trials. So I end up having 80 trials recorded (what I need) but with some 224 in between.
Also, this only happens when I have 3 triggers or more.
interesting - OK to worst comes to worst triggers can be posthoc labelled with their corresponding condition in the analysis - but I know that is not what we want ideally.
Looking on the actiview support site I see that someone had a similar issue and they fixed it using the a write byte approach rather than a write integer method Trigger Codes Missing Sporadically - BioSemi.nl
Hmm ok I am afraid it is a bit tricky for me to advise without being able to test your specific set up - it sounds as though you have tried all the correct steps!
When you mention that it didn’t work - what happened exactly? was an error thrown? or was it just the same pattern as before?
Hi becca
This didn’t work
port.write(trigger.to_bytes(length = 1, byteorder = ‘little’))
When I only have the task with two triggers, the script works perfectly. But when I have three or more triggers sometimes I have 224 as a trigger
I wanted to mention to you that PsychoPy serial() function is based on pySerial app.
This app can only send characters converted to bytes in the format set by default in the “to_byte” function.
That simply means that when ‘1’ is sent to the serial port an actual binary number “49” corresponding to the ASCII code of ‘1’ as a character is sent to the port.
If you want to send numbers to mark certain type of events you have to convert them first to_byte then send to the port.
You could probably try something like this:
val = 1
val_inbytes= val.to_bytes(1, byteorder=‘big’)
port.write( val_inbytes)
You may eliminate the if statement this way.
We are distributors of Biosemi products for Latin America
Hi there,
I ask for your help with the trigger sending via Serial Port EEGbiosemi. I’m using Windows 10Pro and Psychopy v2022.2.5 sith USB Serial Port recognize as COM3, and the same USB serial port showed here by Stephanie_Aedo (the only difference is the bits per seconds which in my case are = 9600).
I have been trying to run in my experiment all the solutions I have seen here in the forum. However, I’am at a loss to understand the multiple errors that appear and have decided to follow a tip I saw around here: to run a simple experiment first so I can indentify the main error. I took this one: trigger_test
#### Running: C:\Users\LabCognicionyEmocion\PAULINA\trigger_test_lastrun.py ####
2937.1665 INFO Loaded monitor calibration from ['2019_09_12 14:31']
pygame 2.1.0 (SDL 2.0.16, Python 3.8.10)
Hello from the pygame community. https://www.pygame.org/contribute.html
2.3924 WARNING We strongly recommend you activate the PTB sound engine in PsychoPy prefs as the preferred audio engine. Its timing is vastly superior. Your prefs are currently set to use ['sounddevice', 'pyo', 'pygame'] (in that order).
Traceback (most recent call last):
1.1035 WARNING Monitor specification not found. Creating a temporary one...
File "C:\Users\LabCognicionyEmocion\PAULINA\trigger_test_lastrun.py", line 355, in <module>
win.flip()
File "C:\Program Files\PsychoPy\lib\site-packages\psychopy\visual\window.py", line 1222, in flip
callEntry['function'](*callEntry['args'], **callEntry['kwargs'])
File "C:\Program Files\PsychoPy\lib\site-packages\serial\serialwin32.py", line 306, in write
raise PortNotOpenError()
serial.serialutil.PortNotOpenError: Attempting to use a port that is not open
################ Experiment ended with exit code 1 [pid:10304] #################
2968.8930 INFO Loaded monitor calibration from ['2019_09_12 14:31']
I would be grateful for any guidance in this regard.
Thanks in advance
Hi, try and change the bits per second. Unfortunately I ended up using a different programme to do my experiments.
but for what I can see, is a port related problem. Try and change the bits per second to baudrate = 115200) and see if this helps.