aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/argaze/GazeFeatures.py53
1 files changed, 37 insertions, 16 deletions
diff --git a/src/argaze/GazeFeatures.py b/src/argaze/GazeFeatures.py
index ab0fb5d..bb99cf3 100644
--- a/src/argaze/GazeFeatures.py
+++ b/src/argaze/GazeFeatures.py
@@ -400,14 +400,35 @@ class TimeStampedGazeStatus(DataStructures.TimeStampedBuffer):
class GazeMovementIdentifier():
"""Abstract class to define what should provide a gaze movement identifier."""
- def identify(self, ts, gaze_position, terminate=False) -> GazeMovementType:
+ def identify(self, ts, gaze_position, terminate=False) -> Tuple[GazeMovementType, GazeMovementType]:
"""Identify gaze movement from successive timestamped gaze positions.
The optional *terminate* argument allows to notify identification algorithm that given gaze position will be the last one.
+
+ Returns:
+ finished_gaze_movement: identified gaze movement once it is finished
"""
raise NotImplementedError('identify() method not implemented')
+ @property
+ def current_gaze_movement(self) -> GazeMovementType:
+ """Get currently identified gaze movement."""
+
+ raise NotImplementedError('current_gaze_movement getter not implemented')
+
+ @property
+ def current_fixation(self) -> GazeMovementType:
+ """Get currently identified fixation."""
+
+ raise NotImplementedError('current_fixation getter not implemented')
+
+ @property
+ def current_saccade(self) -> GazeMovementType:
+ """Get currently identified saccade."""
+
+ raise NotImplementedError('current_saccade getter not implemented')
+
def browse(self, ts_gaze_positions: TimeStampedGazePositions) -> Tuple[TimeStampedGazeMovementsType, TimeStampedGazeMovementsType, TimeStampedGazeStatusType]:
"""Identify fixations and saccades browsing timestamped gaze positions."""
@@ -423,25 +444,25 @@ class GazeMovementIdentifier():
# Iterate on gaze positions
for ts, gaze_position in ts_gaze_positions.items():
- gaze_movement = self.identify(ts, gaze_position, terminate=(ts == last_ts))
+ finished_gaze_movement = self.identify(ts, gaze_position, terminate=(ts == last_ts))
- if is_fixation(gaze_movement):
+ if is_fixation(finished_gaze_movement):
- start_ts, start_position = gaze_movement.positions.first
+ start_ts, start_position = finished_gaze_movement.positions.first
- ts_fixations[start_ts] = gaze_movement
+ ts_fixations[start_ts] = finished_gaze_movement
- for ts, position in gaze_movement.positions.items():
+ for ts, position in finished_gaze_movement.positions.items():
ts_status[ts] = GazeStatus.from_position(position, 'Fixation', len(ts_fixations))
- elif is_saccade(gaze_movement):
+ elif is_saccade(finished_gaze_movement):
- start_ts, start_position = gaze_movement.positions.first
+ start_ts, start_position = finished_gaze_movement.positions.first
- ts_saccades[start_ts] = gaze_movement
+ ts_saccades[start_ts] = finished_gaze_movement
- for ts, position in gaze_movement.positions.items():
+ for ts, position in finished_gaze_movement.positions.items():
ts_status[ts] = GazeStatus.from_position(position, 'Saccade', len(ts_saccades))
@@ -458,8 +479,8 @@ class GazeMovementIdentifier():
ts_gaze_positions: timestamped gaze positions to process.
Returns:
- timestamp
- gaze movement
+ timestamp: first gaze position date of identified gaze movement
+ finished_gaze_movement: identified gaze movement once it is finished
"""
assert(type(ts_gaze_positions) == TimeStampedGazePositions)
@@ -470,13 +491,13 @@ class GazeMovementIdentifier():
# Iterate on gaze positions
for ts, gaze_position in ts_gaze_positions.items():
- gaze_movement = self.identify(ts, gaze_position, terminate=(ts == last_ts))
+ finished_gaze_movement = self.identify(ts, gaze_position, terminate=(ts == last_ts))
- if gaze_movement.valid:
+ if finished_gaze_movement.valid:
- start_ts, start_position = gaze_movement.positions.first
+ start_ts, start_position = finished_gaze_movement.positions.first
- yield start_ts, gaze_movement
+ yield start_ts, finished_gaze_movement
ScanStepType = TypeVar('ScanStep', bound="ScanStep")
# Type definition for type annotation convenience