Hi guys,
I am trying an experiment in Psychopy for randomising the posisitton of some object in one image.
I have the codes.
I am using a code component at the begin experiment tab:
import random, xlrd
#randomize seed
random.seed()
#input file
in_file = 'MyFile.xlsx'
#number of items to load
num_items = 8
#counters to hold the next stimulus reference
cur_image = 0
cur_position = 0
at the begin routine:
#open the excel file
inbook = xlrd.open_workbook(in_file)
insheet = inbook.sheet_by_index(0)
#arrays to hold our stimuli
image_stim = []
position_stim = []
#loop through the rows in the stimulus file
for rowx in range(1, num_items+1):
#reed in an entire row
row= insheet.row_values(rowx)
#save the images and positions
image_stim.push(row[0])
position_stim.push(row[1])
#randomly shuffle the images
random.shuffle(image_stim)
#randomly shuffle the colors
random.shuffle(position_stim)
I have an Excel file which contains everything else for the position.
The problem that I have is in the initialisation of the imports: Alert 4210:JavaScript Syntax Error in ‘Begin JS Experiment’ tab. See ‘Line 1: Unexpected token’ in the ‘Begin JS Experiment’ tab.
For further info see 4210: Probable syntax error detected in your JavaScript code — PsychoPy v2021.2.4
I tried everything that I found in the forum and other forums nothing works. Even the new version with the codes but I still get the same error. Any help would be appreciated.