Howdy, Stranger!

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

Supported by

set allowed responses for touch_response item while keeping timeout option

edited November 2016 in OpenSesame

Hi there,

I'm trying to make a simple Go/NoGo- Task for android devices. I've already read that there's currently no option to set allowed responses for a touch_response item. My intention is to make the participant wait until a timeout of 2 sec is over in case of NoGo trails and to tap a certain part of the screen and continuing immediately with the next trial in case of GoTrials. That worked out fine so far.
The problem ist, that the next trial does not only appear when the correct_response is given but also when there's a tap on any other part of the screen. In case of any trials, I want any other responses to be ignored AND I want to keep the timeout for any trial UNLESS there is a correct response in case of a GoTrial.

I've already tried to solve this by adding an inline_script following the description in this discussion:
http://www.cogsci.nl/forum/index.php?p=/discussion/1030/solved-restricting-allowed-choices-in-touch-response-not-possible/p1

but I couldn't manage to keep the timeout option for the previous touch_response item. The above inline_script makes OpenSesame crash as soon as I give a response which isn't allowed instead of ignoring it.

I'd be really glad if someone had a solution for this

thanks,
Sophie

Comments

  • Hi Sophie,

    The discussion you linked us to was probably written with an older version of Opensesame. Can you post the error message of the crash you encountered? MAybe you can share your current version with us, so we can debug together?

    At any rate, the solution would probably look like this (conceptually)

    while timeout not reached:
        wait for a touch response
        if response in a predefined ROI:
           break the loop and proceed with next trial
        if not:
           do nothing
    

    Does it help?

    Eduard

    Buy Me A Coffee

  • edited December 2016

    Thanks for your response, Eduard!

    I am using OpenSesame 3.1.4 Jazzy James.
    I tried to copy your solution into an inline script right after the touch response item and after doing so, I got the following error message:

    Stopped

    The experiment did not finish normally for the following reason:

    Failed to compile inline script
    Details

    code: while timeout not reached:
    item-stack: experiment[run].experimental_loop[run].block_sequence[run].block_loop[run].trial_sequence[prepare].new_inline_script_3[prepare]
    exception type: SyntaxError
    exception message: invalid syntax (, line 2)
    item: new_inline_script_3
    time: Sat Dec 10 14:59:52 2016
    phase: run
    line: 1
    Traceback (also in debug window)

    File "C:\Program Files (x86)\OpenSesame\lib\site-packages\libopensesame\inline_script.py", line 73, in prepare
    self.var.get(u'_run', _eval=False))
    File "C:\Program Files (x86)\OpenSesame\lib\site-packages\libopensesame\python_workspace.py", line 147, in _compile
    return compile(script, u'', u'exec')
    File "", line 2
    while timeout not reached:
    ^
    SyntaxError: invalid syntax

  • Hi Sophie,

    The script Eduard suggested is not actually a working script, but rather a concept of what such a script should look like ('pseudocode').

    Could you provide the original error code that occured before you added the new inline script?

    Best,
    Laurent

  • Hello Laurent,

    here is the inline script that I previously used:

    allowed_responses = [26]
    while self.get('response') not in allowed_responses:
    exp.items['touch_response'].run()

    The "correct response button" ist on position 26 (I divided the screen into 9 rows and 3 columns).

    This is the error message I got:

    Stopped

    The experiment did not finish normally for the following reason:

    Error while executing inline script
    Details

    item-stack: experiment[run].experimental_loop[run].block_sequence[run].block_loop[run].trial_sequence[run].new_inline_script_3[run]
    exception type: AttributeError
    exception message: _flush not found
    item: new_inline_script_3
    time: Mon Dec 12 12:21:07 2016
    phase: run
    Traceback (also in debug window)

    File "C:\Program Files (x86)\OpenSesame\lib\site-packages\libopensesame\inline_script.py", line 102, in run
    self.experiment.python_workspace._exec(self.crun)
    File "C:\Program Files (x86)\OpenSesame\lib\site-packages\libopensesame\python_workspace.py", line 161, in _exec
    exec(bytecode, self._globals)
    File "", line 4, in
    File "C:\Program Files (x86)\OpenSesame\lib\site-packages\libopensesame\mouse_response.py", line 128, in run
    if self._flush:
    File "C:\Program Files (x86)\OpenSesame\lib\site-packages\libopensesame\item.py", line 238, in getattr
    raise AttributeError(u'%s not found' % var)
    AttributeError: _flush not found

  • Hi Sophie,

    The inline script you used is written in an older version of OpenSesame. Would it help if you changed it to

    allowed_responses = [26]
    while var.response_touch_response not in allowed_responses:
        exp.items['touch_response'].run()
    

    Note that the method of referring to variables has changed, no need to use self.get('variable') anymore. The error message probably occured due to older code. Let me know if it works!

    Best,
    Laurent

  • Hi Laurent,

    I changed the inline script and now it says the following:

    Stopped

    The experiment did not finish normally for the following reason:

    The variable 'response_touch_response' does not exist. Tip: Use the variable inspector (Ctrl+I) to see all variables.
    Details

    item-stack: experiment[run].experimental_loop[run].block_sequence[run].block_loop[run].trial_sequence[run].new_inline_script[run]
    time: Mon Dec 12 14:09:10 2016

    Do I have to replace "response_touch__response" with another (actual) variable from my experiment?

  • Hi Sophie,

    Yes, my bad. That is the name of the variable i just used to check it. Your should replace var.response_touch_response with var.response_[name of your variable]

  • edited December 2016

    ok, thanks
    I think it works now. The only problem is, that now, I'm stuck with the current item when not giving the right response instead of continuing as soon as the timeout is over.

  • Hi Sophie,

    Did you work this problem out yet? If not, it might be an idea to replace the loop described above with some other loop that keeps track of time. And instead of running the touch-response item repeatedly after an erroneous error, have the program stop momentarily ('sleep') and wait for the timeout:

    Before the touch_response item, add an inline_script where, in the run-phase, you state

        start_time = self.time()
    

    Then, after the touch_response item add the following to your script:

    timeout = 2000
    allowed_responses = [26]    
    
    while True:
            # Check the time that has passed since stimulus presentation
            var.current_time = self.time() - start_time
            if var.response_touch_response not in allowed_responses:
                # If unallowed answer is provided, sleep for remainder of time and end trial
                self.sleep(timeout-var.current_time)
                break
            elif var.response_touch_response in allowed_responses:
                # If allowed response is provided, continue to next trial
                break
            elif var.current_time > timeout:
                # If no response is provided, wait until timeout is reached and continue to next trial
                break
    

    This should avoid being stuck with the same item over and over again. Depending on what you want to measure and how you want to provide feedback you can split this loop for Go and NoGo trials. Furthermore, you could assign variables (e.g. var.correct_answer) within the loop to check for correct and incorrect answers and possibly display feedback based on the answers.

    Disclaimer: i don't have a tablet available at the moment so i haven't checked how it behaves on an actual touch-screen. Good luck!

    Best,
    Laurent

  • it works perfectly fine this way! Thank you very much!

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