aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThéo de la Hogue2023-05-22 16:39:35 +0200
committerThéo de la Hogue2023-05-22 16:39:35 +0200
commit8c4b31e37927410a5109b3050cc032e8f4c36090 (patch)
treeecdfafa63b3010ec9fc1dc9e9b8cd881770be860
parent3067eafea0b4959075f68b9d3f66384474208d7e (diff)
downloadargaze-8c4b31e37927410a5109b3050cc032e8f4c36090.zip
argaze-8c4b31e37927410a5109b3050cc032e8f4c36090.tar.gz
argaze-8c4b31e37927410a5109b3050cc032e8f4c36090.tar.bz2
argaze-8c4b31e37927410a5109b3050cc032e8f4c36090.tar.xz
Adding sequence editor into AOIScanPath class.
-rw-r--r--src/argaze/GazeAnalysis/LempelZivComplexity.py26
-rw-r--r--src/argaze/GazeFeatures.py30
2 files changed, 23 insertions, 33 deletions
diff --git a/src/argaze/GazeAnalysis/LempelZivComplexity.py b/src/argaze/GazeAnalysis/LempelZivComplexity.py
index b8d14ca..7d70010 100644
--- a/src/argaze/GazeAnalysis/LempelZivComplexity.py
+++ b/src/argaze/GazeAnalysis/LempelZivComplexity.py
@@ -28,28 +28,4 @@ class AOIScanPathAnalyzer(GazeFeatures.AOIScanPathAnalyzer):
assert(len(aoi_scan_path) > 1)
- self.__index = ord('A')
- aoi_letter = {}
-
- def __get_letter(aoi):
-
- try :
-
- return aoi_letter[aoi_scan_step.aoi]
-
- except KeyError:
-
- letter = chr(self.__index)
- aoi_letter[aoi_scan_step.aoi] = letter
- self.__index += 1
- return letter
-
- # Convet each AOI name into a single char
- sequence = ''
- for aoi_scan_step in aoi_scan_path:
-
- sequence += __get_letter(aoi_scan_step.aoi)
-
- print(sequence)
-
- return lempel_ziv_complexity(sequence)
+ return lempel_ziv_complexity(str(aoi_scan_path))
diff --git a/src/argaze/GazeFeatures.py b/src/argaze/GazeFeatures.py
index 3592b13..a26b1f1 100644
--- a/src/argaze/GazeFeatures.py
+++ b/src/argaze/GazeFeatures.py
@@ -503,6 +503,9 @@ class AOIScanStep():
aoi: str = field(default='')
"""AOI name."""
+ letter: str = field(default='')
+ """AOI unique letter to ease sequence analysis."""
+
def __post_init__(self):
# First movement have to be a fixation
@@ -553,24 +556,35 @@ class AOIScanPath(list):
self.__movements = TimeStampedGazeMovements()
self.__current_aoi = ''
+ self.__index = ord('A')
+ self.__aoi_letter = {}
def __repr__(self):
"""String representation."""
return str(super())
- def __str__(self) -> str:
- """String display."""
+ def __get_aoi_letter(self, aoi):
- output = ''
+ try :
- for step in self:
+ return self.__aoi_letter[aoi]
- output += f'> {step.aoi} '
+ except KeyError:
- output += f'> {self.__current_aoi}'
+ letter = chr(self.__index)
+ self.__aoi_letter[aoi] = letter
+ self.__index += 1
+ return letter
- return output
+ def __str__(self) -> str:
+ """Convert aoi scan path into a string with unique letter per aoi step."""
+
+ sequence = ''
+ for step in self:
+ sequence += step.letter
+
+ return sequence
@property
def current_aoi(self):
@@ -598,7 +612,7 @@ class AOIScanPath(list):
try:
# Edit new step
- new_step = AOIScanStep(self.__movements, self.__current_aoi)
+ new_step = AOIScanStep(self.__movements, self.__current_aoi, self.__get_aoi_letter(self.__current_aoi))
# Append new step
super().append(new_step)