Properties Reference
Complete reference of all properties in the TrialManager class, organized by functional category.
Core Properties
| Property |
Type |
Default |
Description |
participantId |
number |
0 |
Unique identifier for the participant. Used for seeded randomization and data tracking. |
userInitials |
string |
'' |
Participant initials (max 6 chars). Used in data export filename generation. |
testType |
string |
null |
Type of stimulus: 'Shapes', 'Colors', 'Abstract', or 'Pictures'. Determines image set to load. |
totalImages |
number |
null |
Total number of images available for selected test type. Shapes: 193, Colors: 10, Abstract: 403. |
Experiment State Properties
| Property |
Type |
Default |
Description |
trialData |
Array |
[] |
Collection of all completed trial results including timing, objects shown, positions, and gaze data. |
currentTrialData |
Object |
{} |
Data for the currently executing trial. Contains trialNumber, type, startTime, objects, positions. |
currentTrial |
number |
0 |
Index of currently executing trial (0-based). Increments after each trial completes. |
trialCount |
number |
null |
Total number of trials to execute. User-selected from 10-50 during initialization. |
trialTypes |
Array |
["1", "2"] |
Available trial types. Type 1: target + 2 identical foils. Type 2: target + 2 different foils. |
isExperimentStarted |
boolean |
false |
Flag indicating whether experiment trials have begun (post-calibration). |
currentBlockIndex |
number |
0 |
Index of current block in multi-block experiments (Experiment folder only). |
currentTrialIndex |
number |
0 |
Index within current block (Experiment folder only). |
isPractice |
boolean |
false |
Flag for practice trial mode (Experiment folder only). |
Calibration Properties
| Property |
Type |
Default |
Description |
calibrationComplete |
boolean |
false |
Flag indicating successful completion of initial calibration with validation. |
calibrationInProgress |
boolean |
false |
Flag preventing multiple simultaneous calibration sequences. |
CALIBRATION_POINTS |
number |
10 |
Number of calibration points in initial sequence (typically 9-10 in grid pattern). |
Gaze Tracking Properties
Data Storage
| Property |
Type |
Default |
Description |
gazeData |
Array |
[] |
Legacy property for gaze data collection (maintained for compatibility). |
currentGazeData |
Array |
[] |
Gaze points collected during current trial. Reset at start of each trial. |
allGazeData |
Array |
[] |
Complete collection of all gaze points across entire session (calibration + experiment). |
Kalman Filtering
| Property |
Type |
Default |
Description |
kalmanX |
Object |
null |
Kalman filter state for X coordinate. Contains: {q: 0.01, r: 0.1, p: 1, x: 0, k: 0} |
kalmanY |
Object |
null |
Kalman filter state for Y coordinate. Same structure as kalmanX. |
Kalman Filter Parameters:
- q (process noise): 0.01 - Model uncertainty
- r (measurement noise): 0.1 - Sensor uncertainty
- p (estimation error): 1 - Initial uncertainty
- x (estimated value): 0 - Current filtered coordinate
- k (Kalman gain): 0 - Optimal gain computation
Head Pose Tracking
| Property |
Type |
Default |
Description |
baselineHeadPose |
Object | null |
null |
Baseline head pose angles captured at calibration start. All subsequent measurements relative to this. |
Outlier Detection
| Property |
Type |
Default |
Description |
recentGazePoints |
Array |
[] |
Circular buffer of last 5 gaze points for velocity-based outlier detection. |
maxRecentPoints |
number |
5 |
Maximum size of recentGazePoints buffer. Maintains most recent points for jump detection. |
Adaptive Sampling
| Property |
Type |
Default |
Description |
lastSampleTime |
number |
0 |
Timestamp of last processed gaze sample (milliseconds). Used to implement adaptive sampling rate. |
Adaptive Sampling Logic: System adjusts frame rate based on movement speed:
- Fast movement (>100px/s): 60fps (16ms intervals)
- Slow movement (≤100px/s): 30fps (33ms intervals)
Image Management Properties
| Property |
Type |
Default |
Description |
objectImages |
Object |
{} |
Dictionary of loaded images. Keys: object numbers (1-totalImages), Values: HTMLImageElement. |
objectExclusions_Shapes |
Object |
{} |
Exclusion rules for Shapes test type. Maps object numbers to arrays of similar objects. |
objectExclusions_Colors |
Object |
{} |
Exclusion rules for Colors test type. |
objectExclusions_Abstract |
Object |
{} |
Exclusion rules for Abstract test type. |
Example Exclusion Structure
{
1: [2, 3, 15], // Object 1 cannot appear with objects 2, 3, or 15
2: [1, 4], // Object 2 cannot appear with objects 1 or 4
// ... etc
}
UI Element Properties
| Property |
Type |
Default |
Description |
testContainer |
HTMLElement |
null |
Main container div for displaying stimuli. Retrieved from DOM: #test-container |
instructionElement |
HTMLElement |
null |
Element for displaying instructions. Retrieved from DOM: #instruction |
_lastMousePos |
Object |
{x: null, y: null} |
Last known mouse position for fallback tracking (Experiment folder only). |
Property Access Patterns
Reading Trial Data
const currentTrialNum = trialManager.currentTrial + 1;
const totalTrials = trialManager.trialCount;
const progress = (currentTrialNum / totalTrials * 100).toFixed(1) + '%';
const currentGaze = trialManager.currentGazeData;
const gazePointCount = currentGaze.length;
const avgX = currentGaze.reduce((sum, p) => sum + p.x, 0) / gazePointCount;
Checking Calibration Status
if (trialManager.calibrationComplete) {
console.log('Calibration successful - ready for trials');
} else if (trialManager.calibrationInProgress) {
console.log('Calibration in progress...');
} else {
console.log('Calibration not started');
}
Examining Head Pose Data
if (trialManager.baselineHeadPose) {
console.log('Head pose baseline established');
console.log('Baseline:', trialManager.baselineHeadPose);
}
const recentPoints = trialManager.recentGazePoints;
console.log(`Tracking last ${recentPoints.length} gaze points`);
Monitoring Kalman Filter State
console.log('Kalman X state:', trialManager.kalmanX);
const filterRatio = trialManager.kalmanX.q / trialManager.kalmanX.r;
Property Modification Guidelines
Caution: Most properties should not be modified directly outside the class. Use provided methods for state changes.
Safe to Modify (with care)
maxRecentPoints - Adjust outlier detection sensitivity (5-10 recommended)
CALIBRATION_POINTS - Change before calibration (9-15 recommended)
Never Modify Directly
trialData - Managed by runTrial()
allGazeData - Managed by processGazeData()
calibrationComplete - Set by startCalibrationPhase()
kalmanX/kalmanY - Managed by kalmanFilter()
Read-Only in Practice
participantId - Set in constructor
totalImages - Set by setupImages()
testType - Set by showInitialsDialog()
userInitials - Set by showInitialsDialog()
Data Structure Examples
currentTrialData Structure
{
trialNumber: 5,
type: 1,
startTime: 1706284843120,
endTime: 1706284858125,
object1: 45,
testObjects: [45, 127, 127],
positions: [
{ position: "left", objectNum: 45, isTarget: true },
{ position: "center", objectNum: 127, isTarget: false },
{ position: "right", objectNum: 127, isTarget: false }
],
gazeData: [/* array of gaze points for this trial */]
}
Gaze Data Point Structure
{
x: 512.3,
y: 384.7,
rawX: 515.1,
rawY: 388.2,
headPose: {
roll: 0.05,
pitch: -0.02,
yaw: 0.08,
distance: 125.4
},
time: 1706284847123,
relativeTime: 2543,
phase: "experiment"
}
See Also