|
|
|
Forum Member
      
Group: Forum Members
Last Login: 9/23/2008 11:37:24 AM
Posts: 30,
Visits: 146
|
|
My lab does eyetracking research with infants. With the new release of the eyetracking extensions for tobii and E-Prime 2.0 I have the task of building up a habituation paradigm. What this entails is showing the subject a particular movie over and over again, up to a preset maximum number of trials. Trial lengths are entirely dictated by looking time, so that the movie clip will continue to play (up to a maximum length) until the subject looks away for a specific period of time.
Primary Concerns
- Varying the trial lengths: Repeat a movie clip until time limit passes OR subject looks away for longer than 2 seconds.
- Varying the number of trials: The block needs to end when two consecutive trial times (looking times) are less than half of the length of the initial trial.
- The two second look-away rule: The eyetracking extensions have a package call to wait for a fixation of a specified duration, but I need the opposite. What I am most unclear about is how to
keep track of how long something has been happening (for example, how long the subject has held down a key)
|
|
|
|
|
Forum Member
      
Group: Forum Members
Last Login: 9/23/2008 11:37:24 AM
Posts: 30,
Visits: 146
|
|
This is what I've come up with so far for handling keyboard events.
The subroutine checks the keyboard history every 200ms and uses the RTTime values to get accurate time measures.
Does anyone know of a way to have an event respond directly to a keypress/release instead of having to check the history?
'Array for trial lengths
Dim habitArray(11) As Summation
'Summation for handling the sliding window
Dim slidingWindow As Summation
'Keeps track of how many trials have COMPLETED
Dim trialCount As Integer
'Stores the startpoint of the current trial in milliseconds (relative to exp start)
Dim trialTimer As Long
'Stores information about the last keypress
Dim theResponseData As ResponseData
'Timestamp of the beginning of the current look
Dim lookStart As Long
'Total time of last look
Dim lookTime As Long
'Timestamp of look-away start
Dim lookAwayStart As Long
'Total time of last look-away
Dim lookAwayTime As Integer
'Keyboard event handler - checks last key pressed at regular intervals
Sub doHabitEvents()
Dim doAdd As Boolean
lookAwayTime = -1
lookAwayStart = -1
trialTimer = habitClip.FirstFrameTime
'This loop Handles Keyboard Events
Do
Set theResponseData = Keyboard.History(Keyboard.History.Count)
Select Case theResponseData.RESP
Case "5"
'this only runs the first time (when key is first pressed)
if Keyboard.History(Keyboard.History.Count - 1).RESP <> "5" and doAdd = false then
lookStart = theResponseData.RTTime
lookAwayTime = 0
Display.Canvas.text 0, 0, "5 Pressed "& theResponseData.RTTime
doAdd = true
End if
Case "{-5}"
'doAdd will only be true if the last key was 5 down
if doAdd = true then
lookAwayStart = theResponseData.RTTime
lookTime = theResponseData.RTTime - lookStart
habitArray(trialCount).AddObservation lookTime
Display.Canvas.text 0, 0, "5 Released "& theResponseData.RTTime
Display.Canvas.text 500,0, "Looking time: " & habitArray(trialCount).Total
doAdd = false
End if
Case "r"
Case "{-r}"
Exit Do
Case Else
'any other key starts trial timer
Display.Canvas.text 500, 30, "Trial Time: " & Clock.Read - trialTimer
End Select
'keep track of time looked away
if theResponseData.RESP <> "5" and lookAwayStart <> -1 and lookAwayTime <> -1 then
lookAwayTime = Clock.Read - lookAwayStart
Display.Canvas.text 0,30, "Looked away for: " & lookAwayTime
End if
'Check for end of trial and end trial
if Clock.Read - trialTimer >= 90000 or lookAwayTime >= 2000 then
Exit Sub
End if
Sleep 200
Loop
End Sub
|
|
|
|