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
예제 #2
0
 def close(self, tracker):
     """Close Eyelink, import data file, close graphics, close tracker."""
     tracker.setOfflineMode()
     file_name = self.data_file_name
     data_folder = self.data_folder
     tracker.receiveDataFile(file_name, data_folder + file_name)
     pylink.closeGraphics()
     tracker.close()
예제 #3
0
 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)
예제 #4
0
 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()
예제 #5
0
파일: EyeTracking.py 프로젝트: invibe/ANEMO
    def End_exp(self):
        # Transfert et nettoyage de fichiers!
        self.eyelink.setOfflineMode()
        pylink.msecDelay(500)

        # Fermez le fichier et transférez-le sur Display PC
        self.eyelink.closeDataFile()

        self.eyelink.receiveDataFile(self.edfFileName, self.edfFileName_2)
        self.eyelink.close()

        # Fermer les graphiques de l'expérience
        pylink.closeGraphics()
예제 #6
0
 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
예제 #7
0
파일: mcbsf.py 프로젝트: egorananyev/mc
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()
예제 #8
0
 def closeConnectionToEyeTracker(self, eyeMoveFile):
     #Clean everything up, save data and close connection to tracker
     if self.tracker != None:
         # File transfer and cleanup!
         self.tracker.setOfflineMode()
         core.wait(0.5)
         #Close the file and transfer it to Display PC
         self.tracker.closeDataFile()
         self.tracker.receiveDataFile(self.edfFileName, eyeMoveFile)
         self.tracker.close()
         #Close the experiment graphics
         pylink.closeGraphics()
         return "Eyelink connection closed successfully"
     else:
         return "Eyelink not available, not closed properly"
예제 #9
0
 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 closeConnectionToEyeTracker(self,eyeMoveFile):
     #Clean everything up, save data and close connection to tracker
     if self.tracker != None:
         # File transfer and cleanup!
         self.tracker.setOfflineMode();
         core.wait(0.5)
         #Close the file and transfer it to Display PC
         self.tracker.closeDataFile()
         self.tracker.receiveDataFile(self.edfFileName,eyeMoveFile) 
         self.tracker.close();
         #Close the experiment graphics
         pylink.closeGraphics()
         return "Eyelink connection closed successfully"
     else:
         return "Eyelink not available, not closed properly"
예제 #11
0
def CoolDown():
    
    # Save behavioral data
    thisExp.nextEntry() # advance data file
    thisExp.saveAsWideText(filename + '.csv')
    
    # stop recording eye data
    pylink.endRealTimeMode()
    pylink.pumpDelay(100)
    error = tk.stopRecording()
    
    # Clear the screen
    win.flip()
    
    # display cool-down message
    message1.setText("That's the end! ")
    message2.setText("Press 'q' or 'escape' to end the run.")
    win.logOnFlip(level=logging.EXP, msg='Display TheEnd')
    message1.draw()
    message2.draw()
    win.flip()
    
    # Wait for keypress
    thisKey = event.waitKeys(keyList=['q','escape'])

    # --- EyeLink code --- #
    # close the EDF data file
    tk.setOfflineMode()
    tk.closeDataFile()
    pylink.pumpDelay(50)

    # Get the EDF data and say goodbye
    message1.text='Data transfering.....'
    message1.draw()
    win.flip()
    tk.receiveDataFile(dataFileName, dataFolder + dataFileName)

    #close the link to the tracker
    tk.close()

    # close the graphics
    pylink.closeGraphics()
    # --- End EyeLink code --- #

    # exit
    win.close()
    core.quit()
예제 #12
0
    def terminate(self):
        # File transfer and cleanup!
        self.tracker.setOfflineMode()
        pylink.msecDelay(500)

        # Close the file and transfer it to Display PC
        self.tracker.closeDataFile()
        self.tracker.receiveDataFile(self.trackerDatafile, self.localDatafile)
        self.tracker.close()

        self.display_message('Eyelink disconnected.')

        # Close the experiment graphics
        pylink.closeGraphics()

        # convert the edf file to asc file
        self.edf2asc()
