Skip to content

updated multiplication experiment #350

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ test:
- $HOME/miniconda2/bin/python -c "from expfactory.tests import circle_ci_test; circle_ci_test('mindful_attention_awareness','web','.');"
- $HOME/miniconda2/bin/python -c "from expfactory.tests import circle_ci_test; circle_ci_test('motor_selective_stop_signal','web','.');"
- $HOME/miniconda2/bin/python -c "from expfactory.tests import circle_ci_test; circle_ci_test('mpq_control','web','.');"
- $HOME/miniconda2/bin/python -c "from expfactory.tests import circle_ci_test; circle_ci_test('multiplication','web',pause_time=2000);"
- $HOME/miniconda2/bin/python -c "from expfactory.tests import circle_ci_test; circle_ci_test('multiplication','web','.',pause_time=2000);"
- $HOME/miniconda2/bin/python -c "from expfactory.tests import circle_ci_test; circle_ci_test('multisource','web','.');"
- $HOME/miniconda2/bin/python -c "from expfactory.tests import circle_ci_test; circle_ci_test('n_back','web','.');"
- $HOME/miniconda2/bin/python -c "from expfactory.tests import circle_ci_test; circle_ci_test('number_letter','web','.');"
Expand Down
1 change: 1 addition & 0 deletions multiplication/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"static/js/jspsych/poldrack_plugins/jspsych-poldrack-instructions.js",
"static/js/jspsych/poldrack_plugins/jspsych-attention-check.js",
"static/js/jspsych/poldrack_plugins/jspsych-single-stim-button.js",
"static/js/jspsych/plugins/jspsych-call-function.js",
"experiment.js",
"static/css/jspsych.css",
"static/css/default_style.css"
Expand Down
45 changes: 30 additions & 15 deletions multiplication/experiment.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ var randomDraw = function(lst) {

var getStim = function() {
response = 0
num1 = Math.floor(Math.random() * 99) + 1
num2 = Math.floor(Math.random() * 99) + 1
num1 = Math.floor(Math.random() * 89) + 10
num2 = Math.floor(Math.random() * 89) + 10
answer = num1 * num2
var text = '<div class = centerbox><form style="font-size: 24px">' + num1 + ' * ' + num2 +
' = <input type ="text" id ="mathtext" style="font-size: 24px"></form><br></br><button class = "default_button submitButton" id = submit_button onclick = submit()>Submit Answer</button></div>'
' = <input type ="text" id ="mathtext" style="font-size: 24px"></form><br></br><button class = "jspsych-btn submitButton" id = submit_button onclick = submit()>Submit Answer</button></div>'
return text
}
var submit = function() {
Expand All @@ -52,14 +52,15 @@ var num1 = ''
var num2 = ''
var answer = 0
var response = 0
var response_time = 180000
var response_time = 60000
var lstep = 5000
var sstep = 1000
var n_large_steps = 50
var n_small_steps = 50
var p = 0.5 // The probability of a correct response for the staircase
var fatigue_time = 45

var fatigue_start = 0
var timelimit = 20 //time for fatigue block
var elapsed = 0
/* ************************************ */
/* Set up jsPsych blocks */
/* ************************************ */
Expand All @@ -77,7 +78,6 @@ var feedback_instruct_block = {
timing_response: 6000
};
/// This ensures that the subject does not read through the instructions too quickly. If they do it too quickly, then we will go over the loop again.
var instruction_trials = []
var instructions_block = {
type: 'poldrack-instructions',
data: {
Expand All @@ -95,11 +95,9 @@ var instructions_block = {
}, 1010)
}
};
instruction_trials.push(feedback_instruct_block)
instruction_trials.push(instructions_block)

var instruction_node = {
timeline: instruction_trials,
timeline: [feedback_instruct_block, instructions_block],
/* This function defines stopping criteria */
loop_function: function(data) {
for (i = 0; i < data.length; i++) {
Expand Down Expand Up @@ -220,17 +218,34 @@ var fatigue_block = {
}
}

var fatigue_node = {
timeline: [fatigue_block],
loop_function: function() {
elapsed = (new Date() - fatigue_start) / 60000
if (elapsed < timelimit) {
return true;
} else {
return false;
}
}
}

var start_clock_block = {
type: 'call-function',
func: function() {
fatigue_start = new Date()
}
}

/* create experiment definition array */
var multiplication_experiment = []
multiplication_experiment.push(instruction_node)
for (var i = 0; i < 2; i++) { //n_large_steps
for (var i = 0; i < n_large_steps; i++) {
multiplication_experiment.push(largeStep_block)
}
for (var i = 0; i < 2; i++) { //n_small_steps
for (var i = 0; i < n_small_steps; i++) {
multiplication_experiment.push(smallStep_block)
}
for (var i = 0; i < 2; i++) { //Math.floor(180000 * fatigue_time / response_time)
multiplication_experiment.push(fatigue_block)
}
multiplication_experiment.push(start_clock_block)
multiplication_experiment.push(fatigue_node)
multiplication_experiment.push(end_block)