blob: d836864f6e831c8b896cfbe8a80c94e725d9d5f8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
#!/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 ScanPathAnalyzer(GazeFeatures.ScanPathAnalyzer):
"""Implementation of Coefficient K algorithm as proposed by A. Duchowski and Krejtz, 2017.
"""
def __post_init__(self):
pass
def analyze(self, scan_path: GazeFeatures.ScanPathType) -> Any:
"""Analyze scan path."""
assert(len(scan_path) > 1)
durations = []
amplitudes = []
for scan_step in scan_path:
durations.append(scan_step.duration)
amplitudes.append(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 scan_step in scan_path:
Ks.append(((scan_step.duration - duration_mean) / duration_std) - ((scan_step.last_saccade.amplitude - amplitude_mean) / amplitude_std))
K = numpy.array(Ks).mean()
return K
@dataclass
class AOIScanPathAnalyzer(GazeFeatures.AOIScanPathAnalyzer):
"""Implementation of AOI based Coefficient K algorithm as described by Christophe Lounis in its thesis "Monitor the monitoring: pilot assistance through gaze tracking and aoi scanning analyses".
"""
def __post_init__(self):
pass
def analyze(self, aoi_scan_path: GazeFeatures.AOIScanPathType) -> Any:
"""Analyze aoi scan path."""
assert(len(aoi_scan_path) > 1)
durations = []
amplitudes = []
for aoi_scan_step in aoi_scan_path:
durations.append(aoi_scan_step.duration)
amplitudes.append(aoi_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 aoi_scan_step in aoi_scan_path:
Ks.append(((aoi_scan_step.duration - duration_mean) / duration_std) - ((aoi_scan_step.last_saccade.amplitude - amplitude_mean) / amplitude_std))
K = numpy.array(Ks).mean()
return K
|