aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThéo de la Hogue2022-12-19 16:08:17 +0100
committerThéo de la Hogue2022-12-19 16:08:17 +0100
commite185fa9e39d3fc0d2029da2404bca320fead41a2 (patch)
tree5bb9756bfa75780d273295dd3fa50352ffc91863
parent175ff54e321cd6acd7d723a8193b2edb740fa338 (diff)
downloadargaze-e185fa9e39d3fc0d2029da2404bca320fead41a2.zip
argaze-e185fa9e39d3fc0d2029da2404bca320fead41a2.tar.gz
argaze-e185fa9e39d3fc0d2029da2404bca320fead41a2.tar.bz2
argaze-e185fa9e39d3fc0d2029da2404bca320fead41a2.tar.xz
Adding positions valid ratio metric.
-rw-r--r--src/argaze/utils/tobii_segment_gaze_metrics_export.py35
1 files changed, 34 insertions, 1 deletions
diff --git a/src/argaze/utils/tobii_segment_gaze_metrics_export.py b/src/argaze/utils/tobii_segment_gaze_metrics_export.py
index 778e699..a138087 100644
--- a/src/argaze/utils/tobii_segment_gaze_metrics_export.py
+++ b/src/argaze/utils/tobii_segment_gaze_metrics_export.py
@@ -56,14 +56,19 @@ def main():
os.makedirs(destination_path)
print(f'{destination_path} folder created')
+ positions_json_filepath = f'{destination_path}/gaze_positions.json'
+
fixations_json_filepath = f'{destination_path}/gaze_fixations.json'
saccades_json_filepath = f'{destination_path}/gaze_saccades.json'
movements_json_filepath = f'{destination_path}/gaze_movements.json'
gaze_status_json_filepath = f'{destination_path}/gaze_status.json'
- gaze_metrics_period_filepath = f'{destination_path}/gaze_metrics_{args.period}s.csv'
+ gaze_metrics_period_filepath = f'{destination_path}/gaze_metrics_{int(args.period)}s.csv'
gaze_metrics_whole_filepath = f'{destination_path}/gaze_metrics.csv'
+ # Load gaze positions
+ ts_gaze_positions = GazeFeatures.TimeStampedGazePositions.from_json(positions_json_filepath)
+
# Load gaze movements
ts_fixations = GazeFeatures.TimeStampedGazeMovements.from_json(fixations_json_filepath)
ts_saccades = GazeFeatures.TimeStampedGazeMovements.from_json(saccades_json_filepath)
@@ -90,11 +95,20 @@ def main():
# Prepare gaze metrics
ts_metrics = DataStructures.TimeStampedBuffer()
+ positions_exist = len(ts_gaze_positions) > 0
fixations_exist = len(ts_fixations) > 0
saccades_exist = len(ts_saccades) > 0
movements_exist = len(ts_movements) > 0
status_exist = len(ts_status) > 0
+ if positions_exist:
+
+ # Create pandas dataframe
+ positions_dataframe = ts_gaze_positions.as_dataframe()
+
+ # Reset time range offset
+ positions_dataframe.index = positions_dataframe.index - positions_dataframe.index[0]
+
if fixations_exist:
# Create pandas dataframe
@@ -139,6 +153,23 @@ def main():
# Store period duration
period_metrics['duration (ms)'] = period_duration * 1e-3
+ # Default positions analysis
+ period_metrics['positions_number'] = 0
+ period_metrics['positions_valid_ratio (%)'] = None
+
+ # Analyse fixations
+ if positions_exist:
+
+ # Select period
+ positions_period_dataframe = positions_dataframe[(positions_dataframe.index >= period_start_ts) & (positions_dataframe.index < period_end_ts)]
+
+ if not positions_period_dataframe.empty:
+
+ #print('\n* Positions:\n', positions_period_dataframe)
+
+ period_metrics['positions_number'] = positions_period_dataframe.shape[0]
+ period_metrics['positions_valid_ratio (%)'] = positions_period_dataframe.precision.count() / positions_period_dataframe.shape[0] * 100
+
# Default fixation analysis
fixations_duration_sum = 0.0
period_metrics['fixations_number'] = 0
@@ -195,6 +226,7 @@ def main():
period_metrics['movements_duration_mean (ms)'] = None
period_metrics['movements_duration_sum (ms)'] = None
period_metrics['movements_duration_ratio (%)'] = None
+ period_metrics['movements_distance_mean (px)'] = None
# Analyse movements movements
if movements_exist:
@@ -211,6 +243,7 @@ def main():
period_metrics['movements_duration_mean (ms)'] = movements_period_dataframe.duration.mean() * 1e-3
period_metrics['movements_duration_sum (ms)'] = movements_duration_sum * 1e-3
period_metrics['movements_duration_ratio (%)'] = movements_duration_sum / period_duration * 100
+ period_metrics['movements_distance_mean (px)'] = movements_period_dataframe.distance.mean()
# Analyse exploit/explore
if saccades_duration_sum != 0.0 or movements_duration_sum != 0.0: