diff options
Diffstat (limited to 'docs/user_guide/gaze_analysis_pipeline/logging.md')
-rw-r--r-- | docs/user_guide/gaze_analysis_pipeline/logging.md | 86 |
1 files changed, 45 insertions, 41 deletions
diff --git a/docs/user_guide/gaze_analysis_pipeline/logging.md b/docs/user_guide/gaze_analysis_pipeline/logging.md index 6ed497b..6ef3a85 100644 --- a/docs/user_guide/gaze_analysis_pipeline/logging.md +++ b/docs/user_guide/gaze_analysis_pipeline/logging.md @@ -1,30 +1,28 @@ -Log gaze analysis +Record gaze analysis ================= -[ArFrame](../../argaze.md/#argaze.ArFeatures.ArFrame) and [ArLayer](../../argaze.md/#argaze.ArFeatures.ArLayer) analysis can be logged by registering observers to their **look** method. +[ArFrame](../../argaze.md/#argaze.ArFeatures.ArFrame) and [ArLayer](../../argaze.md/#argaze.ArFeatures.ArLayer) analysis can be recorded by registering observers to their **look** method. ## Export gaze analysis to CSV file -[ArFrame](../../argaze.md/#argaze.ArFeatures.ArFrame) and [ArLayer](../../argaze.md/#argaze.ArFeatures.ArLayer) have an observers attribute to enable pipeline execution logging. +[ArFrame](../../argaze.md/#argaze.ArFeatures.ArFrame) and [ArLayer](../../argaze.md/#argaze.ArFeatures.ArLayer) have an *observers* attribute to enable pipeline execution recording. -Here is an extract from the JSON ArFrame configuration file where logging is enabled for the [ArFrame](../../argaze.md/#argaze.ArFeatures.ArFrame) and for one [ArLayer](../../argaze.md/#argaze.ArFeatures.ArLayer) by pointing to dedicated Python files: +Here is an extract from the JSON ArFrame configuration file where recording is enabled for the [ArFrame](../../argaze.md/#argaze.ArFeatures.ArFrame) and for one [ArLayer](../../argaze.md/#argaze.ArFeatures.ArLayer) by loaded classes from Python files: ```json { "name": "My FullHD screen", "size": [1920, 1080], "observers": { - "my_frame_logger.ScanPathAnalysisLogger": { - "path": "./scan_path_metrics.csv", - "header": ["Timestamp (ms)", "Duration (ms)", "Steps number"] + "my_recorders.ScanPathAnalysisRecorder": { + "path": "./scan_path_metrics.csv" }, ... "layers": { "MyLayer": { "observers": { - "my_layer_logger.AOIScanPathAnalysisLogger": { - "path": "./aoi_scan_path_metrics.csv", - "header": ["Timestamp (ms)", "NGram counts"] + "my_recorders.AOIScanPathAnalysisRecorder": { + "path": "./aoi_scan_path_metrics.csv" } }, ... @@ -36,67 +34,73 @@ Here is an extract from the JSON ArFrame configuration file where logging is ena !!! note [ArFrame](../../argaze.md/#argaze.ArFeatures.ArFrame) and its [ArLayers](../../argaze.md/#argaze.ArFeatures.ArLayer) automatically notify **look** method observers after each call. -Here is *my_frame_logger.py* file: +Here is *my_recorders.py* file: ```python -from argaze import DataFeatures -from argaze.GazeAnalysis import Basic from argaze.utils import UtilsFeatures -class ScanPathAnalysisLogger(DataFeatures.PipelineStepObserver, UtilsFeatures.FileWriter): +class ScanPathAnalysisRecorder(UtilsFeatures.FileWriter): + + def __init__(self, **kwargs): + + # Init FileWriter + super().__init__(**kwargs) + + # Edit hearder line + self.header = "Timestamp (ms)", "Duration (ms)", "Steps number" def on_look(self, timestamp, ar_frame, exception): - """Log scan path metrics""" + """Record scan path metrics""" if ar_frame.is_analysis_available(): analysis = ar_frame.analysis() - log = ( + data = ( timestamp, - analysis[Basic.ScanPathAnalyzer].path_duration, - analysis[Basic.ScanPathAnalyzer].steps_number + analysis['argaze.GazeAnalysis.Basic.ScanPathAnalyzer'].path_duration, + analysis['argaze.GazeAnalysis.Basic.ScanPathAnalyzer'].steps_number ) # Write to file - self.write(log) -``` + self.write(data) -Assuming that [ArGaze.GazeAnalysis.Basic](../../argaze.md/#argaze.GazeAnalysis.Basic) scan path analysis module is enabled for 'My FullHD screen' ArFrame, a ***scan_path_metrics.csv*** file would be created: +class AOIScanPathAnalysisRecorder(UtilsFeatures.FileWriter): -|Timestamp (ms)|Duration (ms)|Steps number| -|:-------------|:------------|:-----------| -|3460 |1750 |2 | -|4291 |2623 |3 | -|4769 |3107 |4 | -|6077 |4411 |5 | -|6433 |4760 |6 | -|7719 |6050 |7 | -|... |... |... | + def __init__(self, **kwargs): -Here is *my_layer_logger.py* file: + # Init FileWriter + super().__init__(**kwargs) -```python -from argaze import DataFeatures -from argaze.GazeAnalysis import NGram -from argaze.utils import UtilsFeatures - -class AOIScanPathAnalysisLogger(DataFeatures.PipelineStepObserver, UtilsFeatures.FileWriter): + # Edit header line + self.header = "Timestamp (ms)", "NGram counts" def on_look(self, timestamp, ar_layer, exception): - """Log aoi scan path metrics.""" + """Record aoi scan path metrics.""" if ar_layer.is_analysis_available(): - log = ( + data = ( timestamp, - ar_layer.analysis[NGram.AOIScanPathAnalyzer].ngrams_count + ar_layer.analysis['argaze.GazeAnalysis.NGram.AOIScanPathAnalyzer'].ngrams_count ) # Write to file - self.write(log) + self.write(data) ``` +Assuming that [ArGaze.GazeAnalysis.Basic](../../argaze.md/#argaze.GazeAnalysis.Basic) scan path analysis module is enabled for 'My FullHD screen' ArFrame, a ***scan_path_metrics.csv*** file would be created: + +|Timestamp (ms)|Duration (ms)|Steps number| +|:-------------|:------------|:-----------| +|3460 |1750 |2 | +|4291 |2623 |3 | +|4769 |3107 |4 | +|6077 |4411 |5 | +|6433 |4760 |6 | +|7719 |6050 |7 | +|... |... |... | + Assuming that [ArGaze.GazeAnalysis.NGram](../../argaze.md/#argaze.GazeAnalysis.NGram) AOI scan path analysis module is enabled for 'MyLayer' ArLayer, a ***aoi_scan_path_metrics.csv*** file would be created: |Timestamp (ms)|NGram counts| |