DetectFixations360IDT.m 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. % DetectFixations360IDT.m
  2. %
  3. % This function detects fixations based on the I-DT algorithm of Salvucci,
  4. % Dario D., and Joseph H. Goldberg. "Identifying fixations and saccades in
  5. % eye-tracking protocols." Proceedings of the 2000 symposium on Eye
  6. % tracking research & applications. ACM, 2000.
  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. % dispThres - dispersion threshold in degrees
  14. % windowDur - window duration in us
  15. %
  16. % output:
  17. % result - logical vector with same length as input and true where a
  18. % fixaton was detected
  19. function result = DetectFixations360IDT(data, metadata, attributes, typeOfMotion, dispThres, windowDur)
  20. [eyeFovVec, eyeHeadVec] = GetCartVectors(data, metadata, attributes);
  21. if (typeOfMotion == 1)
  22. vecList = eyeFovVec;
  23. elseif (typeOfMotion == 2)
  24. vecList = eyeHeadVec;
  25. else
  26. error('Uknown motion');
  27. end
  28. timeInd = GetAttPositionArff(attributes, 'time');
  29. startInd = 1;
  30. result = false(size(data,1),1);
  31. endInd = FindEndInd();
  32. while (endInd > 0)
  33. dispersion = GetMaxDispersion(vecList(startInd:endInd,:));
  34. if (dispersion > dispThres)
  35. startInd = startInd + 1;
  36. endInd = FindEndInd();
  37. continue;
  38. end
  39. while(dispersion < dispThres && endInd <= size(data,1))
  40. newDisp = GetDispersion(vecList(endInd,:), vecList(startInd:endInd,:));
  41. dispersion = max([newDisp dispersion]);
  42. endInd = endInd + 1;
  43. end
  44. result(startInd:endInd-1) = 1;
  45. startInd = endInd;
  46. endInd = FindEndInd();
  47. end
  48. function l_endInd = FindEndInd()
  49. l_endInd = -1;
  50. for l_ind=startInd:size(data,1)
  51. if (data(l_ind, timeInd) - data(startInd,timeInd) > windowDur)
  52. break;
  53. end
  54. l_endInd = l_ind;
  55. end
  56. end
  57. end