Howdy, Stranger!

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

Supported by

[solved] keypress or time limit?

edited May 2014 in OpenSesame

Hi everybody,

I have an issue I hope someone might help me resolve :
I display a visual stimulus using sketchpad item. the duration is set
to 1000ms before it disappears - afterwards I had to put another blank
sketchpad or it won't disappear. then I have a keyboard response element.
it works fine minus one thing - if I try to answer before 1000ms are over,
it won't accept my keypress - how can I make accept the answer and move to the next item
if key press is within the presenting time zone ?

thank you !

Comments

  • edited February 2013

    Hi,

    In your experiment it's not surprising that participants cannot respond until 1000ms-since-sketchpad-onset have passed. Because a trial sequence is ran in sequential order, the keyboard item is simply not initiated by then.

    To collect responses immediately after sketchpad and until 1000 ms are passed, you could do the following:

    • Set the duration of your sketchpad to 0. This does not mean that the sketchpad is presented for only 0ms, but that the experiment will advance to the next item (the keyboard_response) right away. Since the keyboard_response waits for a response, but doesn't change the screen, the target will remain visible until a response has been given.
    • Set the timeout of your keyboard_response item to 1000 ms. This is the maximum interval that the keyboard_response waits before deciding that the response was incorrect and setting the 'response' variable to 'None' (in OpenSesame 0.27, in previous versions 'response' get's the value 'timeout').
    • When the keyboard_response item is followed by another sketchpad item (blank screen), this one will be presented as soon as a participant responded or a timeout occurred.

    Does such a trial sequence lead to the desired behaviour? If you still have questions, don't hesitate to ask!

    By the way, I think the best way to become familiar with OpenSesame is by following the step-by-step tutorial (which covers all the above tips and much more). The tutorial can be downloaded here:

    Good luck!

    Lotje

    Did you like my answer? Feel free to Buy Me A Coffee :)

  • edited February 2013

    EDIT: I see Lotje was a wee bit quicker!

    Hi!

    You could set the sketchpad's Duration to 0 and put a keyboard_response directly behind it. Next, set the keyboard_response's timeout to 1000 ms. Now you present the sketchpad for a 1000 ms or until a key is pressed. After 1000 ms, it will disappear and no keypress can be registered anymore, though (your experiment will simply continue).

    If you do not want this to happen, put a second keyboard_response straight behind the first one, with a timeout of 'infinite'. Now, in the sequence item where both keyboard_responses are part of, set the Run if of the second keyboard_reponse to: [response] = 'timeout'. Be sure to but a blank screen between the keyboard_responses if you do not want your stimulus presented after the 1000 ms!

    Good luck!

  • edited 7:49PM

    Hi Lotje, Eric !

    first of all thank you so much for helping !
    I tried what you suggested, but it's not quite what I need.
    I want the patient to have as much time as he wants to respond, but
    the visual stimulus to disappear after 1000ms. If I do as you suggest,
    every answer that is pressed beyond 1000ms is considered erroneous
    even it is correct, any ideas ?

    thanks

    yot

  • edited 7:49PM

    p.s. - I did went through the entire tutorial - was very much helpful to a clueless guy like me ! :)

  • edited 7:49PM

    If you did everything right, the stimulus should disappear after 1000 ms with my solution:

    • sketchpad (showing stimulus), duration: 0 ms
    • keyboard_response_1, timeout: 1000 ms
    • sketchpad (showing blank screen), duration: 0 ms
    • keyboard_response_2, timeout: infinite (Run if: [response] = 'timeout')

    Have you set the correct response correctly in the second keyboard_response?

  • edited 7:49PM

    Just a quick note, to avoid confusion. The Run-if statement should be:

    [response] = None

    It used to be 'timeout', but this was changed in 0.27 to increase consistency (at the expensive of this minor, but unfortunate backwards-incompatibility). To make it work in all versions, use:

    [response] = None or [response] = timeout

    Cheers!

  • edited 7:49PM

    again thank you all, still doesn't work.
    Edwin with your solution for some reason it never runs
    the second keyboard response element (considering sebastiaan
    remark as well).
    and another question - so it does work, I would still get as if
    they were mistaken for the first keyboard response item - furthermore,
    some of the answer would be counted on the first keyboard response
    (in those the patient was fast enough) and others would on the second one -
    so I think it'll ruin my statistics.
    what do you say?

  • edited February 2013

    Hi yotam,

    First, considering the fact that it does not work: I believe None might be perceived as a string (i.e. 'None'), instead of as how it should (i.e. None). Therefore, when the first keyboard_response returns None, it is compared with the entry in the sequence's Run if-statement, which would look as something like this:

    if 'None' == None:
        run this item
    

    To us it's clear that those are kind of the same, but Python has no clue. Sebastiaan, is this actually true? In that case, this would make a fine addition for the list of bugs to be fixed. (I see one simple solution: putting back 'timeout'; otherwise I'm guessing the OpenSesame syntax should recognize None-types, which seems like quite a bit of work...)

    Now, on to when this would work (you could make it work by using OpenSesame 0.26, btw). You could log two different responses: response_keyboard_response_1 and response_keyboard_response_2 by selecting both of them in a log item placed right after the nr. 2 (this would result in having two columns in your logfile, named after the keyboard_response items). The total RT would be the RT of both of these together if a participant took over 1000 ms, or simply that of keyboard_response_1 if the participant was fast enough.

    Same goes for the response itself: if a participant was fast enough, it would be keyboard_response_1, otherwise it would be 'keyboard_response_2'. It should be fairly easy to implement this in an analysis script.

    Other solution: use the following inline_scripts:

    inline_script_1 (run phase, place right after the second sketchpad)

    exp.set("response_1", exp.get("response"))
    exp.set("response_time_1", exp.get("response_time"))
    

    inline_script_2 (run phase, right after second keyboard response, put Run if to same as keyboard_response_2!)

    exp.set("response_time", exp.get("response_time_1") + exp.get("response_time"))
    
  • edited 7:49PM

    Hi guys,

    The situation is easier than it might seem. Neither the variable types (string or None) nor the response times are really an issue. For the response times, Edwin's solution should work (and you can do it post-hoc during the analysis as well, as long as you log all variables), but here's a note on the type issue:

    I believe None might be perceived as a string (i.e. 'None'), instead of as how it should (i.e. None).

    OpenSesame script (of which run-if statements are part) does indeed not recognize the Python None type. But that's not a problem, because OpenSesame will take care of that by automatically choosing variable types in a way that is intended to give the most intuitive results:

    In general, you don't have to worry about types and quotes in Run-if statements. In cases where this becomes ambiguous, you can switch to using Python code by prepending an '=' sign (but this isn't necessary here).

    In other words, this Run-if statement should be fine:

    [response] = None

    For a working example, see:

    Hope this helps!

    Cheers,
    Sebastiaan

  • edited 7:49PM

    Well, turns out i'm an ** !
    Edwin, your solution did work - I did not capitalize the 'N' of None
    so it didn't work. The logging issue on the other hand remains - because
    I have now 2 keyboard response items - so if the patient does not answer
    within 1000ms, it gets correct = 0 , if he answers correct while the next keyboard
    response element is on (after 1000ms) it gets correct = 1 - that means for the same stimulus he gets both correct = 1 and correct = 0 hence accuracy = 50% which is obviusoly wrong.

    the reaction time logging is not as it should be either - because for each response it calculates the average of both keyboard response items - example - if the patient answered after 2000ms - that means 1000ms for the first item + 1000ms for the second item - he will get response time of 1500 for this answer ! which is ofcourse wrong . ...
    I'm uploading an image of my logfile so you could see what I mean.

    You guys are really great,
    thank you so much !!

    yotam

    image

  • edited 7:49PM

    I tried this and it worked well (even with a longer sequence). The feedback, however, seems to be affected. How do I only take into account the provided response (of two or more keyboard responses, for each of the moments on which the participant can interrupt the sequence) in the average RT and accuracy?

  • edited 7:49PM

    I tried this and it worked well (even with a longer sequence). The feedback, however, seems to be affected.

    That's true. Both response items modify the feedback variables, and this throws things off. The easiest way to get around this is probably to keep track of the feedback through an inline_script item. Just before the block_loop, you add an inline_script to clear (and initialize) the feedback variables:

    # Create an empty list to remember the rt and correctness for each response
    global lRt, lCorrect
    lRt = []
    lCorrect = []
    

    Then, after the response collection, you insert a simple script that updates avg_rt and acc, so you can use these in a feedback item n the regular way:

    # We assume that the variables `response_time` and `correct`
    # are correctly set at this point.
    #
    # Add the current response to lRt and lCorrect and use these
    # lists to determine `avg_rt` and `acc`.
    global lRt, lCorrect
    lRt.append(self.get('response_time'))
    if self.get('correct') in (0,1): # correct may also be 'undefined'
        lCorrect.append(self.get('correct'))
    exp.set('avg_rt', 1.*sum(lRt)/len(lRt))
    if len(lCorrect) > 0:
        exp.set('acc', 100.*sum(lCorrect)/len(lCorrect))
    else:
        exp.set('acc', 'undefined')
    

    Hope this helps!

  • edited 7:49PM

    The combination of the two solutions (computing the response time by adding two measurements) and the modified feedback worked!

    My solution, allowing a response after the presentation of the second stimulus:


    Image and video hosting by TinyPic

    With this additional code to compute the response time:

    if self.get('response_time_keyboard_250')<250:
    exp.set('response_time',self.get('response_time_keyboard_250'))

    if self.get('response_time_keyboard_250')>=250 and self.get('response_time_keyboard_500')<500:
    exp.set('response_time',self.get('response_time_keyboard_250')+self.get('response_time_keyboard_500'))

    if self.get('response_time_keyboard_250')>=250 and self.get('response_time_keyboard_500')>=500:
    exp.set('response_time',self.get('response_time_keyboard_250')+self.get('response_time_keyboard_500')+self.get('response_time_keyboard_infinite'))

    My first bit of Python code, so I guess there is still a bit of space for improvement :)

  • edited May 2014

    For an experiment I'm building right now, I had a similar problem. I want to show a stimulus for two seconds and than a blank screen. During both presentation of the stimulus and the blank I want participants to be able to respond. The blank screen is supposed to remain on screen until a response is registered.

    I think I achieved this with just one keyboard response-element and no inline code using a parallel element and a sequence:

    The duration of the word sketchpad is set to the presentation time of two seconds, the blank sketchpad to 0 and the keyboard_response is set to infinite. And I think it records correct response times and responses. ;)

    Does this approach have any drawbacks?

    Edit: Yes, this approach has a major drawback. It works on Linux (Ubuntu) but it crashes when I execute the program on Windows 7. :(

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