diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/argaze.test/GazeAnalysis/Entropy.py | 41 | ||||
-rw-r--r-- | src/argaze/GazeAnalysis/Entropy.py | 18 |
2 files changed, 54 insertions, 5 deletions
diff --git a/src/argaze.test/GazeAnalysis/Entropy.py b/src/argaze.test/GazeAnalysis/Entropy.py new file mode 100644 index 0000000..47d5556 --- /dev/null +++ b/src/argaze.test/GazeAnalysis/Entropy.py @@ -0,0 +1,41 @@ +#!/usr/bin/env python + +""" """ + +__author__ = "Théo de la Hogue" +__credits__ = [] +__copyright__ = "Copyright 2023, Ecole Nationale de l'Aviation Civile (ENAC)" +__license__ = "BSD" + +import unittest + +from argaze import GazeFeatures +from argaze.GazeAnalysis import Entropy, TransitionMatrix +from argaze.utils import MiscFeatures + +GazeFeaturesTest = MiscFeatures.importFromTestPackage('GazeFeatures') + +class TestAOIScanPathAnalyzer(unittest.TestCase): + """Test AOIScanPathAnalyzer class.""" + + def test_analyse(self): + """Test analyse method.""" + + aoi_scan_path = GazeFeaturesTest.build_aoi_scan_path(['Foo', 'Bar', 'Shu'], ['Bar', 'Shu', 'Foo', 'Bar', 'Shu', 'Foo', 'Bar', 'Shu', 'Foo']) + + entropy_analyzer = Entropy.AOIScanPathAnalyzer() + transition_matrix_analyser = TransitionMatrix.AOIScanPathAnalyzer() + + transition_matrix_probabilities, transition_matrix_density = transition_matrix_analyser.analyze(aoi_scan_path) + stationary_entropy, transition_entropy = entropy_analyzer.analyze(aoi_scan_path, transition_matrix_probabilities) + + # Check aoi scan path + self.assertEqual(len(aoi_scan_path), 9) + + # Check entropy analysis + self.assertAlmostEqual(stationary_entropy, 1.09, 1) + self.assertAlmostEqual(transition_entropy, 0, 1) + +if __name__ == '__main__': + + unittest.main()
\ No newline at end of file diff --git a/src/argaze/GazeAnalysis/Entropy.py b/src/argaze/GazeAnalysis/Entropy.py index 649610c..a760b32 100644 --- a/src/argaze/GazeAnalysis/Entropy.py +++ b/src/argaze/GazeAnalysis/Entropy.py @@ -1,6 +1,12 @@ #!/usr/bin/env python -""" """ +"""Implementation of entropy algorithm as described in: + + K Krejtz, T Szmidt, AT Duchowski. 2014. + Entropy-based statistical analysis of eye movement transitions. + In Proceedings of the Symposium on Eye Tracking Research and Applications, ETRA '14, 159-166. + [DOI=https://doi.org/10.1145/2578153.2578176](DOI=https://doi.org/10.1145/2578153.2578176) +""" __author__ = "Théo de la Hogue" __credits__ = [] @@ -17,15 +23,17 @@ import numpy @dataclass class AOIScanPathAnalyzer(GazeFeatures.AOIScanPathAnalyzer): - """Implementation of entropy algorithm as described in Krejtz et al., 2014 - """ def __post_init__(self): pass - def analyze(self, aoi_scan_path: GazeFeatures.AOIScanPathType, transition_matrix_probabilities: pandas.DataFrame) -> Any: - """Analyze aoi scan path.""" + def analyze(self, aoi_scan_path: GazeFeatures.AOIScanPathType, transition_matrix_probabilities: pandas.DataFrame) -> Tuple[float, float]: + """Analyze aoi scan path. + + * **Returns:** + - stationary entropy + - transition entropy""" assert(len(aoi_scan_path) > 1) |