diff options
author | Théo de la Hogue | 2023-05-31 16:02:47 +0200 |
---|---|---|
committer | Théo de la Hogue | 2023-05-31 16:02:47 +0200 |
commit | f861c25ed56bf3204188ecc9170feb21e613794e (patch) | |
tree | ee33496bca71bcc0d6ba669c1175b0c0505fefc2 /src/argaze/GazeAnalysis/DispersionThresholdIdentification.py | |
parent | e35e90d161ffb9202459631a0049448cde905b3c (diff) | |
download | argaze-f861c25ed56bf3204188ecc9170feb21e613794e.zip argaze-f861c25ed56bf3204188ecc9170feb21e613794e.tar.gz argaze-f861c25ed56bf3204188ecc9170feb21e613794e.tar.bz2 argaze-f861c25ed56bf3204188ecc9170feb21e613794e.tar.xz |
Don't ignore last movement on invalid gaze position.
Diffstat (limited to 'src/argaze/GazeAnalysis/DispersionThresholdIdentification.py')
-rw-r--r-- | src/argaze/GazeAnalysis/DispersionThresholdIdentification.py | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/argaze/GazeAnalysis/DispersionThresholdIdentification.py b/src/argaze/GazeAnalysis/DispersionThresholdIdentification.py index c6353d4..9d5a8d7 100644 --- a/src/argaze/GazeAnalysis/DispersionThresholdIdentification.py +++ b/src/argaze/GazeAnalysis/DispersionThresholdIdentification.py @@ -57,7 +57,7 @@ class Fixation(GazeFeatures.Fixation): def point_deviation(self, gaze_position) -> float: """Get distance of a point from the fixation's centroïd.""" - return numpy.sqrt((self.centroid[0] - gaze_position.value[0])**2 + (self.centroid[1] - gaze_position.value[1])**2) + return numpy.sqrt((self.focus[0] - gaze_position.value[0])**2 + (self.focus[1] - gaze_position.value[1])**2) def overlap(self, fixation) -> bool: """Does a gaze position from another fixation having a deviation to this fixation centroïd smaller than maximal deviation?""" @@ -65,7 +65,7 @@ class Fixation(GazeFeatures.Fixation): points = fixation.positions.values() points_x, points_y = [p[0] for p in points], [p[1] for p in points] points_array = numpy.column_stack([points_x, points_y]) - centroid_array = numpy.array([self.centroid[0], self.centroid[1]]) + centroid_array = numpy.array([self.focus[0], self.focus[1]]) deviations_array = numpy.sqrt(numpy.sum((points_array - centroid_array)**2, axis=1)) return min(deviations_array) <= self.deviation_max @@ -133,11 +133,20 @@ class GazeMovementIdentifier(GazeFeatures.GazeMovementIdentifier): if (ts - ts_last) > self.duration_min_threshold: + # Get last movement + last_movement = self.current_saccade if len(self.__fixation_positions) == 0 else self.current_fixation + # Clear all former gaze positions self.__valid_positions = GazeFeatures.TimeStampedGazePositions() self.__fixation_positions = GazeFeatures.TimeStampedGazePositions() self.__saccade_positions = GazeFeatures.TimeStampedGazePositions() + # Store valid gaze position + self.__valid_positions[ts] = gaze_position + + # Return last valid movement if exist + return last_movement + # Store gaze positions until a minimal duration self.__valid_positions[ts] = gaze_position |