DetectLarsson360.m 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. % DetectLarsson360.m
  2. %
  3. % This function detect fixations, saccades, smooth pursuit and blinks. Saccades
  4. % and blinks are detected with the DetectSaccades360 and DetectBlinks360 functions.
  5. % The fixations and smooth pursuit are detected per the Larsson et al. 2015 paper
  6. % "Detection of fixations and smooth pursuit movements in high-speed eye-tracking data"
  7. %
  8. % input:
  9. % data - data from the ARFF file
  10. % metadata - metadata from the ARFF file
  11. % attributes - attributes from the ARFF file
  12. % typeOfMotion - 1 -> eye FOV, 2 -> eye+head
  13. % paramSacc - parameters to use for saccade detection. See function DetectSaccades360
  14. % for details
  15. % paramLarsson - parameters for fixation and saccade detection
  16. %
  17. % output:
  18. % result - vector with the same length as data and values (0,1,2,3,4) representing
  19. % {unassigned, fixation, saccade, sp, noise}
  20. %
  21. % paramLarsson format:
  22. % paramLarsson is a data structure with the following fields. For an explanation
  23. % of each field refer to the original paper
  24. %
  25. % paramLarsson.preprocessVelThres;
  26. % paramLarsson.t_window;
  27. % paramLarsson.t_overlap;
  28. % paramLarsson.eta_p;
  29. % paramLarsson.t_min;
  30. % paramLarsson.eta_d;
  31. % paramLarsson.eta_cd;
  32. % paramLarsson.eta_pd;
  33. % paramLarsson.eta_maxFix;
  34. % paramLarsson.eta_minSmp;
  35. % paramLarsson.phi;
  36. % paramLarsson.minConfidence;
  37. function result = DetectLarsson360(data, metadata, attributes, typeOfMotion, paramSacc, paramLarsson)
  38. c_fix = 1;
  39. c_sacc = 2;
  40. c_sp = 3;
  41. c_noise = 4;
  42. attType = '{unassigned,fixation,saccade,sp,noise}';
  43. result = zeros(size(data,1),1);
  44. % detect saccades (parameters for 360 degrees)
  45. saccades = DetectSaccades360(data, metadata, attributes, typeOfMotion, paramSacc);
  46. result(saccades) = c_sacc;
  47. % detect blinks (parameters for 360 degrees) and merge with saccades
  48. blinks = DetectBlinks360(data, metadata, attributes, typeOfMotion, paramSacc);
  49. result(blinks) = c_noise;
  50. % when confidence below threshold assign noise label
  51. confInd = GetAttPositionArff(attributes, 'confidence');
  52. result(data(:,confInd) < paramLarsson.minConfidence) = c_noise;
  53. thd = paramLarsson.preprocessVelThres;
  54. result = preprocessing(data, metadata, attributes, result, thd, typeOfMotion);
  55. t_window = paramLarsson.t_window;
  56. t_overlap = paramLarsson.t_overlap;
  57. eta_p = paramLarsson.eta_p;
  58. prelSeg = preliminary_segment(data, metadata, attributes, result, typeOfMotion, t_window, t_overlap, eta_p);
  59. t_min = paramLarsson.t_min;
  60. eta_d = paramLarsson.eta_d;
  61. eta_cd = paramLarsson.eta_cd;
  62. eta_pd = paramLarsson.eta_pd;
  63. eta_maxFix = paramLarsson.eta_maxFix;
  64. eta_minSmp = paramLarsson.eta_minSmp;
  65. phi = paramLarsson.phi;
  66. result = extract_sp(data, metadata, attributes, result, typeOfMotion, prelSeg, t_min, eta_d, eta_cd, eta_pd, eta_maxFix, eta_minSmp, phi);
  67. end