From 0d0094d39c04d32afecd33b3f197c409c38aa921 Mon Sep 17 00:00:00 2001 From: Théo de la Hogue Date: Wed, 31 Jan 2024 09:24:27 +0100 Subject: Considering fixations outside AOI as expected aoi. --- src/argaze/ArFeatures.py | 3 ++- src/argaze/GazeFeatures.py | 19 +++++++++++++++---- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/argaze/ArFeatures.py b/src/argaze/ArFeatures.py index 0cb1d77..0314466 100644 --- a/src/argaze/ArFeatures.py +++ b/src/argaze/ArFeatures.py @@ -420,7 +420,8 @@ class ArLayer(DataFeatures.SharedObject, DataFeatures.PipelineStepObject): if GazeFeatures.is_fixation(gaze_movement): # Append fixation to aoi scan path - if self.__aoi_scan_path is not None and self.__looked_aoi_name is not None: + # TODO: add an option to filter None looked_aoi_name or not + if self.__aoi_scan_path is not None: aoi_scan_step = self.__aoi_scan_path.append_fixation(timestamp, gaze_movement, self.__looked_aoi_name) diff --git a/src/argaze/GazeFeatures.py b/src/argaze/GazeFeatures.py index 7254205..81a87c8 100644 --- a/src/argaze/GazeFeatures.py +++ b/src/argaze/GazeFeatures.py @@ -960,6 +960,9 @@ class AOIScanStep(): AOIScanPathType = TypeVar('AOIScanPathType', bound="AOIScanPathType") # Type definition for type annotation convenience +# Define strings for outside AOI case +OutsideAOI = 'GazeFeatures.OutsideAOI' + class AOIScanPath(list): """List of aoi scan steps over successive aoi. @@ -973,7 +976,7 @@ class AOIScanPath(list): self.duration_max = duration_max self.expected_aoi = expected_aoi - + self.__duration = 0 @property @@ -1042,7 +1045,9 @@ class AOIScanPath(list): """ self.clear() - self.__expected_aoi = expected_aoi + self.__expected_aoi = [OutsideAOI] + self.__expected_aoi += expected_aoi + self.__movements = TimeStampedGazeMovements() self.__current_aoi = '' self.__index = ord('A') @@ -1076,9 +1081,15 @@ class AOIScanPath(list): """Append new fixation to aoi scan path and return last new aoi scan step if one have been created. !!! warning - It could raise AOIScanStepError""" + It could raise AOIScanStepError""" + + # Replace None aoi by generic OutsideAOI name + if looked_aoi is None: + + looked_aoi = OutsideAOI - if looked_aoi not in self.__expected_aoi: + # Raise error when aoi is not expected + elif looked_aoi not in self.__expected_aoi: raise AOIScanStepError('AOI not expected', looked_aoi) -- cgit v1.1