With technological advancement, we now have specialized eye-tracking devices that offer high sampling rates, up to 2000 Hz, and allow for measuring eye movements with high accuracy. That is up to you.Eye tracking is a widely used tool for behavioral research in the field of psychology.
#Eye tracking data analysis trial#
Or you don't want to convert your timestamps into seconds or do not want to set the onset of your first trial to 0.
#Eye tracking data analysis code#
Some parts of the code you may need to change, like the index where to split the strings to get the crutial information about event on/offsets. Print ('Could not read ' + str(directory) + ' properly!!! Returned empty data') Return eye_data, fix_data, sac_data, fix_timestamps, sac_timestamps, blink_timestamps, trials, sample_rate # devide TimeStamp to get time in seconds Trials = trials /1000 # does not work with trials/=1000 # substract the first timestamp of trials to set the start of the first video to t0=0 Sac_timestamps = sac_timestamps.rename(columns=event_header)īlink_timestamps = blink_timestamps.rename(columns=event_header) Sac_data = sac_data.rename(columns=data_header)įix_timestamps = fix_timestamps.rename(columns=event_header) # rename header for an even better overviewĮye_data = eye_data.rename(columns=data_header)įix_data = fix_data.rename(columns=data_header) Sac_timestamps = pd.DataFrame(sac_timestamps)īlink_timestamps = pd.DataFrame(blink_timestamps) # convert into pandas fix_data Frames for a better overviewįix_timestamps = pd.DataFrame(fix_timestamps) # then devide by 1000 to convert from milliseconds to seconds # convert every item in list into a float, substract the start of the first trial to set the start of the first video to t0=0 # drop the last data point, because it is the 'END' message # the first element is 'MSG', we don't need it, then we split the second element to seperate the timestamp and only keep it as an integer the blink endedīlink_timestamps.append (.split(' '),row])Įlif any('TRIAL' in item for item in row): Sac_timestamps.append (.split(' '),row])Įlif any('SBLINK' in item for item in row): # stop reading here because the blinks contain NaNĮlif any('EBLINK' in item for item in row): # start reading again. If any('SYNCTIME' in item for item in row): # only start reading after this messageĮlif any('SFIX' in item for item in row): passĮlif any('EFIX' in item for item in row):įix_timestamps.append (.split(' '),row])Įlif any('SSACC' in item for item in row):Įlif any('ESACC' in item for item in row): # Trial messages -> MSG timestamp\t TRIAL Ĭsv_reader = csv.reader(f, delimiter ='\t') # End of EVENTS -> E \t \t \t \t \t \t \t \t # SAMPLES GAZE LEFT RATE 500.00 TRACKING CR FILTER 2 # EVENTS GAZE LEFT RATE 500.00 TRACKING CR FILTER 2 # a bunch of messages containing information about callibration/validation and so on all starting with 'MSG' # a header - every line starts with a '**' # read the file and store, depending on the messages the data Trials: numpy array containing information about trial onsetsĭata_header = Saccades: numpy array containing information about saccade onsets and offsetsīlinks: numpy array containing information about blink onsets and offsets Sac_data: pandas dataframe containing only data from saccadesįixation: numpy array containing information about fixation onsets and offsets It returns eye_data: A pandas dataframe containing data from fixations AND saccades fix_data: A pandas dataframe containing only data from fixations This function takes a directory from which it tries to read in ASCII files containing eyetracking data Revisiting this question after working on my own Eyetracking data I thought I might share a function wrote, to work with my data: def eyedata2pandasframe(directory):
It looks cool and works fine with the example data, but sadly does not work with mine
You can also check out PyGaze, I haven't worked with it, but searching for a toolbox, this one always popped up. The first number corresponds to the timestamp, the second and third to x-y coordinates and the last is your pupil diameter (what the last numbers after ESACC are, I don't know). I don't know your setup but the Eyelink 1000 itself detects saccades and fixation. In this way it is easier to read it to get a first impression.įor this there exist many tools, but I used the SR-Research Eyelink Developers Kit ( here). Hey the question seems rather old but maybe I can reactivate it, because I am currently facing the same situation.