aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThéo de la Hogue2023-05-10 15:11:17 +0200
committerThéo de la Hogue2023-05-10 15:11:17 +0200
commitdb65cd2c55a66f76760f1460d3209bcfa0b4df34 (patch)
treec24c3a76d535d625ca767094b8f46975093d065f
parentc8b6647d4d8390655e8f57baef3e6557e5fd605a (diff)
downloadargaze-db65cd2c55a66f76760f1460d3209bcfa0b4df34.zip
argaze-db65cd2c55a66f76760f1460d3209bcfa0b4df34.tar.gz
argaze-db65cd2c55a66f76760f1460d3209bcfa0b4df34.tar.bz2
argaze-db65cd2c55a66f76760f1460d3209bcfa0b4df34.tar.xz
Moving code into GazeFeatures
-rw-r--r--src/argaze/GazeAnalysis/DispersionThresholdIdentification.py22
1 files changed, 7 insertions, 15 deletions
diff --git a/src/argaze/GazeAnalysis/DispersionThresholdIdentification.py b/src/argaze/GazeAnalysis/DispersionThresholdIdentification.py
index cb29055..92df6d2 100644
--- a/src/argaze/GazeAnalysis/DispersionThresholdIdentification.py
+++ b/src/argaze/GazeAnalysis/DispersionThresholdIdentification.py
@@ -18,9 +18,6 @@ SaccadeType = TypeVar('Saccade', bound="Saccade")
class Fixation(GazeFeatures.Fixation):
"""Define dispersion based fixation."""
- centroid: tuple = field(init=False)
- """Centroïd of all gaze positions belonging to the fixation."""
-
deviation_max: float = field(init=False)
"""Maximal gaze position distance to the centroïd."""
@@ -28,28 +25,23 @@ class Fixation(GazeFeatures.Fixation):
super().__post_init__()
- self.update()
-
- def point_deviation(self, gaze_position) -> float:
- """Get distance of a point from the fixation's centroïd."""
-
- return numpy.sqrt((self.centroid[0] - gaze_position.value[0])**2 + (self.centroid[1] - gaze_position.value[1])**2)
-
- def update(self):
- """Update fixation's centroïd then maximal gaze positions deviation from this centroïd."""
-
points = self.positions.values()
points_x, points_y = [p[0] for p in points], [p[1] for p in points]
points_array = numpy.column_stack([points_x, points_y])
centroid_array = numpy.array([numpy.mean(points_x), numpy.mean(points_y)])
deviations_array = numpy.sqrt(numpy.sum((points_array - centroid_array)**2, axis=1))
- # Update frozen centroid attribute
- object.__setattr__(self, 'centroid', (centroid_array[0], centroid_array[1]))
+ # Update frozen focus attribute using centroid
+ object.__setattr__(self, 'focus', (centroid_array[0], centroid_array[1]))
# Update frozen deviation_max attribute
object.__setattr__(self, 'deviation_max', max(deviations_array))
+ def point_deviation(self, gaze_position) -> float:
+ """Get distance of a point from the fixation's centroïd."""
+
+ return numpy.sqrt((self.centroid[0] - gaze_position.value[0])**2 + (self.centroid[1] - gaze_position.value[1])**2)
+
def overlap(self, fixation) -> bool:
"""Does a gaze position from another fixation having a deviation to this fixation centroïd smaller than maximal deviation?"""