Howdy, Stranger!

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

Supported by

[solved] Accuracy based on mouse location

edited September 2014 in OpenSesame

Hi everyone!

I'm a relatively new user of OpenSesame, I've only built 2 experiments so far. However I find it awesome!

I'm currently building an experiment in which, after a presentation of 5 geometrical shapes and sounds appearing in 5 successive 3x3 matrices, the subjects would be asked to relocate a shape or a sound in an empty matrix thanks to the mouse.

I'm only working with screen coordinates. Here is a diagram showing what it looks like:

image

When the subjects clicks, the program is supposed to return a number (1 through 9) according to the location of the click. Assuming that it couldn't be done with the mouse_response element, I've added an inline_script.

I've already coded something, but when OpenSesame comes to the answer screen, it freezes and I must exit manually.

Here's my code:

        from openexp.mouse import mouse
        my_mouse = mouse(exp, buttonlist = ([1]), visible = True)


        n_click = 0
        max_click = 1


        while n_click < max_click:

      position = my_mouse.get_click()
      x,y = position

      if x>518 and x<813 and y<299:
          exp.set("answer", 1)

      if x>813 and x<1108 and y<299:
          exp.set("answer", 2)

      if x>1108 and x<1403 and y<299:
          exp.set("answer", 3)  

      if x>518 and x<813 and y>299 and y<598:
          exp.set("answer", 4)


      if x>813 and x<1108 and y>299 and y<598:
          exp.set("answer", 5)


      if x>1108 and x<1403 and y>299 and y<598:
          exp.set("answer", 6)


      if x>518 and x<813 and y>598 and y<897:
          exp.set("answer", 7)


      if x>813 and x<1108 and y>598 and y<897:
          exp.set("answer", 8)


      if x>1108 and x<1403 and y>598 and y<897:
          exp.set("answer", 9)

      n_click += 1 

It's not really fancy but I thought it might work. I'm stuck, the rest of the experiment is ready, and that's the only thing that keeps me from moving on. I'm sure I'm missing something, like with the "canvas" function or something, but I'm not sure.

So I'm asking for your help! Please?

Comments

  • edited 3:53AM

    Hi,

    Your script looks ok, assuming that the indentation is correct (but I guess that got messed up when pasting it here on the forum). But there's a plug-in for this very purpose: the touch_response. So it will probably be easier to use that.

    See also:

    Good luck!
    Sebastiaan

  • edited 3:53AM

    Thanks! That's great! I didn't know it existed. I should have looked harder. I'm trying this out as soon as I get enough time to! Looking to the description, I'm sure it will fit!
    I'll keep you posted!

    Thanks again!

    Yojimbanima.

  • edited 3:53AM

    Hi again!

    I've tried the touch_response plug-in, though it doesn't exactly fit to my expectations, I've incorporated it in my experiment and drawn a grid corresponding to the touch_response boundaries.

    Unfortunately, a problem remains. The program crashes during the parallel plug-in named "Reponse" which includes a inline_script named "Grille" and touch_response plug-in named "Response_Matrix".

    Here's a link to download my experiment:

    https://onedrive.live.com/redir?resid=54E977011C3388B0!818

    Do you have any idea why this happens?

    By the way, I'd like to apologize if I made any typing mistake. As you can see in my experiment, English is not my native language.

  • edited 3:53AM

    Hi Yojimbanima,

    I cannot download your experiment, but the parallel plug-in is known to be unstable. What happens exactly? Does OpenSesame crash completely, or do you see a Python stacktrace in the debug window? (If so, please post.)

    By the way, I'd like to apologize if I made any typing mistake. As you can see in my experiment, English is not my native language.

    Don't worry and welcome to the club ;-)

    Cheers,
    Sebastiaan

  • edited 3:53AM

    Hi!

    Opensesame crashes completely or acts as if the experiment was over.

    This new link should solve the download problem:

    https://onedrive.live.com/redir?resid=54E977011C3388B0!820&amp;authkey=!AFDS1xK32ZXpEqU&amp;ithint=file,gz

    Thanks for your help!

    Yojimbanima.

  • edited 3:53AM

    Hi Yojimbanima,

    The parallel plug-in is best avoided, because, as I mentioned above, it can be unstable. But in your case it doesn't seem to be necessary at all. You use the parallel for two purposes, neither of which require true parallelism:

    1. Playing a sound and showing a stimulus simultaneously. This is not necessary because sound will play in the background if you set the duration to 0.
    2. Showing a canvas and collecting a response. This is not necessary, because you can simply show the canvas first and collect the response after (i.e. sequentially).

    So I think you should be fine if you just avoid the parallel plug-in.

    Hope this helps!

    Sebastiaan

  • edited 3:53AM

    Hi!

    Thank you so much for your help. I'll work on that. I'll keep you informed.

    Take care!

    Yojimbanima.

  • edited October 2014

    Hi again!

    I got rid of all the occurrences of the parallel plug-in. Then, I aslo got rid of the touch_response plug-in that didn't quite match my expectations.

    I used an in-line script to draw an empty grid (which dimensions correspond to my presentation matrix) in which the subjects would have to relocate the geometrical shapes or the sources of the sounds they heard.

    The accuracy is based on the location of the mouse when it gets clicked returning a number corresponding to the different locations in the empty grid.

    Again, thank you so much for your help and your availability! Keep on doing such a good job!

    Yojimbanima.

Sign In or Register to comment.