@jspsych/plugin-tobii-validation 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,170 @@
1
+ # @jspsych/plugin-tobii-validation
2
+
3
+ jsPsych plugin for Tobii eye tracker validation. Validates calibration accuracy by measuring gaze error at target points and provides detailed visual feedback with per-point metrics.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @jspsych/plugin-tobii-validation
9
+ ```
10
+
11
+ ## Compatibility
12
+
13
+ This plugin requires jsPsych v8.0.0 or later and the `@jspsych/extension-tobii` extension.
14
+
15
+ ## Usage
16
+
17
+ ```javascript
18
+ import TobiiValidationPlugin from '@jspsych/plugin-tobii-validation';
19
+
20
+ const trial = {
21
+ type: TobiiValidationPlugin,
22
+ validation_points: 9,
23
+ tolerance: 0.05,
24
+ show_feedback: true,
25
+ };
26
+ ```
27
+
28
+ The Tobii extension must be loaded, connected, and calibrated before this plugin runs. See the [extension documentation](../extension-tobii/README.md) for setup instructions.
29
+
30
+ ## Parameters
31
+
32
+ | Parameter | Type | Default | Description |
33
+ |-----------|------|---------|-------------|
34
+ | validation_points | int | `9` | Number of validation points. Supported values: `5`, `9`, `13`, `15`, `19`, `25`. |
35
+ | point_size | int | `20` | Size of validation points in pixels. |
36
+ | point_color | string | `'#00ff00'` | Color of validation points (CSS color value). |
37
+ | collection_duration | int | `1000` | Duration to collect gaze data at each point (ms). |
38
+ | show_progress | boolean | `true` | Show a progress indicator (e.g., "Point 3 of 9"). |
39
+ | custom_points | array | `null` | Array of custom validation points. Each point is an object with `x` and `y` properties (normalized 0-1). Overrides `validation_points` when provided. |
40
+ | show_feedback | boolean | `true` | Show visual feedback after validation, including a scatter plot of targets vs. gaze positions and a per-point accuracy table. |
41
+ | instructions | string | `'Look at each point as it appears on the screen to validate calibration accuracy.'` | Instructions text shown before validation begins. |
42
+ | background_color | string | `'#808080'` | Background color of the validation container. |
43
+ | button_color | string | `'#28a745'` | Primary button color. |
44
+ | button_hover_color | string | `'#218838'` | Primary button hover color. |
45
+ | retry_button_color | string | `'#dc3545'` | Retry button color. |
46
+ | retry_button_hover_color | string | `'#c82333'` | Retry button hover color. |
47
+ | success_color | string | `'#28a745'` | Success message heading color. |
48
+ | error_color | string | `'#dc3545'` | Error message heading color. |
49
+ | tolerance | float | `0.05` | Normalized tolerance for acceptable accuracy (0-1 scale). Validation passes if average accuracy error is less than or equal to this value. For example, `0.05` means 5% of screen dimensions. |
50
+ | max_retries | int | `1` | Maximum number of retry attempts allowed if validation fails. The participant is shown a retry button on failure. Set to `0` to disable retries. |
51
+ | zoom_duration | int | `300` | Duration of zoom in/out point animations in ms. |
52
+
53
+ ### Tolerance Guidelines
54
+
55
+ | Tolerance | Use Case |
56
+ |-----------|----------|
57
+ | 0.02 (2%) | High precision research |
58
+ | 0.05 (5%) | Standard experiments (default) |
59
+ | 0.10 (10%) | Exploratory/pilot studies |
60
+
61
+ ## Data Generated
62
+
63
+ In addition to the [default data collected by jsPsych plugins](https://www.jspsych.org/latest/overview/plugins/#data-collected-by-all-plugins), this plugin collects the following data for each trial.
64
+
65
+ | Name | Type | Description |
66
+ |------|------|-------------|
67
+ | validation_success | boolean | Whether validation passed (average accuracy <= tolerance). |
68
+ | average_accuracy | float | Average accuracy error across all points (normalized, 0-1 scale). Lower is better. |
69
+ | average_precision | float | Average precision (consistency) across all points (normalized, 0-1 scale). Lower is better. |
70
+ | tolerance | float | The tolerance value used for this validation. |
71
+ | num_points | int | Number of validation points used. |
72
+ | validation_data | object | Full validation result from the server (see below). |
73
+ | num_attempts | int | Number of validation attempts made (including retries). |
74
+
75
+ ### validation_data Object
76
+
77
+ The `validation_data` field contains the full server response, including:
78
+
79
+ | Field | Type | Description |
80
+ |-------|------|-------------|
81
+ | success | boolean | Whether the server-side validation computation succeeded. |
82
+ | averageAccuracyNorm | float | Average accuracy error (normalized). |
83
+ | averagePrecisionNorm | float | Average precision (normalized). |
84
+ | pointData | array | Per-point validation data (see below). |
85
+
86
+ ### Per-Point Data
87
+
88
+ Each element in the `pointData` array contains:
89
+
90
+ | Field | Type | Description |
91
+ |-------|------|-------------|
92
+ | point | object | Target point with `x` and `y` (normalized 0-1). |
93
+ | accuracyNorm | float | Accuracy error at this point (normalized). |
94
+ | precisionNorm | float | Precision at this point (normalized). |
95
+ | meanGaze | object | Mean gaze position (`{ x, y }`) during data collection at this point. |
96
+ | numSamples | int | Number of valid gaze samples used for this point. |
97
+ | numSamplesTotal | int | Total number of gaze samples collected. |
98
+ | numSamplesSkipped | int | Number of invalid samples that were skipped. |
99
+ | gazeSamples | array | Raw gaze sample positions (`[{ x, y }, ...]`). |
100
+
101
+ ## Validation Point Grids
102
+
103
+ The `validation_points` parameter supports the same grid sizes as the calibration plugin:
104
+
105
+ - **5**: Four corners + center
106
+ - **9**: 3x3 grid (recommended default)
107
+ - **13**: 3x3 outer grid + 4 diagonal midpoints
108
+ - **15**: 5 rows x 3 columns
109
+ - **19**: Symmetric 3-5-3-5-3 pattern
110
+ - **25**: 5x5 full grid
111
+
112
+ All standard grids use points spanning from 0.1 to 0.9 in normalized coordinates.
113
+
114
+ ## Examples
115
+
116
+ ### Basic Validation
117
+
118
+ ```javascript
119
+ const trial = {
120
+ type: TobiiValidationPlugin,
121
+ validation_points: 9,
122
+ tolerance: 0.05,
123
+ };
124
+ ```
125
+
126
+ ### Strict Validation with No Retries
127
+
128
+ ```javascript
129
+ const trial = {
130
+ type: TobiiValidationPlugin,
131
+ validation_points: 9,
132
+ tolerance: 0.02,
133
+ max_retries: 0,
134
+ };
135
+ ```
136
+
137
+ ### Lenient Validation with Custom Styling
138
+
139
+ ```javascript
140
+ const trial = {
141
+ type: TobiiValidationPlugin,
142
+ validation_points: 5,
143
+ tolerance: 0.10,
144
+ point_color: '#00aaff',
145
+ background_color: '#333333',
146
+ };
147
+ ```
148
+
149
+ ### Using Validation Results for Conditional Logic
150
+
151
+ ```javascript
152
+ const trial = {
153
+ type: TobiiValidationPlugin,
154
+ validation_points: 9,
155
+ tolerance: 0.05,
156
+ on_finish: (data) => {
157
+ if (!data.validation_success) {
158
+ // Add recalibration to the timeline
159
+ jsPsych.addNodeToEndOfTimeline({
160
+ type: TobiiCalibrationPlugin,
161
+ calibration_points: 9,
162
+ });
163
+ }
164
+ },
165
+ };
166
+ ```
167
+
168
+ ## Citation
169
+
170
+ If you use this plugin in your research, please cite it. See [CITATION.cff](CITATION.cff).