Welcome!

Sign in with your CogSci, Facebook, Google, or Twitter account.

Or register to create a new account.

We'll use your information only for signing in to this forum.

Supported by

auto response mode doesn't work anymore

timotimo Posts: 21
edited January 10 in OpenSesame

Hi and a happy new year to all of you!
For some reason the auto response mode doesn't work for me anymore. It's been some time since I last used it, so i can't tell since when it stopped working.
Problem occurs with different experiments and in all three "Run" modes.

Any ideas? I am designing a new experiment, which needs some testing. I'd kill (or finally translate missing .md's to German :tongue: ) for auto response mode...
Best,
timo

System
System: Windows
Architecture: 32bit
Modules and packages

OpenSesame 3.1.4
Python 2.7.12 |Continuum Analytics, Inc.| (default, Jun 29 2016, 11:42:13) [MSC v.1500 32 bit (Intel)]
QProgEdit 4.0.6
datamatrix 0.3.1
qdatamatrix 0.1.9
pseudorandom 0.2.2
fileinspector 1.0.2
QNotifications 1.1.1
QOpenScienceFramework 1.1.8
opencv [not available]
expyriment 0.8.1.opensesame2
IPython 4.2.0
numpy 1.11.1
scipy 0.17.1
PIL/ PILLOW 1.1.7
psychopy 1.82.01
pygame 1.9.2a0
pygaze 0.6.0a21
pyglet 1.2.4
PyQt 4.11.4
serial 2.7
markdown 2.6.6
bidi 0.4.0
yaml 3.11

Comments

  • sebastiaansebastiaan Posts: 2,403

    Hi Timo,

    Right, auto-response has been removed in 3.1. This release included a reworked way to handle responses, and the old (awful) implementation of auto-responses was removed as a part of this. I do want to re-introduce this in the 3.2 series though. But for the immediate future, all I can promise is that I will remove the defunct menu item!

    Any ideas? I am designing a new experiment, which needs some testing. I'd kill (or finally translate missing .md's to German :tongue: ) for auto response mode...

    For now, you can monkey-patch the keyboard class to return a dummy response ('a') right away by putting the following code in the prepare phase of an inline_script at the start of the experiment (replace legacy by the backend that you're using):

    from openexp._keyboard.legacy import legacy as legacy_keyboard
    
    def auto_get_key(*args, **kwargs):
        return 'a', clock.time()
    
    legacy_keyboard.get_key = auto_get_key
    

    And now get translating! :wink:

    Cheers,
    Sebastiaan

    Thanked by 1timo

    There's much bigger issues in the world, I know. But I first have to take care of the world I know.
    cogsci.nl/smathot

  • shamshirshamshir Posts: 10

    Hi timo and sebastiaan,

    Does this mean that, with that code I can "fake" a keyboard response and get a sketchpad to end (that has been set to "keypress"), without having to press any actual key?

    Regards,
    Javi

  • sebastiaansebastiaan Posts: 2,403

    Hi Javi,

    Yes, it does. It basically overrides the real keyboard.get_key() with a custom function that simulates an immediate key press.

    Cheers,
    Sebastiaan

    There's much bigger issues in the world, I know. But I first have to take care of the world I know.
    cogsci.nl/smathot

  • shamshirshamshir Posts: 10
    edited January 12

    Thanks sebastiaan!

    This will be very useful for me. However, i'm having problems getting it to work.

    On one hand, OpenSesame doesn't recognize the module "xpyriment" when I use the same code you posted but with Xpyriment:

    from openexp._keyboard.xpyriment import xpyriment as xpyriment_keyboard
    
    def auto_get_key(*args, **kwargs):
        return 'a', clock.time()
    
    xpyriment_keyboard.get_key = auto_get_key
    

    On the other hand, I'm not entirely sure how to trigger this dummy response. Could it be something like this or does it work in another way?

    for event in pygame.event.get():
            if event.type == pygame.KEYUP:
                auto_get_key
    

    Thanks a lot for your help!
    Regards
    Javi

  • timotimo Posts: 21

    Thanks again, Sebastiaan!!!
    My word is my bond!

  • sebastiaansebastiaan Posts: 2,403

    On one hand, OpenSesame doesn't recognize the module "xpyriment" when I use the same code you posted but with Xpyriment:

    Ow right: The xpyriment backend actually uses the legacy keyboard backend. Each backend is a predetermined combination of a canvas backend, keyboard backend, etc. If you click on backend settings in the General Properties tab, you will see which backends are actually used.

    On the other hand, I'm not entirely sure how to trigger this dummy response. Could it be something like this or does it work in another way?

    You don't need to trigger it: That's the idea of auto-response! The only thing that you need to do is add this code to your experiment.

    There's much bigger issues in the world, I know. But I first have to take care of the world I know.
    cogsci.nl/smathot

  • shamshirshamshir Posts: 10

    Thanks a lot sebastiaan! I wonder if there could be any way to customize this auto-response. I'd like to only use this auto-response in a specific loop and not in the whole experiment and, if posible, only apply the auto-response in specific cases and not with all keyboard_responses.

    If I try to put the inline script in a given loop it only works from that loop on, but I don't know how to stop it for the other loops and trials of the experiment.

    I'm sorry if all this has a very simple answer, but I'm still kind of new to programming.

    Regards
    Javi

  • sebastiaansebastiaan Posts: 2,403

    Hi Javi,

    You can re-enable responses by restoring the original get_key() function. So if you use this script to enable auto responses:

    from openexp._keyboard.legacy import legacy as legacy_keyboard
    
    def auto_get_key(*args, **kwargs):
        return 'a', clock.time()
    
    legacy_keyboard.original_get_key = legacy_keyboard.get_key
    legacy_keyboard.get_key = auto_get_key
    

    Then you can use this script to revert back to normal responses:

    legacy_keyboard.get_key = legacy_keyboard.original_get_key
    

    Do you see the logic?

    Cheers,
    Sebastiaan

    There's much bigger issues in the world, I know. But I first have to take care of the world I know.
    cogsci.nl/smathot

  • shamshirshamshir Posts: 10

    Thank you very much Sebastiaan!
    Yes, I see the logic and it works like a charm!

    Regards
    Javi

Sign In or Register to comment.