Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

inline scripts starting time in Coroutines: sending triggers for EEG

Hey everyone,

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 :

s.send(('<trigger>'+str(1)+'</trigger>').encode())

presentation trigger stop signal:

if var.stop_signal ==1 :
s.send(('').encode())

and response_trigger:

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,

Uroš

Comments

  • Hi @Uros ,

    If I understand correctly, and to simplify a long story, your main question is how you can send a trigger exactly once and at a predictable moment in the context of coroutines . Is that correct?

    The main thing to understand is that the run phase of an inline_script inside a coroutines is executed over and over again with a frequency that depends on the speed of your computer and the other items that are part of the coroutines . See also this page:

    In your case, you're setting 0 and 1 ms durations for the inline_script items with the idea that therefore the code is executed only once. But that doesn't necessarily need to be the case. A more reliable way to accomplish what you need is to have a single inline_script that maintains a list of triggers that need to be sent, and sends them exactly once, like so:

    Insert an inline_script into the coroutines that runs for the entire duration. In the Prepare phase initialize the triggers:

    # Initialize the starting time to None
    t0 = None
    # A list of trigger code, timestamp values
    triggers = [(1, 0),
                (2, 1000)]
    

    In the Run phase, send each trigger at the right moment:

    # If the start time is not defined, define it now
    if t0 is None:
        t0 = clock.time()
    # If there are still triggers to be sent ...
    if triggers:
        # Check the time since start
        dt = clock.time() - t0
        # Get the next trigger
        next_trigger_code, next_dt = triggers[0]
        # Check if the trigger should be sent
        if dt >= next_dt:
            # Send trigger (change to actual sending code)
            print(f'Send trigger {next_trigger_code}')
            # remove trigger from list
            triggers.pop(0)
    

    This should work. One caveat: the triggers aren't explicitly locked to the presentations of the sketchpads . So check carefully whether the timing is accurate!

    — Sebastiaan

Sign In or Register to comment.

agen judi bola , sportbook, casino, togel, number game, singapore, tangkas, basket, slot, poker, dominoqq, agen bola. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 50.000 ,- bonus cashback hingga 10% , diskon togel hingga 66% bisa bermain di android dan IOS kapanpun dan dimana pun. poker , bandarq , aduq, domino qq , dominobet. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 10.000 ,- bonus turnover 0.5% dan bonus referral 20%. Bonus - bonus yang dihadirkan bisa terbilang cukup tinggi dan memuaskan, anda hanya perlu memasang pada situs yang memberikan bursa pasaran terbaik yaitu http://45.77.173.118/ Bola168. Situs penyedia segala jenis permainan poker online kini semakin banyak ditemukan di Internet, salah satunya TahunQQ merupakan situs Agen Judi Domino66 Dan BandarQ Terpercaya yang mampu memberikan banyak provit bagi bettornya. Permainan Yang Di Sediakan Dewi365 Juga sangat banyak Dan menarik dan Peluang untuk memenangkan Taruhan Judi online ini juga sangat mudah . Mainkan Segera Taruhan Sportbook anda bersama Agen Judi Bola Bersama Dewi365 Kemenangan Anda Berapa pun akan Terbayarkan. Tersedia 9 macam permainan seru yang bisa kamu mainkan hanya di dalam 1 ID saja. Permainan seru yang tersedia seperti Poker, Domino QQ Dan juga BandarQ Online. Semuanya tersedia lengkap hanya di ABGQQ. Situs ABGQQ sangat mudah dimenangkan, kamu juga akan mendapatkan mega bonus dan setiap pemain berhak mendapatkan cashback mingguan. ABGQQ juga telah diakui sebagai Bandar Domino Online yang menjamin sistem FAIR PLAY disetiap permainan yang bisa dimainkan dengan deposit minimal hanya Rp.25.000. DEWI365 adalah Bandar Judi Bola Terpercaya & resmi dan terpercaya di indonesia. Situs judi bola ini menyediakan fasilitas bagi anda untuk dapat bermain memainkan permainan judi bola. Didalam situs ini memiliki berbagai permainan taruhan bola terlengkap seperti Sbobet, yang membuat DEWI365 menjadi situs judi bola terbaik dan terpercaya di Indonesia. Tentunya sebagai situs yang bertugas sebagai Bandar Poker Online pastinya akan berusaha untuk menjaga semua informasi dan keamanan yang terdapat di POKERQQ13. Kotakqq adalah situs Judi Poker Online Terpercayayang menyediakan 9 jenis permainan sakong online, dominoqq, domino99, bandarq, bandar ceme, aduq, poker online, bandar poker, balak66, perang baccarat, dan capsa susun. Dengan minimal deposit withdraw 15.000 Anda sudah bisa memainkan semua permaina pkv games di situs kami. Jackpot besar,Win rate tinggi, Fair play, PKV Games