Skip to content

Commit

Permalink
Revert "8.2.0 - preregistration upright"
Browse files Browse the repository at this point in the history
This reverts commit 9d5e601.
  • Loading branch information
belledon committed Sep 1, 2023
1 parent 53148e6 commit 0a9acff
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 72 deletions.
8 changes: 2 additions & 6 deletions scripts/parse_jatos_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@ def parse_trial_data(df, data : dict):
scene, door = data['a'].split('_')
df['scene'].append(int(scene))
df['door'].append(int(door))
same = data['a'] == data['b']
correct = data['response'] == 'j' if same else data['response'] == 'f'
df['same'].append(same)
df['correct'].append(correct)
df['same'].append(data['answer'] == 'same')
df['correct'].append(data['correct'])
df['rt'].append(data['rt'])
df['order'].append(data['trial_index'])

Expand All @@ -34,8 +32,6 @@ def parse_jatos_file(path : str):
'correct' : [], 'rt' : [], 'order' : []}

for exp_trial in timeline:
if (exp_trial['response'] is None):
continue
parse_trial_data(data, exp_trial)

data['uid'] = unique_id
Expand Down
85 changes: 19 additions & 66 deletions src/experiment.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @title Change Detection
* @description Change Detection experiment for FunctionalScenes
* @version 8.2.1
* @version 8.2.0
*
* @assets assets/
*/
Expand Down Expand Up @@ -33,18 +33,17 @@ const trial_list = trial_list_wrapped[0];

// Define global experiment variables
var N_TRIALS = trial_list.length;
const N_MASKS = 5;
var EXP_DURATION = 20; // in minutes
var EXP_DURATION = 10; // in minutes
const STIM_IMAGE_W = 720;
const STIM_IMAGE_H = 480;
const STIM_DEG = 10;
const PIXELS_PER_UNIT = STIM_IMAGE_W / STIM_DEG;
// vss 2022 parameters
// const STIM_IMAGE_DUR = 500; // ms
// const STIM_MASK_DUR = 750; // ms
const STIM_IMAGE_DUR = 2000; // ms
const STIM_IMAGE_DUR = 500; // ms
const STIM_MASK_DUR = 750; // ms
const STIM_IMAGE_FLIPY = true; // for inverted experiment
const STIM_IMAGE_FLIPY = false; // for inverted experiment

// Debug Variables
const SKIP_PROLIFIC_ID = false;
Expand All @@ -61,75 +60,30 @@ var genImgHtml = function (img, flipx) {
return ihtml;
};

var sampleRandomMask = function (jsPsych) {
const mask_id = jsPsych.randomization.randomInt(1, N_MASKS);
const mask_file = `mask_${mask_id}.png`
return mask_file;
};

/* helper to generate timeline parts for a trial */
var genTrial = function (jsPsych, img_a, img_b, flipx) {
const img_1 = {
type: HtmlKeyboardResponsePlugin,
stimulus: `<div class="centered"> ${genImgHtml(img_a, flipx)} </div>`,
choices: "NO_KEYS",
trial_duration: STIM_IMAGE_DUR,
};
const mask_img = sampleRandomMask(jsPsych);
const mask = {
type: HtmlKeyboardResponsePlugin,
stimulus: `<div class="centered"> ${genImgHtml(mask_img, false)} </div>`,
choices: "NO_KEYS",
trial_duration: STIM_MASK_DUR,

};
const img_2 = {
type: HtmlKeyboardResponsePlugin,
stimulus: `<div class="centered"> ${genImgHtml(img_b, flipx)} </div>`,
choices: "NO_KEYS",
trial_duration: STIM_IMAGE_DUR,
};
const response = {
type: HtmlKeyboardResponsePlugin,
stimulus: '',
choices: ['f', 'j'],
const sd = {
type: SameDifferentHtmlPlugin,
stimuli: [
`<div class="centered"> ${genImgHtml(img_a, flipx)} </div>`,
`<div class="centered"> ${genImgHtml(img_b, flipx)} </div>`,
],
prompt: `<p>Press 'f' if the images are the <b>DIFFERENT</b>.</p> <p>Press 'j' if the images are the <b>SAME</b>.</p>`,
same_key: 'j',
different_key: 'f',
first_stim_duration: STIM_IMAGE_DUR,
gap_duration: STIM_MASK_DUR,
second_stim_duration: STIM_IMAGE_DUR,
post_trial_gap: 1000, // 1000ms gap

};
const tl = {
timeline: [img_1, mask, img_2, response],
answer: img_a == img_b ? 'same' : 'different',
// trial data used for analysis
data: {
a: img_a.slice(0, -4),
b: img_b.slice(0, -4),
mask: mask_img
}
};
return (tl);
return (sd);
};
// var genTrial = function (jsPsych, img_a, img_b, flipx) {
// const sd = {
// type: SameDifferentHtmlPlugin,
// stimuli: [
// `<div class="centered"> ${genImgHtml(img_a, flipx)} </div>`,
// `<div class="centered"> ${genImgHtml(img_b, flipx)} </div>`,
// ],
// prompt: `<p>Press 'f' if the images are the <b>DIFFERENT</b>.</p> <p>Press 'j' if the images are the <b>SAME</b>.</p>`,
// same_key: 'j',
// different_key: 'f',
// first_stim_duration: STIM_IMAGE_DUR,
// gap_duration: STIM_MASK_DUR,
// second_stim_duration: STIM_IMAGE_DUR,
// post_trial_gap: 1000, // 1000ms gap
// answer: img_a == img_b ? 'same' : 'different',
// // trial data used for analysis
// data: {
// a: img_a.slice(0, -4),
// b: img_b.slice(0, -4),
// }
// };
// return (sd);
// };

/**
* This function will be executed by jsPsych Builder and is expected to run the jsPsych experiment
Expand Down Expand Up @@ -294,8 +248,7 @@ export async function run({ assetPaths, input = {}, environment, title, version
timeline: [instructions, exampleTrial, comp_check, comp_feedback],
loop_function: function (data) {
// return false if comprehension passes to break loop
let values = data.values();
return (!(values[values.length - 2].correct));
return (!(data.values()[2].correct));
}
};

Expand Down

0 comments on commit 0a9acff

Please sign in to comment.