aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/argaze/GazeAnalysis/KCoefficient.py29
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: