From 097980e2c67ad81b1acbbc00707b141dd55397bf Mon Sep 17 00:00:00 2001 From: Théo de la Hogue Date: Tue, 13 Dec 2022 10:54:11 +0100 Subject: Adding message to unvalid gaze position. --- src/argaze/GazeFeatures.py | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/src/argaze/GazeFeatures.py b/src/argaze/GazeFeatures.py index dd07974..c3778bb 100644 --- a/src/argaze/GazeFeatures.py +++ b/src/argaze/GazeFeatures.py @@ -83,7 +83,9 @@ class GazePosition(): class UnvalidGazePosition(GazePosition): """Unvalid gaze position.""" - def __init__(self): + def __init__(self, message=None): + + self.message = message super().__init__((None, None), precision=None) @@ -161,13 +163,6 @@ class Saccade(GazeMovement): # Update frozen distance attribute object.__setattr__(self, 'distance', distance) -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 @@ -175,9 +170,9 @@ class TimeStampedGazeMovements(DataStructures.TimeStampedBuffer): """Define timestamped buffer to store gaze movements.""" def __setitem__(self, key, value: GazeMovement): - """Force value to inherit from GazeMovement.""" + """Force value to be or inherit from GazeMovement.""" - assert(type(value).__bases__[0] == Fixation or type(value).__bases__[0] == Saccade or type(value).__bases__[0] == UnknownGazeMovement) + assert(isinstance(value, GazeMovement) or type(value).__bases__[0] == Fixation or type(value).__bases__[0] == Saccade) super().__setitem__(key, value) @@ -243,7 +238,7 @@ class GazeMovementIdentifier(): ts_fixations = TimeStampedGazeMovements() ts_saccades = TimeStampedGazeMovements() - ts_unknown = TimeStampedGazeMovements() + ts_movements = TimeStampedGazeMovements() ts_status = TimeStampedGazeStatus() for gaze_movement in self(ts_gaze_positions): @@ -272,13 +267,13 @@ class GazeMovementIdentifier(): start_ts, start_position = gaze_movement.positions.first - ts_unknown[start_ts] = gaze_movement + ts_movements[start_ts] = gaze_movement for ts, position in gaze_movement.positions.items(): - ts_status[ts] = GazeStatus.from_position(position, 'UnknownGazeMovement', len(ts_unknown)) + ts_status[ts] = GazeStatus.from_position(position, 'GazeMovement', len(ts_movements)) - return ts_fixations, ts_saccades, ts_unknown, ts_status + return ts_fixations, ts_saccades, ts_movements, ts_status @dataclass class VisualScanStep(): -- cgit v1.1