From a9c7ba832d26b869aa442e4665f38295b311aed5 Mon Sep 17 00:00:00 2001 From: Théo de la Hogue Date: Fri, 9 Dec 2022 23:04:03 +0100 Subject: Adding a new abstract UnknownGazeMovement. --- src/argaze/GazeFeatures.py | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/argaze/GazeFeatures.py b/src/argaze/GazeFeatures.py index 4d2ef80..e5dfdf0 100644 --- a/src/argaze/GazeFeatures.py +++ b/src/argaze/GazeFeatures.py @@ -150,6 +150,13 @@ class Saccade(GazeMovement): super().__post_init__() +class UnknownGazeMovement(GazeMovement): + """Define abstract unknown gaze movement.""" + + def __post_init__(self): + + super().__post_init__() + TimeStampedGazeMovementsType = TypeVar('TimeStampedGazeMovements', bound="TimeStampedGazeMovements") # Type definition for type annotation convenience @@ -159,7 +166,7 @@ class TimeStampedGazeMovements(DataStructures.TimeStampedBuffer): def __setitem__(self, key, value: GazeMovement): """Force value to inherit from GazeMovement.""" - assert(type(value).__bases__[0] == Fixation or type(value).__bases__[0] == Saccade) + assert(type(value).__bases__[0] == Fixation or type(value).__bases__[0] == Saccade or type(value).__bases__[0] == UnknownGazeMovement) super().__setitem__(key, value) @@ -225,6 +232,7 @@ class GazeMovementIdentifier(): ts_fixations = TimeStampedGazeMovements() ts_saccades = TimeStampedGazeMovements() + ts_unknown = TimeStampedGazeMovements() ts_status = TimeStampedGazeStatus() for gaze_movement in self(ts_gaze_positions): @@ -250,9 +258,16 @@ class GazeMovementIdentifier(): ts_status[end_ts] = GazeStatus.from_position(end_position, 'Saccade', len(ts_saccades)) else: - continue - return ts_fixations, ts_saccades, ts_status + start_ts, start_position = gaze_movement.positions.first + + ts_unknown[start_ts] = gaze_movement + + for ts, position in gaze_movement.positions.items(): + + ts_status[ts] = GazeStatus.from_position(position, 'UnknownGazeMovement', len(ts_unknown)) + + return ts_fixations, ts_saccades, ts_unknown, ts_status @dataclass class VisualScanStep(): -- cgit v1.1