예제 #13
0
def EyelinkStop(Name, el=pylink.getEYELINK()):
    """ Performs stopping routines for the EyeLink 1000 Plus eyetracker.

    **Author** : Wanja Mössing, WWU Münster | [email protected] \n
    *July 2017*

    Parameters:
    -----------
    Name    : string
        filename of the edf. Doesn't have to, but can, end on '.edf'
        Must be the same name used during EyelinkStart()
    el : Eyelink Object
        Eyelink object returned by EyelinkStart().
        By default this function tried to find it itself.
    """
    # Check filename
    if '.edf' not in Name.lower():
        Name += '.edf'
    # stop realtime mode
    pylink.endRealTimeMode(0)
    # make sure all experimental procedures finished
    pylink.msecDelay(1000)
    # stop the recording
    el.stopRecording()
    # put Eyelink back to idle
    el.setOfflineMode()
    # wait for stuff to finish
    pylink.msecDelay(500)
    # close edf
    el.closeDataFile()
    # transfer edf to display-computer
    try:
        print('Wait for EDF to be copied over LAN...')
        if not path.exists('./EDF'):
            mkdir('./EDF')
        el.receiveDataFile(Name, './EDF/' + Name)
        print('Done. EDF has been copied to ./EDF folder.')
    except RuntimeError:
        print('Error while pulling EDF file. Try to find it on Eyelink host..')
    el.close()
    pylink.closeGraphics()
    return
예제 #14
0
def EyelinkStop(Name, el=pylink.getEYELINK()):
    """ Performs stopping routines for the EyeLink 1000 Plus eyetracker.

    **Author** : Wanja Mössing, WWU Münster | [email protected] \n
    *July 2017*

    Parameters:
    -----------
    Name    : string
        filename of the edf. Doesn't have to, but can, end on '.edf'
        Must be the same name used during EyelinkStart()
    el : Eyelink Object
        Eyelink object returned by EyelinkStart().
        By default this function tried to find it itself.
    """
    # Check filename
    if '.edf' not in Name.lower():
            Name += '.edf'
    # stop realtime mode
    pylink.endRealTimeMode()
    # make sure all experimental procedures finished
    pylink.msecDelay(1000)
    # stop the recording
    el.stopRecording()
    # put Eyelink back to idle
    el.setOfflineMode()
    # wait for stuff to finish
    pylink.msecDelay(500)
    # close edf
    el.closeDataFile()
    # transfer edf to display-computer
    try:
        print('Wait for EDF to be copied over LAN...')
        if not path.exists('./EDF'):
            mkdir('./EDF')
        el.receiveDataFile(Name, './EDF/'+Name)
        print('Done. EDF has been copied to ./EDF folder.')
    except RuntimeError:
        print('Error while pulling EDF file. Try to find it on Eyelink host..')
    el.close()
    pylink.closeGraphics()
    return
예제 #15
0
# set up the camera and calibrate the tracker at the beginning of each block
tk.doTrackerSetup()

# run a block of trials
testList = trials[:] * 1  # construct the trial list
random.shuffle(testList)  # randomize the trial list

# Looping through the trial list
for t in testList:
    runTrial(t)

# close the EDF data file
tk.setOfflineMode()
tk.closeDataFile()
pylink.pumpDelay(50)

# Get the EDF data and say goodbye
msg.text = 'Data transfering.....'
msg.draw()
win.flip()
tk.receiveDataFile(dataFileName, dataFolder + dataFileName)

#close the link to the tracker
tk.close()

# close the graphics
pylink.closeGraphics()
win.close()
core.quit()
예제 #16
0
 def close_connection(self):
     self.tracker.close()
     pl.closeGraphics()
예제 #17
0
 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///'
예제 #18
0
파일: mcbsf.py 프로젝트: egorananyev/mc
def drCor(el,dr,cd):
    pl.openGraphics(dr,cd)
    el.doDriftCorrect(calScreenCenter[0], calScreenCenter[1], 1, 0)
    pl.closeGraphics()
    print '///Finished drift correction///'
예제 #19
0
    def close_connection(self):
        """Closes the connection to the tracker.

        Must be called at the end of the experiment."""
        self.tracker.close()
        pl.closeGraphics()