def _setup_eyelink(win_size): """set up the eyelink eye-tracking """ # Connect to eyelink eyetracker = pylink.EyeLink('192.168.1.5') pylink.openGraphics() # Set content of edf file eyetracker.sendCommand('link_sample_data=LEFT,RIGHT,GAZE,AREA') eyetracker.sendCommand( 'file_sample_data=LEFT,RIGHT,GAZE,AREA,GAZERES,STATUS') eyetracker.sendCommand( 'file_event_filter=LEFT,RIGHT,FIXATION,SACCADE,BLINK,MESSAGE,BUTTON') # Set coords eyetracker.sendCommand('screen_pixel_coords=0 0 {} {}'.format(*win_size)) eyetracker.sendMessage('DISPLAY_COORDS 0 0 {} {}'.format(*win_size)) # Calibrate eyetracker.setCalibrationType('HV5') eyetracker.doTrackerSetup(win_size) pylink.closeGraphics() return eyetracker
def setup_eyelink(self): '''Thank you very much ''' # call for eyelink self.eyelink_tracker = pl.EyeLink("100.1.1.1") #parameters for eyelink self.monitor = monitors.Monitor('testMonitor') self.winSize = self.monitor.getSizePix() self.foreground = (250,250,250) self.background = (127,127,127) # create file self.edfFileName = "cbConfig" + str(self.subjectID) if len(self.edfFileName) > 8: self.edfFileName = self.edfFileName[0:8] pl.getEYELINK().openDataFile(self.edfFileName) pl.getEYELINK().setOfflineMode() #Eyelink - Gets the display surface and sends a mesage to EDF file; pl.getEYELINK().sendCommand("screen_pixel_coords = 0 0 %d %d"%(self.winSize[0]-1, self.winSize[1]-1)) pl.getEYELINK().sendMessage("Resolution %d %d" %((self.winSize[0]-1, self.winSize[1]-1))) pl.getEYELINK().sendMessage("EyeToScreen %d" %(self.monitor.getDistance())) pl.getEYELINK().sendMessage("MonitorWidth %d" %(self.monitor.getWidth())) #EyeLink - Set data file contents pl.getEYELINK().sendCommand("file_sample_data = LEFT,RIGHT,GAZE,AREA,GAZERES,STATUS,HTARGET,INPUT") pl.getEYELINK().sendCommand("link_sample_data = LEFT,RIGHT,GAZE,GAZERES,AREA,STATUS,HTARGET,INPUT") #EyeLink - Set Filter contents pl.getEYELINK().sendCommand("file_event_filter = LEFT,RIGHT,FIXATION,SACCADE,BLINK,MESSAGE,BUTTON,INPUT") pl.getEYELINK().sendCommand("link_event_filter = LEFT,RIGHT,FIXATION,SACCADE,BLINK,BUTTON,INPUT") #EyeLink - Set Calibration Environment pl.setCalibrationColors(self.foreground, self.background); #Sets the calibration target and background color - background color should match testing background pl.flushGetkeyQueue() pl.getEYELINK().setOfflineMode() winX = int(self.winSize[0]) winY = int(self.winSize[1]) pl.openGraphics((winX,winY),32) pl.getEYELINK().doTrackerSetup() pl.closeGraphics() pl.setCalibrationSounds("", "", ""); pl.setDriftCorrectSounds("", "off", "off"); # close configuration file event.clearEvents() pl.getEYELINK().closeDataFile() transferFileName = self.edfFileName + '.edf' # fileName pl.getEYELINK().receiveDataFile(self.edfFileName, transferFileName)
def eyeTrkCalib(self, colordepth=32): """ callibration. not used? @param colordepth - color depth of display (why?) """ sp = self.sp pl.openGraphics(sp, colordepth) pl.setCalibrationColors((255, 255, 255), (0, 0, 0)) pl.setTargetSize(int(sp[0] / 70), int(sp[1] / 300)) pl.setCalibrationSounds("", "", "") pl.setDriftCorrectSounds("", "off", "off") self.el.doTrackerSetup() pl.closeGraphics()
def calibrate(self): ''' Open a pygame window, run a calibration routine and close it. ''' # start the main calibration/validation interface pylink.openGraphics(self.size) # these commands cause a hard crash if sent before openGraphics pylink.setCalibrationColors(self.fgcolor, self.bgcolor) pylink.setTargetSize(self.targetdiameter, self.targethole) self.tracker.doTrackerSetup() self.eyeused = self.tracker.eyeAvailable() pylink.closeGraphics() return
def eyeTrkCalib (el=el,dr=dr,cd=cd): # "opens the graphics if the display mode is not set" pl.openGraphics(dr,cd) pl.setCalibrationColors((255,255,255),(0,177,177)) pl.setTargetSize(10, 5) pl.setCalibrationSounds("","","") el.setCalibrationType('H3') pl.setDriftCorrectSounds("","off","off") el.disableAutoCalibration() el.doTrackerSetup() el.drawCalTarget(calTarg1) el.drawCalTarget(calTarg2) el.drawCalTarget(calTarg3) pl.closeGraphics() el.setOfflineMode()
def eyeTrkCalib (el,dr,cd): # "opens the graphics if the display mode is not set" pl.openGraphics(dr,cd) pl.setCalibrationColors((255,255,255),(0,177,177)) pl.setTargetSize(10, 5) pl.setCalibrationSounds("","","") el.setCalibrationType('H3') pl.setDriftCorrectSounds("","off","off") el.disableAutoCalibration() el.doTrackerSetup() el.drawCalTarget(calTarg1) el.drawCalTarget(calTarg2) el.drawCalTarget(calTarg3) pl.closeGraphics() el.setOfflineMode()
myDlg.addField('age:', 21) ok_data = myDlg.show() # show dialog and wait for OK or Cancel window = tkinter.Tk() w = window.winfo_screenwidth() h = window.winfo_screenheight() if not myDlg.OK: core.quit() result['name'] = ok_data[0] result['sex'] = ok_data[1] result['age'] = ok_data[2] # eyelinktracker = EyeLink(trackeraddress=None) eyelinktracker = EyeLink() # 眼动仪 pylink.openGraphics((w, h), 32) edfFileName = "%s.EDF" % result['name'] getEYELINK().openDataFile(edfFileName) pylink.flushGetkeyQueue() getEYELINK().setOfflineMode() getEYELINK().sendCommand("screen_pixel_coords = 0 0 %d %d" % (w - 1, h - 1)) getEYELINK().sendMessage("DISPLAY_COORDS 0 0 %d %d" % (w - 1, h - 1)) if getEYELINK().getTrackerVersion() == 2: getEYELINK().sendCommand("select_parser_configuration 0") else: getEYELINK().sendCommand("saccade_velocity_threshold = 35") getEYELINK().sendCommand("saccade_acceleration_threshold = 9500") getEYELINK().setFileEventFilter( "LEFT,RIGHT,FIXATION,SACCADE,BLINK,MESSAGE,BUTTON") getEYELINK().setFileSampleFilter("LEFT,RIGHT,GAZE,AREA,GAZERES,STATUS") getEYELINK().setLinkEventFilter("LEFT,RIGHT,FIXATION,SACCADE,BLINK,BUTTON")
eye = "left" # Note that for Eyelink 1000/II, the file name cannot exceeds 8 characters # we need to open eyelink data files early so as to record as much info as possible tk.openDataFile(EDF) # add personalized header (preamble text) tk.sendCommand("add_file_preamble_text 'Psychopy GC demo'") screen, screen_width, screen_height = psypsyinterface.initialisation_pygame( (200, 200, 200)) #### MONITOR INFO: Initialize custom graphics for camera setup & drift correction ################## ################# ## SET MONITOR ## pylink.openGraphics([screen_width, screen_height]) #### TRACKER SETUP: Set up the tracker ################################################################ # we need to put the tracker in offline mode before we change its configrations tk.setOfflineMode() # sampling rate, 250, 500, 1000, or 2000 tk.sendCommand('sample_rate 500') # Online parser configuration: 0-> standard/coginitve, 1-> sensitive/psychophysiological # [see Eyelink User Manual, Section 4.3: EyeLink Parser Configuration] tk.sendCommand('select_parser_configuration 0') # Set the tracker to record Event Data in "GAZE" (or "HREF") coordinates tk.sendCommand("recording_parse_type = GAZE") # inform the tracker the resolution of the subject display # [see Eyelink Installation Guide, Section 8.4: Customizing Your PHYSICAL.INI Settings ]
import pygame import fixdur_tracker as tracker import pylink pygame.init() # set up the window surf = pygame.display.set_mode((1280, 960), 0, 32) pylink.openGraphics() el = tracker.Tracker(surf, 'test1.edf') el.setup() el.start_trial()
def drCor(el=el,dr=dr,cd=cd): pl.openGraphics(dr,cd) el.doDriftCorrect(calScreenCenter[0], calScreenCenter[1], 1, 0) pl.closeGraphics() print '///Finished drift correction///'
def _init_graphics(self): self.screen = pygame.display.get_surface() self.screenRect = self.screen.get_rect() pylink.openGraphics()
def drCor(el,dr,cd): pl.openGraphics(dr,cd) el.doDriftCorrect(calScreenCenter[0], calScreenCenter[1], 1, 0) pl.closeGraphics() print '///Finished drift correction///'
def Start_exp(self): # --------------------------------------------------- # point de départ de l'expérience # --------------------------------------------------- pylink.openGraphics((self.screen_width_px, self.screen_height_px), 32) # Initialise les graphiques self.eyelink.openDataFile(self.edfFileName) # Ouvre le fichier EDF. # réinitialise les touches et réglez le mode de suivi en mode hors connexion. pylink.flushGetkeyQueue() self.eyelink.setOfflineMode() # Définit le système de coordonnées d'affichage et envoie un message à cet effet au fichier EDF; self.eyelink.sendCommand( "screen_pixel_coords = 0 0 %d %d" % (self.screen_width_px - 1, self.screen_height_px - 1)) self.eyelink.sendMessage( "DISPLAY_COORDS 0 0 %d %d" % (self.screen_width_px - 1, self.screen_height_px - 1)) # --------------------------------------------------- # NETOYER ??? version = 3 # --------------------------------------------------- tracker_software_ver = 0 eyelink_ver = self.eyelink.getTrackerVersion() if eyelink_ver == 3: tvstr = self.eyelink.getTrackerVersionString() vindex = tvstr.find("EYELINK CL") tracker_software_ver = int( float(tvstr[(vindex + len("EYELINK CL")):].strip())) if eyelink_ver >= 2: self.eyelink.sendCommand("select_parser_configuration 0") if eyelink_ver == 2: # Éteignez les caméras scenelink self.eyelink.sendCommand("scene_camera_gazemap = NO") else: self.eyelink.sendCommand("saccade_velocity_threshold = 35") self.eyelink.sendCommand("saccade_acceleration_threshold = 9500") # Définir le contenu du fichier EDF self.eyelink.sendCommand( "file_event_filter = LEFT,RIGHT,FIXATION,SACCADE,BLINK,MESSAGE,BUTTON,INPUT" ) if tracker_software_ver >= 4: self.eyelink.sendCommand( "file_sample_data = LEFT,RIGHT,GAZE,AREA,GAZERES,STATUS,HTARGET,INPUT" ) else: self.eyelink.sendCommand( "file_sample_data = LEFT,RIGHT,GAZE,AREA,GAZERES,STATUS,INPUT" ) # Définir les données du lien (utilisé pour le curseur du regard) self.eyelink.sendCommand( "link_event_filter = LEFT,RIGHT,FIXATION,FIXUPDATE,SACCADE,BLINK,BUTTON,INPUT" ) if tracker_software_ver >= 4: self.eyelink.sendCommand( "link_sample_data = LEFT,RIGHT,GAZE,GAZERES,AREA,STATUS,HTARGET,INPUT" ) else: self.eyelink.sendCommand( "link_sample_data = LEFT,RIGHT,GAZE,GAZERES,AREA,STATUS,INPUT" ) ############################# # Calibration ############################# pylink.setCalibrationColors( (255, 255, 255), (128, 128, 128) ) # Définit couleur de la cible d'étalonnage (blanc) et de l'arrière-plan (gris) pylink.setTargetSize(self.screen_width_px // 70, self.screen_width_px // 300) # Définit taille de la cible d'étalonnage pylink.setCalibrationSounds("", "", "") pylink.setDriftCorrectSounds("", "off", "off")