Dispaly stimuli in blocks
Hi Florian,
I have an excel file consist of 10x3 elements (rows=10). In the code below, I read each line of the excel file and add 3 stimuli to the block. In each block, I would like to only display 5 stimuli. But with the code below I only display each stimuli 2 times. I know it's wrong. Any advice about how I can allocate first five stimuli to block one and second five stimuli to block number 2 and so on, is appreciated.
for blocks in range(0,2):
for trial_num in range(0, rows):
data_list = [df.iloc[trial_num , 1], df.iloc[trial_num , 2],
df.iloc[trial_num , 3]]
key = "Trial{}".format(trial_num )
words[key] = data_list
block_num="block"+str(blocks)
block_num= expyriment.design.Block(name="activation")
var="trial"+str(trial_num )
var = expyriment.design.Trial()
stim1 = expyriment.stimuli.TextLine(text=words[key][0], position=(0,200),text_size=32)
stim2 = expyriment.stimuli.TextLine(text=words[key][1], position=(-230,-230),text_size=32)
stim3 = expyriment.stimuli.TextLine(text=words[key][2], position=(230,-230),text_size=32)
canvas = expyriment.stimuli.Canvas(size=(600, 600))
stim1.plot(canvas)
stim2.plot(canvas)
stim3.plot(canvas)
canvas.preload()
var.add_stimulus(canvas)
block_num.add_trial(var)
exp.add_block(block_num)
Comments
Hi Juliette,
how about this:
Dear Florian,
Thank you for your comment. There is a problem about converting excel file to csv file. It seems Python can't encode French accents to csv file and therefore it cant display the word in canvas. Although, I might be wrong. I only increased one line to your comment
Hi Juliette,
instead of
open("se_de1.csv")
, try toimport codecs
and thencodecs.open("se_de_1.csv", encoding="utf-16")
, and see whether that works.