aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-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?"""