aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/argaze/GazeFeatures.py56
-rw-r--r--src/argaze/utils/demo_gaze_features_run.py6
2 files changed, 31 insertions, 31 deletions
diff --git a/src/argaze/GazeFeatures.py b/src/argaze/GazeFeatures.py
index d004129..e17c9f9 100644
--- a/src/argaze/GazeFeatures.py
+++ b/src/argaze/GazeFeatures.py
@@ -286,34 +286,35 @@ class GazeMovementIdentifier():
return ts_fixations, ts_saccades, ts_status
-VisualScanNodeType = TypeVar('VisualScanNode', bound="VisualScanNode")
+VisualScanStepType = TypeVar('VisualScanStep', bound="VisualScanStep")
# Type definition for type annotation convenience
@dataclass(frozen=True)
-class VisualScanNode():
- """Define a visual scan node as a set of successive gaze movements onto a same AOI."""
+class VisualScanStep():
+ """Define a visual scan step as a set of successive gaze movements onto a same AOI."""
movements: TimeStampedGazeMovements
- """ """
+ """All movements over an aoi and the last saccade that comes out."""
aoi: str = field(default='')
- """Name of the looked AOI"""
+ """Name of the looked AOI."""
-VisualScanArcType = TypeVar('VisualScanArc', bound="VisualScanArc")
-# Type definition for type annotation convenience
+ def __post_init__(self):
-@dataclass(frozen=True)
-class VisualScanArc():
- """Define a visual scan arc as a saccade to a next visual scan node."""
+ # Last movement should be a saccade
+ _, last_movement = self.movements.last
- saccade: Saccade
- """Saccade to the next scan node"""
+ assert(type(last_movement).__bases__[0] == Saccade)
- to: VisualScanNode
- """Node where the saccade ends"""
+ @property
+ def transition(self):
+ """Last saccade that comes out looked aoi"""
+
+ _, last_movement = self.movements.last
+ return last_movement
class VisualScan(list):
- """Build a linear path made of nodes relied by arcs from successive timestamped gaze movements over aoi."""
+ """List visual scan steps over successive aoi."""
def __init__(self):
@@ -332,9 +333,9 @@ class VisualScan(list):
output = ''
- for arc in self:
+ for step in self:
- output += f'> {arc.to.aoi} '
+ output += f'> {step.aoi} '
return output
@@ -344,21 +345,16 @@ class VisualScan(list):
self.__movements[ts] = saccade
def append_fixation(self, ts, fixation, looked_aoi: str) -> bool:
- """Append a new fixation to visual scan and return True if a new arc have been created."""
+ """Append a new fixation to visual scan and return last new visual scan step if one have been created."""
# Is the fixation onto a new aoi?
if looked_aoi != self.__last_aoi and len(self.__movements) > 0:
- # Last movement should be a saccade
- last_ts, last_movement = self.__movements.pop_last()
- assert(type(last_movement).__bases__[0] == Saccade)
-
- # Edit new node and arc
- new_node = VisualScanNode(self.__movements, looked_aoi)
- new_arc = VisualScanArc(last_movement, new_node)
+ # Edit new step
+ new_step = VisualScanStep(self.__movements, looked_aoi)
- # Append new arc
- super().append(new_arc)
+ # Append new step
+ super().append(new_step)
# Clear movements
self.__movements = TimeStampedGazeMovements()
@@ -369,8 +365,8 @@ class VisualScan(list):
# Remember new aoi
self.__last_aoi = looked_aoi
- # Return new arc
- return new_arc
+ # Return new step
+ return new_step
else:
@@ -382,7 +378,7 @@ class VisualScan(list):
class VisualScanAnalyzer():
"""Abstract class to define what should provide a visual scan analyzer."""
- def analyze(self, visual_scan: list[VisualScanArcType]) -> Any:
+ def analyze(self, visual_scan: list[VisualScanStepType]) -> Any:
"""Analyze visual scan."""
raise NotImplementedError('analyze() method not implemented')
diff --git a/src/argaze/utils/demo_gaze_features_run.py b/src/argaze/utils/demo_gaze_features_run.py
index 8e8c282..5507b68 100644
--- a/src/argaze/utils/demo_gaze_features_run.py
+++ b/src/argaze/utils/demo_gaze_features_run.py
@@ -83,7 +83,11 @@ def main():
break
# Append fixation to visual scan
- new_arc = visual_scan.append_fixation(data_ts, gaze_movement, look_at)
+ new_step = visual_scan.append_fixation(data_ts, gaze_movement, look_at)
+
+ if new_step:
+
+ print(visual_scan)
if isinstance(gaze_movement, DispersionBasedGazeMovementIdentifier.Saccade):