jsPsych version (e.g. 7.3.1): unsure
I’ve created a Synonym Judgement Task in PsychoPy that works fine locally, and I’ve modified some of the code to fix translation issues in JavaScript. However, there are still a few things that I haven’t been able to translate properly, and I would really appreciate some help.
The main issue is related to the fact that I’m using xlrd in my python code. I’ve updated the JS code to import my stimuli using trial handlers, but I’m having trouble drawing 3 columns from the same file at once. I’m doing this because I need to display three stimuli at once (a cue in the middle, a target and a probe on either side of it).
This is my Python code:
#access word file
inbook_A2B2 = xlrd.open_workbook(A2B2_w)
insheet_A2B2 = inbook_A2B2.sheet_by_index(0)
#arrays
A2B2 = []
A2B2_target = []
A2B2_distractor = []
for rowx in list(range(1, A2B2_items +1)):
#read in values of all columns on this row
row = insheet_A2B2.row_values(rowx)
#saving the word to the word array
A2B2.append(row[0])
A2B2_target.append(row[1])
A2B2_distractor.append(row[2])
I implemented the TrialHandler in a routine before my loop in the Begin Experiment tab with only JS:
A2B2_w = 'resources/SocMot_A2B2_Run1.xls'
cond_mot = 'resources/Trial_Order_cleanSocMot.xlsx'
A2B2_stim = new TrialHandler({
psychoJS: psychoJS,
nReps: 1, method: TrialHandler.Method.SEQUENTIAL,
extraInfo: expInfo, originPath: undefined,
trialList: A2B2_w,
seed: undefined, name: 'A2B2_stim'
});
And this was my attempt at the JS code. What I’m particularly struggling with is the for loop that would read the values of all columns from a row.
const A2B2_w= 'resources/SocMot_A2B2_Run1.xls'
const A2B2_items = 60;
const A2B2 = [];
const A2B2_target = [];
const A2B2_distractor = [];
for (let rowx = 1; rowx < (A2B2_items +1); rowx++) {
let row = A2B2_stim.getRow(rowx);
A2B2.push(parseInt(row[0]));
A2B2_target.push(parseInt(row[1]));
A2B2_distractor.push(parseInt(row[2]));
}
The most recent error that I’m getting is: “A2B2_stim.getRow is not a function”
How can I change the JS code to give me the values of all three columns for each row per trial?
Thanks in advance!