aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThéo de la Hogue2023-05-10 10:14:48 +0200
committerThéo de la Hogue2023-05-10 10:14:48 +0200
commite878adc45ce77cf5d088036a3988bfea909baf1c (patch)
tree578c1d906c9acc1a038a74b771d3a11d00561435
parent41f7085be40a360dd564a39b78657876a98e7d74 (diff)
downloadargaze-e878adc45ce77cf5d088036a3988bfea909baf1c.zip
argaze-e878adc45ce77cf5d088036a3988bfea909baf1c.tar.gz
argaze-e878adc45ce77cf5d088036a3988bfea909baf1c.tar.bz2
argaze-e878adc45ce77cf5d088036a3988bfea909baf1c.tar.xz
Adding a new TransitionProbabilityMatrix.py file.
-rw-r--r--src/argaze/GazeAnalysis/TransitionProbabilityMatrix.py32
-rw-r--r--src/argaze/GazeAnalysis/__init__.py2
2 files changed, 33 insertions, 1 deletions
diff --git a/src/argaze/GazeAnalysis/TransitionProbabilityMatrix.py b/src/argaze/GazeAnalysis/TransitionProbabilityMatrix.py
new file mode 100644
index 0000000..e27265d
--- /dev/null
+++ b/src/argaze/GazeAnalysis/TransitionProbabilityMatrix.py
@@ -0,0 +1,32 @@
+#!/usr/bin/env python
+
+from typing import TypeVar, Tuple, Any
+from dataclasses import dataclass, field
+import math
+
+from argaze import GazeFeatures
+
+import pandas
+
+@dataclass
+class VisualScanAnalyzer(GazeFeatures.VisualScanAnalyzer):
+ """Implementation of transition probability matrix algorithm as described in ...
+ """
+
+ def __post_init__(self):
+
+ pass
+
+ def analyze(self, visual_scan: GazeFeatures.VisualScanType) -> Any:
+ """Analyze visual scan."""
+
+ assert(len(visual_scan) > 1)
+
+ sequence = []
+
+ for step in visual_scan:
+
+ sequence.append(step.aoi)
+
+ return pandas.crosstab(pandas.Series(sequence[1:], name='to'), pandas.Series(sequence[:-1], name='from'), normalize=1)
+
diff --git a/src/argaze/GazeAnalysis/__init__.py b/src/argaze/GazeAnalysis/__init__.py
index 4643641..2e66274 100644
--- a/src/argaze/GazeAnalysis/__init__.py
+++ b/src/argaze/GazeAnalysis/__init__.py
@@ -2,4 +2,4 @@
.. include:: README.md
"""
__docformat__ = "restructuredtext"
-__all__ = ['DispersionBasedGazeMovementIdentifier'] \ No newline at end of file
+__all__ = ['DispersionBasedGazeMovementIdentifier', 'TransitionProbabilityMatrix'] \ No newline at end of file