Howdy, Stranger!

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

Supported by

Touch response coordinates

Hello everyone!

First of all, I'm loving the experiment builder! I'm an absolute newbie still, but the idea of running experiments on a tablet opens up so many possibilities, and I'm definitely excited to try!

One question I have is whether it is possible to get the coordinates of a touch response in pixel space (or close to it). As I understand it, Open Sesame allows to divide the screen into rows and columns so that each resulting region has its own discrete identifier. However, for an experiment I am trying to build, I would need the location of the response to be as continuous as possible, in order to then calculate the angle between the touch location and another point on the screen. I know that detecting locations on a touchscreen is by necessity a matter of approximation to an extent, but I was wondering if Open Sesame would allow me to do this within the accuracy limits of the hardware itself.

I hope this makes sense. I probably shouldn't try to explain myself after midnight.

Comments

  • Hi Fabio,

    That's what the mouse_response item does! When working with a touch screen, a touch is (for most purposes) equivalent to a mouse click.

    Cheers,
    Sebastiaan

  • Thank you, that makes sense. I guess I took "mouse response" quite literally :)

  • I'm sorry to resurrect this thread, but I've only just been able to get back to OpenSesame and I'm now finding it rather tricky to build my experiment.

    The sequence involves a visual stimulus being presented on a sketchpad item while an audio recording plays through a sampler item. That much I can do. However, I then need participants to make a touchscreen response on a new sketchpad, and I need an arrow element to be drawn on it with the apex of the arrow pointing in the direction of the location participants touched on the screen. Think of it as a compass.

    That's where I'm stuck, as I'm not sure how to reference the screen coordinates of the touch response. Any help welcome!

  • Hi Fabio,

    A touch response is essentially behaving like a mouse response. However, I think it will be rather tricky to get the coordinates of a click by only using the plugin. Probably it is better if you used some inline_scripting, see here.

    The second return value of mouse.get_click()gives you the coordinates of that click. These you can use the draw the arrow into the direction, you want. Will you also need help with that, or is that reasonably clear?

    At any rate, let me know if you need more help.

    Eduard

    Buy Me A Coffee

  • Hi Eduard,

    Yes, I ended up using an inline script to do this, it now works just as I need it to. Just in case anyone else needs to do something similar, this is my code.

    This part sets up the canvas that participants will use to perform their response. I actually create two canvases, one with an arrow element and one without. That way, when participants make their response, the canvas and arrow will be re-drawn, giving the impression that the arrow has moved. There may be a more elegant way of achieving that effect, but it works for my purposes.

    starting_canvas = canvas()
    my_mouse = mouse()
    
    while True:
            starting_canvas.clear()
            starting_canvas.text("INSTRUCTIONS", center=True, x=0.0, y=372.0, color='white')
            starting_canvas.circle(0, 0, 300, color='white')
            default_canvas = canvas()
            default_canvas.copy(starting_canvas)
            starting_canvas.arrow(0, 0, 0, -300, body_width=0.5, head_width=30, fill = True)
    

    Here I record the time the canvas first appears, and collect the both the time the response is made and the coordinates of the response. These are saved as a tuple, but I also store the X and Y as separate variables, the values of which I will use later to re-draw the arrow. NOTE: The my_mouse.show_cursor line was meant to help during testing of the script on Windows (the actual experiment will run on Android), but it never actually worked. I believe this is a known issue with some backends.

            t0 = starting_canvas.show()
            starting_canvas.show()
            my_mouse.show_cursor(show=True)
            button, position, t1 = my_mouse.get_click()
            var.pos_tuple = position
            var.xpos = position[0]
            var.ypos = position[1]
            var.arrow_length = xy_distance(0, 0, var.xpos, var.ypos)
    

    Here, the touch response triggers the clearing of the canvas, which is replaced by the original one without the arrow. Then a new arrow is drawn on it with the X and Y of participants' responses as the position of the arrow head.

            if position != None:
                starting_canvas.clear()
                default_canvas.show()
                default_canvas.arrow(0, 0, var.xpos, var.ypos, body_width=0.5, head_width=30, fill = True)
                default_canvas.show()
    

    This bit computes the response time, and the angle of the response (i.e. the angle between the 0 degree vector of the circle and the arrow vector).

                var.RT = t1 - t0
                var.rad_angle = math.atan2((0-var.xpos),(0-var.ypos))
                var.deg_angle = math.degrees(var.rad_angle)*-1
                if 0-(var.xpos) > 0:
                    var.deg_angle = 360-math.degrees(var.rad_angle)
                print('angle is (%f)' % (var.deg_angle))
                var.error = var.deg_angle - var.correct
                print('error is (%f)' % (var.error))
                clock.sleep(1000)
                break
    

    I hope this saves someone a lot of trial and error! I'm sure there are more elegant and efficient ways of writing this, so feedback is welcome.

  • Great! Thanks for sharing.

    Buy Me A Coffee

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