From d74c6c9ffc05a13ed7485ddcbdfa18ad5b6bf59b Mon Sep 17 00:00:00 2001 From: Théo de la Hogue Date: Sat, 10 Dec 2022 00:01:04 +0100 Subject: More work to identify saccade and unknown movement. --- .../DispersionBasedGazeMovementIdentifier.py | 38 +++++++++++++--------- 1 file changed, 23 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/argaze/GazeAnalysis/DispersionBasedGazeMovementIdentifier.py b/src/argaze/GazeAnalysis/DispersionBasedGazeMovementIdentifier.py index b60291c..62e8723 100644 --- a/src/argaze/GazeAnalysis/DispersionBasedGazeMovementIdentifier.py +++ b/src/argaze/GazeAnalysis/DispersionBasedGazeMovementIdentifier.py @@ -212,31 +212,39 @@ class GazeMovementIdentifier(GazeFeatures.GazeMovementIdentifier): # Is there a new movement ? if len(moving_gaze_positions) > 0: - # Check first and last gaze position of the moving positions buffer + # Compare first and last gaze position of the moving positions buffer to last and new fixation start_position_ts, start_position = moving_gaze_positions.first end_position_ts, end_position = moving_gaze_positions.last - if not moving_gaze_positions.first[0] > self.__last_fixation.positions.last[0]: - print('first moving_gaze_positions not after last self.__last_fixation.positions') - print(moving_gaze_positions.first[0], self.__last_fixation.positions.last[0]) + last_ts, last_position = self.__last_fixation.positions.last + new_ts, new_position = new_fixation.positions.first - if not moving_gaze_positions.last[0] < new_fixation.positions.first[0]: - print('last moving_gaze_positions not before first new_fixation.positions') - print(moving_gaze_positions.last[0], new_fixation.positions.first[0]) - - # Saccade shouldn't be longer than fixation + # Saccade conditions: + # - should be between two fixations + # - shouldn't be longer than fixation # TODO : add a saccade duration threshold attribute ? - if end_position_ts - start_position_ts < self.duration_threshold: + if start_position_ts > last_ts and end_position_ts < new_ts and last_ts - new_ts <= self.duration_threshold: - yield Saccade(moving_gaze_positions) + saccade_gaze_positions = GazeFeatures.TimeStampedGazePositions() + saccade_gaze_positions[last_ts] = last_position + saccade_gaze_positions.append(moving_gaze_positions) + saccade_gaze_positions[new_ts] = new_position + + yield Saccade(saccade_gaze_positions) - # This movement is unknown + # Otherwise, this movement is unknown else: - # This unknown movement should be dispersed - assert(Fixation(moving_gaze_positions).dispersion > self.dispersion_threshold) + # Does this unknown movement an unmatched fixation ? + unmatched_fixation = Fixation(moving_gaze_positions) + + if unmatched_fixation.dispersion < self.dispersion_threshold: + + yield unmatched_fixation + + else: - yield UnknownGazeMovement(moving_gaze_positions) + yield UnknownGazeMovement(moving_gaze_positions) # Forget former moving gaze positions moving_gaze_positions = GazeFeatures.TimeStampedGazePositions() -- cgit v1.1