pylink detection saccades online
Hi,
I am designing an experiment in which I want to make sure people are fixating and not making large saccades when a peripheral cue is presented. I initially thought to do this by getting the gaze position, however I would like it more if I could check online whether participants performed a saccade larger than 1 visual angle. To ensure both fixation and the absence of large saccades, I wrote this function
def showDisplaySampleGaze(showPlaceholders=False, showCue=False, showFixDots=False, showAdapters=False, showTarget=False, showMasks=False, duration=None): max_gaze_deviation = angle2pix(1) failed_fix = 0 timeZero = core.getTime() blue=[] while core.getTime()-timeZero < (duration/1000): # duration specified in the function # draw stimuli if showAdapters: for ad in adapters: ad.draw() if showCue: for cu in cues: cu.draw() elif showPlaceholders: for ph in placeholders: ph.draw() if showFixDots: for fd in fixdots: fd.draw() if showTarget: tg.draw() if showMasks: for mk in masks: mk.draw() # get eye data eye_ev = pylink.getEYELINK().getNextData() # if a saccade is detected then get its amplitude, start position and end position if eye_ev == pylink.ENDSACC: eye_dat = pylink.getEYELINK().getFloatData() sac_amp = eye_dat.getAmplitude() sac_start_pos = eye_dat.getStartGaze() # start position sac_end_pos = eye_dat.getEndGaze() # end position dis_start = np.sqrt(sac_start_pos[0]**2+sac_start_pos[1]**2) dis_end = np.sqrt(sac_end_pos[0]**2+sac_end_pos[1]**2) if sac_amp > max_gaze_deviation and dis_start<max_gaze_deviation and dis_end<max_gaze_deviation: blue.append(1) c = visual.GratingStim(win, tex=None, mask='circle',pos=(0,0), color='blue', size=fdSize) c.draw() win.flip() elif sac_amp < max_gaze_deviation and (dis_start>max_gaze_deviation or dis_end>max_gaze_deviation): blue.append(1) c = visual.GratingStim(win, tex=None, mask='circle',pos=(0,0), color='blue', size=fdSize) c.draw() win.flip() elif sac_amp <= max_gaze_deviation and dis_start<max_gaze_deviation and dis_end<max_gaze_deviation: blue.append(0) win.flip() else: win.flip() if sum(blue)!=0: failed_fix = 1 edf_var('failed_fixation', failed_fix) return failed_fix
The problem is that pylink.getEYELINK().getNextData() returns a number and not an event type. How can I see whether the detected event is a saccade? Is there something wrong in the way I am thinking about this?
The while loop is presented every time a new stimulus is drawn and the stimuli might last on the screen for just 31ms. Does the function pylink.getEYELINK().getNextData() consider also the eye data collected before the while loop? That is, if a participant starts a saccade 80ms before, can I see it ending even if my while loop started 30ms ago? It is a bit convoluted, but I hope the explanation is clear. Many thanks for any help you might provide!
Comments
PS for some reason the indentations are messed up in the code that I pasted
Hi @SINE,
Why do you want a saccade detection and not just a fixation check? Latter is much easier to implement. From personal experience, a few years ago, I also implemented a saccade detector and even though it worked in the end, the process was not nice, and the result was not the most robust algorithm. So, my advice would be to stick with checking the gaze position if you don't necessarily need saccades for some reason.
In terms of your code, I can't help unfortunately, because I don't have experience with using pylink directly. I interacted with the eyetracker via pygaze (which is a higher-level wrapper around pylink for eyelink eyetrackers). If you are interested you can check out my algorithm (in helper_functions the
wait_for
functions. Perhaps that helps.Good luck!
Eduard
Hi @eduard,
thanks for the code, it looks very helpful! I was wondering whether you would know where I can find info about the pylink functions? I have been looking for a github repository or code on SRresearch, but I can't fine them.
Thanks again!
Hi Sine,
The SRResearch forum would be the place, they create the library. I am not sure whether there is a proper documentation anywhere, but the developers will be able to help you if you ask your questions there.
Good luck!
Eduard