diff options
-rw-r--r-- | src/argaze/GazeAnalysis/CoefficientK.py | 49 | ||||
-rw-r--r-- | src/argaze/GazeAnalysis/__init__.py | 2 |
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 |