aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThéo de la Hogue2023-07-12 14:25:57 +0200
committerThéo de la Hogue2023-07-12 14:25:57 +0200
commit1ca28396352fd122bcaa1128723dae9553df7a70 (patch)
tree7c40ab1eb1c13446786a11ae33e255037e4eb43b
parentacf3fabf7c60aa486c0b8c264283ee449a221326 (diff)
downloadargaze-1ca28396352fd122bcaa1128723dae9553df7a70.zip
argaze-1ca28396352fd122bcaa1128723dae9553df7a70.tar.gz
argaze-1ca28396352fd122bcaa1128723dae9553df7a70.tar.bz2
argaze-1ca28396352fd122bcaa1128723dae9553df7a70.tar.xz
Rewriting basic metrics plugin.
-rw-r--r--src/argaze/GazeAnalysis/Basic.py48
1 files changed, 38 insertions, 10 deletions
diff --git a/src/argaze/GazeAnalysis/Basic.py b/src/argaze/GazeAnalysis/Basic.py
index d6a8ca1..03b2878 100644
--- a/src/argaze/GazeAnalysis/Basic.py
+++ b/src/argaze/GazeAnalysis/Basic.py
@@ -22,17 +22,31 @@ class ScanPathAnalyzer(GazeFeatures.ScanPathAnalyzer):
super().__init__()
- self.__length = 0
+ self.__steps_number = 0
+ self.__step_fixation_durations_average = 0
def analyze(self, scan_path: GazeFeatures.ScanPathType):
"""Analyze scan path."""
- self.__length = len(scan_path)
+ self.__steps_number = len(scan_path)
+
+ sum_fixation_durations = 0
+
+ for scan_step in scan_path:
+
+ sum_fixation_durations += scan_step.fixation_duration
+
+ self.__step_fixation_durations_average = sum_fixation_durations / self.__steps_number
@property
- def length(self) -> float:
+ def steps_number(self) -> float:
- return self.__length
+ return self.__steps_number
+
+ @property
+ def step_fixation_durations_average(self) -> float:
+
+ return self.__step_fixation_durations_average
@dataclass
class AOIScanPathAnalyzer(GazeFeatures.AOIScanPathAnalyzer):
@@ -42,14 +56,28 @@ class AOIScanPathAnalyzer(GazeFeatures.AOIScanPathAnalyzer):
super().__init__()
- self.__length = 0
+ self.__steps_number = 0
+ self.__step_fixation_durations_average = 0
- def analyze(self, scan_path: GazeFeatures.ScanPathType):
- """Analyze scan path."""
+ def analyze(self, aoi_scan_path: GazeFeatures.ScanPathType):
+ """Analyze aoi scan path."""
+
+ self.__steps_number = len(aoi_scan_path)
+
+ sum_fixation_durations = 0
+
+ for aoi_scan_step in aoi_scan_path:
+
+ sum_fixation_durations += aoi_scan_step.fixation_duration
+
+ self.__step_fixation_durations_average = sum_fixation_durations / self.__steps_number
+
+ @property
+ def steps_number(self) -> float:
- self.__length = len(scan_path)
+ return self.__steps_number
@property
- def length(self) -> float:
+ def step_fixation_durations_average(self) -> float:
- return self.__length \ No newline at end of file
+ return self.__step_fixation_durations_average \ No newline at end of file