Commit 7e29923e authored by Thomas Pronk's avatar Thomas Pronk

Changed webgazer library to modified version of 2.0.1

parent 215ee329
......@@ -61,12 +61,14 @@ psychoJS.start({
]
});
psychoJS.experimentLogger.setLevel(core.Logger.ServerLevel.EXP);
var frameDur;
function updateInfo() {
expInfo['date'] = util.MonotonicClock.getDateStr(); // add a simple timestamp
expInfo['expName'] = expName;
expInfo['psychopyVersion'] = '2020.2.0';
expInfo['psychopyVersion'] = '2020.2.4';
expInfo['OS'] = window.navigator.platform;
// store frame rate of monitor if we can measure it successfully
......@@ -104,7 +106,7 @@ function experimentInit() {
// Download the webgazer library and re-download seedrandom.js (since webgazer
// overrides it with a version that conflicts with PsychoJS)
psychoJS.downloadResources([
{ name: 'webgazer.js', path: 'js/webgazer-1.7.3.js' },
{ name: 'webgazer.js', path: 'js/webgazer-2.0.1.tp.js' },
{ name: 'seedrandom.js', path: 'https://cdnjs.cloudflare.com/ajax/libs/seedrandom/3.0.1/seedrandom.min.js' }
]);
// Initialize x and y arrays; we use these to calculate running averages of
......@@ -324,6 +326,7 @@ function webcam_trialRoutineBegin(snapshot) {
var prevButtonState;
var _mouseButtons;
function webcam_trialRoutineEachFrame(snapshot) {
return function () {
//------Loop for each frame of Routine 'webcam_trial'-------
......@@ -353,10 +356,10 @@ function webcam_trialRoutineEachFrame(snapshot) {
prevButtonState = mouse.getPressed(); // if button is down already this ISN'T a new click
}
if (mouse.status === PsychoJS.Status.STARTED) { // only update if started and not finished!
let buttons = mouse.getPressed();
if (!buttons.every( (e,i,) => (e == prevButtonState[i]) )) { // button state changed?
prevButtonState = buttons;
if (buttons.reduce( (e, acc) => (e+acc) ) > 0) { // state changed to a new click
_mouseButtons = mouse.getPressed();
if (!_mouseButtons.every( (e,i,) => (e == prevButtonState[i]) )) { // button state changed?
prevButtonState = _mouseButtons;
if (_mouseButtons.reduce( (e, acc) => (e+acc) ) > 0) { // state changed to a new click
// abort routine on response
continueRoutine = false;
}
......@@ -389,6 +392,7 @@ function webcam_trialRoutineEachFrame(snapshot) {
}
var _mouseXYs;
function webcam_trialRoutineEnd(snapshot) {
return function () {
//------Ending Routine 'webcam_trial'-------
......@@ -398,13 +402,13 @@ function webcam_trialRoutineEnd(snapshot) {
}
});
// store data for thisExp (ExperimentHandler)
const xys = mouse.getPos();
const buttons = mouse.getPressed();
psychoJS.experiment.addData('mouse.x', xys[0]);
psychoJS.experiment.addData('mouse.y', xys[1]);
psychoJS.experiment.addData('mouse.leftButton', buttons[0]);
psychoJS.experiment.addData('mouse.midButton', buttons[1]);
psychoJS.experiment.addData('mouse.rightButton', buttons[2]);
_mouseXYs = mouse.getPos();
_mouseButtons = mouse.getPressed();
psychoJS.experiment.addData('mouse.x', _mouseXYs[0]);
psychoJS.experiment.addData('mouse.y', _mouseXYs[1]);
psychoJS.experiment.addData('mouse.leftButton', _mouseButtons[0]);
psychoJS.experiment.addData('mouse.midButton', _mouseButtons[1]);
psychoJS.experiment.addData('mouse.rightButton', _mouseButtons[2]);
// the Routine "webcam_trial" was not non-slip safe, so reset the non-slip timer
routineTimer.reset();
......@@ -467,10 +471,10 @@ function intro_calibatrion_trialRoutineEachFrame(snapshot) {
prevButtonState = mouse_2.getPressed(); // if button is down already this ISN'T a new click
}
if (mouse_2.status === PsychoJS.Status.STARTED) { // only update if started and not finished!
let buttons = mouse_2.getPressed();
if (!buttons.every( (e,i,) => (e == prevButtonState[i]) )) { // button state changed?
prevButtonState = buttons;
if (buttons.reduce( (e, acc) => (e+acc) ) > 0) { // state changed to a new click
_mouseButtons = mouse_2.getPressed();
if (!_mouseButtons.every( (e,i,) => (e == prevButtonState[i]) )) { // button state changed?
prevButtonState = _mouseButtons;
if (_mouseButtons.reduce( (e, acc) => (e+acc) ) > 0) { // state changed to a new click
// abort routine on response
continueRoutine = false;
}
......@@ -512,13 +516,13 @@ function intro_calibatrion_trialRoutineEnd(snapshot) {
}
});
// store data for thisExp (ExperimentHandler)
const xys = mouse_2.getPos();
const buttons = mouse_2.getPressed();
psychoJS.experiment.addData('mouse_2.x', xys[0]);
psychoJS.experiment.addData('mouse_2.y', xys[1]);
psychoJS.experiment.addData('mouse_2.leftButton', buttons[0]);
psychoJS.experiment.addData('mouse_2.midButton', buttons[1]);
psychoJS.experiment.addData('mouse_2.rightButton', buttons[2]);
_mouseXYs = mouse_2.getPos();
_mouseButtons = mouse_2.getPressed();
psychoJS.experiment.addData('mouse_2.x', _mouseXYs[0]);
psychoJS.experiment.addData('mouse_2.y', _mouseXYs[1]);
psychoJS.experiment.addData('mouse_2.leftButton', _mouseButtons[0]);
psychoJS.experiment.addData('mouse_2.midButton', _mouseButtons[1]);
psychoJS.experiment.addData('mouse_2.rightButton', _mouseButtons[2]);
// the Routine "intro_calibatrion_trial" was not non-slip safe, so reset the non-slip timer
routineTimer.reset();
......@@ -619,10 +623,10 @@ function calibration_trialRoutineEachFrame(snapshot) {
prevButtonState = mouse_3.getPressed(); // if button is down already this ISN'T a new click
}
if (mouse_3.status === PsychoJS.Status.STARTED) { // only update if started and not finished!
let buttons = mouse_3.getPressed();
if (!buttons.every( (e,i,) => (e == prevButtonState[i]) )) { // button state changed?
prevButtonState = buttons;
if (buttons.reduce( (e, acc) => (e+acc) ) > 0) { // state changed to a new click
_mouseButtons = mouse_3.getPressed();
if (!_mouseButtons.every( (e,i,) => (e == prevButtonState[i]) )) { // button state changed?
prevButtonState = _mouseButtons;
if (_mouseButtons.reduce( (e, acc) => (e+acc) ) > 0) { // state changed to a new click
// check if the mouse was inside our 'clickable' objects
gotValidClick = false;
for (const obj of [calibration_square]) {
......@@ -673,13 +677,13 @@ function calibration_trialRoutineEnd(snapshot) {
}
});
// store data for thisExp (ExperimentHandler)
const xys = mouse_3.getPos();
const buttons = mouse_3.getPressed();
psychoJS.experiment.addData('mouse_3.x', xys[0]);
psychoJS.experiment.addData('mouse_3.y', xys[1]);
psychoJS.experiment.addData('mouse_3.leftButton', buttons[0]);
psychoJS.experiment.addData('mouse_3.midButton', buttons[1]);
psychoJS.experiment.addData('mouse_3.rightButton', buttons[2]);
_mouseXYs = mouse_3.getPos();
_mouseButtons = mouse_3.getPressed();
psychoJS.experiment.addData('mouse_3.x', _mouseXYs[0]);
psychoJS.experiment.addData('mouse_3.y', _mouseXYs[1]);
psychoJS.experiment.addData('mouse_3.leftButton', _mouseButtons[0]);
psychoJS.experiment.addData('mouse_3.midButton', _mouseButtons[1]);
psychoJS.experiment.addData('mouse_3.rightButton', _mouseButtons[2]);
if (mouse_3.clicked_name.length > 0) {
psychoJS.experiment.addData('mouse_3.clicked_name', mouse_3.clicked_name[0]);}
// the Routine "calibration_trial" was not non-slip safe, so reset the non-slip timer
......
......@@ -71,12 +71,14 @@ psychoJS.start({
]
});
psychoJS.experimentLogger.setLevel(core.Logger.ServerLevel.EXP);
var frameDur;
function updateInfo() {
expInfo['date'] = util.MonotonicClock.getDateStr(); // add a simple timestamp
expInfo['expName'] = expName;
expInfo['psychopyVersion'] = '2020.2.0';
expInfo['psychopyVersion'] = '2020.2.4';
expInfo['OS'] = window.navigator.platform;
// store frame rate of monitor if we can measure it successfully
......@@ -114,7 +116,7 @@ function experimentInit() {
// Download the webgazer library and re-download seedrandom.js (since webgazer
// overrides it with a version that conflicts with PsychoJS)
psychoJS.downloadResources([
{ name: 'webgazer.js', path: 'js/webgazer-1.7.3.js' },
{ name: 'webgazer.js', path: 'js/webgazer-2.0.1.tp.js' },
{ name: 'seedrandom.js', path: 'https://cdnjs.cloudflare.com/ajax/libs/seedrandom/3.0.1/seedrandom.min.js' }
]);
// Initialize x and y arrays; we use these to calculate running averages of
......@@ -332,6 +334,7 @@ function webcam_trialRoutineBegin(snapshot) {
var prevButtonState;
var _mouseButtons;
function webcam_trialRoutineEachFrame(snapshot) {
return function () {
//------Loop for each frame of Routine 'webcam_trial'-------
......@@ -361,10 +364,10 @@ function webcam_trialRoutineEachFrame(snapshot) {
prevButtonState = mouse.getPressed(); // if button is down already this ISN'T a new click
}
if (mouse.status === PsychoJS.Status.STARTED) { // only update if started and not finished!
let buttons = mouse.getPressed();
if (!buttons.every( (e,i,) => (e == prevButtonState[i]) )) { // button state changed?
prevButtonState = buttons;
if (buttons.reduce( (e, acc) => (e+acc) ) > 0) { // state changed to a new click
_mouseButtons = mouse.getPressed();
if (!_mouseButtons.every( (e,i,) => (e == prevButtonState[i]) )) { // button state changed?
prevButtonState = _mouseButtons;
if (_mouseButtons.reduce( (e, acc) => (e+acc) ) > 0) { // state changed to a new click
// abort routine on response
continueRoutine = false;
}
......@@ -397,6 +400,7 @@ function webcam_trialRoutineEachFrame(snapshot) {
}
var _mouseXYs;
function webcam_trialRoutineEnd(snapshot) {
return function () {
//------Ending Routine 'webcam_trial'-------
......@@ -406,13 +410,13 @@ function webcam_trialRoutineEnd(snapshot) {
}
}
// store data for thisExp (ExperimentHandler)
const xys = mouse.getPos();
const buttons = mouse.getPressed();
psychoJS.experiment.addData('mouse.x', xys[0]);
psychoJS.experiment.addData('mouse.y', xys[1]);
psychoJS.experiment.addData('mouse.leftButton', buttons[0]);
psychoJS.experiment.addData('mouse.midButton', buttons[1]);
psychoJS.experiment.addData('mouse.rightButton', buttons[2]);
_mouseXYs = mouse.getPos();
_mouseButtons = mouse.getPressed();
psychoJS.experiment.addData('mouse.x', _mouseXYs[0]);
psychoJS.experiment.addData('mouse.y', _mouseXYs[1]);
psychoJS.experiment.addData('mouse.leftButton', _mouseButtons[0]);
psychoJS.experiment.addData('mouse.midButton', _mouseButtons[1]);
psychoJS.experiment.addData('mouse.rightButton', _mouseButtons[2]);
// the Routine "webcam_trial" was not non-slip safe, so reset the non-slip timer
routineTimer.reset();
......@@ -474,10 +478,10 @@ function intro_calibatrion_trialRoutineEachFrame(snapshot) {
prevButtonState = mouse_2.getPressed(); // if button is down already this ISN'T a new click
}
if (mouse_2.status === PsychoJS.Status.STARTED) { // only update if started and not finished!
let buttons = mouse_2.getPressed();
if (!buttons.every( (e,i,) => (e == prevButtonState[i]) )) { // button state changed?
prevButtonState = buttons;
if (buttons.reduce( (e, acc) => (e+acc) ) > 0) { // state changed to a new click
_mouseButtons = mouse_2.getPressed();
if (!_mouseButtons.every( (e,i,) => (e == prevButtonState[i]) )) { // button state changed?
prevButtonState = _mouseButtons;
if (_mouseButtons.reduce( (e, acc) => (e+acc) ) > 0) { // state changed to a new click
// abort routine on response
continueRoutine = false;
}
......@@ -519,13 +523,13 @@ function intro_calibatrion_trialRoutineEnd(snapshot) {
}
}
// store data for thisExp (ExperimentHandler)
const xys = mouse_2.getPos();
const buttons = mouse_2.getPressed();
psychoJS.experiment.addData('mouse_2.x', xys[0]);
psychoJS.experiment.addData('mouse_2.y', xys[1]);
psychoJS.experiment.addData('mouse_2.leftButton', buttons[0]);
psychoJS.experiment.addData('mouse_2.midButton', buttons[1]);
psychoJS.experiment.addData('mouse_2.rightButton', buttons[2]);
_mouseXYs = mouse_2.getPos();
_mouseButtons = mouse_2.getPressed();
psychoJS.experiment.addData('mouse_2.x', _mouseXYs[0]);
psychoJS.experiment.addData('mouse_2.y', _mouseXYs[1]);
psychoJS.experiment.addData('mouse_2.leftButton', _mouseButtons[0]);
psychoJS.experiment.addData('mouse_2.midButton', _mouseButtons[1]);
psychoJS.experiment.addData('mouse_2.rightButton', _mouseButtons[2]);
// the Routine "intro_calibatrion_trial" was not non-slip safe, so reset the non-slip timer
routineTimer.reset();
......@@ -624,10 +628,10 @@ function calibration_trialRoutineEachFrame(snapshot) {
prevButtonState = mouse_3.getPressed(); // if button is down already this ISN'T a new click
}
if (mouse_3.status === PsychoJS.Status.STARTED) { // only update if started and not finished!
let buttons = mouse_3.getPressed();
if (!buttons.every( (e,i,) => (e == prevButtonState[i]) )) { // button state changed?
prevButtonState = buttons;
if (buttons.reduce( (e, acc) => (e+acc) ) > 0) { // state changed to a new click
_mouseButtons = mouse_3.getPressed();
if (!_mouseButtons.every( (e,i,) => (e == prevButtonState[i]) )) { // button state changed?
prevButtonState = _mouseButtons;
if (_mouseButtons.reduce( (e, acc) => (e+acc) ) > 0) { // state changed to a new click
// check if the mouse was inside our 'clickable' objects
gotValidClick = false;
for (const obj of [calibration_square]) {
......@@ -678,13 +682,13 @@ function calibration_trialRoutineEnd(snapshot) {
}
}
// store data for thisExp (ExperimentHandler)
const xys = mouse_3.getPos();
const buttons = mouse_3.getPressed();
psychoJS.experiment.addData('mouse_3.x', xys[0]);
psychoJS.experiment.addData('mouse_3.y', xys[1]);
psychoJS.experiment.addData('mouse_3.leftButton', buttons[0]);
psychoJS.experiment.addData('mouse_3.midButton', buttons[1]);
psychoJS.experiment.addData('mouse_3.rightButton', buttons[2]);
_mouseXYs = mouse_3.getPos();
_mouseButtons = mouse_3.getPressed();
psychoJS.experiment.addData('mouse_3.x', _mouseXYs[0]);
psychoJS.experiment.addData('mouse_3.y', _mouseXYs[1]);
psychoJS.experiment.addData('mouse_3.leftButton', _mouseButtons[0]);
psychoJS.experiment.addData('mouse_3.midButton', _mouseButtons[1]);
psychoJS.experiment.addData('mouse_3.rightButton', _mouseButtons[2]);
if (mouse_3.clicked_name.length > 0) {
psychoJS.experiment.addData('mouse_3.clicked_name', mouse_3.clicked_name[0]);}
// the Routine "calibration_trial" was not non-slip safe, so reset the non-slip timer
......
<?xml version="1.0" ?>
<PsychoPy2experiment encoding="utf-8" version="2020.2.0">
<PsychoPy2experiment encoding="utf-8" version="2020.2.4">
<Settings>
<Param name="Audio latency priority" updates="None" val="use prefs" valType="str"/>
<Param name="Audio lib" updates="None" val="use prefs" valType="str"/>
......@@ -38,7 +38,7 @@
<Param name="Before Experiment" updates="constant" val="ale" valType="extendedCode"/>
<Param name="Before JS Experiment" updates="constant" val="" valType="extendedCode"/>
<Param name="Begin Experiment" updates="constant" val="" valType="extendedCode"/>
<Param name="Begin JS Experiment" updates="constant" val="// Download the webgazer library and re-download seedrandom.js (since webgazer&amp;#10;// overrides it with a version that conflicts with PsychoJS)&amp;#10;psychoJS.downloadResources([&amp;#10; { name: 'webgazer.js', path: 'js/webgazer-1.7.3.js' },&amp;#10; { name: 'seedrandom.js', path: 'https://cdnjs.cloudflare.com/ajax/libs/seedrandom/3.0.1/seedrandom.min.js' }&amp;#10;]);&amp;#10;// Initialize x and y arrays; we use these to calculate running averages of &amp;#10;// current gaze position; the longer the window, the slower, but more fluent&amp;#10;// the updates&amp;#10;let averagingWindow = 10;&amp;#10;window.xGazes = new Array(averagingWindow ).fill(0);&amp;#10;window.yGazes = new Array(averagingWindow ).fill(0);&amp;#10;&amp;#10;" valType="extendedCode"/>
<Param name="Begin JS Experiment" updates="constant" val="// Download the webgazer library and re-download seedrandom.js (since webgazer&amp;#10;// overrides it with a version that conflicts with PsychoJS)&amp;#10;psychoJS.downloadResources([&amp;#10; { name: 'webgazer.js', path: 'js/webgazer-2.0.1.tp.js' },&amp;#10; { name: 'seedrandom.js', path: 'https://cdnjs.cloudflare.com/ajax/libs/seedrandom/3.0.1/seedrandom.min.js' }&amp;#10;]);&amp;#10;// Initialize x and y arrays; we use these to calculate running averages of &amp;#10;// current gaze position; the longer the window, the slower, but more fluent&amp;#10;// the updates&amp;#10;let averagingWindow = 10;&amp;#10;window.xGazes = new Array(averagingWindow ).fill(0);&amp;#10;window.yGazes = new Array(averagingWindow ).fill(0);&amp;#10;&amp;#10;" valType="extendedCode"/>
<Param name="Begin JS Routine" updates="constant" val="" valType="extendedCode"/>
<Param name="Begin Routine" updates="constant" val="" valType="extendedCode"/>
<Param name="Code Type" updates="None" val="JS" valType="str"/>
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment