Below is an example of a gaze sequence I recorded during a 3 seconds display. That is, where the eye was at every millisecond. While we should have 3000 points, we are missing some due to blinking.
Fixation or visual fixation is the maintaining of the visual gaze on a single location. I need to extract those fixations. That is group of gazes that are both contiguous in time and space. Below is the location of fixations. Of course we'll have to implement thresholds.
In this file available for download, you will find 7 sequences there if you simply open and run the attached notebook.
gazeSeq[1]
is the first out of 7 sequences made out of 3000 sublists representing each gaze record as {x,y,time}
:
gazeSeq[1][[1]]
Out[1]= {-0.562, 0.125, 1000.}
where time
goes from 1000 to 4000 corresponding to the 3 seconds of display. As said above some data points might be missing.
While I tried to use GatherBy
, I could not manage to include the condition of "time contiguity" and would get grouping of gazes that did not happen during the same interval during the trial.
Answer
Finding the cluster centers is the hard part. There are zillions of ways to do this, such as standardizing $(x,y,t)$ and applying some (almost any) kind of cluster analysis. But these data are special: the eye movement has a measurable speed. The gaze is resting if and only if the speed is low. The threshold for "low" is physically determined (but can also be found in a histogram of the speeds: there will be a break just above 0). That yields the very simple solution: fixations occur at the points of low speed.
It's a good idea to smooth the original data slightly before estimating the speeds:
data = Transpose[Import["f:/temp/gazeSeq_1.dat"]];
smooth = MovingAverage[#, 5] & /@ data;
delta = Differences /@ smooth;
speeds = Prepend[Norm[Most[#]]/Last[#] & /@ Transpose[delta], 0];
Histogram[Log[# + 0.002] & /@ speeds]
The bimodality is clear. The gap is around $\exp(-6)-0.002\approx 0.0005$. Whence
w = Append[smooth, speeds];
ListPlot[#[[1 ;; 2]] & /@ Select[Transpose[w], Last[#] < 0.0005 &],
PlotStyle -> PointSize[0.015]]
There are the gaze fixations. having found them, the clustering is (almost) trivial to do (because each fixation now exists as a contiguous sequence of observations in the original data, from which it is readily split off: this respects the time component as well as the spatial ones). This method works beautifully for all seven of the sample datasets.
One advantage of this approach is that it can detect clusters of very short gaze fixations, even those of just two points in the dataset. These would likely go unnoticed by most general-purpose or ad hoc solutions. Of course you can screen them out later if they are of little interest.
Comments
Post a Comment