diff options
author | Théo de la Hogue | 2023-10-10 13:51:11 +0200 |
---|---|---|
committer | Théo de la Hogue | 2023-10-10 13:51:11 +0200 |
commit | 992b84ea72e1d20b395ab8d3d50abbd494c1a749 (patch) | |
tree | 72b96ff0e9ab54de100d2ded936bc1ce214446ed | |
parent | 07d8e2535a8d902d5cb731d8343ebc349c198d65 (diff) | |
download | argaze-992b84ea72e1d20b395ab8d3d50abbd494c1a749.zip argaze-992b84ea72e1d20b395ab8d3d50abbd494c1a749.tar.gz argaze-992b84ea72e1d20b395ab8d3d50abbd494c1a749.tar.bz2 argaze-992b84ea72e1d20b395ab8d3d50abbd494c1a749.tar.xz |
Fixing KCoefficient formula.
-rw-r--r-- | src/argaze/GazeAnalysis/KCoefficient.py | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/src/argaze/GazeAnalysis/KCoefficient.py b/src/argaze/GazeAnalysis/KCoefficient.py index 80fe1fd..c50bc3a 100644 --- a/src/argaze/GazeAnalysis/KCoefficient.py +++ b/src/argaze/GazeAnalysis/KCoefficient.py @@ -52,19 +52,24 @@ class ScanPathAnalyzer(GazeFeatures.ScanPathAnalyzer): duration_std = numpy.std(durations) amplitude_std = numpy.std(amplitudes) - Ks = [] - for scan_step in scan_path: + if duration_std > 0. and amplitude_std > 0.: + + Ks = [] + for scan_step in scan_path: + + Ks.append((abs(scan_step.duration - duration_mean) / duration_std) - (abs(scan_step.last_saccade.amplitude - amplitude_mean) / amplitude_std)) + + self.__K = numpy.array(Ks).mean() - Ks.append(((scan_step.duration - duration_mean) / duration_std) - ((scan_step.last_saccade.amplitude - amplitude_mean) / amplitude_std)) + else: - self.__K = numpy.array(Ks).mean() + self.__K = 0. @property def K(self) -> float: """K coefficient.""" return self.__K - @dataclass class AOIScanPathAnalyzer(GazeFeatures.AOIScanPathAnalyzer): @@ -104,12 +109,18 @@ class AOIScanPathAnalyzer(GazeFeatures.AOIScanPathAnalyzer): duration_std = numpy.std(durations) amplitude_std = numpy.std(amplitudes) - Ks = [] - for aoi_scan_step in aoi_scan_path: + if duration_std > 0. and amplitude_std > 0.: + + Ks = [] + for aoi_scan_step in aoi_scan_path: + + Ks.append((abs(aoi_scan_step.duration - duration_mean) / duration_std) - (abs(aoi_scan_step.last_saccade.amplitude - amplitude_mean) / amplitude_std)) + + self.__K = numpy.array(Ks).mean() - Ks.append(((aoi_scan_step.duration - duration_mean) / duration_std) - ((aoi_scan_step.last_saccade.amplitude - amplitude_mean) / amplitude_std)) + else: - self.__K = numpy.array(Ks).mean() + self.__K = 0. @property def K(self) -> float: |