Howdy, Stranger!

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

Supported by

[solved] Keyboard Arrows for Selection

edited December 2015 in OpenSesame

I'm trying to design a paradigm where a participant needs to rate a stimulus from a range of 1-5. This would be easy if it wasn't an fMRI, and as the case is such, I can't use mouse clicks. (We don't have an MRI compatible mouse)

A previous paradigm coded on E-Prime made use of a keyboard with 4 buttons. 2 of them were used to toggle left and right (to select options 1-5) and one key was used as a 'select' option.

I've seen the forms and the questionnaire templates, but all of them rely on single button/mouse clicks. How would I be able to build my desired kind of a paradigm? I'm not too familiar with Python either.

Comments

  • edited December 2015

    Hi Jacob,

    This will indeed require a bit of Python coding, but nothing terribly complicated. Below you see an example of how you can adjust a 5-point scale with left/ right key presses, and accept by pressing space. The logic is explained in the code comments. You'll probably need to modify it a bit for your purpose, but it should get you started!

    See also:

    Cheers,
    Sebastiaan

    # For OpenSesame >= 3.0
    
    # Create a keyboard and canvas object
    cnv = canvas()
    kb = keyboard(keylist=['left', 'right', 'space'])
    
    # For the score, we use a 0 - 4 scale, and start at 2
    min_score = 0
    max_score = 4
    var.score = 2 # Use var to make this an experimental variable
    
    question = 'How awesome is OpenSesame?'
    
    while True:
        # Example: A score of two would be "XX___"
        # Clear the canvas and show this score string
        score_str = var.score*'X' + (max_score-var.score) * '_' 
        cnv.clear()
        cnv.text('%s<br /><br />%s' % (question, score_str))
        cnv.show()
        # Collect a response, and break the loop (i.e. accept the response)
        # When a space is pressed. Decrease the score for 'left', and increase
        # the score for 'right'.
        response, timestamp = kb.get_key()
        if response == 'space':
            break
        if response == 'left':
            var.score = max(min_score, var.score-1)
        elif response == 'right':
            var.score = min(max_score, var.score+1)
    
  • edited 1:58AM

    Hey Sebastien,

    Thanks a bunch!! Yes, I modified it a bit to suit the experiment, but on the whole its just perfect. Thanks a bunch!
    4 stars for you and Open Sesame.

    Cheers!

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