Howdy, Stranger!

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

Supported by

[open] Define fixation start parameters

edited February 2016 in OpenSesame

Hi,
I'm really new to OpenSesame, and not particularly proficient in Python but I've been able to do pretty much everything I've needed to so far through the GUI. I'm getting stuck with setting a trial to start and end based on fixation at a specific location (I want the trial to begin with fixation at pos x,y and end with a fixation at pos x',y'). I've been looking for an example of the inline code used to do this - the GUI seems to provide the basic functionality for this through the py_gaze_wait button - but in terms of defining the specific parameters (namely, where the gaze needs to be located to continue and for how long) I'm pretty lost. Also, I've read through the pygaze function list and I do see that fixation start/end are included but again, not sure how to implement them inline and I saw that a similar question was asked a few years ago: http://forum.cogsci.nl/index.php?p=/discussion/577/solved-eye-tracking-experiment-question-gaze-contingent-stimuli-presentation/p1, but again the implementation is a little beyond me + it seems like the functionality of OS has greatly expanded since? Apologies if this is a super basic/redundant query!

Thank you!

Comments

  • edited 8:58PM

    Hi,

    I don't know whether you can do what you want just with the GUI. I personally, am using mostly inline_scripts. However, you don't need to worry. The script you would have to write is rather simple. It basically boils down to sampling eye positions, and check whether they lie in any of your defined target regions. Of course, you could do it in more sophisticated ways, but this example provides you with the basic logic. You can look up other commands from the website.

    Btw. The link you mentioned in your post, is rather outdated. It might still be working, but in the meantime there is a more powerful and better approach (pygaze).

    So, here is the example:

    <br /># define some arbitrary ROI
    startx = 0
    starty = 0
    
    endx = 400
    endy = 0
    tolerance = 20
    
    def dist(x1,y1,x2,y2):
        # function to compute the Euclidian distance between two points
        return math.sqrt((x2-x1)**2 + (y2-y1)**2)
    
    t1 = clock.time()
    while True:
          # sample current eye position
          ex,ey = exp.pygaze_eyetracker.sample()
          # measure distance between target region and current position
          if dist(endx,endy,ex,ey)< tolerance:
               print 'Fixated target'
               break
          # 5 seconds timeout
          if clock.time()-t1 >5000:
               break
    

    I hope this helped. Let me know, if you need more explanation.

    Good luck,

    Eduard

  • edited 8:58PM

    Hi Eduard,

    Thank you, that's very helpful. But one main thing:
    I'm still not totally clear on how to integrate the code you provided with the rest of the experiment. To summarize: I'm going to have stimuli (images) at both the start and end eye-position (basically one image in the center and 4 images in the periphery and the images are going to be randomized as well as which peripheral location needs to be looked at to end the trial). I can integrate the images and randomize their location into a sketchpad, and I can probably figure out how to randomize the 'endx, endy' vars, but I'm having trouble integrating the two. Again I apologize as I'm sure if I had a more robust coding background I'd be able to do this with ease.

    Thank you!

  • edited 8:58PM

    Also, when I tried to test run it, it said that it couldn't find the 'math' function?

  • edited February 2016

    Hi,

    Sorry for the last response, I was quite busy recently...

    it said that it couldn't find the 'math' function

    Again sorry. This package needs to be imported before you can use it. Just add import math in the beginning of your inline_script.

    Regarding your first question, the code I provided, is basically what happens during a trial. In particular, the whileloop is what is characteristic for a trial. The stuff before (when I defined the ROI), is what you probably want to set in your loop. If you manage to present your stimuli, in the way you described, you just have to add the code of me in an inline_script as next element in the sequence and you should be done (at least as far as I understand your experiment). So, something like that seems to be alright:

    • block_sequence
    • trial_sequence
      • Show stimuli (one or multiple sketchpad)
      • Monitor eye movements and do stuff once a specific eye movement occurred (inline_script)

    Does this make sense?

    Eduard

  • edited 8:58PM

    Hi Eduard,

    Thanks for your help! Apologies for not getting back. I will test it out sometime in the future and get back to you. Thank you again!

Sign In or Register to comment.