Howdy, Stranger!

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

Supported by

[open] Visual world paradigm

edited March 2013 in OpenSesame

Hi!

I want to implement sth very similar to Hunter's (http://forum.cogsci.nl/index.php?p=/discussion/351/mousetracking-and-visual-world-paradigm/p1) so, I have a fixation dot and I want them to click ON the dot, which would then be followed by a sketchpad with four pictures. I am asking them to click on of the pictures.
So, everything looks beautiful, only, the procedure is not restricted (as it should) only on the points of interest. That is,clicking to any part of the screen will make the phase go to the next step.

I know it is trivial. but i can't see where the problem lies..

Thank you in advance,
Sophia

Comments

  • edited 9:26PM

    Hi Sophia,

    If you are not interested in the trajectory of the mouse, it would be easier to use forms with image_button widgets. But since you generally are interested in the trajectory in the visual world paradigm (?), let's see how you can prevent the click from being accepted when it's on an invalid area of the screen.

    Basically, the trick is to check the coordinates of the clicked position against a list of pre-specified valid coordinates, i.e. the coordinates of your images. The principle is illustrated in the script below, which you can combine with the more elaborate script that Hunter posted.

    from math import sqrt
    from openexp.mouse import mouse
    
    # Create a mouse object
    my_mouse = mouse(exp, visible=True)
    
    # Create a list of x,y tuples that correspond to clickable coordinates
    clickableList = [ (100, 100), (512, 384) ]
    
    # The maximum distance that clicks can be from one of the coordinates 
    maxDist = 100
    
    # Go into a loop
    while True:
    
        # Get the cursor position
        position, timestamp = my_mouse.get_pos()
        x, y = position
    
        # See which buttons are pressed
        lclick, mclick, rclick = my_mouse.get_pressed()
    
        # If the left button is pressed
        if lclick:
    
            # Assume that the click is not valid
            clickValid = False
    
            # Walk through all clickable coordinates
            for vX, vY in clickableList:
                # Use Pythagoras to see how far we have clicked from
                # this coordinate ...
                d = sqrt((x-vX)**2 + (y-vY)**2)
                # ... and if close enough decide that the click is 
                # valid!
                if d < maxDist:
                    clickValid = True
    
            # If one of the clicks was valid, break!
            if clickValid:
                break
    

    Hope this helps, and good luck!

    Cheers,
    Sebastiaan

  • edited 9:26PM

    Thank you!
    I'll try it out!

    ~s

Sign In or Register to comment.