aboutsummaryrefslogtreecommitdiff
path: root/docs/user_guide/gaze_analysis_pipeline/timestamped_gaze_positions_edition.md
diff options
context:
space:
mode:
authorThéo de la Hogue2023-08-10 09:04:31 +0200
committerThéo de la Hogue2023-08-10 09:04:31 +0200
commit293d1cc9b0fe6d7e871511cd716001f5765d9118 (patch)
tree444cff250f3a3e9997288dedf1d88c6dd8499209 /docs/user_guide/gaze_analysis_pipeline/timestamped_gaze_positions_edition.md
parent80e122453c1120b4211015a3b7625be089db8a9f (diff)
downloadargaze-293d1cc9b0fe6d7e871511cd716001f5765d9118.zip
argaze-293d1cc9b0fe6d7e871511cd716001f5765d9118.tar.gz
argaze-293d1cc9b0fe6d7e871511cd716001f5765d9118.tar.bz2
argaze-293d1cc9b0fe6d7e871511cd716001f5765d9118.tar.xz
Working on gaze analysis pipeline documentation. Still in progress...
Diffstat (limited to 'docs/user_guide/gaze_analysis_pipeline/timestamped_gaze_positions_edition.md')
-rw-r--r--docs/user_guide/gaze_analysis_pipeline/timestamped_gaze_positions_edition.md73
1 files changed, 73 insertions, 0 deletions
diff --git a/docs/user_guide/gaze_analysis_pipeline/timestamped_gaze_positions_edition.md b/docs/user_guide/gaze_analysis_pipeline/timestamped_gaze_positions_edition.md
new file mode 100644
index 0000000..e7deab2
--- /dev/null
+++ b/docs/user_guide/gaze_analysis_pipeline/timestamped_gaze_positions_edition.md
@@ -0,0 +1,73 @@
+Edit Timestamped Gaze Positions
+===============================
+
+Whatever eye data comes from a file on disk or from a live stream, timestamped gaze positions are required before to go further.
+
+![Timestamped Gaze Positions](../../img/timestamped_gaze_positions.png)
+
+## Import gaze positions from CSV file
+
+It is possible to load timestamped gaze positions from a [Pandas DataFrame](https://pandas.pydata.org/docs/getting_started/intro_tutorials/01_table_oriented.html#min-tut-01-tableoriented) object which can be loaded from a CSV file.
+
+```python
+from argaze import GazeFeatures
+import pandas
+
+# Load gaze positions from a CSV file into Panda Dataframe
+dataframe = pandas.read_csv('gaze_positions.csv', delimiter=",", low_memory=False)
+
+# Convert Panda dataframe into timestamped gaze positions precising the use of each specific column labels
+ts_gaze_positions = GazeFeatures.TimeStampedGazePositions.from_dataframe(dataframe, timestamp = 'Recording timestamp [ms]', x = 'Gaze point X [px]', y = 'Gaze point Y [px]')
+
+# Iterate over timestamped gaze positions
+for timestamp, gaze_position in ts_gaze_positions.items():
+
+ # Do something with each timestamped gaze position
+ ...
+```
+
+## Edit gaze positions from live stream
+
+When gaze positions comes from a real time input, gaze position can be edited thanks to [GazePosition](../../../argaze/#argaze.GazeFeatures.GazePosition) class.
+Besides, timestamps can be edited from the incoming data stream or, if not available, they can be edited thanks to the python [time package](https://docs.python.org/3/library/time.html).
+
+``` python
+from argaze import GazeFeatures
+
+# Assuming to be inside the function where timestamp_µs, gaze_x and gaze_y values are catched
+...
+ # Edit a second timestamp from a microsecond second timestamp
+ timestamp = timestamp_µs * 1e-6
+
+ # Define a basic gaze position
+ gaze_position = GazeFeatures.GazePosition((gaze_x, gaze_y))
+
+ # Do something with each timestamped gaze position
+ ...
+```
+
+``` python
+from argaze import GazeFeatures
+
+import time
+
+# Init timestamp
+start_time = time.time()
+
+# Assuming to be inside the function where only gaze_x and gaze_y values are catched (no timestamp)
+...
+
+ # Edit a millisecond timestamp
+ timestamp = int((time.time() - start_time) * 1e3)
+
+ # Define a basic gaze position
+ gaze_position = GazeFeatures.GazePosition((gaze_x, gaze_y))
+
+ # Do something with each timestamped gaze position
+ ...
+```
+
+!!! warning
+ **ArGaze doesn't impose any time unit.** Timestamps can either be integer or float, second, millisecond or what ever you need. The only concern is that all time values used in further configurations have to be all the same unit.
+
+Now we have timestamped gaze positions at expected format, let's see how to analyze them. \ No newline at end of file