From a483e0544221504cf6aba91124ac8d870208a279 Mon Sep 17 00:00:00 2001 From: Théo de la Hogue Date: Thu, 6 Jul 2023 15:54:27 +0200 Subject: Finishing gaze movement outputted at terminate time. --- src/argaze/GazeAnalysis/DispersionThresholdIdentification.py | 4 ++-- src/argaze/GazeAnalysis/VelocityThresholdIdentification.py | 4 ++-- src/argaze/GazeFeatures.py | 4 +++- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/argaze/GazeAnalysis/DispersionThresholdIdentification.py b/src/argaze/GazeAnalysis/DispersionThresholdIdentification.py index 3015d51..230e402 100644 --- a/src/argaze/GazeAnalysis/DispersionThresholdIdentification.py +++ b/src/argaze/GazeAnalysis/DispersionThresholdIdentification.py @@ -178,7 +178,7 @@ class GazeMovementIdentifier(GazeFeatures.GazeMovementIdentifier): self.__fixation_positions = self.__valid_positions.copy() # Output last saccade - return last_saccade if not terminate else self.current_fixation + 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: @@ -199,7 +199,7 @@ class GazeMovementIdentifier(GazeFeatures.GazeMovementIdentifier): self.__valid_positions = GazeFeatures.TimeStampedGazePositions() # Output last fixation - return last_fixation if not terminate else self.current_saccade + return last_fixation if not terminate else self.current_saccade.finish() # Valid gaze positions deviation too wide while identifying saccade (or not) else: diff --git a/src/argaze/GazeAnalysis/VelocityThresholdIdentification.py b/src/argaze/GazeAnalysis/VelocityThresholdIdentification.py index 9a645c7..a514ea7 100644 --- a/src/argaze/GazeAnalysis/VelocityThresholdIdentification.py +++ b/src/argaze/GazeAnalysis/VelocityThresholdIdentification.py @@ -194,7 +194,7 @@ class GazeMovementIdentifier(GazeFeatures.GazeMovementIdentifier): # Identification must stop: ends with current saccade if terminate: - return self.current_saccade + return self.current_saccade.finish() # Velocity is less or equals to threshold else: @@ -220,7 +220,7 @@ class GazeMovementIdentifier(GazeFeatures.GazeMovementIdentifier): # Identification must stop: ends with current fixation if terminate: - return self.current_fixation + return self.current_fixation.finish() # Always return unvalid gaze movement at least return GazeFeatures.UnvalidGazeMovement() diff --git a/src/argaze/GazeFeatures.py b/src/argaze/GazeFeatures.py index 855b90b..ab0fb5d 100644 --- a/src/argaze/GazeFeatures.py +++ b/src/argaze/GazeFeatures.py @@ -270,12 +270,14 @@ class GazeMovement(): return len(self.positions) > 0 - def finish(self): + def finish(self) -> GazeMovementType: """Set gaze movement as finished""" # Update frozen finished attribute object.__setattr__(self, 'finished', True) + return self + def draw_positions(self, image: numpy.array, color=(0, 55, 55)): """Draw gaze movement positions""" -- cgit v1.1