inline scripts starting time in Coroutines: sending triggers for EEG
I've already opened the discussion about sending triggers for EEG from OpenSesame to NIC2 software, and after a while came up with the solution which is on this link.
Now, I'm trying to implement the same inline scripts for sending triggers in the Stop-Signal task which is a bit different in its structure since it has the coroutines item. The triggers are being sent, and communication between the two software is established but the timing of triggers onset seems wrong and sometimes random. Also, some of the triggers are being appeared in the trials when they shouldn't or more than once in the same trial which also shouldn't be happening.
You can see the overview of the practice block on the photo below:
The coroutines is consisted of a stimulus presentation sketchpad (which is the Go task, the participant needs to answer whether the triangle or circle is presented on the screen), presentation trigger inline script for sending triggers at the moment when triangle/circle is presented. Then we have a sketchpad for stop signal which is being presented on variable, adaptive delay after the go stimulus. The next item is the inline script for the trigger of Stop-signal presentation which should appear at the same moment as the stop signal. The next item is keyboard response which is related to the response for triangle/circle and then we have the inline script for sending triggers when the response is given.
You can see the coroutines settings on the photo below:
Participant has only 1 second to respond so the duration is set to 1000. Stimulus (Go condition) and go presentation trigger should always be presented at the beginning of the trial so their start time is set to 0. I'm not sure what should be set for the end time in this case (when I tried to put 1000 or some other value, it looked like so many triggers were being sent at the same moment and the NIC2 program would crash in a few seconds). The stop sketchpad is set to start at the adaptive SSD (which is being calculated by other inline scripts in the task). I've tried to put the same value ( [SSD] ) for the start time of presentation_trigger_stop but in that case, the task is crashing when it comes to the particular trial with the stop signal. I have the same doubt about the end time, should it be [SSD] + 1 or something else?
After that, we have the keyboard response item which should be always on and start at the beginning and record the participants response time whenever it happens within the 1-secondIts window. The next item is the inline script for sending triggers at the moment when participant gives the response. Its start time should be keypress (that didn't work when possibly tried it) or the exact time of the keyboard response (which is written on the photo and also didn't work). A possible reason that [response_time_keyboard_response] didn't work is because the variable is still not created before the coroutines have been run, but making that variable in some other inline script beforehand would help because the code wouldn't catch the exact response time from the specific trial. I'm also not sure about the End time for this item in the coroutines.
I think that the problem should be with the set-up of ending and starting times for every item but I'm not sure if I'm on the right way and if I can possibly change some other settings in order to succesfully send triggers at the right time.
I will also share the codes in inline scripts since I'm note sure if there is any mistake :
presentation trigger in the run section :
presentation trigger stop signal:
if var.stop_signal ==1 : s.send(('').encode())
s.send(('').encode()) else: s.send(('').encode())
These inline scripts are sending triggers, but specifically, the presentation trigger is being sent twice at the same moment, and the response trigger 5 (the else one) is being sent too early (with the presentation trigger). In the stop trials, we can observe all three triggers at the same time, practically. If I don't give any keyboard response, the response trigger is being appeared etc...
Does anyone have an idea how can I solve this or how to possibly set [response_time_keyboard_response] or [SSD] for a starting time of the inline scripts or is there any other way to do it via GUI or some simple coding or I should create a custom generator function (I've read a bit about that on the forum)? Thank you so much in advance, I hope that someone can come up with some solution.
All the best,