aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/argaze.test/GazeAnalysis/DispersionBasedGazeMovementIdentifier.py8
-rw-r--r--src/argaze/GazeAnalysis/DispersionBasedGazeMovementIdentifier.py9
-rw-r--r--src/argaze/GazeFeatures.py8
3 files changed, 15 insertions, 10 deletions
diff --git a/src/argaze.test/GazeAnalysis/DispersionBasedGazeMovementIdentifier.py b/src/argaze.test/GazeAnalysis/DispersionBasedGazeMovementIdentifier.py
index c732a6f..cf0af1e 100644
--- a/src/argaze.test/GazeAnalysis/DispersionBasedGazeMovementIdentifier.py
+++ b/src/argaze.test/GazeAnalysis/DispersionBasedGazeMovementIdentifier.py
@@ -138,7 +138,7 @@ class TestDispersionBasedGazeMovementIdentifierClass(unittest.TestCase):
# Check first fixation
ts, fixation = ts_fixations.pop_first()
- self.assertEqual(len(fixation.positions.keys()), size-1)
+ self.assertEqual(len(fixation.positions.keys()), size)
self.assertLessEqual(fixation.deviation_max, deviation_max)
self.assertGreaterEqual(fixation.duration, size * min_time)
self.assertLessEqual(fixation.duration, size * max_time)
@@ -146,9 +146,9 @@ class TestDispersionBasedGazeMovementIdentifierClass(unittest.TestCase):
# Check first saccade
ts, saccade = ts_saccades.pop_first()
- self.assertEqual(len(saccade.positions.keys()), 2)
- self.assertGreaterEqual(saccade.duration, min_time)
- self.assertLessEqual(saccade.duration, max_time)
+ self.assertEqual(len(saccade.positions.keys()), 1)
+ self.assertGreaterEqual(saccade.duration, 0.)
+ self.assertLessEqual(saccade.duration, 0.)
# Check second fixation
ts, fixation = ts_fixations.pop_first()
diff --git a/src/argaze/GazeAnalysis/DispersionBasedGazeMovementIdentifier.py b/src/argaze/GazeAnalysis/DispersionBasedGazeMovementIdentifier.py
index 07136f8..4cece04 100644
--- a/src/argaze/GazeAnalysis/DispersionBasedGazeMovementIdentifier.py
+++ b/src/argaze/GazeAnalysis/DispersionBasedGazeMovementIdentifier.py
@@ -99,12 +99,13 @@ class GazeMovementIdentifier(GazeFeatures.GazeMovementIdentifier):
self.__fixation_positions = GazeFeatures.TimeStampedGazePositions()
self.__saccade_positions = GazeFeatures.TimeStampedGazePositions()
- def identify(self, ts, gaze_position):
+ def identify(self, ts, gaze_position, terminate=False):
# Ignore non valid gaze position
if not gaze_position.valid:
- return
+ return None if not terminate else self.current_fixation
+
# Check if too much time elapsed since last gaze position
if len(self.__valid_positions) > 0:
@@ -142,7 +143,7 @@ class GazeMovementIdentifier(GazeFeatures.GazeMovementIdentifier):
self.__fixation_positions = self.__valid_positions.copy()
# Output last saccade
- return last_saccade
+ return last_saccade if not terminate else self.current_fixation
# Valid gaze positions deviation too wide while identifying fixation
elif len(self.__fixation_positions) > 0:
@@ -160,7 +161,7 @@ class GazeMovementIdentifier(GazeFeatures.GazeMovementIdentifier):
self.__valid_positions = GazeFeatures.TimeStampedGazePositions()
# Output last fixation
- return last_fixation
+ return last_fixation if not terminate else self.current_saccade
# Valid gaze positions deviation too wide while identifying saccade (or not)
else:
diff --git a/src/argaze/GazeFeatures.py b/src/argaze/GazeFeatures.py
index 83835d2..dd4fc20 100644
--- a/src/argaze/GazeFeatures.py
+++ b/src/argaze/GazeFeatures.py
@@ -236,7 +236,7 @@ class TimeStampedGazeStatus(DataStructures.TimeStampedBuffer):
class GazeMovementIdentifier():
"""Abstract class to define what should provide a gaze movement identifier."""
- def identify(self, ts, gaze_position) -> GazeMovementType:
+ def identify(self, ts, gaze_position, terminate=False) -> GazeMovementType:
raise NotImplementedError('identify() method not implemented')
def browse(self, ts_gaze_positions: TimeStampedGazePositions) -> Tuple[TimeStampedGazeMovementsType, TimeStampedGazeMovementsType, TimeStampedGazeStatusType]:
@@ -248,9 +248,13 @@ class GazeMovementIdentifier():
ts_saccades = TimeStampedGazeMovements()
ts_status = TimeStampedGazeStatus()
+ # Get last ts to terminate identification on last gaze position
+ last_ts, _ = ts_gaze_positions.last
+
+ # Iterate on gaze positions
for ts, gaze_position in ts_gaze_positions.items():
- gaze_movement = self.identify(ts, gaze_position)
+ gaze_movement = self.identify(ts, gaze_position, terminate=(ts == last_ts))
if isinstance(gaze_movement, Fixation):