I got eye tracking gaze data in the form of x/y coordinates and timestamps.
Now I want to plot the saccades using the R package saccades. Unfortunately, it doesn't work. I guess it's a matter of having the data in the wrong format.
My data:
head(EUFKDCDL_Q09AS_saccades)
# A tibble: 6 x 4
time x y trial
<dbl> <dbl> <dbl> <dbl>
1 1550093577941 732 391 1
2 1550093577962 706 320 1
3 1550093577980 666 352 1
4 1550093578000 886 288 1
5 1550093578017 787 221 1
6 1550093578037 729 302 1
The code that didn't work:
fixations <- detect.fixations(EUFKDCDL_Q09AS_saccades)
Error in detect.fixations(EUFKDCDL_Q09AS_saccades) : No saccades were detected. Something went wrong.
The full code that shouldwork according github (https://github.com/tmalsburg/saccades):
library(saccades)
data(samples)
head(samples)
time x y trial
1 0 53.18 375.73 1
2 4 53.20 375.79 1
3 8 53.35 376.14 1
4 12 53.92 376.39 1
5 16 54.14 376.52 1
6 20 54.46 376.74 1
fixations <- detect.fixations(samples)
head(fixations[c(1,4,5,10)])
trial x y dur
0 1 53.81296 377.40741 71
1 1 39.68156 379.58711 184
2 1 59.99267 379.92467 79
3 1 18.97898 56.94046 147
4 1 40.28365 39.03599 980
5 1 47.36547 35.39441 1310
diagnostic.plot(samples, fixations)
So there must be a problem with how my data is structured I guess? What does the mean?
I hope that any of you can help me creating this saccade plot as in the sceenshot attached
I am an R beginner.
Before you attempt to analyse your data, you must visualise it. This will help you see if the data is actually what you think it is, and to show qualitatively the extent of some data quality issues.
If your data is actually a gaze data time series, then you could visualise it as in your example above simply by plotting x
as a function of time
and y
as a function of time
. This would not require that you run the data through a saccade detection algorithm first. The plot you show above is simply a visualisation of the raw data, with the saccade detections superimposed (the grey lines), but that is an optional step.
Now to your raw data: if you plot it as suggested, I suspect it isn't going to be what you think it is. Compare it to the example data that you posted from https://github.com/tmalsburg/saccades. That dataset shows a couple of characteristics:
x
position shifting from 53.18
to 53.20
from one sample to the next). This is typical of real gaze data during a fixation. During a saccade, adjacent samples start changing much more rapidly of course, and you can often detect them visually simply by scrolling down a column of values and noting where the adjacent values change quickly. Compare this to your data, which is completely different: values bounce up and down erratically from one sample to the next (e.g. from 732
to 706
to 666
to 886
in successive samples). This is not typical of a good gaze data signal. So plot your time series and see what you actually have there.I suspect that there are discontinuities in your data, and this will cause any saccade or fixation detection algorithm to fail. Try to figure out what your data actually is representing, and/or what the quality issues are, before attempting to parse into saccades and fixations.
Hint: using the ggplot2
library to visualise your data:
library(ggplot2)
ggplot(data = EUFKDCDL_Q09AS_saccades,
aes(x = time)) + # define time series x axis
geom_line(aes(y = x), colour = 'red') + # plot horizontal data
geom_line(aes(y = y), colour = 'yellow') # plot vertical time series too
If ggplot2
isn't installed, call install.packages('ggplot2')
first.