Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

canvas stimuli problem

Hello,
I’m currently working to present more than one stimuli on the screen (rectangle and circle) with two trial in one block. My purpose is to create more than one blocks with more trials. As Fladd suggest :
With canvas I tried :
`block_one = expyriment.design.Block(name="1")
trial_one = expyriment.design.Trial()
stim1 = expyriment.stimuli.Rectangle([150,150], position = [-100,0], colour = expyriment.misc.constants.C_YELLOW)
stim1.plot(canvas)
stim2 = expyriment.stimuli.Circle(radius = 100, position = [100,0], colour = expyriment.misc.constants.C_GREEN)
stim2.plot(canvas)
trial_one.add_stimulus(canvas)
corr_res = 122
label_id = 'rectangle-circle'
trial_two = expyriment.design.Trial()
stim2 = expyriment.stimuli.Circle(radius = 100, position = [100,0], colour = expyriment.misc.constants.C_GREEN)
stim2.plot(canvas)
stim3 = expyriment.stimuli.Rectangle([150,150], position = [-100,0], colour = expyriment.misc.constants.C_GREEN)
stim3.plot(canvas)
trial_two.add_stimulus(canvas)
corr_res = 109
label_id = 'circle-rectangle'
block_one.add_trial(trial_one)
block_one.add_trial(trial_two)
block_one.shuffle_trials()
exp.add_block(block_one)

expyriment.control.start(skip_ready_screen=True)
fixation_cross = expyriment.stimuli.FixCross()
fixation_cross.preload()
blankscreen = expyriment.stimuli.BlankScreen()
blankscreen.preload()

for block in exp.blocks:
for trial in block.trials:
trial.stimuli[0].preload()
fixation_cross.present()
exp.clock.wait(dur)
trial.stimuli[0].present()
canvas.present()
exp.clock.reset_stopwatch()
key, rt = exp.keyboard.wait(keys=[expyriment.misc.constants.K_m,
expyriment.misc.constants.K_z])
expyriment.control.end()`
There is no error, two trial presented as squences, fixation poin not missing, however only last stimuli presented.

Other solution, I tried :
`block_one = expyriment.design.Block(name="1")
var_one = expyriment.design.Trial()
stim1 = expyriment.stimuli.Rectangle([150,150], position = [-100,0], colour = expyriment.misc.constants.C_YELLOW)
stim2 = expyriment.stimuli.Circle(radius = 100, position = [100,0], colour = expyriment.misc.constants.C_GREEN)
var_one.add_stimulus(stim1)
var_one.add_stimulus(stim2)
corr_res = 122
label_id = 'rectangle-circle'
var_two = expyriment.design.Trial()
stim3 = expyriment.stimuli.Circle(radius = 100, position = [100,0], colour = expyriment.misc.constants.C_GREEN)
stim4 = expyriment.stimuli.Rectangle([150,150], position = [-100,0], colour = expyriment.misc.constants.C_GREEN)
var_two.add_stimulus(stim3)
var_two.add_stimulus(stim4)
corr_res = 109
label_id = 'circle-rectangle'
block_one.add_trial(var_one)
block_one.add_trial(var_two)
block_one.shuffle_trials()
exp.add_block(block_one)

expyriment.control.start(skip_ready_screen=True)
fixation_cross = expyriment.stimuli.FixCross()
fixation_cross.preload()
blankscreen = expyriment.stimuli.BlankScreen()
blankscreen.preload()

for block in exp.blocks:
for trial in block.trials:
fixation_cross.present()
trial.stimuli[0].preload()
trial.stimuli[0].present(update=False)
trial.stimuli[1].present(clear=False)
exp.clock.reset_stopwatch()
key,rt = exp.keyboard.wait(keys=[expyriment.misc.constants.K_m,
expyriment.misc.constants.K_z])
expyriment.control.end()`

All stimuli can be presented, but there is no fixation point and swap between rectangle-circle or circle-rectangle. Any help or suggest would be appreciated and sorry for the code.

Thanks
Tanto

Comments

  • Dear tanto,

    the code you provided does not run. Can you post a running example?

    Florian Krause (Developer)
    http://www.expyriment.org

  • Apologize for that. This is my code and should work
    Hope this help

    Many thanks
    Tanto

  • So from what I can see is that you are adding all 6 stimuli to the same canvas. From your description above this is not what you want...
    Simply creating a canvas stimulus in each trial, would solve this.

    #block1
    block_one = expyriment.design.Block(name="1")
    trial_one = expyriment.design.Trial()
    canvas = expyriment.stimuli.Canvas(size=(500,500))
    stim1 = expyriment.stimuli.Rectangle([150,150], position = [-100,0], colour = expyriment.misc.constants.C_YELLOW)
    stim1.plot(canvas)
    stim2 = expyriment.stimuli.Circle(radius = 100, position = [100,0], colour = expyriment.misc.constants.C_GREEN)
    stim2.plot(canvas)
    trial_one.add_stimulus(canvas)
    corr_res = 122
    label_id = 'rectangle-circle'
    trial_two = expyriment.design.Trial()
    canvas = expyriment.stimuli.Canvas(size=(500,500))
    stim2 = expyriment.stimuli.Circle(radius = 100, position = [100,0], colour = expyriment.misc.constants.C_GREEN)
    stim2.plot(canvas)
    stim3 = expyriment.stimuli.Rectangle([150,150], position = [-100,0], colour = expyriment.misc.constants.C_GREEN)
    stim3.plot(canvas)
    trial_two.add_stimulus(canvas)
    corr_res = 109
    label_id = 'rectangle-circle'
    trial_three = expyriment.design.Trial()
    canvas = expyriment.stimuli.Canvas(size=(500,500))
    stim3 = expyriment.stimuli.Rectangle([150,150], position = [-100,0], colour = expyriment.misc.constants.C_GREEN)
    stim3.plot(canvas)
    stim4 = expyriment.stimuli.Circle(radius = 100, position = [100,0], colour = expyriment.misc.constants.C_YELLOW)
    stim4.plot(canvas)
    trial_three.add_stimulus(canvas)
    corr_ress = 122
    label_id = 'rectangle-circle'
    trial_four = expyriment.design.Trial()
    canvas = expyriment.stimuli.Canvas(size=(500,500))
    stim5 = expyriment.stimuli.Circle(radius = 100, position = [100,0], colour = expyriment.misc.constants.C_YELLOW)
    stim5.plot(canvas)
    stim6 = expyriment.stimuli.Rectangle([150,150], position = [-100,0], colour = expyriment.misc.constants.C_YELLOW)
    stim6.plot(canvas)
    trial_four.add_stimulus(canvas)
    corr_res = 109
    label_id = 'circle-rectangle'
    block_one.add_trial(trial_one)
    block_one.add_trial(trial_two)
    block_one.add_trial(trial_three)
    block_one.add_trial(trial_four)
    block_one.shuffle_trials()
    exp.add_block(block_one)
    
    Thanked by 1Tanto

    Florian Krause (Developer)
    http://www.expyriment.org

  • Thanks Fladd for your fast answer. Now it works like what I expected. Also an embarrassing problem from my code is I accidentally put the exact position for the both stimuli, which make them not swaping from trial to trial.
    I'm really apologize for the obscurity.
    Best Regard

Sign In or Register to comment.