aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThéo de la Hogue2022-12-09 01:38:35 +0100
committerThéo de la Hogue2022-12-09 01:38:35 +0100
commit7521e92b03c80c15152f0985ffc1e3af057329a9 (patch)
tree05648d9b500b9d455dce659b5ec8da30f502fc6f
parent8a4888ace0ff5b4da4cd1d426f14c410c6d00b47 (diff)
downloadargaze-7521e92b03c80c15152f0985ffc1e3af057329a9.zip
argaze-7521e92b03c80c15152f0985ffc1e3af057329a9.tar.gz
argaze-7521e92b03c80c15152f0985ffc1e3af057329a9.tar.bz2
argaze-7521e92b03c80c15152f0985ffc1e3af057329a9.tar.xz
Merging overlapping fixations.
-rw-r--r--src/argaze.test/GazeAnalysis/DispersionBasedGazeMovementIdentifier.py4
-rw-r--r--src/argaze/GazeAnalysis/DispersionBasedGazeMovementIdentifier.py43
2 files changed, 33 insertions, 14 deletions
diff --git a/src/argaze.test/GazeAnalysis/DispersionBasedGazeMovementIdentifier.py b/src/argaze.test/GazeAnalysis/DispersionBasedGazeMovementIdentifier.py
index 497a23f..0ddebc6 100644
--- a/src/argaze.test/GazeAnalysis/DispersionBasedGazeMovementIdentifier.py
+++ b/src/argaze.test/GazeAnalysis/DispersionBasedGazeMovementIdentifier.py
@@ -178,7 +178,7 @@ class TestDispersionBasedGazeMovementIdentifierClass(unittest.TestCase):
# Check that fixation overlaps
self.assertTrue(fixation_B.overlap(fixation_C))
self.assertTrue(fixation_C.overlap(fixation_B))
- '''
+
def test_fixation_overlapping_identification(self):
"""Test DispersionBasedGazeMovementIdentifier identification when fixations overlap."""
@@ -210,7 +210,7 @@ class TestDispersionBasedGazeMovementIdentifierClass(unittest.TestCase):
#self.assertGreaterEqual(fixation.dispersion, dispersion)
self.assertGreaterEqual(fixation.duration, 2 * size * min_time)
self.assertLessEqual(fixation.duration, 2 * size * max_time)
- '''
+
if __name__ == '__main__':
unittest.main() \ No newline at end of file
diff --git a/src/argaze/GazeAnalysis/DispersionBasedGazeMovementIdentifier.py b/src/argaze/GazeAnalysis/DispersionBasedGazeMovementIdentifier.py
index 8498f84..477aec5 100644
--- a/src/argaze/GazeAnalysis/DispersionBasedGazeMovementIdentifier.py
+++ b/src/argaze/GazeAnalysis/DispersionBasedGazeMovementIdentifier.py
@@ -183,27 +183,46 @@ class GazeMovementIdentifier(GazeFeatures.GazeMovementIdentifier):
# is the new fixation have a duration ?
if new_fixation.duration > 0:
+ # does a former fixation have been identified ?
if self.__last_fixation != None:
- # store start and end positions in a timestamped buffer
- ts_saccade_positions = GazeFeatures.TimeStampedGazePositions()
+ # merge new fixation if it overlaps last fixation
+ if self.__last_fixation.overlap(new_fixation):
- start_position_ts, start_position = self.__last_fixation.positions.last
- ts_saccade_positions[start_position_ts] = start_position
+ self.__last_fixation.merge(new_fixation)
+ new_fixation = None
- end_position_ts, end_position = new_fixation.positions.first
- ts_saccade_positions[end_position_ts] = end_position
+ # else output last fixation and create a saccade
+ else:
- if end_position_ts > start_position_ts:
+ yield self.__last_fixation
+
+ # store start and end positions in a timestamped buffer
+ ts_saccade_positions = GazeFeatures.TimeStampedGazePositions()
- new_saccade = Saccade(ts_saccade_positions)
-
- yield new_saccade
+ start_position_ts, start_position = self.__last_fixation.positions.last
+ ts_saccade_positions[start_position_ts] = start_position
- self.__last_fixation = new_fixation
+ end_position_ts, end_position = new_fixation.positions.first
+ ts_saccade_positions[end_position_ts] = end_position
- yield new_fixation
+ if end_position_ts > start_position_ts:
+
+ new_saccade = Saccade(ts_saccade_positions)
+
+ yield new_saccade
+
+ self.__last_fixation = new_fixation
+
+ else:
+
+ self.__last_fixation = new_fixation
+ yield self.__last_fixation
# dispersion too wide : consider next gaze position
else:
self.__ts_gaze_positions.pop_first()
+
+ # output last fixation
+ if self.__last_fixation != None:
+ yield self.__last_fixation