aboutsummaryrefslogtreecommitdiff
path: root/src/argaze.test/GazeAnalysis
diff options
context:
space:
mode:
authorThéo de la Hogue2023-05-31 15:35:28 +0200
committerThéo de la Hogue2023-05-31 15:35:28 +0200
commite35e90d161ffb9202459631a0049448cde905b3c (patch)
tree0ad987c3ffcea30f739cc8e106df2a5f00ad22da /src/argaze.test/GazeAnalysis
parentd1cdae406d349023eb9e221fd226c05744064dfd (diff)
downloadargaze-e35e90d161ffb9202459631a0049448cde905b3c.zip
argaze-e35e90d161ffb9202459631a0049448cde905b3c.tar.gz
argaze-e35e90d161ffb9202459631a0049448cde905b3c.tar.bz2
argaze-e35e90d161ffb9202459631a0049448cde905b3c.tar.xz
Testing all gaze analysis algorithm. Unifying paper citation.
Diffstat (limited to 'src/argaze.test/GazeAnalysis')
-rw-r--r--src/argaze.test/GazeAnalysis/Entropy.py12
-rw-r--r--src/argaze.test/GazeAnalysis/KCoefficient.py56
-rw-r--r--src/argaze.test/GazeAnalysis/LempelZivComplexity.py54
-rw-r--r--src/argaze.test/GazeAnalysis/NGram.py57
-rw-r--r--src/argaze.test/GazeAnalysis/NearestNeighborIndex.py40
-rw-r--r--src/argaze.test/GazeAnalysis/TransitionMatrix.py13
6 files changed, 220 insertions, 12 deletions
diff --git a/src/argaze.test/GazeAnalysis/Entropy.py b/src/argaze.test/GazeAnalysis/Entropy.py
index 47d5556..b69f329 100644
--- a/src/argaze.test/GazeAnalysis/Entropy.py
+++ b/src/argaze.test/GazeAnalysis/Entropy.py
@@ -18,20 +18,20 @@ 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'])
+ def test_analyze(self):
+ """Test analyze method."""
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)
+ aoi_scan_path = GazeFeaturesTest.build_aoi_scan_path(['Foo', 'Bar', 'Shu'], ['Bar', 'Shu', 'Foo', 'Bar', 'Shu', 'Foo', 'Bar', 'Shu', 'Foo'])
# Check aoi scan path
self.assertEqual(len(aoi_scan_path), 9)
+ 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 entropy analysis
self.assertAlmostEqual(stationary_entropy, 1.09, 1)
self.assertAlmostEqual(transition_entropy, 0, 1)
diff --git a/src/argaze.test/GazeAnalysis/KCoefficient.py b/src/argaze.test/GazeAnalysis/KCoefficient.py
new file mode 100644
index 0000000..07dff79
--- /dev/null
+++ b/src/argaze.test/GazeAnalysis/KCoefficient.py
@@ -0,0 +1,56 @@
+#!/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 KCoefficient
+from argaze.utils import MiscFeatures
+
+GazeFeaturesTest = MiscFeatures.importFromTestPackage('GazeFeatures')
+
+class TestScanPathAnalyzer(unittest.TestCase):
+ """Test ScanPathAnalyzer class."""
+
+ def test_analyze(self):
+ """Test analyze method."""
+
+ kcoeff_analyzer = KCoefficient.AOIScanPathAnalyzer()
+
+ scan_path = GazeFeaturesTest.build_scan_path(10)
+
+ # Check scan path
+ self.assertEqual(len(scan_path), 10)
+
+ K = kcoeff_analyzer.analyze(scan_path)
+
+ # Check that K coefficient is almost equal to 0
+ self.assertAlmostEqual(K, 0)
+
+class TestAOIScanPathAnalyzer(unittest.TestCase):
+ """Test AOIScanPathAnalyzer class."""
+
+ def test_analyze(self):
+ """Test analyze method."""
+
+ kcoeff_analyzer = KCoefficient.AOIScanPathAnalyzer()
+
+ aoi_scan_path = GazeFeaturesTest.build_aoi_scan_path(['Foo', 'Bar', 'Shu'], ['Bar', 'Shu', 'Foo', 'Bar'])
+
+ # Check aoi scan path
+ self.assertEqual(len(aoi_scan_path), 4)
+
+ K = kcoeff_analyzer.analyze(aoi_scan_path)
+
+ # Check that K coefficient is almost equal to 0
+ self.assertAlmostEqual(K, 0)
+
+if __name__ == '__main__':
+
+ unittest.main() \ No newline at end of file
diff --git a/src/argaze.test/GazeAnalysis/LempelZivComplexity.py b/src/argaze.test/GazeAnalysis/LempelZivComplexity.py
new file mode 100644
index 0000000..75afc4d
--- /dev/null
+++ b/src/argaze.test/GazeAnalysis/LempelZivComplexity.py
@@ -0,0 +1,54 @@
+#!/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 LempelZivComplexity
+from argaze.utils import MiscFeatures
+
+GazeFeaturesTest = MiscFeatures.importFromTestPackage('GazeFeatures')
+
+class TestAOIScanPathAnalyzer(unittest.TestCase):
+ """Test AOIScanPathAnalyzer class."""
+
+ @unittest.skip("The result is not like in the paper.")
+ def test_analyze_first_example(self):
+ """Test analyze method with first example sequence from the paper."""
+
+ lzc_analyzer = LempelZivComplexity.AOIScanPathAnalyzer()
+
+ aoi_scan_path = GazeFeaturesTest.build_aoi_scan_path(['Foo', 'Bar', 'Shu'], ['Bar', 'Shu', 'Bar', 'Shu', 'Bar', 'Shu', 'Bar', 'Shu', 'Bar', 'Shu', 'Bar', 'Shu', 'Foo'])
+
+ # Check aoi scan path
+ self.assertEqual(len(aoi_scan_path), 13)
+
+ lzc = lzc_analyzer.analyze(aoi_scan_path)
+
+ # Check LZC coefficient
+ self.assertEqual(lzc, 6)
+
+ def test_analyze_seconde_example(self):
+ """Test analyze method with second example sequence from the paper."""
+
+ lzc_analyzer = LempelZivComplexity.AOIScanPathAnalyzer()
+
+ aoi_scan_path = GazeFeaturesTest.build_aoi_scan_path(['Ade', 'Bar', 'Cob', 'Gno', 'Kel', 'Iop', 'Eca'], ['Bar', 'Cob', 'Ade', 'Kel', 'Ade', 'Cob', 'Kel', 'Gno', 'Kel', 'Ade', 'Kel', 'Iop', 'Eca'])
+
+ # Check aoi scan path
+ self.assertEqual(len(aoi_scan_path), 13)
+
+ lzc = lzc_analyzer.analyze(aoi_scan_path)
+
+ # Check LZC coefficient
+ self.assertEqual(lzc, 9)
+
+if __name__ == '__main__':
+
+ unittest.main() \ No newline at end of file
diff --git a/src/argaze.test/GazeAnalysis/NGram.py b/src/argaze.test/GazeAnalysis/NGram.py
new file mode 100644
index 0000000..9608b90
--- /dev/null
+++ b/src/argaze.test/GazeAnalysis/NGram.py
@@ -0,0 +1,57 @@
+#!/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 NGram
+from argaze.utils import MiscFeatures
+
+GazeFeaturesTest = MiscFeatures.importFromTestPackage('GazeFeatures')
+
+class TestAOIScanPathAnalyzer(unittest.TestCase):
+ """Test AOIScanPathAnalyzer class."""
+
+ def test_analyze(self):
+ """Test analyze method."""
+
+ ngram_analyzer = NGram.AOIScanPathAnalyzer()
+
+ aoi_scan_path = GazeFeaturesTest.build_aoi_scan_path(['Foo', 'Bar', 'Shu'], ['Bar', 'Shu', 'Foo', 'Bar', 'Shu', 'Foo'])
+
+ # Check aoi scan path
+ self.assertEqual(len(aoi_scan_path), 6)
+
+ ngram_analysis = ngram_analyzer.analyze(aoi_scan_path, 2)
+
+ # Check 2-gram analysis
+ self.assertEqual(len(ngram_analysis), 3)
+ self.assertEqual(ngram_analysis[('Bar', 'Shu')], 2)
+ self.assertEqual(ngram_analysis[('Shu', 'Foo')], 2)
+ self.assertEqual(ngram_analysis[('Foo', 'Bar')], 1)
+
+ ngram_analysis = ngram_analyzer.analyze(aoi_scan_path, 3)
+
+ # Check 3-gram analysis
+ self.assertEqual(len(ngram_analysis), 3)
+ self.assertEqual(ngram_analysis[('Bar', 'Shu', 'Foo')], 2)
+ self.assertEqual(ngram_analysis[('Shu', 'Foo', 'Bar')], 1)
+ self.assertEqual(ngram_analysis[('Foo', 'Bar', 'Shu')], 1)
+
+ ngram_analysis = ngram_analyzer.analyze(aoi_scan_path, 4)
+
+ # Check 4-gram analysis
+ self.assertEqual(len(ngram_analysis), 3)
+ self.assertEqual(ngram_analysis[('Bar', 'Shu', 'Foo', 'Bar')], 1)
+ self.assertEqual(ngram_analysis[('Shu', 'Foo', 'Bar', 'Shu')], 1)
+ self.assertEqual(ngram_analysis[('Foo', 'Bar', 'Shu', 'Foo')], 1)
+
+if __name__ == '__main__':
+
+ unittest.main() \ No newline at end of file
diff --git a/src/argaze.test/GazeAnalysis/NearestNeighborIndex.py b/src/argaze.test/GazeAnalysis/NearestNeighborIndex.py
new file mode 100644
index 0000000..fb7d4ec
--- /dev/null
+++ b/src/argaze.test/GazeAnalysis/NearestNeighborIndex.py
@@ -0,0 +1,40 @@
+#!/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 NearestNeighborIndex
+from argaze.utils import MiscFeatures
+
+GazeFeaturesTest = MiscFeatures.importFromTestPackage('GazeFeatures')
+
+class TestScanPathAnalyzer(unittest.TestCase):
+ """Test ScanPathAnalyzer class."""
+
+ def test_analyze(self):
+ """Test analyze."""
+
+ nni_analyzer = NearestNeighborIndex.ScanPathAnalyzer()
+
+ screen_dimension = (100, 100)
+ scan_path = GazeFeaturesTest.build_scan_path(6, screen_dimension)
+
+ # Check aoi scan path
+ self.assertEqual(len(scan_path), 6)
+
+ nni = nni_analyzer.analyze(scan_path, screen_dimension)
+
+ # Check NNI
+ self.assertGreaterEqual(nni, 0)
+ self.assertLessEqual(nni, 1)
+
+if __name__ == '__main__':
+
+ unittest.main() \ No newline at end of file
diff --git a/src/argaze.test/GazeAnalysis/TransitionMatrix.py b/src/argaze.test/GazeAnalysis/TransitionMatrix.py
index 14a34ce..997b706 100644
--- a/src/argaze.test/GazeAnalysis/TransitionMatrix.py
+++ b/src/argaze.test/GazeAnalysis/TransitionMatrix.py
@@ -18,17 +18,18 @@ 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'])
-
+ def test_analyze(self):
+ """Test analyze method."""
+
transition_matrix_analyser = TransitionMatrix.AOIScanPathAnalyzer()
- transition_matrix_probabilities, transition_matrix_density = transition_matrix_analyser.analyze(aoi_scan_path)
+
+ aoi_scan_path = GazeFeaturesTest.build_aoi_scan_path(['Foo', 'Bar', 'Shu'], ['Bar', 'Shu', 'Foo', 'Bar'])
# Check aoi scan path
self.assertEqual(len(aoi_scan_path), 4)
+ transition_matrix_probabilities, transition_matrix_density = transition_matrix_analyser.analyze(aoi_scan_path)
+
# Check transition matrix probabilities ([destination][departure])
self.assertEqual(transition_matrix_probabilities['Foo']['Foo'], 0)
self.assertEqual(transition_matrix_probabilities['Bar']['Bar'], 0)