Commit 8e967b63 authored by HSINYUAN CHEN's avatar HSINYUAN CHEN

_

parent cbc760ec
......@@ -19,7 +19,6 @@ psychoJS.openWindow({
let expName = 'IncorrectStopEXP'; // from the Builder filename that created this script
let expInfo = {'session': '01', 'participant': ''};
// Start code blocks for 'Before Experiment'
// schedule the experiment:
psychoJS.schedule(psychoJS.gui.DlgFromDict({
dictionary: expInfo,
......@@ -50,14 +49,12 @@ psychoJS.start({
expInfo: expInfo,
});
psychoJS.experimentLogger.setLevel(core.Logger.ServerLevel.DEBUG);
var frameDur;
function updateInfo() {
expInfo['date'] = util.MonotonicClock.getDateStr(); // add a simple timestamp
expInfo['expName'] = expName;
expInfo['psychopyVersion'] = '2020.2.8';
expInfo['psychopyVersion'] = '2020.1.3';
expInfo['OS'] = window.navigator.platform;
// store frame rate of monitor if we can measure it successfully
......@@ -138,7 +135,7 @@ function experimentInit() {
var trials2;
var currentLoop;
function trials2LoopBegin(trials2LoopScheduler) {
function trials2LoopBegin(thisScheduler) {
// set up handler to look after randomisation of conditions etc
trials2 = new TrialHandler({
psychoJS: psychoJS,
......@@ -154,15 +151,15 @@ function trials2LoopBegin(trials2LoopScheduler) {
trials2.forEach(function() {
const snapshot = trials2.getSnapshot();
trials2LoopScheduler.add(importConditions(snapshot));
trials2LoopScheduler.add(instructRoutineBegin(snapshot));
trials2LoopScheduler.add(instructRoutineEachFrame(snapshot));
trials2LoopScheduler.add(instructRoutineEnd(snapshot));
thisScheduler.add(importConditions(snapshot));
thisScheduler.add(instructRoutineBegin(snapshot));
thisScheduler.add(instructRoutineEachFrame(snapshot));
thisScheduler.add(instructRoutineEnd(snapshot));
const trials1LoopScheduler = new Scheduler(psychoJS);
trials2LoopScheduler.add(trials1LoopBegin, trials1LoopScheduler);
trials2LoopScheduler.add(trials1LoopScheduler);
trials2LoopScheduler.add(trials1LoopEnd);
trials2LoopScheduler.add(endLoopIteration(trials2LoopScheduler, snapshot));
thisScheduler.add(trials1LoopBegin, trials1LoopScheduler);
thisScheduler.add(trials1LoopScheduler);
thisScheduler.add(trials1LoopEnd);
thisScheduler.add(endLoopIteration(thisScheduler, snapshot));
});
return Scheduler.Event.NEXT;
......@@ -170,7 +167,7 @@ function trials2LoopBegin(trials2LoopScheduler) {
var trials1;
function trials1LoopBegin(trials1LoopScheduler) {
function trials1LoopBegin(thisScheduler) {
// set up handler to look after randomisation of conditions etc
trials1 = new TrialHandler({
psychoJS: psychoJS,
......@@ -186,11 +183,11 @@ function trials1LoopBegin(trials1LoopScheduler) {
trials1.forEach(function() {
const snapshot = trials1.getSnapshot();
trials1LoopScheduler.add(importConditions(snapshot));
trials1LoopScheduler.add(trialRoutineBegin(snapshot));
trials1LoopScheduler.add(trialRoutineEachFrame(snapshot));
trials1LoopScheduler.add(trialRoutineEnd(snapshot));
trials1LoopScheduler.add(endLoopIteration(trials1LoopScheduler, snapshot));
thisScheduler.add(importConditions(snapshot));
thisScheduler.add(trialRoutineBegin(snapshot));
thisScheduler.add(trialRoutineEachFrame(snapshot));
thisScheduler.add(trialRoutineEnd(snapshot));
thisScheduler.add(endLoopIteration(thisScheduler, snapshot));
});
return Scheduler.Event.NEXT;
......@@ -215,7 +212,7 @@ var t;
var frameN;
var _ready_allKeys;
var instructComponents;
function instructRoutineBegin(snapshot) {
function instructRoutineBegin(trials) {
return function () {
//------Prepare to start Routine 'instruct'-------
t = 0;
......@@ -234,16 +231,14 @@ function instructRoutineBegin(snapshot) {
if ('status' in thisComponent)
thisComponent.status = PsychoJS.Status.NOT_STARTED;
});
// check if the Routine should terminate
if (!continueRoutine) { // a component has requested a forced-end of Routine
return Scheduler.Event.NEXT;
}
return Scheduler.Event.NEXT;
};
}
var continueRoutine;
function instructRoutineEachFrame(snapshot) {
function instructRoutineEachFrame(trials) {
return function () {
//------Loop for each frame of Routine 'instruct'-------
let continueRoutine = true; // until we're told otherwise
......@@ -312,7 +307,7 @@ function instructRoutineEachFrame(snapshot) {
}
function instructRoutineEnd(snapshot) {
function instructRoutineEnd(trials) {
return function () {
//------Ending Routine 'instruct'-------
instructComponents.forEach( function(thisComponent) {
......@@ -331,7 +326,7 @@ function instructRoutineEnd(snapshot) {
var _resp_allKeys;
var number_correct;
var trialComponents;
function trialRoutineBegin(snapshot) {
function trialRoutineBegin(trials) {
return function () {
//------Prepare to start Routine 'trial'-------
t = 0;
......@@ -356,15 +351,13 @@ function trialRoutineBegin(snapshot) {
if ('status' in thisComponent)
thisComponent.status = PsychoJS.Status.NOT_STARTED;
});
// check if the Routine should terminate
if (!continueRoutine) { // a component has requested a forced-end of Routine
return Scheduler.Event.NEXT;
}
return Scheduler.Event.NEXT;
};
}
function trialRoutineEachFrame(snapshot) {
function trialRoutineEachFrame(trials) {
return function () {
//------Loop for each frame of Routine 'trial'-------
let continueRoutine = true; // until we're told otherwise
......@@ -439,7 +432,7 @@ function trialRoutineEachFrame(snapshot) {
}
function trialRoutineEnd(snapshot) {
function trialRoutineEnd(trials) {
return function () {
//------Ending Routine 'trial'-------
trialComponents.forEach( function(thisComponent) {
......@@ -490,7 +483,7 @@ function trialRoutineEnd(snapshot) {
var thanksComponents;
function thanksRoutineBegin(snapshot) {
function thanksRoutineBegin(trials) {
return function () {
//------Prepare to start Routine 'thanks'-------
t = 0;
......@@ -506,16 +499,14 @@ function thanksRoutineBegin(snapshot) {
if ('status' in thisComponent)
thisComponent.status = PsychoJS.Status.NOT_STARTED;
});
// check if the Routine should terminate
if (!continueRoutine) { // a component has requested a forced-end of Routine
return Scheduler.Event.NEXT;
}
return Scheduler.Event.NEXT;
};
}
var frameRemains;
function thanksRoutineEachFrame(snapshot) {
function thanksRoutineEachFrame(trials) {
return function () {
//------Loop for each frame of Routine 'thanks'-------
let continueRoutine = true; // until we're told otherwise
......@@ -534,7 +525,7 @@ function thanksRoutineEachFrame(snapshot) {
}
frameRemains = 0.0 + 2.0 - psychoJS.window.monitorFramePeriod * 0.75; // most of one frame period left
if ((thanksText.status === PsychoJS.Status.STARTED || thanksText.status === PsychoJS.Status.FINISHED) && t >= frameRemains) {
if (thanksText.status === PsychoJS.Status.STARTED && t >= frameRemains) {
thanksText.setAutoDraw(false);
}
// check for quit (typically the Esc key)
......@@ -564,7 +555,7 @@ function thanksRoutineEachFrame(snapshot) {
}
function thanksRoutineEnd(snapshot) {
function thanksRoutineEnd(trials) {
return function () {
//------Ending Routine 'thanks'-------
thanksComponents.forEach( function(thisComponent) {
......@@ -577,21 +568,21 @@ function thanksRoutineEnd(snapshot) {
}
function endLoopIteration(scheduler, snapshot) {
function endLoopIteration(thisScheduler, loop) {
// ------Prepare for next entry------
return function () {
if (typeof snapshot !== 'undefined') {
if (typeof loop !== 'undefined') {
// ------Check if user ended loop early------
if (snapshot.finished) {
if (loop.finished) {
// Check for and save orphaned data
if (psychoJS.experiment.isEntryEmpty()) {
psychoJS.experiment.nextEntry(snapshot);
psychoJS.experiment.nextEntry(loop);
}
scheduler.stop();
thisScheduler.stop();
} else {
const thisTrial = snapshot.getCurrentTrial();
const thisTrial = loop.getCurrentTrial();
if (typeof thisTrial === 'undefined' || !('isTrials' in thisTrial) || thisTrial.isTrials) {
psychoJS.experiment.nextEntry(snapshot);
psychoJS.experiment.nextEntry(loop);
}
}
return Scheduler.Event.NEXT;
......@@ -600,9 +591,9 @@ function endLoopIteration(scheduler, snapshot) {
}
function importConditions(currentLoop) {
function importConditions(trials) {
return function () {
psychoJS.importAttributes(currentLoop.getCurrentTrial());
psychoJS.importAttributes(trials.getCurrentTrial());
return Scheduler.Event.NEXT;
};
}
......
......@@ -6,12 +6,9 @@ import { PsychoJS } from './lib/core-2020.1.js';
import * as core from './lib/core-2020.1.js';
import { TrialHandler } from './lib/data-2020.1.js';
import { Scheduler } from './lib/util-2020.1.js';
import * as util from './lib/util-2020.1.js';
import * as visual from './lib/visual-2020.1.js';
import * as sound from './lib/sound-2020.1.js';
import * as util from './lib/util-2020.1.js';
//some handy aliases as in the psychopy scripts;
const { abs, sin, cos, PI: pi, sqrt } = Math;
const { round } = util;
// init psychoJS:
const psychoJS = new PsychoJS({
......@@ -30,7 +27,6 @@ psychoJS.openWindow({
let expName = 'IncorrectStopEXP'; // from the Builder filename that created this script
let expInfo = {'session': '01', 'participant': ''};
// Start code blocks for 'Before Experiment'
// schedule the experiment:
psychoJS.schedule(psychoJS.gui.DlgFromDict({
dictionary: expInfo,
......@@ -61,14 +57,12 @@ psychoJS.start({
expInfo: expInfo,
});
psychoJS.experimentLogger.setLevel(core.Logger.ServerLevel.DEBUG);
var frameDur;
function updateInfo() {
expInfo['date'] = util.MonotonicClock.getDateStr(); // add a simple timestamp
expInfo['expName'] = expName;
expInfo['psychopyVersion'] = '2020.2.8';
expInfo['psychopyVersion'] = '2020.1.3';
expInfo['OS'] = window.navigator.platform;
// store frame rate of monitor if we can measure it successfully
......@@ -149,7 +143,7 @@ function experimentInit() {
var trials2;
var currentLoop;
function trials2LoopBegin(trials2LoopScheduler) {
function trials2LoopBegin(thisScheduler) {
// set up handler to look after randomisation of conditions etc
trials2 = new TrialHandler({
psychoJS: psychoJS,
......@@ -164,15 +158,15 @@ function trials2LoopBegin(trials2LoopScheduler) {
// Schedule all the trials in the trialList:
for (const thisTrials2 of trials2) {
const snapshot = trials2.getSnapshot();
trials2LoopScheduler.add(importConditions(snapshot));
trials2LoopScheduler.add(instructRoutineBegin(snapshot));
trials2LoopScheduler.add(instructRoutineEachFrame(snapshot));
trials2LoopScheduler.add(instructRoutineEnd(snapshot));
thisScheduler.add(importConditions(snapshot));
thisScheduler.add(instructRoutineBegin(snapshot));
thisScheduler.add(instructRoutineEachFrame(snapshot));
thisScheduler.add(instructRoutineEnd(snapshot));
const trials1LoopScheduler = new Scheduler(psychoJS);
trials2LoopScheduler.add(trials1LoopBegin, trials1LoopScheduler);
trials2LoopScheduler.add(trials1LoopScheduler);
trials2LoopScheduler.add(trials1LoopEnd);
trials2LoopScheduler.add(endLoopIteration(trials2LoopScheduler, snapshot));
thisScheduler.add(trials1LoopBegin, trials1LoopScheduler);
thisScheduler.add(trials1LoopScheduler);
thisScheduler.add(trials1LoopEnd);
thisScheduler.add(endLoopIteration(thisScheduler, snapshot));
}
return Scheduler.Event.NEXT;
......@@ -180,7 +174,7 @@ function trials2LoopBegin(trials2LoopScheduler) {
var trials1;
function trials1LoopBegin(trials1LoopScheduler) {
function trials1LoopBegin(thisScheduler) {
// set up handler to look after randomisation of conditions etc
trials1 = new TrialHandler({
psychoJS: psychoJS,
......@@ -195,11 +189,11 @@ function trials1LoopBegin(trials1LoopScheduler) {
// Schedule all the trials in the trialList:
for (const thisTrials1 of trials1) {
const snapshot = trials1.getSnapshot();
trials1LoopScheduler.add(importConditions(snapshot));
trials1LoopScheduler.add(trialRoutineBegin(snapshot));
trials1LoopScheduler.add(trialRoutineEachFrame(snapshot));
trials1LoopScheduler.add(trialRoutineEnd(snapshot));
trials1LoopScheduler.add(endLoopIteration(trials1LoopScheduler, snapshot));
thisScheduler.add(importConditions(snapshot));
thisScheduler.add(trialRoutineBegin(snapshot));
thisScheduler.add(trialRoutineEachFrame(snapshot));
thisScheduler.add(trialRoutineEnd(snapshot));
thisScheduler.add(endLoopIteration(thisScheduler, snapshot));
}
return Scheduler.Event.NEXT;
......@@ -224,7 +218,7 @@ var t;
var frameN;
var _ready_allKeys;
var instructComponents;
function instructRoutineBegin(snapshot) {
function instructRoutineBegin(trials) {
return function () {
//------Prepare to start Routine 'instruct'-------
t = 0;
......@@ -242,16 +236,14 @@ function instructRoutineBegin(snapshot) {
for (const thisComponent of instructComponents)
if ('status' in thisComponent)
thisComponent.status = PsychoJS.Status.NOT_STARTED;
// check if the Routine should terminate
if (!continueRoutine) { // a component has requested a forced-end of Routine
return Scheduler.Event.NEXT;
}
return Scheduler.Event.NEXT;
};
}
var continueRoutine;
function instructRoutineEachFrame(snapshot) {
function instructRoutineEachFrame(trials) {
return function () {
//------Loop for each frame of Routine 'instruct'-------
let continueRoutine = true; // until we're told otherwise
......@@ -320,7 +312,7 @@ function instructRoutineEachFrame(snapshot) {
}
function instructRoutineEnd(snapshot) {
function instructRoutineEnd(trials) {
return function () {
//------Ending Routine 'instruct'-------
for (const thisComponent of instructComponents) {
......@@ -339,7 +331,7 @@ function instructRoutineEnd(snapshot) {
var _resp_allKeys;
var number_correct;
var trialComponents;
function trialRoutineBegin(snapshot) {
function trialRoutineBegin(trials) {
return function () {
//------Prepare to start Routine 'trial'-------
t = 0;
......@@ -363,15 +355,13 @@ function trialRoutineBegin(snapshot) {
for (const thisComponent of trialComponents)
if ('status' in thisComponent)
thisComponent.status = PsychoJS.Status.NOT_STARTED;
// check if the Routine should terminate
if (!continueRoutine) { // a component has requested a forced-end of Routine
return Scheduler.Event.NEXT;
}
return Scheduler.Event.NEXT;
};
}
function trialRoutineEachFrame(snapshot) {
function trialRoutineEachFrame(trials) {
return function () {
//------Loop for each frame of Routine 'trial'-------
let continueRoutine = true; // until we're told otherwise
......@@ -446,7 +436,7 @@ function trialRoutineEachFrame(snapshot) {
}
function trialRoutineEnd(snapshot) {
function trialRoutineEnd(trials) {
return function () {
//------Ending Routine 'trial'-------
for (const thisComponent of trialComponents) {
......@@ -497,7 +487,7 @@ function trialRoutineEnd(snapshot) {
var thanksComponents;
function thanksRoutineBegin(snapshot) {
function thanksRoutineBegin(trials) {
return function () {
//------Prepare to start Routine 'thanks'-------
t = 0;
......@@ -512,16 +502,14 @@ function thanksRoutineBegin(snapshot) {
for (const thisComponent of thanksComponents)
if ('status' in thisComponent)
thisComponent.status = PsychoJS.Status.NOT_STARTED;
// check if the Routine should terminate
if (!continueRoutine) { // a component has requested a forced-end of Routine
return Scheduler.Event.NEXT;
}
return Scheduler.Event.NEXT;
};
}
var frameRemains;
function thanksRoutineEachFrame(snapshot) {
function thanksRoutineEachFrame(trials) {
return function () {
//------Loop for each frame of Routine 'thanks'-------
let continueRoutine = true; // until we're told otherwise
......@@ -540,7 +528,7 @@ function thanksRoutineEachFrame(snapshot) {
}
frameRemains = 0.0 + 2.0 - psychoJS.window.monitorFramePeriod * 0.75; // most of one frame period left
if ((thanksText.status === PsychoJS.Status.STARTED || thanksText.status === PsychoJS.Status.FINISHED) && t >= frameRemains) {
if (thanksText.status === PsychoJS.Status.STARTED && t >= frameRemains) {
thanksText.setAutoDraw(false);
}
// check for quit (typically the Esc key)
......@@ -570,7 +558,7 @@ function thanksRoutineEachFrame(snapshot) {
}
function thanksRoutineEnd(snapshot) {
function thanksRoutineEnd(trials) {
return function () {
//------Ending Routine 'thanks'-------
for (const thisComponent of thanksComponents) {
......@@ -583,21 +571,21 @@ function thanksRoutineEnd(snapshot) {
}
function endLoopIteration(scheduler, snapshot) {
function endLoopIteration(thisScheduler, loop) {
// ------Prepare for next entry------
return function () {
if (typeof snapshot !== 'undefined') {
if (typeof loop !== 'undefined') {
// ------Check if user ended loop early------
if (snapshot.finished) {
if (loop.finished) {
// Check for and save orphaned data
if (psychoJS.experiment.isEntryEmpty()) {
psychoJS.experiment.nextEntry(snapshot);
psychoJS.experiment.nextEntry(loop);
}
scheduler.stop();
thisScheduler.stop();
} else {
const thisTrial = snapshot.getCurrentTrial();
const thisTrial = loop.getCurrentTrial();
if (typeof thisTrial === 'undefined' || !('isTrials' in thisTrial) || thisTrial.isTrials) {
psychoJS.experiment.nextEntry(snapshot);
psychoJS.experiment.nextEntry(loop);
}
}
return Scheduler.Event.NEXT;
......@@ -606,9 +594,9 @@ function endLoopIteration(scheduler, snapshot) {
}
function importConditions(currentLoop) {
function importConditions(trials) {
return function () {
psychoJS.importAttributes(currentLoop.getCurrentTrial());
psychoJS.importAttributes(trials.getCurrentTrial());
return Scheduler.Event.NEXT;
};
}
......
......@@ -18,12 +18,12 @@
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/seedrandom/3.0.1/seedrandom.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/pixi.js/5.3.3/pixi.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/pixi.js/4.8.7/pixi.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/PreloadJS/1.0.1/preloadjs.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.24.0/moment.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.14.2/xlsx.full.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/log4javascript/1.4.9/log4javascript.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/tone/14.7.61/Tone.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/tone/13.8.6/Tone.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/howler/2.1.2/howler.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/pako/1.0.10/pako.min.js"></script>
......
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