Commit 3c8abc96 authored by HSINYUAN CHEN's avatar HSINYUAN CHEN

move coder component

move the coder from top to bottom
parent f9880d16
...@@ -35,23 +35,6 @@ ...@@ -35,23 +35,6 @@
</Settings> </Settings>
<Routines> <Routines>
<Routine name="trial"> <Routine name="trial">
<CodeComponent name="code">
<Param name="Before Experiment" updates="constant" val="" 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="" valType="extendedCode"/>
<Param name="Begin JS Routine" updates="constant" val="if ((trials1.thisN === 0)) {&amp;#10; number_correct = 0;&amp;#10;}&amp;#10;" valType="extendedCode"/>
<Param name="Begin Routine" updates="constant" val="if trials1.thisN == 0:&amp;#10; number_correct = 0" valType="extendedCode"/>
<Param name="Code Type" updates="None" val="Auto-&gt;JS" valType="str"/>
<Param name="Each Frame" updates="constant" val="" valType="extendedCode"/>
<Param name="Each JS Frame" updates="constant" val="" valType="extendedCode"/>
<Param name="End Experiment" updates="constant" val="" valType="extendedCode"/>
<Param name="End JS Experiment" updates="constant" val="" valType="extendedCode"/>
<Param name="End JS Routine" updates="constant" val="if (resp.corr) {&amp;#10; number_correct = (number_correct + 1);&amp;#10; console.log((&quot;Correct: &quot; + number_correct.toString()));&amp;#10;} else {&amp;#10; console.log(&quot;Not correct&quot;);&amp;#10;}&amp;#10;if (((trials1.thisN + 1) === trials1.nTotal)) {&amp;#10; if (((number_correct / (trials1.nTotal + 1)) &gt;= 0.5)) {&amp;#10; trials2.finished = true;&amp;#10; console.log(&quot;Finished.&quot;);&amp;#10; } else {&amp;#10; console.log((&quot;Score: &quot; + (number_correct / (trials1.nTotal + 1)).toString()));&amp;#10; }&amp;#10;} else {&amp;#10; console.log((&quot;Trial: &quot; + trials1.thisN.toString()));&amp;#10;}&amp;#10;" valType="extendedCode"/>
<Param name="End Routine" updates="constant" val="if resp.corr:&amp;#10; number_correct = number_correct + 1&amp;#10; print('Correct: ' + str(number_correct))&amp;#10;else:&amp;#10; print('Not correct')&amp;#10;&amp;#10;if trials1.thisN + 1 == trials1.nTotal:&amp;#10; if number_correct/(trials1.nTotal + 1) &gt;= 0.5:&amp;#10; trials2.finished = True&amp;#10; print('Finished.')&amp;#10; else:&amp;#10; print('Score: ' + str(number_correct/(trials1.nTotal + 1)))&amp;#10;else:&amp;#10; print('Trial: ' + str(trials1.thisN))" valType="extendedCode"/>
<Param name="disabled" updates="None" val="False" valType="bool"/>
<Param name="name" updates="None" val="code" valType="code"/>
</CodeComponent>
<TextComponent name="word"> <TextComponent name="word">
<Param name="color" updates="set every repeat" val="$letterColor" valType="str"/> <Param name="color" updates="set every repeat" val="$letterColor" valType="str"/>
<Param name="colorSpace" updates="constant" val="rgb" valType="str"/> <Param name="colorSpace" updates="constant" val="rgb" valType="str"/>
...@@ -94,6 +77,23 @@ ...@@ -94,6 +77,23 @@
<Param name="storeCorrect" updates="constant" val="True" valType="bool"/> <Param name="storeCorrect" updates="constant" val="True" valType="bool"/>
<Param name="syncScreenRefresh" updates="constant" val="True" valType="bool"/> <Param name="syncScreenRefresh" updates="constant" val="True" valType="bool"/>
</KeyboardComponent> </KeyboardComponent>
<CodeComponent name="code">
<Param name="Before Experiment" updates="constant" val="" 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="" valType="extendedCode"/>
<Param name="Begin JS Routine" updates="constant" val="if ((trials1.thisN === 0)) {&amp;#10; number_correct = 0;&amp;#10;}&amp;#10;" valType="extendedCode"/>
<Param name="Begin Routine" updates="constant" val="if trials1.thisN == 0:&amp;#10; number_correct = 0" valType="extendedCode"/>
<Param name="Code Type" updates="None" val="Auto-&gt;JS" valType="str"/>
<Param name="Each Frame" updates="constant" val="" valType="extendedCode"/>
<Param name="Each JS Frame" updates="constant" val="" valType="extendedCode"/>
<Param name="End Experiment" updates="constant" val="" valType="extendedCode"/>
<Param name="End JS Experiment" updates="constant" val="" valType="extendedCode"/>
<Param name="End JS Routine" updates="constant" val="if (resp.corr) {&amp;#10; number_correct = (number_correct + 1);&amp;#10; console.log((&quot;Correct: &quot; + number_correct.toString()));&amp;#10;} else {&amp;#10; console.log(&quot;Not correct&quot;);&amp;#10;}&amp;#10;if (((trials1.thisN + 1) === trials1.nTotal)) {&amp;#10; if (((number_correct / (trials1.nTotal + 1)) &gt;= 0.85)) {&amp;#10; trials2.finished = true;&amp;#10; console.log(&quot;Finished.&quot;);&amp;#10; } else {&amp;#10; console.log((&quot;Score: &quot; + (number_correct / (trials1.nTotal + 1)).toString()));&amp;#10; }&amp;#10;} else {&amp;#10; console.log((&quot;Trial: &quot; + trials1.thisN.toString()));&amp;#10;}&amp;#10;" valType="extendedCode"/>
<Param name="End Routine" updates="constant" val="if resp.corr:&amp;#10; number_correct = number_correct + 1&amp;#10; print('Correct: ' + str(number_correct))&amp;#10;else:&amp;#10; print('Not correct')&amp;#10;&amp;#10;if trials1.thisN + 1 == trials1.nTotal:&amp;#10; if number_correct/(trials1.nTotal + 1) &gt;= 0.85:&amp;#10; trials2.finished = True&amp;#10; print('Finished.')&amp;#10; else:&amp;#10; print('Score: ' + str(number_correct/(trials1.nTotal + 1)))&amp;#10;else:&amp;#10; print('Trial: ' + str(trials1.thisN))" valType="extendedCode"/>
<Param name="disabled" updates="None" val="False" valType="bool"/>
<Param name="name" updates="None" val="code" valType="code"/>
</CodeComponent>
</Routine> </Routine>
<Routine name="instruct"> <Routine name="instruct">
<TextComponent name="instrText"> <TextComponent name="instrText">
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
""" """
This experiment was created using PsychoPy3 Experiment Builder (v2020.2.8), This experiment was created using PsychoPy3 Experiment Builder (v2020.2.8),
on Mon Dec 7 17:02:05 2020 on Mon Dec 7 17:06:28 2020
If you publish work using this script the most relevant publication is: If you publish work using this script the most relevant publication is:
Peirce J, Gray JR, Simpson S, MacAskill M, Höchenberger R, Sogo H, Kastman E, Lindeløv JK. (2019) Peirce J, Gray JR, Simpson S, MacAskill M, Höchenberger R, Sogo H, Kastman E, Lindeløv JK. (2019)
...@@ -99,7 +99,7 @@ word = visual.TextStim(win=win, name='word', ...@@ -99,7 +99,7 @@ word = visual.TextStim(win=win, name='word',
pos=[0, 0], height=0.2, wrapWidth=None, ori=0, pos=[0, 0], height=0.2, wrapWidth=None, ori=0,
color='white', colorSpace='rgb', opacity=1, color='white', colorSpace='rgb', opacity=1,
languageStyle='LTR', languageStyle='LTR',
depth=-1.0); depth=0.0);
resp = keyboard.Keyboard() resp = keyboard.Keyboard()
# Initialize components for Routine "thanks" # Initialize components for Routine "thanks"
...@@ -244,13 +244,13 @@ for thisTrials2 in trials2: ...@@ -244,13 +244,13 @@ for thisTrials2 in trials2:
# ------Prepare to start Routine "trial"------- # ------Prepare to start Routine "trial"-------
continueRoutine = True continueRoutine = True
# update component parameters for each repeat # update component parameters for each repeat
if trials1.thisN == 0:
number_correct = 0
word.setColor(letterColor, colorSpace='rgb') word.setColor(letterColor, colorSpace='rgb')
word.setText(text) word.setText(text)
resp.keys = [] resp.keys = []
resp.rt = [] resp.rt = []
_resp_allKeys = [] _resp_allKeys = []
if trials1.thisN == 0:
number_correct = 0
# keep track of which components have finished # keep track of which components have finished
trialComponents = [word, resp] trialComponents = [word, resp]
for thisComponent in trialComponents: for thisComponent in trialComponents:
...@@ -332,20 +332,6 @@ for thisTrials2 in trials2: ...@@ -332,20 +332,6 @@ for thisTrials2 in trials2:
for thisComponent in trialComponents: for thisComponent in trialComponents:
if hasattr(thisComponent, "setAutoDraw"): if hasattr(thisComponent, "setAutoDraw"):
thisComponent.setAutoDraw(False) thisComponent.setAutoDraw(False)
if resp.corr:
number_correct = number_correct + 1
print('Correct: ' + str(number_correct))
else:
print('Not correct')
if trials1.thisN + 1 == trials1.nTotal:
if number_correct/(trials1.nTotal + 1) >= 0.5:
trials2.finished = True
print('Finished.')
else:
print('Score: ' + str(number_correct/(trials1.nTotal + 1)))
else:
print('Trial: ' + str(trials1.thisN))
trials1.addData('word.started', word.tStartRefresh) trials1.addData('word.started', word.tStartRefresh)
trials1.addData('word.stopped', word.tStopRefresh) trials1.addData('word.stopped', word.tStopRefresh)
# check responses # check responses
...@@ -363,6 +349,20 @@ for thisTrials2 in trials2: ...@@ -363,6 +349,20 @@ for thisTrials2 in trials2:
trials1.addData('resp.rt', resp.rt) trials1.addData('resp.rt', resp.rt)
trials1.addData('resp.started', resp.tStartRefresh) trials1.addData('resp.started', resp.tStartRefresh)
trials1.addData('resp.stopped', resp.tStopRefresh) trials1.addData('resp.stopped', resp.tStopRefresh)
if resp.corr:
number_correct = number_correct + 1
print('Correct: ' + str(number_correct))
else:
print('Not correct')
if trials1.thisN + 1 == trials1.nTotal:
if number_correct/(trials1.nTotal + 1) >= 0.85:
trials2.finished = True
print('Finished.')
else:
print('Score: ' + str(number_correct/(trials1.nTotal + 1)))
else:
print('Trial: ' + str(trials1.thisN))
# the Routine "trial" was not non-slip safe, so reset the non-slip timer # the Routine "trial" was not non-slip safe, so reset the non-slip timer
routineTimer.reset() routineTimer.reset()
thisExp.nextEntry() thisExp.nextEntry()
......
...@@ -110,7 +110,7 @@ function experimentInit() { ...@@ -110,7 +110,7 @@ function experimentInit() {
units: undefined, units: undefined,
pos: [0, 0], height: 0.2, wrapWidth: undefined, ori: 0, pos: [0, 0], height: 0.2, wrapWidth: undefined, ori: 0,
color: new util.Color('white'), opacity: 1, color: new util.Color('white'), opacity: 1,
depth: -1.0 depth: 0.0
}); });
resp = new core.Keyboard({psychoJS: psychoJS, clock: new util.Clock(), waitForStart: true}); resp = new core.Keyboard({psychoJS: psychoJS, clock: new util.Clock(), waitForStart: true});
...@@ -328,8 +328,8 @@ function instructRoutineEnd(snapshot) { ...@@ -328,8 +328,8 @@ function instructRoutineEnd(snapshot) {
} }
var number_correct;
var _resp_allKeys; var _resp_allKeys;
var number_correct;
var trialComponents; var trialComponents;
function trialRoutineBegin(snapshot) { function trialRoutineBegin(snapshot) {
return function () { return function () {
...@@ -338,15 +338,15 @@ function trialRoutineBegin(snapshot) { ...@@ -338,15 +338,15 @@ function trialRoutineBegin(snapshot) {
trialClock.reset(); // clock trialClock.reset(); // clock
frameN = -1; frameN = -1;
// update component parameters for each repeat // update component parameters for each repeat
if ((trials1.thisN === 0)) {
number_correct = 0;
}
word.setColor(new util.Color(letterColor)); word.setColor(new util.Color(letterColor));
word.setText(text); word.setText(text);
resp.keys = undefined; resp.keys = undefined;
resp.rt = undefined; resp.rt = undefined;
_resp_allKeys = []; _resp_allKeys = [];
if ((trials1.thisN === 0)) {
number_correct = 0;
}
// keep track of which components have finished // keep track of which components have finished
trialComponents = []; trialComponents = [];
trialComponents.push(word); trialComponents.push(word);
...@@ -447,23 +447,6 @@ function trialRoutineEnd(snapshot) { ...@@ -447,23 +447,6 @@ function trialRoutineEnd(snapshot) {
thisComponent.setAutoDraw(false); thisComponent.setAutoDraw(false);
} }
}); });
if (resp.corr) {
number_correct = (number_correct + 1);
console.log(("Correct: " + number_correct.toString()));
} else {
console.log("Not correct");
}
if (((trials1.thisN + 1) === trials1.nTotal)) {
if (((number_correct / (trials1.nTotal + 1)) >= 0.5)) {
trials2.finished = true;
console.log("Finished.");
} else {
console.log(("Score: " + (number_correct / (trials1.nTotal + 1)).toString()));
}
} else {
console.log(("Trial: " + trials1.thisN.toString()));
}
// was no response the correct answer?! // was no response the correct answer?!
if (resp.keys === undefined) { if (resp.keys === undefined) {
if (['None','none',undefined].includes(corrAns)) { if (['None','none',undefined].includes(corrAns)) {
...@@ -481,6 +464,23 @@ function trialRoutineEnd(snapshot) { ...@@ -481,6 +464,23 @@ function trialRoutineEnd(snapshot) {
} }
resp.stop(); resp.stop();
if (resp.corr) {
number_correct = (number_correct + 1);
console.log(("Correct: " + number_correct.toString()));
} else {
console.log("Not correct");
}
if (((trials1.thisN + 1) === trials1.nTotal)) {
if (((number_correct / (trials1.nTotal + 1)) >= 0.85)) {
trials2.finished = true;
console.log("Finished.");
} else {
console.log(("Score: " + (number_correct / (trials1.nTotal + 1)).toString()));
}
} else {
console.log(("Trial: " + trials1.thisN.toString()));
}
// the Routine "trial" was not non-slip safe, so reset the non-slip timer // the Routine "trial" was not non-slip safe, so reset the non-slip timer
routineTimer.reset(); routineTimer.reset();
......
...@@ -121,7 +121,7 @@ function experimentInit() { ...@@ -121,7 +121,7 @@ function experimentInit() {
units: undefined, units: undefined,
pos: [0, 0], height: 0.2, wrapWidth: undefined, ori: 0, pos: [0, 0], height: 0.2, wrapWidth: undefined, ori: 0,
color: new util.Color('white'), opacity: 1, color: new util.Color('white'), opacity: 1,
depth: -1.0 depth: 0.0
}); });
resp = new core.Keyboard({psychoJS: psychoJS, clock: new util.Clock(), waitForStart: true}); resp = new core.Keyboard({psychoJS: psychoJS, clock: new util.Clock(), waitForStart: true});
...@@ -336,8 +336,8 @@ function instructRoutineEnd(snapshot) { ...@@ -336,8 +336,8 @@ function instructRoutineEnd(snapshot) {
} }
var number_correct;
var _resp_allKeys; var _resp_allKeys;
var number_correct;
var trialComponents; var trialComponents;
function trialRoutineBegin(snapshot) { function trialRoutineBegin(snapshot) {
return function () { return function () {
...@@ -346,15 +346,15 @@ function trialRoutineBegin(snapshot) { ...@@ -346,15 +346,15 @@ function trialRoutineBegin(snapshot) {
trialClock.reset(); // clock trialClock.reset(); // clock
frameN = -1; frameN = -1;
// update component parameters for each repeat // update component parameters for each repeat
if ((trials1.thisN === 0)) {
number_correct = 0;
}
word.setColor(new util.Color(letterColor)); word.setColor(new util.Color(letterColor));
word.setText(text); word.setText(text);
resp.keys = undefined; resp.keys = undefined;
resp.rt = undefined; resp.rt = undefined;
_resp_allKeys = []; _resp_allKeys = [];
if ((trials1.thisN === 0)) {
number_correct = 0;
}
// keep track of which components have finished // keep track of which components have finished
trialComponents = []; trialComponents = [];
trialComponents.push(word); trialComponents.push(word);
...@@ -454,23 +454,6 @@ function trialRoutineEnd(snapshot) { ...@@ -454,23 +454,6 @@ function trialRoutineEnd(snapshot) {
thisComponent.setAutoDraw(false); thisComponent.setAutoDraw(false);
} }
} }
if (resp.corr) {
number_correct = (number_correct + 1);
console.log(("Correct: " + number_correct.toString()));
} else {
console.log("Not correct");
}
if (((trials1.thisN + 1) === trials1.nTotal)) {
if (((number_correct / (trials1.nTotal + 1)) >= 0.5)) {
trials2.finished = true;
console.log("Finished.");
} else {
console.log(("Score: " + (number_correct / (trials1.nTotal + 1)).toString()));
}
} else {
console.log(("Trial: " + trials1.thisN.toString()));
}
// was no response the correct answer?! // was no response the correct answer?!
if (resp.keys === undefined) { if (resp.keys === undefined) {
if (['None','none',undefined].includes(corrAns)) { if (['None','none',undefined].includes(corrAns)) {
...@@ -488,6 +471,23 @@ function trialRoutineEnd(snapshot) { ...@@ -488,6 +471,23 @@ function trialRoutineEnd(snapshot) {
} }
resp.stop(); resp.stop();
if (resp.corr) {
number_correct = (number_correct + 1);
console.log(("Correct: " + number_correct.toString()));
} else {
console.log("Not correct");
}
if (((trials1.thisN + 1) === trials1.nTotal)) {
if (((number_correct / (trials1.nTotal + 1)) >= 0.85)) {
trials2.finished = true;
console.log("Finished.");
} else {
console.log(("Score: " + (number_correct / (trials1.nTotal + 1)).toString()));
}
} else {
console.log(("Trial: " + trials1.thisN.toString()));
}
// the Routine "trial" was not non-slip safe, so reset the non-slip timer // the Routine "trial" was not non-slip safe, so reset the non-slip timer
routineTimer.reset(); routineTimer.reset();
......
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