aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThéo de la Hogue2022-12-19 15:53:28 +0100
committerThéo de la Hogue2022-12-19 15:53:28 +0100
commit9e13b3f7f5191301256a8a4e657b1ec74d78f356 (patch)
treedd47b1470ea13f7219ca3d5f096b9cd4b01a318c
parent8a251e6849f3b7706b07d7ad3291be8b4b933daa (diff)
downloadargaze-9e13b3f7f5191301256a8a4e657b1ec74d78f356.zip
argaze-9e13b3f7f5191301256a8a4e657b1ec74d78f356.tar.gz
argaze-9e13b3f7f5191301256a8a4e657b1ec74d78f356.tar.bz2
argaze-9e13b3f7f5191301256a8a4e657b1ec74d78f356.tar.xz
Processing GazeMovement distance not only in Saccade.
-rw-r--r--src/argaze/GazeFeatures.py22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/argaze/GazeFeatures.py b/src/argaze/GazeFeatures.py
index f3fa45a..2b5cdde 100644
--- a/src/argaze/GazeFeatures.py
+++ b/src/argaze/GazeFeatures.py
@@ -139,6 +139,9 @@ class GazeMovement():
duration: float = field(init=False)
"""Inferred duration from first and last timestamps."""
+ distance: float = field(init=False)
+ """Inferred distance from first and last positions."""
+
def __post_init__(self):
start_position_ts, start_position = self.positions.first
@@ -147,6 +150,14 @@ class GazeMovement():
# Update frozen duration attribute
object.__setattr__(self, 'duration', end_position_ts - start_position_ts)
+ _, start_position = self.positions.first
+ _, end_position = self.positions.last
+
+ distance = numpy.linalg.norm( numpy.array(start_position.value) - numpy.array(end_position.value))
+
+ # Update frozen distance attribute
+ object.__setattr__(self, 'distance', distance)
+
def __str__(self) -> str:
"""String display"""
@@ -168,21 +179,10 @@ class Fixation(GazeMovement):
class Saccade(GazeMovement):
"""Define abstract saccade as gaze movement."""
- distance: float = field(init=False)
- """Inferred distance from first and last positions."""
-
def __post_init__(self):
super().__post_init__()
- _, start_position = self.positions.first
- _, end_position = self.positions.last
-
- distance = numpy.linalg.norm( numpy.array(start_position.value) - numpy.array(end_position.value))
-
- # Update frozen distance attribute
- object.__setattr__(self, 'distance', distance)
-
TimeStampedGazeMovementsType = TypeVar('TimeStampedGazeMovements', bound="TimeStampedGazeMovements")
# Type definition for type annotation convenience