So I have realized I put the wrong port name here (it should have been COM3). However, I still get the same error when I use the serial Port component.
That’s why I tried to communicate with the port with a code. I used the code described here: Sending triggers via a Serial Port — PsychoPy v2022.2.2
And my code is as follows:
port = serial.Serial('COM3')
pulse_started = False
pulse_ended = False
if face_hab.status == STARTED and not pulse_started:
port.write([trigger_values_hab]) # trigger_values_hab is the header of an excel coloumn where I define the triggers
pulse_started = True
pulse_ended = False
pulse_start_time = globalClock.getTime()
if pulse_started and not pulse_ended:
if globalClock.getTime() - pulse_start_time >= 0.005:
pulse_ended = True
However I have some issues / questions and any help would be appreciated:
1. I want to use the win.callOnFlip function as described in the link above and as can be seen below:
But I receive this error:
“C:\Users\kppadmin\Desktop\Metin_Paradigm_2\Paradigm_2_ThirdTry_lastrun.py”, line 1451, in
File “C:\Program Files\PsychoPy\lib\site-packages\psychopy\visual\window.py”, line 1219, in flip
TypeError: ‘int’ object is not callable
I have also tried to change the settings in the properties of the excel coloums (I defined the values as “Text”, rather than “Standard”. Because otherwise the first code I wrote above did not work either…) But then, I receive this error:
data = to_bytes(data)
File “C:\Program Files\PsychoPy\lib\site-packages\serial\serialutil.py”, line 68, in to_bytes
TypeError: ‘float’ object cannot be interpreted as an integer
Any idea how I can make the win.callOnFlip function work while indexing to my trigger list on the excel sheet?
2. I have realized that not all the triggers are sent to the EEG. And I have figured out a pattern: If, let’s say, two identical triggers (I give the triggers values like 1,2 and 3 on the excel sheet) appear sequentially, then only the first one is being sent. For example, if I have stimuli_2 appear two times sequentially (meaning have two "2"s on the trigger_list_hab coloumn one coming after the other in rows), then a trigger called S2 is sent for the first stimuli_2, but not for the second stimuli_2. Do you know maybe what causes this?
Thanks in advance!