Commit 4098f5c7 authored by Azalea's avatar Azalea

Traducción a español

Se cambiaron las instrucciones a español y se alargó el experimento a 30 repeticiones
parent f333f467
<?xml version="1.0" ?>
<PsychoPy2experiment encoding="utf-8" version="3.1.2">
<PsychoPy2experiment encoding="utf-8" version="3.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"/>
<Param name="Completed URL" updates="None" val="" valType="str"/>
<Param name="Data filename" updates="None" val="u'data/%s_%s_%s' % (expInfo['participant'], expName, expInfo['date'])" valType="code"/>
<Param name="Enable Escape" updates="None" val="True" valType="bool"/>
......@@ -51,7 +53,7 @@
<Param name="stopType" updates="None" val="duration (s)" valType="str"/>
<Param name="stopVal" updates="constant" val="" valType="code"/>
<Param name="syncScreenRefresh" updates="None" val="True" valType="bool"/>
<Param name="text" updates="constant" val="Please observe which way the fish in the centre is facing. If the fish is facing left press left arrow. If the fish is facing right press right arrow. Ignore the fish around the central fish. You are about to start practice trials and feedback will be provided. Please answer as quickly as possible. Press space to begin practice trials." valType="str"/>
<Param name="text" updates="constant" val="Por favor, observa hacia dónde esta observando el pez del centro. &amp;#10;Si este pez está observando a la izquierda, presiona la flecha navegadora de la izquierda. Si este pez está observando a la derecha, presiona la flecha navegadora de la derecha. &amp;#10;Ignora el resto de los peces. Relizarás algunos ensayos con retroalimentación. Por favor, responde tan rápido como puedas. &amp;#10;&amp;#10;Presiona la barra espaciadora para comenzar." valType="str"/>
<Param name="units" updates="None" val="from exp settings" valType="str"/>
<Param name="wrapWidth" updates="constant" val="" valType="code"/>
</TextComponent>
......@@ -247,8 +249,8 @@
<CodeComponent name="feedback_code">
<Param name="Begin Experiment" updates="constant" val="" valType="extendedCode"/>
<Param name="Begin JS Experiment" updates="constant" val="" valType="extendedCode"/>
<Param name="Begin JS Routine" updates="constant" val="if (response.corr==1) {&amp;#10; msg = &quot;Correct!&quot;;&amp;#10;} else {&amp;#10; msg = &quot;Incorrect&quot;;&amp;#10;}" valType="extendedCode"/>
<Param name="Begin Routine" updates="constant" val="if response.corr:&amp;#10; msg = &quot;Correct! RT=%.2f s&quot; %(response.rt)&amp;#10;else:&amp;#10; msg = &quot;Incorrect&quot;" valType="extendedCode"/>
<Param name="Begin JS Routine" updates="constant" val="if (response.corr==1) {&amp;#10; msg = &quot;Correcto!&quot;;&amp;#10;} else {&amp;#10; msg = &quot;Incorrecto&quot;;&amp;#10;}" valType="extendedCode"/>
<Param name="Begin Routine" updates="constant" val="if response.corr:&amp;#10; msg = &quot;Correcto! RT=%.2f s&quot; %(response.rt)&amp;#10;else:&amp;#10; msg = &quot;Incorrecto&quot;" valType="extendedCode"/>
<Param name="Code Type" updates="None" val="Both" valType="str"/>
<Param name="Each Frame" updates="constant" val="" valType="extendedCode"/>
<Param name="Each JS Frame" updates="constant" val="" valType="extendedCode"/>
......@@ -305,7 +307,7 @@
<Param name="stopType" updates="None" val="duration (s)" valType="str"/>
<Param name="stopVal" updates="constant" val="3" valType="code"/>
<Param name="syncScreenRefresh" updates="None" val="True" valType="bool"/>
<Param name="text" updates="constant" val="This is the end of the experiment.&amp;#10;Thank you for your time." valType="str"/>
<Param name="text" updates="constant" val="Se ha finalizado el experimento!&amp;#10;&amp;#10;Gracias por tu tiempo." valType="str"/>
<Param name="units" updates="None" val="from exp settings" valType="str"/>
<Param name="wrapWidth" updates="constant" val="" valType="code"/>
</TextComponent>
......@@ -331,7 +333,7 @@
<Param name="stopType" updates="None" val="duration (s)" valType="str"/>
<Param name="stopVal" updates="constant" val="" valType="code"/>
<Param name="syncScreenRefresh" updates="None" val="True" valType="bool"/>
<Param name="text" updates="constant" val="This is the end of the practice trials. Feedback will no longer be provided on experimental trials. Press space to continue to experimental trials." valType="str"/>
<Param name="text" updates="constant" val="Se ha terminado la práctica. &amp;#10;La retroalimentación ya no se realizará en el experimento. &amp;#10;&amp;#10;Presiona la barra espaciadora para comenzar con el experimento." valType="str"/>
<Param name="units" updates="None" val="from exp settings" valType="str"/>
<Param name="wrapWidth" updates="constant" val="" valType="code"/>
</TextComponent>
......@@ -548,7 +550,7 @@
<Param name="endPoints" updates="None" val="[0, 1]" valType="num"/>
<Param name="isTrials" updates="None" val="True" valType="bool"/>
<Param name="loopType" updates="None" val="random" valType="str"/>
<Param name="nReps" updates="None" val="1" valType="code"/>
<Param name="nReps" updates="None" val="30" valType="code"/>
<Param name="name" updates="None" val="exp_trials" valType="code"/>
<Param name="random seed" updates="None" val="" valType="code"/>
</LoopInitiator>
......
This diff is collapsed.
......@@ -2,13 +2,13 @@
* Children Flanker Task Test *
******************************/
import { PsychoJS } from 'https://pavlovia.org/lib/core.js';
import * as core from 'https://pavlovia.org/lib/core.js';
import { TrialHandler } from 'https://pavlovia.org/lib/data.js';
import { Scheduler } from 'https://pavlovia.org/lib/util.js';
import * as util from 'https://pavlovia.org/lib/util.js';
import * as visual from 'https://pavlovia.org/lib/visual.js';
import { Sound } from 'https://pavlovia.org/lib/sound.js';
import { PsychoJS } from 'https://pavlovia.org/lib/core-3.2.js';
import * as core from 'https://pavlovia.org/lib/core-3.2.js';
import { TrialHandler } from 'https://pavlovia.org/lib/data-3.2.js';
import { Scheduler } from 'https://pavlovia.org/lib/util-3.2.js';
import * as util from 'https://pavlovia.org/lib/util-3.2.js';
import * as visual from 'https://pavlovia.org/lib/visual-3.2.js';
import { Sound } from 'https://pavlovia.org/lib/sound-3.2.js';
// init psychoJS:
var psychoJS = new PsychoJS({
......@@ -19,7 +19,8 @@ var psychoJS = new PsychoJS({
psychoJS.openWindow({
fullscr: true,
color: new util.Color([(- 1.0), (- 0.38), 0.231]),
units: 'height'
units: 'height',
waitBlanking: true
});
// store info about the experiment session:
......@@ -67,7 +68,8 @@ var frameDur;
function updateInfo() {
expInfo['date'] = util.MonotonicClock.getDateStr(); // add a simple timestamp
expInfo['expName'] = expName;
expInfo['psychopyVersion'] = '3.1.2';
expInfo['psychopyVersion'] = '3.2.4';
expInfo['OS'] = window.navigator.platform;
// store frame rate of monitor if we can measure it successfully
expInfo['frameRate'] = psychoJS.window.getActualFrameRate();
......@@ -84,6 +86,7 @@ function updateInfo() {
var InstructionsClock;
var instructions;
var key_resp;
var PracticeClock;
var fixation;
var fish_1;
......@@ -91,10 +94,12 @@ var fish_2;
var target_fish;
var fish_3;
var fish_4;
var response;
var FeedbackClock;
var feedback_text;
var Exp_TrialClock;
var exp_trials_text;
var key_resp_2;
var TrialClock;
var fixation_2;
var Fish_1;
......@@ -102,6 +107,7 @@ var Fish_2;
var TargetFish;
var Fish_3;
var Fish_4;
var response_2;
var EndClock;
var thank_you;
var globalClock;
......@@ -112,7 +118,7 @@ function experimentInit() {
instructions = new visual.TextStim({
win: psychoJS.window,
name: 'instructions',
text: 'Please observe which way the fish in the centre is facing. If the fish is facing left press left arrow. If the fish is facing right press right arrow. Ignore the fish around the central fish. You are about to start practice trials and feedback will be provided. Please answer as quickly as possible. Press space to begin practice trials.',
text: 'Por favor, observa hacia dónde esta observando el pez del centro. \nSi este pez está observando a la izquierda, presiona la flecha navegadora de la izquierda. Si este pez está observando a la derecha, presiona la flecha navegadora de la derecha. \nIgnora el resto de los peces. Relizarás algunos ensayos con retroalimentación. Por favor, responde tan rápido como puedas. \n\nPresiona la barra espaciadora para comenzar.',
font: 'Arial',
units : undefined,
pos: [0, 0], height: 0.05, wrapWidth: undefined, ori: 0,
......@@ -120,6 +126,8 @@ function experimentInit() {
depth: 0.0
});
key_resp = new core.Keyboard({psychoJS, clock: new util.Clock(), waitForStart: true});
// Initialize components for Routine "Practice"
PracticeClock = new util.Clock();
fixation = new visual.TextStim({
......@@ -178,6 +186,8 @@ function experimentInit() {
flipHoriz : false, flipVert : false,
texRes : 128, interpolate : true, depth : -5.0
});
response = new core.Keyboard({psychoJS, clock: new util.Clock(), waitForStart: true});
// Initialize components for Routine "Feedback"
FeedbackClock = new util.Clock();
feedback_text = new visual.TextStim({
......@@ -196,7 +206,7 @@ function experimentInit() {
exp_trials_text = new visual.TextStim({
win: psychoJS.window,
name: 'exp_trials_text',
text: 'This is the end of the practice trials. Feedback will no longer be provided on experimental trials. Press space to continue to experimental trials.',
text: 'Se ha terminado la práctica. \nLa retroalimentación ya no se realizará en el experimento. \n\nPresiona la barra espaciadora para comenzar con el experimento.',
font: 'Arial',
units : undefined,
pos: [0, 0], height: 0.05, wrapWidth: undefined, ori: 0,
......@@ -204,6 +214,8 @@ function experimentInit() {
depth: 0.0
});
key_resp_2 = new core.Keyboard({psychoJS, clock: new util.Clock(), waitForStart: true});
// Initialize components for Routine "Trial"
TrialClock = new util.Clock();
fixation_2 = new visual.TextStim({
......@@ -262,12 +274,14 @@ function experimentInit() {
flipHoriz : false, flipVert : false,
texRes : 128, interpolate : true, depth : -5.0
});
response_2 = new core.Keyboard({psychoJS, clock: new util.Clock(), waitForStart: true});
// Initialize components for Routine "End"
EndClock = new util.Clock();
thank_you = new visual.TextStim({
win: psychoJS.window,
name: 'thank_you',
text: 'This is the end of the experiment.\nThank you for your time.',
text: 'Se ha finalizado el experimento!\n\nGracias por tu tiempo.',
font: 'Arial',
units : undefined,
pos: [0, 0], height: 0.05, wrapWidth: undefined, ori: 0,
......@@ -284,7 +298,6 @@ function experimentInit() {
var t;
var frameN;
var key_resp;
var InstructionsComponents;
function InstructionsRoutineBegin() {
//------Prepare to start Routine 'Instructions'-------
......@@ -292,8 +305,8 @@ function InstructionsRoutineBegin() {
InstructionsClock.reset(); // clock
frameN = -1;
// update component parameters for each repeat
key_resp = new core.BuilderKeyResponse(psychoJS);
key_resp.keys = undefined;
key_resp.rt = undefined;
// keep track of which components have finished
InstructionsComponents = [];
InstructionsComponents.push(instructions);
......@@ -329,16 +342,17 @@ function InstructionsRoutineEachFrame() {
// keep track of start time/frame for later
key_resp.tStart = t; // (not accounting for frame time here)
key_resp.frameNStart = frameN; // exact frame index
key_resp.status = PsychoJS.Status.STARTED;
// keyboard checking is just starting
psychoJS.eventManager.clearEvents({eventType:'keyboard'});
psychoJS.window.callOnFlip(function() { key_resp.clock.reset(); }); // t=0 on next screen flip
psychoJS.window.callOnFlip(function() { key_resp.start(); }); // start on screen flip
psychoJS.window.callOnFlip(function() { key_resp.clearEvents(); });
}
if (key_resp.status === PsychoJS.Status.STARTED) {
let theseKeys = psychoJS.eventManager.getKeys({keyList:['space']});
let theseKeys = key_resp.getKeys({keyList: ['space'], waitRelease: false});
// check for quit:
if (theseKeys.indexOf('escape') > -1) {
if (theseKeys.length > 0 && theseKeys[0].name === 'escape') {
psychoJS.experiment.experimentEnded = true;
}
......@@ -410,7 +424,7 @@ function practice_trialsLoopBegin(thisScheduler) {
thisScheduler.add(FeedbackRoutineBegin);
thisScheduler.add(FeedbackRoutineEachFrame);
thisScheduler.add(FeedbackRoutineEnd);
thisScheduler.add(endLoopIteration(thisScheduler, thisPractice_trial));
thisScheduler.add(endLoopIteration({thisScheduler, isTrials : true}));
}
return Scheduler.Event.NEXT;
......@@ -428,7 +442,7 @@ function exp_trialsLoopBegin(thisScheduler) {
// set up handler to look after randomisation of conditions etc
exp_trials = new TrialHandler({
psychoJS: psychoJS,
nReps: 1, method: TrialHandler.Method.RANDOM,
nReps: 30, method: TrialHandler.Method.RANDOM,
extraInfo: expInfo, originPath: undefined,
trialList: 'conditions.xlsx',
seed: undefined, name: 'exp_trials'});
......@@ -441,7 +455,7 @@ function exp_trialsLoopBegin(thisScheduler) {
thisScheduler.add(TrialRoutineBegin);
thisScheduler.add(TrialRoutineEachFrame);
thisScheduler.add(TrialRoutineEnd);
thisScheduler.add(endLoopIteration(thisScheduler, thisExp_trial));
thisScheduler.add(endLoopIteration({thisScheduler, isTrials : true}));
}
return Scheduler.Event.NEXT;
......@@ -454,7 +468,6 @@ function exp_trialsLoopEnd() {
return Scheduler.Event.NEXT;
}
var response;
var PracticeComponents;
function PracticeRoutineBegin() {
//------Prepare to start Routine 'Practice'-------
......@@ -467,8 +480,8 @@ function PracticeRoutineBegin() {
target_fish.setImage(targetFish);
fish_3.setImage(fish3);
fish_4.setImage(fish4);
response = new core.BuilderKeyResponse(psychoJS);
response.keys = undefined;
response.rt = undefined;
// keep track of which components have finished
PracticeComponents = [];
PracticeComponents.push(fixation);
......@@ -558,25 +571,25 @@ function PracticeRoutineEachFrame() {
// keep track of start time/frame for later
response.tStart = t; // (not accounting for frame time here)
response.frameNStart = frameN; // exact frame index
response.status = PsychoJS.Status.STARTED;
// keyboard checking is just starting
psychoJS.window.callOnFlip(function() { response.clock.reset(); }); // t = 0 on screen flip
psychoJS.eventManager.clearEvents({eventType:'keyboard'});
psychoJS.window.callOnFlip(function() { response.clock.reset(); }); // t=0 on next screen flip
psychoJS.window.callOnFlip(function() { response.start(); }); // start on screen flip
psychoJS.window.callOnFlip(function() { response.clearEvents(); });
}
if (response.status === PsychoJS.Status.STARTED) {
let theseKeys = psychoJS.eventManager.getKeys({keyList:['left', 'right']});
let theseKeys = response.getKeys({keyList: ['left', 'right'], waitRelease: false});
// check for quit:
if (theseKeys.indexOf('escape') > -1) {
if (theseKeys.length > 0 && theseKeys[0].name === 'escape') {
psychoJS.experiment.experimentEnded = true;
}
if (theseKeys.length > 0) { // at least one key was pressed
response.keys = theseKeys[theseKeys.length-1]; // just the last key pressed
response.rt = response.clock.getTime();
response.keys = theseKeys[0].name; // just the last key pressed
response.rt = theseKeys[0].rt;
// was this 'correct'?
if (response.keys == corrAns) {
if (response.keys === corrAns) {
response.corr = 1;
} else {
response.corr = 0;
......@@ -620,12 +633,6 @@ function PracticeRoutineEnd() {
thisComponent.setAutoDraw(false);
}
}
// check responses
if (response.keys === undefined || response.keys.length === 0) { // No response was made
response.keys = undefined;
}
// was no response the correct answer?!
if (response.keys === undefined) {
if (['None','none',undefined].includes(corrAns)) {
......@@ -637,11 +644,12 @@ function PracticeRoutineEnd() {
// store data for thisExp (ExperimentHandler)
psychoJS.experiment.addData('response.keys', response.keys);
psychoJS.experiment.addData('response.corr', response.corr);
if (typeof response.keys !== 'undefined') { // we had a response
if (typeof response.keys !== undefined) { // we had a response
psychoJS.experiment.addData('response.rt', response.rt);
routineTimer.reset();
}
response.stop();
// the Routine "Practice" was not non-slip safe, so reset the non-slip timer
routineTimer.reset();
......@@ -658,9 +666,9 @@ function FeedbackRoutineBegin() {
routineTimer.add(1.000000);
// update component parameters for each repeat
if (response.corr==1) {
msg = "Correct!";
msg = "Correcto!";
} else {
msg = "Incorrect";
msg = "Incorrecto";
}
feedback_text.setText(msg);
// keep track of which components have finished
......@@ -732,7 +740,6 @@ function FeedbackRoutineEnd() {
return Scheduler.Event.NEXT;
}
var key_resp_2;
var Exp_TrialComponents;
function Exp_TrialRoutineBegin() {
//------Prepare to start Routine 'Exp_Trial'-------
......@@ -740,8 +747,8 @@ function Exp_TrialRoutineBegin() {
Exp_TrialClock.reset(); // clock
frameN = -1;
// update component parameters for each repeat
key_resp_2 = new core.BuilderKeyResponse(psychoJS);
key_resp_2.keys = undefined;
key_resp_2.rt = undefined;
// keep track of which components have finished
Exp_TrialComponents = [];
Exp_TrialComponents.push(exp_trials_text);
......@@ -777,16 +784,17 @@ function Exp_TrialRoutineEachFrame() {
// keep track of start time/frame for later
key_resp_2.tStart = t; // (not accounting for frame time here)
key_resp_2.frameNStart = frameN; // exact frame index
key_resp_2.status = PsychoJS.Status.STARTED;
// keyboard checking is just starting
psychoJS.eventManager.clearEvents({eventType:'keyboard'});
psychoJS.window.callOnFlip(function() { key_resp_2.clock.reset(); }); // t=0 on next screen flip
psychoJS.window.callOnFlip(function() { key_resp_2.start(); }); // start on screen flip
psychoJS.window.callOnFlip(function() { key_resp_2.clearEvents(); });
}
if (key_resp_2.status === PsychoJS.Status.STARTED) {
let theseKeys = psychoJS.eventManager.getKeys({keyList:['space']});
let theseKeys = key_resp_2.getKeys({keyList: ['space'], waitRelease: false});
// check for quit:
if (theseKeys.indexOf('escape') > -1) {
if (theseKeys.length > 0 && theseKeys[0].name === 'escape') {
psychoJS.experiment.experimentEnded = true;
}
......@@ -836,7 +844,6 @@ function Exp_TrialRoutineEnd() {
return Scheduler.Event.NEXT;
}
var response_2;
var TrialComponents;
function TrialRoutineBegin() {
//------Prepare to start Routine 'Trial'-------
......@@ -849,8 +856,8 @@ function TrialRoutineBegin() {
TargetFish.setImage(targetFish);
Fish_3.setImage(fish3);
Fish_4.setImage(fish4);
response_2 = new core.BuilderKeyResponse(psychoJS);
response_2.keys = undefined;
response_2.rt = undefined;
// keep track of which components have finished
TrialComponents = [];
TrialComponents.push(fixation_2);
......@@ -940,25 +947,25 @@ function TrialRoutineEachFrame() {
// keep track of start time/frame for later
response_2.tStart = t; // (not accounting for frame time here)
response_2.frameNStart = frameN; // exact frame index
response_2.status = PsychoJS.Status.STARTED;
// keyboard checking is just starting
psychoJS.window.callOnFlip(function() { response_2.clock.reset(); }); // t = 0 on screen flip
psychoJS.eventManager.clearEvents({eventType:'keyboard'});
psychoJS.window.callOnFlip(function() { response_2.clock.reset(); }); // t=0 on next screen flip
psychoJS.window.callOnFlip(function() { response_2.start(); }); // start on screen flip
psychoJS.window.callOnFlip(function() { response_2.clearEvents(); });
}
if (response_2.status === PsychoJS.Status.STARTED) {
let theseKeys = psychoJS.eventManager.getKeys({keyList:['left', 'right']});
let theseKeys = response_2.getKeys({keyList: ['left', 'right'], waitRelease: false});
// check for quit:
if (theseKeys.indexOf('escape') > -1) {
if (theseKeys.length > 0 && theseKeys[0].name === 'escape') {
psychoJS.experiment.experimentEnded = true;
}
if (theseKeys.length > 0) { // at least one key was pressed
response_2.keys = theseKeys[theseKeys.length-1]; // just the last key pressed
response_2.rt = response_2.clock.getTime();
response_2.keys = theseKeys[0].name; // just the last key pressed
response_2.rt = theseKeys[0].rt;
// was this 'correct'?
if (response_2.keys == corrAns) {
if (response_2.keys === corrAns) {
response_2.corr = 1;
} else {
response_2.corr = 0;
......@@ -1002,12 +1009,6 @@ function TrialRoutineEnd() {
thisComponent.setAutoDraw(false);
}
}
// check responses
if (response_2.keys === undefined || response_2.keys.length === 0) { // No response was made
response_2.keys = undefined;
}
// was no response the correct answer?!
if (response_2.keys === undefined) {
if (['None','none',undefined].includes(corrAns)) {
......@@ -1019,11 +1020,12 @@ function TrialRoutineEnd() {
// store data for thisExp (ExperimentHandler)
psychoJS.experiment.addData('response_2.keys', response_2.keys);
psychoJS.experiment.addData('response_2.corr', response_2.corr);
if (typeof response_2.keys !== 'undefined') { // we had a response
if (typeof response_2.keys !== undefined) { // we had a response
psychoJS.experiment.addData('response_2.rt', response_2.rt);
routineTimer.reset();
}
response_2.stop();
// the Routine "Trial" was not non-slip safe, so reset the non-slip timer
routineTimer.reset();
......@@ -1108,13 +1110,17 @@ function EndRoutineEnd() {
}
function endLoopIteration(thisScheduler, thisTrial) {
function endLoopIteration({thisScheduler, isTrials=true}) {
// ------Prepare for next entry------
return function () {
// ------Check if user ended loop early------
if (currentLoop.finished) {
// Check for and save orphaned data
if (Object.keys(psychoJS.experiment._thisEntry).length > 0) {
psychoJS.experiment.nextEntry();
}
thisScheduler.stop();
} else if (typeof thisTrial === 'undefined' || !('isTrials' in thisTrial) || thisTrial.isTrials) {
} else if (isTrials) {
psychoJS.experiment.nextEntry();
}
return Scheduler.Event.NEXT;
......@@ -1133,6 +1139,10 @@ function importConditions(loop) {
function quitPsychoJS(message, isCompleted) {
// Check for and save orphaned data
if (Object.keys(psychoJS.experiment._thisEntry).length > 0) {
psychoJS.experiment.nextEntry();
}
psychoJS.window.close();
psychoJS.quit({message: message, isCompleted: isCompleted});
......
......@@ -11,7 +11,8 @@ var psychoJS = new PsychoJS({
psychoJS.openWindow({
fullscr: true,
color: new util.Color([(- 1.0), (- 0.38), 0.231]),
units: 'height'
units: 'height',
waitBlanking: true
});
// store info about the experiment session:
......@@ -59,7 +60,8 @@ var frameDur;
function updateInfo() {
expInfo['date'] = util.MonotonicClock.getDateStr(); // add a simple timestamp
expInfo['expName'] = expName;
expInfo['psychopyVersion'] = '3.1.2';
expInfo['psychopyVersion'] = '3.2.4';
expInfo['OS'] = window.navigator.platform;
// store frame rate of monitor if we can measure it successfully
expInfo['frameRate'] = psychoJS.window.getActualFrameRate();
......@@ -76,6 +78,7 @@ function updateInfo() {
var InstructionsClock;
var instructions;
var key_resp;
var PracticeClock;
var fixation;
var fish_1;
......@@ -83,10 +86,12 @@ var fish_2;
var target_fish;
var fish_3;
var fish_4;
var response;
var FeedbackClock;
var feedback_text;
var Exp_TrialClock;
var exp_trials_text;
var key_resp_2;
var TrialClock;
var fixation_2;
var Fish_1;
......@@ -94,6 +99,7 @@ var Fish_2;
var TargetFish;
var Fish_3;
var Fish_4;
var response_2;
var EndClock;
var thank_you;
var globalClock;
......@@ -104,7 +110,7 @@ function experimentInit() {
instructions = new visual.TextStim({
win: psychoJS.window,
name: 'instructions',
text: 'Please observe which way the fish in the centre is facing. If the fish is facing left press left arrow. If the fish is facing right press right arrow. Ignore the fish around the central fish. You are about to start practice trials and feedback will be provided. Please answer as quickly as possible. Press space to begin practice trials.',
text: 'Por favor, observa hacia dónde esta observando el pez del centro. \nSi este pez está observando a la izquierda, presiona la flecha navegadora de la izquierda. Si este pez está observando a la derecha, presiona la flecha navegadora de la derecha. \nIgnora el resto de los peces. Relizarás algunos ensayos con retroalimentación. Por favor, responde tan rápido como puedas. \n\nPresiona la barra espaciadora para comenzar.',
font: 'Arial',
units : undefined,
pos: [0, 0], height: 0.05, wrapWidth: undefined, ori: 0,
......@@ -112,6 +118,8 @@ function experimentInit() {
depth: 0.0
});
key_resp = new core.Keyboard({psychoJS, clock: new util.Clock(), waitForStart: true});
// Initialize components for Routine "Practice"
PracticeClock = new util.Clock();
fixation = new visual.TextStim({
......@@ -170,6 +178,8 @@ function experimentInit() {
flipHoriz : false, flipVert : false,
texRes : 128, interpolate : true, depth : -5.0
});
response = new core.Keyboard({psychoJS, clock: new util.Clock(), waitForStart: true});
// Initialize components for Routine "Feedback"
FeedbackClock = new util.Clock();
feedback_text = new visual.TextStim({
......@@ -188,7 +198,7 @@ function experimentInit() {
exp_trials_text = new visual.TextStim({
win: psychoJS.window,
name: 'exp_trials_text',
text: 'This is the end of the practice trials. Feedback will no longer be provided on experimental trials. Press space to continue to experimental trials.',
text: 'Se ha terminado la práctica. \nLa retroalimentación ya no se realizará en el experimento. \n\nPresiona la barra espaciadora para comenzar con el experimento.',
font: 'Arial',
units : undefined,
pos: [0, 0], height: 0.05, wrapWidth: undefined, ori: 0,
......@@ -196,6 +206,8 @@ function experimentInit() {
depth: 0.0
});
key_resp_2 = new core.Keyboard({psychoJS, clock: new util.Clock(), waitForStart: true});
// Initialize components for Routine "Trial"
TrialClock = new util.Clock();
fixation_2 = new visual.TextStim({
......@@ -254,12 +266,14 @@ function experimentInit() {
flipHoriz : false, flipVert : false,
texRes : 128, interpolate : true, depth : -5.0
});
response_2 = new core.Keyboard({psychoJS, clock: new util.Clock(), waitForStart: true});
// Initialize components for Routine "End"
EndClock = new util.Clock();
thank_you = new visual.TextStim({
win: psychoJS.window,
name: 'thank_you',
text: 'This is the end of the experiment.\nThank you for your time.',
text: 'Se ha finalizado el experimento!\n\nGracias por tu tiempo.',
font: 'Arial',
units : undefined,
pos: [0, 0], height: 0.05, wrapWidth: undefined, ori: 0,
......@@ -276,7 +290,6 @@ function experimentInit() {
var t;
var frameN;
var key_resp;
var InstructionsComponents;
function InstructionsRoutineBegin() {
//------Prepare to start Routine 'Instructions'-------
......@@ -284,8 +297,8 @@ function InstructionsRoutineBegin() {
InstructionsClock.reset(); // clock
frameN = -1;
// update component parameters for each repeat
key_resp = new core.BuilderKeyResponse(psychoJS);
key_resp.keys = undefined;
key_resp.rt = undefined;
// keep track of which components have finished
InstructionsComponents = [];
InstructionsComponents.push(instructions);
......@@ -322,16 +335,17 @@ function InstructionsRoutineEachFrame() {
// keep track of start time/frame for later
key_resp.tStart = t; // (not accounting for frame time here)
key_resp.frameNStart = frameN; // exact frame index
key_resp.status = PsychoJS.Status.STARTED;
// keyboard checking is just starting
psychoJS.eventManager.clearEvents({eventType:'keyboard'});
psychoJS.window.callOnFlip(function() { key_resp.clock.reset(); }); // t=0 on next screen flip
psychoJS.window.callOnFlip(function() { key_resp.start(); }); // start on screen flip
psychoJS.window.callOnFlip(function() { key_resp.clearEvents(); });
}
if (key_resp.status === PsychoJS.Status.STARTED) {
let theseKeys = psychoJS.eventManager.getKeys({keyList:['space']});
let theseKeys = key_resp.getKeys({keyList: ['space'], waitRelease: false});
// check for quit:
if (theseKeys.indexOf('escape') > -1) {
if (theseKeys.length > 0 && theseKeys[0].name === 'escape') {
psychoJS.experiment.experimentEnded = true;
}
......@@ -407,7 +421,7 @@ function practice_trialsLoopBegin(thisScheduler) {
thisScheduler.add(FeedbackRoutineBegin);
thisScheduler.add(FeedbackRoutineEachFrame);
thisScheduler.add(FeedbackRoutineEnd);
thisScheduler.add(endLoopIteration(thisScheduler, thisPractice_trial));
thisScheduler.add(endLoopIteration({thisScheduler, isTrials : true}));
}
return Scheduler.Event.NEXT;
......@@ -425,7 +439,7 @@ function exp_trialsLoopBegin(thisScheduler) {
// set up handler to look after randomisation of conditions etc
exp_trials = new TrialHandler({
psychoJS: psychoJS,
nReps: 1, method: TrialHandler.Method.RANDOM,
nReps: 30, method: TrialHandler.Method.RANDOM,
extraInfo: expInfo, originPath: undefined,
trialList: 'conditions.xlsx',
seed: undefined, name: 'exp_trials'});
......@@ -443,7 +457,7 @@ function exp_trialsLoopBegin(thisScheduler) {
thisScheduler.add(TrialRoutineBegin);
thisScheduler.add(TrialRoutineEachFrame);
thisScheduler.add(TrialRoutineEnd);
thisScheduler.add(endLoopIteration(thisScheduler, thisExp_trial));
thisScheduler.add(endLoopIteration({thisScheduler, isTrials : true}));
}
return Scheduler.Event.NEXT;
......@@ -456,7 +470,6 @@ function exp_trialsLoopEnd() {
return Scheduler.Event.NEXT;
}
var response;
var PracticeComponents;
function PracticeRoutineBegin() {
//------Prepare to start Routine 'Practice'-------
......@@ -469,8 +482,8 @@ function PracticeRoutineBegin() {
target_fish.setImage(targetFish);
fish_3.setImage(fish3);
fish_4.setImage(fish4);
response = new core.BuilderKeyResponse(psychoJS);
response.keys = undefined;
response.rt = undefined;
// keep track of which components have finished
PracticeComponents = [];
PracticeComponents.push(fixation);
......@@ -561,25 +574,25 @@ function PracticeRoutineEachFrame() {
// keep track of start time/frame for later
response.tStart = t; // (not accounting for frame time here)
response.frameNStart = frameN; // exact frame index
response.status = PsychoJS.Status.STARTED;
// keyboard checking is just starting
psychoJS.window.callOnFlip(function() { response.clock.reset(); }); // t = 0 on screen flip
psychoJS.eventManager.clearEvents({eventType:'keyboard'});
psychoJS.window.callOnFlip(function() { response.clock.reset(); }); // t=0 on next screen flip
psychoJS.window.callOnFlip(function() { response.start(); }); // start on screen flip
psychoJS.window.callOnFlip(function() { response.clearEvents(); });
}
if (response.status === PsychoJS.Status.STARTED) {
let theseKeys = psychoJS.eventManager.getKeys({keyList:['left', 'right']});
let theseKeys = response.getKeys({keyList: ['left', 'right'], waitRelease: false});
// check for quit:
if (theseKeys.indexOf('escape') > -1) {
if (theseKeys.length > 0 && theseKeys[0].name === 'escape') {
psychoJS.experiment.experimentEnded = true;
}
if (theseKeys.length > 0) { // at least one key was pressed
response.keys = theseKeys[theseKeys.length-1]; // just the last key pressed
response.rt = response.clock.getTime();
response.keys = theseKeys[0].name; // just the last key pressed
response.rt = theseKeys[0].rt;
// was this 'correct'?
if (response.keys == corrAns) {
if (response.keys === corrAns) {
response.corr = 1;
} else {
response.corr = 0;
......@@ -621,12 +634,6 @@ function PracticeRoutineEnd() {
if (typeof thisComponent.setAutoDraw === 'function') {
thisComponent.setAutoDraw(false);
}});
// check responses
if (response.keys === undefined || response.keys.length === 0) { // No response was made
response.keys = undefined;
}
// was no response the correct answer?!
if (response.keys === undefined) {
if (['None','none',undefined].includes(corrAns)) {
......@@ -638,11 +645,12 @@ function PracticeRoutineEnd() {
// store data for thisExp (ExperimentHandler)
psychoJS.experiment.addData('response.keys', response.keys);
psychoJS.experiment.addData('response.corr', response.corr);
if (typeof response.keys !== 'undefined') { // we had a response
if (typeof response.keys !== undefined) { // we had a response
psychoJS.experiment.addData('response.rt', response.rt);
routineTimer.reset();
}
response.stop();
// the Routine "Practice" was not non-slip safe, so reset the non-slip timer
routineTimer.reset();
......@@ -659,9 +667,9 @@ function FeedbackRoutineBegin() {
routineTimer.add(1.000000);
// update component parameters for each repeat
if (response.corr==1) {
msg = "Correct!";
msg = "Correcto!";
} else {
msg = "Incorrect";
msg = "Incorrecto";
}
feedback_text.setText(msg);
// keep track of which components have finished
......@@ -732,7 +740,6 @@ function FeedbackRoutineEnd() {
return Scheduler.Event.NEXT;
}
var key_resp_2;
var Exp_TrialComponents;
function Exp_TrialRoutineBegin() {
//------Prepare to start Routine 'Exp_Trial'-------
......@@ -740,8 +747,8 @@ function Exp_TrialRoutineBegin() {
Exp_TrialClock.reset(); // clock
frameN = -1;
// update component parameters for each repeat
key_resp_2 = new core.BuilderKeyResponse(psychoJS);
key_resp_2.keys = undefined;
key_resp_2.rt = undefined;
// keep track of which components have finished
Exp_TrialComponents = [];
Exp_TrialComponents.push(exp_trials_text);
......@@ -778,16 +785,17 @@ function Exp_TrialRoutineEachFrame() {
// keep track of start time/frame for later
key_resp_2.tStart = t; // (not accounting for frame time here)
key_resp_2.frameNStart = frameN; // exact frame index
key_resp_2.status = PsychoJS.Status.STARTED;
// keyboard checking is just starting
psychoJS.eventManager.clearEvents({eventType:'keyboard'});
psychoJS.window.callOnFlip(function() { key_resp_2.clock.reset(); }); // t=0 on next screen flip
psychoJS.window.callOnFlip(function() { key_resp_2.start(); }); // start on screen flip
psychoJS.window.callOnFlip(function() { key_resp_2.clearEvents(); });
}
if (key_resp_2.status === PsychoJS.Status.STARTED) {
let theseKeys = psychoJS.eventManager.getKeys({keyList:['space']});
let theseKeys = key_resp_2.getKeys({keyList: ['space'], waitRelease: false});
// check for quit:
if (theseKeys.indexOf('escape') > -1) {
if (theseKeys.length > 0 && theseKeys[0].name === 'escape') {
psychoJS.experiment.experimentEnded = true;
}
......@@ -835,7 +843,6 @@ function Exp_TrialRoutineEnd() {
return Scheduler.Event.NEXT;
}
var response_2;
var TrialComponents;
function TrialRoutineBegin() {
//------Prepare to start Routine 'Trial'-------
......@@ -848,8 +855,8 @@ function TrialRoutineBegin() {
TargetFish.setImage(targetFish);
Fish_3.setImage(fish3);
Fish_4.setImage(fish4);
response_2 = new core.BuilderKeyResponse(psychoJS);
response_2.keys = undefined;
response_2.rt = undefined;
// keep track of which components have finished
TrialComponents = [];
TrialComponents.push(fixation_2);
......@@ -940,25 +947,25 @@ function TrialRoutineEachFrame() {
// keep track of start time/frame for later
response_2.tStart = t; // (not accounting for frame time here)
response_2.frameNStart = frameN; // exact frame index
response_2.status = PsychoJS.Status.STARTED;
// keyboard checking is just starting
psychoJS.window.callOnFlip(function() { response_2.clock.reset(); }); // t = 0 on screen flip
psychoJS.eventManager.clearEvents({eventType:'keyboard'});
psychoJS.window.callOnFlip(function() { response_2.clock.reset(); }); // t=0 on next screen flip
psychoJS.window.callOnFlip(function() { response_2.start(); }); // start on screen flip
psychoJS.window.callOnFlip(function() { response_2.clearEvents(); });
}
if (response_2.status === PsychoJS.Status.STARTED) {
let theseKeys = psychoJS.eventManager.getKeys({keyList:['left', 'right']});
let theseKeys = response_2.getKeys({keyList: ['left', 'right'], waitRelease: false});
// check for quit:
if (theseKeys.indexOf('escape') > -1) {
if (theseKeys.length > 0 && theseKeys[0].name === 'escape') {
psychoJS.experiment.experimentEnded = true;
}
if (theseKeys.length > 0) { // at least one key was pressed
response_2.keys = theseKeys[theseKeys.length-1]; // just the last key pressed
response_2.rt = response_2.clock.getTime();
response_2.keys = theseKeys[0].name; // just the last key pressed
response_2.rt = theseKeys[0].rt;
// was this 'correct'?
if (response_2.keys == corrAns) {
if (response_2.keys === corrAns) {
response_2.corr = 1;
} else {
response_2.corr = 0;
......@@ -1000,12 +1007,6 @@ function TrialRoutineEnd() {
if (typeof thisComponent.setAutoDraw === 'function') {
thisComponent.setAutoDraw(false);
}});
// check responses
if (response_2.keys === undefined || response_2.keys.length === 0) { // No response was made
response_2.keys = undefined;
}
// was no response the correct answer?!
if (response_2.keys === undefined) {
if (['None','none',undefined].includes(corrAns)) {
......@@ -1017,11 +1018,12 @@ function TrialRoutineEnd() {
// store data for thisExp (ExperimentHandler)
psychoJS.experiment.addData('response_2.keys', response_2.keys);
psychoJS.experiment.addData('response_2.corr', response_2.corr);
if (typeof response_2.keys !== 'undefined') { // we had a response
if (typeof response_2.keys !== undefined) { // we had a response
psychoJS.experiment.addData('response_2.rt', response_2.rt);
routineTimer.reset();
}
response_2.stop();
// the Routine "Trial" was not non-slip safe, so reset the non-slip timer
routineTimer.reset();
......@@ -1105,13 +1107,17 @@ function EndRoutineEnd() {
}
function endLoopIteration(thisScheduler, thisTrial) {
function endLoopIteration({thisScheduler, isTrials=true}) {
// ------Prepare for next entry------
return function () {
// ------Check if user ended loop early------
if (currentLoop.finished) {
// Check for and save orphaned data
if (Object.keys(psychoJS.experiment._thisEntry).length > 0) {
psychoJS.experiment.nextEntry();
}
thisScheduler.stop();
} else if (typeof thisTrial === 'undefined' || !('isTrials' in thisTrial) || thisTrial.isTrials) {
} else if (isTrials) {
psychoJS.experiment.nextEntry();
}
return Scheduler.Event.NEXT;
......@@ -1130,6 +1136,10 @@ function importConditions(loop) {
function quitPsychoJS(message, isCompleted) {
// Check for and save orphaned data
if (Object.keys(psychoJS.experiment._thisEntry).length > 0) {
psychoJS.experiment.nextEntry();
}
psychoJS.window.close();
psychoJS.quit({message: message, isCompleted: isCompleted});
......
......@@ -30,7 +30,7 @@
<!-- older browsers -->
<script nomodule type="text/javascript" src="https://unpkg.com/@ungap/url-search-params"></script>
<script nomodule type="text/javascript" src="https://lib.pavlovia.org/psychojs.js"></script>
<script nomodule type="text/javascript" src="https://lib.pavlovia.org/psychojs-3.2.js"></script>
<script nomodule type="text/javascript" src="./Children Flanker TaskNoModule.js"></script>
</body>
......
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