diff options
author | Théo de la Hogue | 2022-12-09 01:06:27 +0100 |
---|---|---|
committer | Théo de la Hogue | 2022-12-09 01:06:27 +0100 |
commit | 8a4888ace0ff5b4da4cd1d426f14c410c6d00b47 (patch) | |
tree | 1860c48b059753ecfbc6f0e327e2278bc9dd98c7 /src/argaze | |
parent | ba1a1eb9d76083b43f2b3c4ffa18651f2e516e6f (diff) | |
download | argaze-8a4888ace0ff5b4da4cd1d426f14c410c6d00b47.zip argaze-8a4888ace0ff5b4da4cd1d426f14c410c6d00b47.tar.gz argaze-8a4888ace0ff5b4da4cd1d426f14c410c6d00b47.tar.bz2 argaze-8a4888ace0ff5b4da4cd1d426f14c410c6d00b47.tar.xz |
Adding and testing fixation overlap function.
Diffstat (limited to 'src/argaze')
-rw-r--r-- | src/argaze/GazeAnalysis/DispersionBasedGazeMovementIdentifier.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/argaze/GazeAnalysis/DispersionBasedGazeMovementIdentifier.py b/src/argaze/GazeAnalysis/DispersionBasedGazeMovementIdentifier.py index 4fd5aab..8498f84 100644 --- a/src/argaze/GazeAnalysis/DispersionBasedGazeMovementIdentifier.py +++ b/src/argaze/GazeAnalysis/DispersionBasedGazeMovementIdentifier.py @@ -52,6 +52,20 @@ class Fixation(GazeFeatures.Fixation): # Update frozen centroid attribute object.__setattr__(self, 'centroid', (cx, cy)) + def overlap(self, fixation) -> float: + """Does this fixation overlap another fixation?""" + + dist = (self.centroid[0] - fixation.centroid[0])**2 + (self.centroid[1] - fixation.centroid[1])**2 + dist = numpy.sqrt(dist) + + return dist < (self.dispersion + fixation.dispersion) + + def merge(self, fixation) -> float: + """Merge another fixation into this fixation.""" + + self.positions.append(fixation.positions) + self.__post_init__() + @dataclass(frozen=True) class Saccade(GazeFeatures.Saccade): """Define dispersion based saccade.""" @@ -91,6 +105,7 @@ class GazeMovementIdentifier(GazeFeatures.GazeMovementIdentifier): # Ignore non valid start position if not gaze_position_start.valid: + self.__ts_gaze_positions.pop_first() continue @@ -129,6 +144,7 @@ class GazeMovementIdentifier(GazeFeatures.GazeMovementIdentifier): # remove selected gaze positions for gp in ts_gaze_positions: + self.__ts_gaze_positions.pop_first() # extend fixation position from a copy @@ -143,7 +159,9 @@ class GazeMovementIdentifier(GazeFeatures.GazeMovementIdentifier): # Ignore non valid position # Should we consider invalid position to not break fixation ? if not gaze_position_next.valid: + remaining_ts_gaze_positions.pop_first() + self.__ts_gaze_positions.pop_first() continue ts_gaze_positions_extension[ts_next] = gaze_position_next |