@jspsych/plugin-tobii-user-position 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,133 @@
1
+ # @jspsych/plugin-tobii-user-position
2
+
3
+ jsPsych plugin for Tobii eye tracker user position guide. Displays real-time head position feedback to help participants maintain optimal positioning for eye tracking. Useful before calibration to ensure good tracking conditions.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @jspsych/plugin-tobii-user-position
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 TobiiUserPositionPlugin from '@jspsych/plugin-tobii-user-position';
19
+
20
+ const trial = {
21
+ type: TobiiUserPositionPlugin,
22
+ message: 'Please position yourself so the indicators are green',
23
+ require_good_position: true,
24
+ show_distance_feedback: true,
25
+ show_position_feedback: true,
26
+ };
27
+ ```
28
+
29
+ The Tobii extension must be loaded and connected before this plugin runs. See the [extension documentation](../extension-tobii/README.md) for setup instructions.
30
+
31
+ ## Parameters
32
+
33
+ | Parameter | Type | Default | Description |
34
+ |-----------|------|---------|-------------|
35
+ | duration | int | `null` | Duration to show the position guide (ms). Set to `null` for manual continuation via a button. |
36
+ | message | string | `'Please position yourself so the indicators are green'` | Instructions message displayed to the participant. |
37
+ | update_interval | int | `100` | How often to poll and update the position display (ms). |
38
+ | show_distance_feedback | boolean | `true` | Show distance (Z-axis) feedback text indicating whether the participant is too close, too far, or at the right distance. |
39
+ | show_position_feedback | boolean | `true` | Show XY position feedback text indicating whether the participant should adjust left/right/up/down. |
40
+ | button_text | string | `'Continue'` | Text on the continue button (only shown when `duration` is `null`). |
41
+ | require_good_position | boolean | `false` | When `true`, the continue button is disabled until the participant is in a good position. Has no effect when `duration` is set. |
42
+ | background_color | string | `'#f0f0f0'` | Background color of the position guide. |
43
+ | good_color | string | `'#28a745'` | Color for good position indicators (green). |
44
+ | fair_color | string | `'#ffc107'` | Color for fair position indicators (yellow). |
45
+ | poor_color | string | `'#dc3545'` | Color for poor position indicators (red). |
46
+ | button_color | string | `'#007bff'` | Continue button color. |
47
+ | button_hover_color | string | `'#0056b3'` | Continue button hover color. |
48
+ | font_size | string | `'18px'` | Font size for feedback text (CSS value). |
49
+ | position_threshold_good | float | `0.15` | Maximum normalized offset from center (0.5) for the XY position to be rated "good". |
50
+ | position_threshold_fair | float | `0.25` | Maximum normalized offset from center for the XY position to be rated "fair". Offsets beyond this are rated "poor". |
51
+ | distance_threshold_good | float | `0.1` | Maximum normalized offset from optimal distance (0.5) for the Z position to be rated "good". |
52
+ | distance_threshold_fair | float | `0.2` | Maximum normalized offset from optimal distance for the Z position to be rated "fair". Offsets beyond this are rated "poor". |
53
+
54
+ ### Position Quality Thresholds
55
+
56
+ The eye position indicators are color-coded based on how far the participant's eyes are from the center of the tracking box:
57
+
58
+ | Quality | XY Offset | Z Offset | Color |
59
+ |---------|-----------|----------|-------|
60
+ | Good | <= 0.15 | <= 0.1 | Green |
61
+ | Fair | <= 0.25 | <= 0.2 | Yellow |
62
+ | Poor | > 0.25 | > 0.2 | Red |
63
+
64
+ These thresholds can be customized with the `position_threshold_*` and `distance_threshold_*` parameters.
65
+
66
+ ## Data Generated
67
+
68
+ 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.
69
+
70
+ | Name | Type | Description |
71
+ |------|------|-------------|
72
+ | average_x | float | Average horizontal eye position during the trial (normalized, 0-1, 0.5 is center). `null` if no valid samples. |
73
+ | average_y | float | Average vertical eye position during the trial (normalized, 0-1, 0.5 is center). `null` if no valid samples. |
74
+ | average_z | float | Average distance/depth during the trial (normalized, 0-1, 0.5 is optimal). `null` if no valid samples. |
75
+ | position_good | boolean | Whether the participant was in a good position at the end of the trial (all axes rated "good"). |
76
+ | horizontal_status | string | Horizontal position quality at trial end: `'good'`, `'fair'`, or `'poor'`. |
77
+ | vertical_status | string | Vertical position quality at trial end: `'good'`, `'fair'`, or `'poor'`. |
78
+ | distance_status | string | Distance quality at trial end: `'good'`, `'fair'`, or `'poor'`. |
79
+ | rt | int | Response time in ms (duration from trial start to when the participant clicked Continue, or the full duration if timed). |
80
+
81
+ ## Examples
82
+
83
+ ### Manual Continuation (Recommended Before Calibration)
84
+
85
+ ```javascript
86
+ const trial = {
87
+ type: TobiiUserPositionPlugin,
88
+ message: 'Adjust your position until both eye indicators are green, then click Continue.',
89
+ require_good_position: true,
90
+ };
91
+ ```
92
+
93
+ ### Timed Display
94
+
95
+ ```javascript
96
+ const trial = {
97
+ type: TobiiUserPositionPlugin,
98
+ duration: 10000,
99
+ message: 'Hold still for the position check.',
100
+ };
101
+ ```
102
+
103
+ ### Custom Thresholds
104
+
105
+ ```javascript
106
+ const trial = {
107
+ type: TobiiUserPositionPlugin,
108
+ require_good_position: true,
109
+ position_threshold_good: 0.10,
110
+ position_threshold_fair: 0.20,
111
+ distance_threshold_good: 0.08,
112
+ distance_threshold_fair: 0.15,
113
+ };
114
+ ```
115
+
116
+ ### Position Check Before Each Block
117
+
118
+ ```javascript
119
+ const positionCheck = {
120
+ type: TobiiUserPositionPlugin,
121
+ message: 'Please re-center before the next block.',
122
+ require_good_position: true,
123
+ show_distance_feedback: true,
124
+ show_position_feedback: true,
125
+ };
126
+
127
+ // Insert between experimental blocks
128
+ timeline.push(block1);
129
+ timeline.push(positionCheck);
130
+ timeline.push(block2);
131
+ timeline.push(positionCheck);
132
+ timeline.push(block3);
133
+ ```