aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThéo de la Hogue2023-05-10 19:58:25 +0200
committerThéo de la Hogue2023-05-10 19:58:25 +0200
commit4b141c3bd11617a3c24412bfd12e59d8af0962a5 (patch)
tree482e2f258da2198787caeae148364ed043929441 /src
parent9a4ba48dbf6c8cd3d7f1a6d3b2aa7b704f6ede8d (diff)
downloadargaze-4b141c3bd11617a3c24412bfd12e59d8af0962a5.zip
argaze-4b141c3bd11617a3c24412bfd12e59d8af0962a5.tar.gz
argaze-4b141c3bd11617a3c24412bfd12e59d8af0962a5.tar.bz2
argaze-4b141c3bd11617a3c24412bfd12e59d8af0962a5.tar.xz
Adding new gaze analysis.
Diffstat (limited to 'src')
-rw-r--r--src/argaze/GazeAnalysis/CoefficientK.py49
-rw-r--r--src/argaze/GazeAnalysis/__init__.py2
2 files changed, 50 insertions, 1 deletions
diff --git a/src/argaze/GazeAnalysis/CoefficientK.py b/src/argaze/GazeAnalysis/CoefficientK.py
new file mode 100644
index 0000000..724faac
--- /dev/null
+++ b/src/argaze/GazeAnalysis/CoefficientK.py
@@ -0,0 +1,49 @@
+#!/usr/bin/env python
+
+from typing import TypeVar, Tuple, Any
+from dataclasses import dataclass, field
+import math
+
+from argaze import GazeFeatures
+
+import numpy
+
+@dataclass
+class VisualScanPathAnalyzer(GazeFeatures.VisualScanPathAnalyzer):
+ """Implementation of transition probability matrix algorithm as described by Christophe Lounis in its thesis "Monitor the monitoring: pilot assistance through gaze tracking and visual scanning analyses".
+ """
+
+ def __post_init__(self):
+
+ pass
+
+ def analyze(self, visual_scan_path: GazeFeatures.VisualScanPathType) -> Any:
+ """Analyze visual scan."""
+
+ assert(len(visual_scan_path) > 1)
+
+ durations = []
+ amplitudes = []
+
+ for visual_scan_step in visual_scan_path:
+
+ durations.append(visual_scan_step.duration)
+ amplitudes.append(visual_scan_step.last_saccade.amplitude)
+
+ durations = numpy.array(durations)
+ amplitudes = numpy.array(amplitudes)
+
+ duration_mean = numpy.mean(durations)
+ amplitude_mean = numpy.mean(amplitudes)
+
+ duration_std = numpy.std(durations)
+ amplitude_std = numpy.std(amplitudes)
+
+ Ks = []
+ for visual_scan_step in visual_scan_path:
+
+ Ks.append(((visual_scan_step.duration - duration_mean) / duration_std) - ((visual_scan_step.last_saccade.amplitude - amplitude_mean) / amplitude_std))
+
+ K = numpy.array(Ks).mean()
+
+ return K \ No newline at end of file
diff --git a/src/argaze/GazeAnalysis/__init__.py b/src/argaze/GazeAnalysis/__init__.py
index 7603693..faddbce 100644
--- a/src/argaze/GazeAnalysis/__init__.py
+++ b/src/argaze/GazeAnalysis/__init__.py
@@ -2,4 +2,4 @@
.. include:: README.md
"""
__docformat__ = "restructuredtext"
-__all__ = ['DispersionThresholdIdentification', 'VelocityThresholdIdentification', 'TransitionProbabilityMatrix'] \ No newline at end of file
+__all__ = ['DispersionThresholdIdentification', 'VelocityThresholdIdentification', 'TransitionProbabilityMatrix', 'CoefficientK'] \ No newline at end of file