Howdy, Stranger!

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

Supported by

using a coroutine

Hey guys,

I'm trying to use the coroutine item for the first time but I don't seem to achieve what I have in mind. Basically, I want to show a stimulus for 350ms ("probe" in the pic I attached) then a fixation for 5000ms while participants can respond with the mouse any time between the presentation of the stimulus and the end of the fixation (i.e., any time within that 5350ms interval). I attach a pic of how I set this up but it doesn't work as I had imagined. The problem is that "fixation3" does not stay up for 5000ms and I think the same happens for the "probe" (i.e., not staying up for 350ms). I've read that sketchpads and feedback items don't have an end time so I'm not sure if I can manage what I want with a coroutine. Any help?

PS I've done it in another way (i.e., having two mouse inputs and adding the time) based on another thread in the forum but I was hoping that it would have been more straightforward with co-routines.



  • Hi Mario,

    I suspect that having fixation3 as End after item is the reason for the it not staying up, which makes sense, because that field is supposed to shut down the co-routine, once a specified event happened. In your case that event is the presentation of the sketchpad. So instead of waiting out the duration of the coroutine it will just quit. Can you confirm that?

    By the way, is there a reason you have probe a feedback, and fixation3 a sketchpad? Normally, it doesn't matter, but potentially you will introduce some annoying jitter. Have a look here to get an explanation:


    Thanked by 1mariosav
  • Hi Eduard,
    Thanks for your swift reply. I'm not sure I get what you're saying about the "End after item"...where do I check if this is the case?
    I'm using a feedback for the probe because I set the identity of the stimuli to be displayed with an inline script after the loop is ran (using info from the selection made at the loop). I know that sketchpads are prepared in advance so it wouldn't work with a sketchpad. Is using the canvas a better option than a feedback?

  • This is a screenshot from the image you posted. As you can see, on the top part of the coroutine item, you can specify the fields duration, end after item and generator function. You put something after the second one. Remove it, and you should be set.


    Thanked by 1mariosav
  • I see. When I removed it, it didn't seem to work ok. But when I specified "mouse_response" in the End After field, it seems to work fine (but I have to check the timings in the logged data to verify). Thanks Eduard! Regarding the issue with the feedback items, does using the canvas instead helps for timing purposes?

  • Nice.

    Regarding the issue with the feedback items, does using the canvas instead helps for timing purposes?

    Inline_scripts could help, but it depends on how you program it. Generally, they are just more powerful, as you have more control over order of things and their timing. So, you could invest some time to figure things out and you might improve your experiment. However, often enough feedback and sketchpad items are just as valid, so I'm a little hesitant to say. Inline_scripts are better timing-wise than the other (if your implementation is not good, you could even introduce worse performance)

    Hope that clears things up.


    Thanked by 1mariosav
  • Thanks Eduard. Really appreciate your help.

  • edited July 2018

    One last question and I promise not to bother you again for a bit :) I replaced my feedback objects with sketchpads to ensure accurate timings and all seems to work as envisioned.

    Now, the only thing I am worried about (which is hard to check) is whether the response latency is logged accurately with the coroutine I use with the mouse_response object. I add below my coroutine. The duration of the "prob" is set to 350m and the duration of "fixation3" to 5350ms. I ran the experiment but without clicking a response and expected to see something close to 5350m in the response_time variable. But I get values that are 5344ms or 5333ms. I don't really care about those "non-responses" but this deviation got me worried about the timing of the trials when I actually click the mouse. Is there anything I can do to check? Should I expect deviations that are this big with the co-routine? If yes, maybe it was a bad idea to have a mouse response item in a coroutine?


Sign In or Register to comment.