' Check to ensure we are to be handling eye data If GetConditionalExitState() <> 0 Then GoTo SaveGazeData_Finish If GetUserBreakState() <> 0 Then GoTo SaveGazeData_Finish If TET_Device Is Nothing Then GoTo SaveGazeData_Finish If TET_Device.GetState() <> ebStateOpen Then GoTo SaveGazeData_Finish If TET_bIsOpen <> True Then GoTo SaveGazeData_Finish If TET_bIsEnabled <> True Then GoTo SaveGazeData_Finish Dim theGazeData As TobiiEyeTrackerResponseData Dim theUserEyeGazeData As UserEyeGazeData Dim nMaxHistoryCount As Long Dim n As Long Dim theSlide As Slide Dim theState As SlideState Dim nObject As Long Dim nLastObject As Long Dim theRunnableInputObject As RteRunnableInputObject Dim theFeedback As FeedbackDisplay Dim theProcedure As Procedure 'Get access to the critical stimulus 'Note: If object not named "Stimulus", change that here. Set theSlide = CSlide(Rte.GetObject("Stimulus")) Debug.Assert Not theSlide Is Nothing If theSlide Is Nothing Then Rte.AbortExperiment -1,"SaveGazeData expected Slide \"Stimulus\". Slide could not be found. SaveGazeData cannot continue." End If ' Get access to the currently active state on the slide Set theState = theSlide.ActiveSlideState ' Set variables to record the eye tracking data for the user defined data ' Obtain the sequential sample number from the currently running list theUserEyeGazeData.TrialId = c.GetAttrib( c.GetAttrib("Running") & ".Sample" ) ' Logs the properties associated with the Prime Attribute theUserEyeGazeData.Prime = c.GetAttrib( "Prime" ) ' Sets AOI1 to Attribute LeftImage in the TrialList theUserEyeGazeData.AOI1 = c.GetAttrib( "LeftImage" ) ' Sets AOI2 to the Attribute RightImage in the TrialList theUserEyeGazeData.AOI2 = c.GetAttrib( "RightImage" ) ' Creates AOI variable to hold the value of the current AOI ' This is set in the script "Determine which E-Prime object was running when this sample was taken" theUserEyeGazeData.AOI = "" ' Creates AOIStimulus variable to hold the string that is a text description of the current AOI ' This is set in the script " Determine which object is being viewed if the critical stimulus is on screen " theUserEyeGazeData.AOIStimulus = "" ' The variables below hold the response timing information of the trial theUserEyeGazeData.CRESP = theSlide.CRESP theUserEyeGazeData.RESP = theSlide.RESP theUserEyeGazeData.ACC = theSlide.ACC theUserEyeGazeData.RT = theSlide.RT ' Logs the current display object theUserEyeGazeData.CurrentObject = "" ' Enumerate through all of the objects on the current Procedure to determine ' which object was active during the eye tracker sample ' We cache the times into an array to make this loop efficient Set theProcedure = CProcedure(Rte.GetObject(c.GetAttrib("Procedure"))) ' If this assert fires then a Procedure cannot be found Debug.Assert Not theProcedure Is Nothing Dim arrOnsets() As Long ReDim arrOnsets(1 To theProcedure.ChildObjectCount) As Long nLastObject = 1 For nObject = 1 To theProcedure.ChildObjectCount Set theRunnableInputObject = CRteRunnableInputObject(Rte.GetObject(theProcedure.GetChildObjectName(nObject))) If Not theRunnableInputObject Is Nothing Then arrOnsets(nObject) = theRunnableInputObject.OnsetTime Set theFeedback = CFeedbackDisplay(Rte.GetObject(theProcedure.GetChildObjectName(nObject))) If Not theFeedback Is Nothing Then Exit For Next ' See how many samples are currently saved in the history nMaxHistoryCount = TET_Device.History.Count ' Write out all the accumulated gaze data For n = 1 To nMaxHistoryCount ' User requested exit? If GetConditionalExitState() <> 0 Then Exit For If GetUserBreakState() <> 0 Then Exit For ' Get the next gaze data point Set theGazeData = CTobiiEyeTrackerResponseData( TET_Device.History( n ) ) If Not theGazeData Is Nothing Then ' Associate the name of the object on screen for this eye data For nObject = nLastObject To theProcedure.ChildObjectCount ' Determine which E-Prime object was running when this sample was taken If theGazeData.RTTime >= arrOnsets(nObject) And arrOnsets(nObject) > 0 Then theUserEyeGazeData.CurrentObject = theProcedure.GetChildObjectName(nObject) ElseIf arrOnsets(nObject) > 0 And Len(theUserEyeGazeData.CurrentObject) > 0 Then ' Object had an onset and timestamp happened before this object onset ' (accounts for objects skipped or do not have a timestamp like InLine) ' Assign the last object used so the next iteration can skip the first ' part of the procedure already covered nLastObject = nObject Exit For End If Next ' Determine which object is being viewed if the critical stimulus is on screen If theGazeData.RTTime >= theSlide.OnsetTime Then Select Case theState.HitTest( theGazeData.CursorX, theGazeData.CursorY ) Case "AOI1" theUserEyeGazeData.AOI = "1" theUserEyeGazeData.AOIStimulus = theUserEyeGazeData.AOI1 Case "AOI2" theUserEyeGazeData.AOI = "2" theUserEyeGazeData.AOIStimulus = theUserEyeGazeData.AOI2 Case "Fixation" theUserEyeGazeData.AOI = "Fixation" theUserEyeGazeData.AOIStimulus = "Fixation" Case Else theUserEyeGazeData.AOI = "" theUserEyeGazeData.AOIStimulus = "" End Select End If ' Write this sample to the user defined gaze data file. UserWriteGazeDataFile c, theGazeData, theUserEyeGazeData End If Next n SaveGazeData_Finish: ' Release references Set theState = Nothing Set theSlide = Nothing Set theGazeData = Nothing Set theFeedback = Nothing Set theRunnableInputObject = Nothing Set theProcedure = Nothing