aboutsummaryrefslogtreecommitdiff
path: root/src/argaze/GazeAnalysis/DispersionThresholdIdentification.py
diff options
context:
space:
mode:
authorThéo de la Hogue2023-07-10 14:08:30 +0200
committerThéo de la Hogue2023-07-10 14:08:30 +0200
commit49d6cf63d02b80d10c96cfe2edc6fd197558c899 (patch)
treeac958b51f0531f4a74b8f056e8c1218636e97266 /src/argaze/GazeAnalysis/DispersionThresholdIdentification.py
parent17d247f0652afcc68b9477bce718e91c850d5499 (diff)
downloadargaze-49d6cf63d02b80d10c96cfe2edc6fd197558c899.zip
argaze-49d6cf63d02b80d10c96cfe2edc6fd197558c899.tar.gz
argaze-49d6cf63d02b80d10c96cfe2edc6fd197558c899.tar.bz2
argaze-49d6cf63d02b80d10c96cfe2edc6fd197558c899.tar.xz
Improving and testing gaze movement identification. Now each movement have to share its last position with the next movement.
Diffstat (limited to 'src/argaze/GazeAnalysis/DispersionThresholdIdentification.py')
-rw-r--r--src/argaze/GazeAnalysis/DispersionThresholdIdentification.py55
1 files changed, 36 insertions, 19 deletions
diff --git a/src/argaze/GazeAnalysis/DispersionThresholdIdentification.py b/src/argaze/GazeAnalysis/DispersionThresholdIdentification.py
index f29858a..ae7105e 100644
--- a/src/argaze/GazeAnalysis/DispersionThresholdIdentification.py
+++ b/src/argaze/GazeAnalysis/DispersionThresholdIdentification.py
@@ -126,13 +126,15 @@ class GazeMovementIdentifier(GazeFeatures.GazeMovementIdentifier):
return GazeFeatures.UnvalidGazeMovement() if not terminate else self.current_fixation.finish()
- # Check if too much time elapsed since last gaze position
+ # Check if too much time elapsed since last valid gaze position
if len(self.__valid_positions) > 0:
ts_last, _ = self.__valid_positions.last
if (ts - ts_last) > self.duration_min_threshold:
+ # What about last valid positions !?
+
# Get last movement
last_movement = self.current_saccade.finish() if len(self.__fixation_positions) == 0 else self.current_fixation.finish()
@@ -162,11 +164,20 @@ class GazeMovementIdentifier(GazeFeatures.GazeMovementIdentifier):
# Valid gaze positions deviation small enough
if deviation <= self.deviation_max_threshold:
- # Store last saccade
- last_saccade = self.current_saccade.finish()
+ last_saccade = GazeFeatures.UnvalidGazeMovement()
- # Clear saccade positions
- self.__saccade_positions = GazeFeatures.TimeStampedGazePositions()
+ # Is there saccade positions?
+ if len(self.__saccade_positions) > 0:
+
+ # Copy oldest valid position into saccade positions
+ first_ts, first_position = self.__valid_positions.first
+ self.__saccade_positions[first_ts] = first_position
+
+ # Finish last saccade
+ last_saccade = self.current_saccade.finish()
+
+ # Clear saccade positions
+ self.__saccade_positions = GazeFeatures.TimeStampedGazePositions()
# Copy valid gaze positions into fixation positions
self.__fixation_positions = self.__valid_positions.copy()
@@ -174,26 +185,32 @@ class GazeMovementIdentifier(GazeFeatures.GazeMovementIdentifier):
# Output last saccade
return last_saccade if not terminate else self.current_fixation.finish()
- # Valid gaze positions deviation too wide while identifying fixation
- elif len(self.__fixation_positions) > 0:
+ # Valid gaze positions deviation too wide
+ else:
- # Store last fixation
- last_fixation = self.current_fixation.finish()
+ last_fixation = GazeFeatures.UnvalidGazeMovement()
- # Start saccade positions with current gaze position
- self.__saccade_positions[ts] = gaze_position
+ # Is there fixation positions?
+ if len(self.__fixation_positions) > 0:
- # Clear fixation positions
- self.__fixation_positions = GazeFeatures.TimeStampedGazePositions()
+ # Copy most recent fixation position into saccade positions
+ last_ts, last_position = self.__fixation_positions.last
+ self.__saccade_positions[last_ts] = last_position
- # Clear valid positions
- self.__valid_positions = GazeFeatures.TimeStampedGazePositions()
+ # Finish last fixation
+ last_fixation = self.current_fixation.finish()
- # Output last fixation
- return last_fixation if not terminate else self.current_saccade.finish()
+ # Clear fixation positions
+ self.__fixation_positions = GazeFeatures.TimeStampedGazePositions()
- # Valid gaze positions deviation too wide while identifying saccade (or not)
- else:
+ # Clear valid positions
+ self.__valid_positions = GazeFeatures.TimeStampedGazePositions()
+
+ # Store current gaze position
+ self.__valid_positions[ts] = gaze_position
+
+ # Output last fixation
+ return last_fixation if not terminate else self.current_saccade.finish()
# Move oldest valid position into saccade positions
first_ts, first_position = self.__valid_positions.pop_first()