diff options
author | Théo de la Hogue | 2023-05-10 10:14:48 +0200 |
---|---|---|
committer | Théo de la Hogue | 2023-05-10 10:14:48 +0200 |
commit | e878adc45ce77cf5d088036a3988bfea909baf1c (patch) | |
tree | 578c1d906c9acc1a038a74b771d3a11d00561435 /src | |
parent | 41f7085be40a360dd564a39b78657876a98e7d74 (diff) | |
download | argaze-e878adc45ce77cf5d088036a3988bfea909baf1c.zip argaze-e878adc45ce77cf5d088036a3988bfea909baf1c.tar.gz argaze-e878adc45ce77cf5d088036a3988bfea909baf1c.tar.bz2 argaze-e878adc45ce77cf5d088036a3988bfea909baf1c.tar.xz |
Adding a new TransitionProbabilityMatrix.py file.
Diffstat (limited to 'src')
-rw-r--r-- | src/argaze/GazeAnalysis/TransitionProbabilityMatrix.py | 32 | ||||
-rw-r--r-- | src/argaze/GazeAnalysis/__init__.py | 2 |
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 |