eye tracking experiments august 29th, 2014 daniel schreij vu cognitive psychology departement

37
Eye tracking experiments August 29th, 2014 Daniel Schreij VU Cognitive Psychology departement http://ems.psy.vu.nl/userpages/data-analysis- course

Upload: dante-latus

Post on 14-Dec-2015

216 views

Category:

Documents


0 download

TRANSCRIPT

  • Slide 1

Eye tracking experiments August 29th, 2014 Daniel Schreij VU Cognitive Psychology departement http://ems.psy.vu.nl/userpages/data-analysis-course Slide 2 Today Creating eye tracking experiments using OpenSesame and PyGaze Get from EDF (Eyelink Data Format) to other more easily usable data formats Analyze data with Pandas and Python Slide 3 PyGaze Download from http://www.pygaze.orghttp://www.pygaze.org Standalone Python module to communicate with any Eyetracker, with a unified interface (so the code for each eye tracker is the same) Has OpenSesame plug-in Slide 4 Pygaze | Items Initialize Eyetracker (connection & calibration) Drift correct Log message(s) Start recording Stop recording Pause recording Slide 5 PyGaze | Typical experiment Calibrate Per trial/block Drift correct Per trial Start recording Log variables Stop recording Basic steps Slide 6 PyGaze | Another way Start recording at beginning of experiment and stop at the end Drift correct is done afterwards Preferable for pupil dilation data, or similar experiments that require a constant dat stream (even in between trials) Slide 7 PyGaze | Initialize Slide 8 PyGaze | Logging messages Slide 9 Data files After you have run your experiment you often get data files in proprietary formats (.EDF) Developers like you to use their tools... You can then either Use proprietary tools to look at data export them to a textual format Working with the data in textual format enables you to use your own tool chain such as Python and all its modules Slide 10 Data Files | EDF Eyelink data format You can import them to Eyelink Data viewer and then create reports Saccade, fixation, etc. You can use the tool EDF2ASC to convert the EDF file to an ASCII format and then parse it yourself (or with available scripts https://github.com/tknapen/analysis_tools/ ) https://github.com/tknapen/analysis_tools/ Slide 11 Data Files | EDF2ASC MSG 2436129 TRIALID T1Rg200 0 0 220 200 START 2436164 LEFT RIGHT EVENTS PRESCALER 1 VPRESCALER 1 EVENTS GAZE LEFT RIGHT SFIX L 2436164 SFIX R 2436164 MSG 2436678 SYNCTIME MSG 2436678 DRAWN NEW TARGET EFIX L 2436164 2436832 672 321.7 246.8 1422 EFIX R 2436164 2436832 672 321.7 242.1 1683 SSACC L 2436836 SSACC R 2436836 ESACC R 2436836 2436872 40 323.6 247.4 496.5 250.2 6.75 276.4 SFIX R 2436876 ESACC L 2436836 2436876 44 324.3 251.6 500.5 247.4 6.93 273.3 MSG 2436878 ERASED OLD TARGET SFIX L 2436880 EFIX R 2436876 2437000 128 492.7 249.2 1682 SSACC R 2437004 EFIX L 2436880 2437004 128 499.8 245.0 1323 SSACC L 2437008 ESACC L 2437008 2437028 24 506.6 242.2 565.4 251.1 2.35 151.4 ESACC R 2437004 2437028 28 493.9 248.5 551.7 258.4 2.29 147.2 Slide 12 Eyelink Data Viewer Slide 13 Eyelink Data Viewer | Fixations Slide 14 Eyelink Data Viewer | Saccades Slide 15 Eyelink Data Viewer | Samples Slide 16 Eyelink Data Viewer | Heatmap Slide 17 EDF | Saving variables During the experiment, you can send trial variables to the Eyelink to be stored in the EDF file If you use the appropriate syntax, the EDV will recognize them as variables (and not as random messages) These variables can be included in reports which you subject to your analysis scripts later ALWAYS SAVE AS MUCH OPENSESAME VARIABLE DATA AS POSSIBLE TO THE EDF FILE Slide 18 EDF | Variable syntax !V TRIAL_VAR In OpenSesame, send this with send_command() in script exp.eyetracker.send_command("!V TRIAL_VAR RespTime 350") Alternatively, you can use the pygaze_log item Slide 19 Example experiment Slide 20 Example Experiment | log variables Setting background image: !V IMGLOAD FILL Slide 21 Eyelink Data Viewer | Variables Slide 22 Slide 23 Eyelink Data Viewer | Interest Periods Example OpenSesame script for showing stimuli self.fix_canvas.show() self.sleep(1000) exp.eyetracker.send_command("SHOWING target display") self.target_canvas.show() Right before target display is shown, Eyelink receives the message "SHOWING target display" Slide 24 Eyelink Data Viewer | Interest Periods Slide 25 Slide 26 Full trial period From Target presentation Slide 27 Eyelink Data Viewer | Interest Areas Just like variables, you can send commands during your experiment to define interest areas in your display area It is also possible to draw these interest areas after all data has been collected (but this is much more work) Slide 28 Eyelink Data Viewer | Interest Areas Basic syntax !V IAREA [label] For a rectangle !V IAREA RECTANGLE 1 10 5 20 15 cue For a circle !V IAREA ELLIPSE 2 300 200 400 300 target For a custom shaped polygon !V IAREA FREEHAND... [label] Slide 29 Eyelink Data Viewer | Interest Areas Slide 30 Slide 31 Eyelink Data Viewer | Reports EDV has options to export EDF data to other tabular formats as csv or Excel You can create reports containing lists of Saccades Fixations Interest areas Samples Trials Slide 32 Eyelink Data Viewer | Reports Slide 33 Slide 34 Reports | Analysis You can use your favorite software to read in and start analyzing these report files Excel, MatLab, R, SPSS, Pandas, etc. For pandas raw_data = pd.read_csv("SaccadeReport.csv") Slide 3596 and correct==1") # Only get first saccades criteria = "CURRENT_SAC_INDEX == 1 and " criteria += "CURRENT_SAC_NEAREST_END_INTEREST_AREA_LABEL != '.'" first_saccades = work_data.query(criteria) # Create pivot table cols = ["onset","CURRENT_SAC_NEAREST_END_INTEREST_AREA_LABEL"] fs_pt = first_saccades.pivot_table("rt",index="cue", columns=cols, aggfunc="count") # Plot data (fs_pt/fs_pt.sum().sum()).plot(kind="bar")"> Analysis example try: raw_data except: raw_data = pd.read_csv("ExampleData.csv",sep=";") # Drop empty columns (don't know why these are there....) raw_data = raw_data.drop(raw_data.columns[-10:],axis=1) # Filter data to only contain real and correct trials work_data = raw_data.query("TRIAL_INDEX > 96 and correct==1") # Only get first saccades criteria = "CURRENT_SAC_INDEX == 1 and " criteria += "CURRENT_SAC_NEAREST_END_INTEREST_AREA_LABEL != '.'" first_saccades = work_data.query(criteria) # Create pivot table cols = ["onset","CURRENT_SAC_NEAREST_END_INTEREST_AREA_LABEL"] fs_pt = first_saccades.pivot_table("rt",index="cue", columns=cols, aggfunc="count") # Plot data (fs_pt/fs_pt.sum().sum()).plot(kind="bar") Slide 36 Analysis example Slide 37 # RT pivot table cols = ["onset","CURRENT_SAC_NEAREST_END_INTEREST_AREA_LABEL"] fs_pt = first_saccades.pivot_table("rt",index="cue", columns=cols,aggfunc="mean") fs_pt.plot(xlim=[-0.5,1.5],ylim=[650,1000],style="o-")