mirror of
https://github.com/jspsych/jsPsych.git
synced 2025-05-10 11:10:54 +00:00
add round_predictions parameter
This commit is contained in:
parent
d584faa71d
commit
7c7fda1959
@ -16,7 +16,8 @@ jsPsych.init({
|
|||||||
|
|
||||||
Parameter | Type | Default Value | Description
|
Parameter | Type | Default Value | Description
|
||||||
----------|------|---------------|------------
|
----------|------|---------------|------------
|
||||||
webgazer | object | `undefined` | You can explicitly pass a reference to a loaded instance of the webgazer.js library. If no explicit reference is passed then the extension will look for a global `webgazer` object.
|
webgazer | object | `undefined` | You can explicitly pass a reference to a loaded instance of the webgazer.js library. If no explicit reference is passed then the extension will look for a global `webgazer` object. If you are loading webgazer.js via a `<script>` tag you do not need to set this parameter in most circumstances.
|
||||||
|
round_predictions | bool | true | Whether to round the `x`,`y` coordinates predicted by WebGazer to the nearest whole number. This *greatly* reduces the size of the data, as WebGazer records data to 15 decimal places by default. Given the noise of the system, there's really no need to record data to this level of precision.
|
||||||
|
|
||||||
## Data Generated
|
## Data Generated
|
||||||
|
|
||||||
|
@ -21,6 +21,12 @@ jsPsych.extensions['webgazer'] = (function () {
|
|||||||
} else {
|
} else {
|
||||||
state.webgazer = params.webgazer;
|
state.webgazer = params.webgazer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (typeof params.round_predictions === 'undefined'){
|
||||||
|
state.round_predictions = true;
|
||||||
|
} else {
|
||||||
|
state.round_predictions = params.round_predictions;
|
||||||
|
}
|
||||||
|
|
||||||
// sets up event handler for webgazer data
|
// sets up event handler for webgazer data
|
||||||
state.webgazer.setGazeListener(handleGazeDataUpdate);
|
state.webgazer.setGazeListener(handleGazeDataUpdate);
|
||||||
@ -129,6 +135,10 @@ jsPsych.extensions['webgazer'] = (function () {
|
|||||||
|
|
||||||
extension.getCurrentPrediction = async function () {
|
extension.getCurrentPrediction = async function () {
|
||||||
var prediction = await state.webgazer.getCurrentPrediction();
|
var prediction = await state.webgazer.getCurrentPrediction();
|
||||||
|
if(state.round_predictions){
|
||||||
|
prediction.x = Math.round(prediction.x);
|
||||||
|
prediction.y = Math.round(prediction.y);
|
||||||
|
}
|
||||||
return prediction;
|
return prediction;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -139,9 +149,9 @@ jsPsych.extensions['webgazer'] = (function () {
|
|||||||
function handleGazeDataUpdate(gazeData, elapsedTime) {
|
function handleGazeDataUpdate(gazeData, elapsedTime) {
|
||||||
if (gazeData !== null && state.activeTrial) {
|
if (gazeData !== null && state.activeTrial) {
|
||||||
var d = {
|
var d = {
|
||||||
x: gazeData.x,
|
x: state.round_predictions ? Math.round(gazeData.x) : gazeData.x,
|
||||||
y: gazeData.y,
|
y: state.round_predictions ? Math.round(gazeData.y) : gazeData.y,
|
||||||
t: performance.now() - state.currentTrialStart
|
t: Math.round(performance.now() - state.currentTrialStart)
|
||||||
}
|
}
|
||||||
state.currentTrialData.push(d); // add data to current trial's data
|
state.currentTrialData.push(d); // add data to current trial's data
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user