aboutsummaryrefslogtreecommitdiff
path: root/src/argaze/GazeAnalysis/DispersionBasedGazeMovementIdentifier.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/argaze/GazeAnalysis/DispersionBasedGazeMovementIdentifier.py')
-rw-r--r--src/argaze/GazeAnalysis/DispersionBasedGazeMovementIdentifier.py55
1 files changed, 35 insertions, 20 deletions
diff --git a/src/argaze/GazeAnalysis/DispersionBasedGazeMovementIdentifier.py b/src/argaze/GazeAnalysis/DispersionBasedGazeMovementIdentifier.py
index 1364c99..5cbf6c4 100644
--- a/src/argaze/GazeAnalysis/DispersionBasedGazeMovementIdentifier.py
+++ b/src/argaze/GazeAnalysis/DispersionBasedGazeMovementIdentifier.py
@@ -204,32 +204,25 @@ class GazeMovementIdentifier(GazeFeatures.GazeMovementIdentifier):
# Does a former fixation have been identified ?
if self.__last_fixation != None:
- # Inter fixations movement should:
- # - starts at last position of last fixation (this position is out so it have to be popped)
- # - stops at the first position inside new fixation
- start_movement_ts, start_position = self.__last_fixation.positions.pop_last()
- stop_movement_ts, stop_position = new_fixation.positions.pop_first()
-
# Remove last gaze position of the new fixation as it is it's out position
last_new_ts, last_new_position = new_fixation.positions.pop_last()
- # Rare case : the last fixation position is the same than the first position of the new fixation
- if start_movement_ts == stop_movement_ts:
- start_movement_ts, start_position = self.__last_fixation.positions.pop_last()
-
- # Update last and new fixations
- self.__last_fixation.update()
- new_fixation.update()
-
# Edit inter fixations movement gaze positions
movement_gaze_positions = GazeFeatures.TimeStampedGazePositions()
- # Edit first movement gaze position
- movement_gaze_positions[start_movement_ts] = start_position
-
- # Is there unmatched gaze positions that belong to the movement?
+ # If such unmatched positions exist
if len(unmatched_gaze_positions) > 0:
+ # Inter fixations movement should:
+ # - starts at last position of last fixation (this position is out so it have to be popped)
+ # - stops at the first position inside new fixation
+ start_movement_ts, start_position = self.__last_fixation.positions.pop_last()
+ stop_movement_ts, stop_position = new_fixation.positions.pop_first()
+
+ # Edit first movement gaze position
+ movement_gaze_positions[start_movement_ts] = start_position
+
+ # Edit movement positions with unmatched positions if there are between the 2 fixations
start_unmatched_ts, _ = unmatched_gaze_positions.first
end_unmatched_ts, _ = unmatched_gaze_positions.last
@@ -245,12 +238,34 @@ class GazeMovementIdentifier(GazeFeatures.GazeMovementIdentifier):
# Ignore them: GazeMovementIdentifier have to output movements according their time apparition
pass
- # Edit last movement gaze position
- movement_gaze_positions[stop_movement_ts] = stop_position
+ # Edit last movement gaze position
+ movement_gaze_positions[stop_movement_ts] = stop_position
+
+ # When there is no unmatched positions between 2 fixations (*rare case)
+ else:
+
+ # the last fixation position is the same than the first position of the new fixation
+ stop_movement_ts, stop_position = self.__last_fixation.positions.pop_last()
+ start_movement_ts, start_position = self.__last_fixation.positions.pop_last()
+
+ # Edit first movement gaze position
+ movement_gaze_positions[start_movement_ts] = start_position
+
+ # Edit last movement gaze position
+ movement_gaze_positions[stop_movement_ts] = stop_position
+
+ # Update last and new fixations
+ self.__last_fixation.update()
+ new_fixation.update()
# Does new fixation overlap last fixation?
if self.__last_fixation.overlap(new_fixation):
+ # (*rare case)
+ if len(unmatched_gaze_positions) == 0:
+ self.__last_fixation.positions[start_movement_ts] = start_position
+ self.__last_fixation.positions[stop_movement_ts] = stop_position
+
# Merge new fixation into last fixation
self.__last_fixation.merge(new_fixation)