Welcome!

Sign in with your CogSci, Facebook, Google, or Twitter account.

Or register to create a new account.

We'll use your information only for signing in to this forum.

Supported by

Triangle stimuli in a block

Dear Florian,

I am sorry to take your time so often, actually, I am implementing few different tasks into Expyriment.
In the code below I tried to represent a trial with triangle structure in each trial as you can see below: I first prepared stimuli and add it to the block. ( I took out unnecessary parts of code)

    exp = expyriment.design.Experiment(name="TASK")
    expyriment.control.initialize(exp)

    for row_num in range(0, rows):
        # read stimuli from excel file 
        block_one = expyriment.design.Block(name="activation")
        var="trial"+str(row_num)

        var = expyriment.design.Trial()
        stim1 = expyriment.stimuli.TextLine(text=words[key][0], position=(0,200),text_size=42)
        stim2 = expyriment.stimuli.TextLine(text=words[key][1], position=(-250,-250),text_size=42)
        stim3 = expyriment.stimuli.TextLine(text=words[key][2], position=(250,-250),text_size=42)  
        stim1.preload()
        stim2.preload()
        stim3.preload() 
        var.add_stimulus(stim1)
        var.add_stimulus(stim2)
        var.add_stimulus(stim3)
        block_one.add_trial(var)
        exp.add_block(block_one)

In the next part, I tried to start the experiment as below:

    expyriment.control.start()

    for block in exp.blocks:
      for trial in block.trials:

         canvas = expyriment.stimuli.Canvas(size=(600, 600)) 
         canvas.present()
         trial.stimuli[0].present(update=False)
         trial.stimuli[1].present(clear=False, update=False)
         trial.stimuli[2].present(update=False)
         exp.clock.wait(2000)

    expyriment.control.end()

But it doesn't show all three stimuli in triangle form in each trial . Do you please have any advice for me?

Comments

  • fladdfladd Posts: 69

    Hi Juliette,

    canvas.present()
    trial.stimuli[0].present(update=False)
    trial.stimuli[1].present(clear=False, update=False)
    trial.stimuli[2].present(update=False)
    

    What happens here is:

    1. canvas is presented, but never seen on screen, as you immediately do
    2. trial.stimuli[0] and trial.stimuli[1] will be presented together, but never seen, as you
    3. are clearing the screen when presenting trial.stimuli[2], so now, trial.stimuli[2] should be the only stimulus on screen.

    It seems to me that you are mixing two different presentations techniques here. If you just want to present all thee stimuli on the screen, there are to ways to achieve this:

    1. Prepare everything beforehand by plotting the three stimuli on a canvas, then present it as one stimulus:

      exp = expyriment.design.Experiment(name="TASK")
      expyriment.control.initialize(exp)
      
      block_one = expyriment.design.Block(name="activation")
      var = expyriment.design.Trial()
      stim1 = expyriment.stimuli.TextLine(text=words[key][0], position=(0,200),text_size=42)
      stim2 = expyriment.stimuli.TextLine(text=words[key][1], position=(-250,-250),text_size=42)
      stim3 = expyriment.stimuli.TextLine(text=words[key][2], position=(250,-250),text_size=42)
      canvas = expyriment.stimuli.Canvas(size=(600, 600))
      stim1.plot(canvas) 
      stim2.plot(canvas) 
      stim2.plot(canvas)
      canvas.preload()
      var.add_stimulus(canvas)
      block_one.add_trial(var)
      exp.add_block(block_one)
      
      expyriment.control.start()
      
      for block in exp.blocks:
         for trial in block.trials:
             trial.stimuli[0].present()
             exp.clock.wait(2000)
      
      expyriment.control.end()
      
    2. Present the three stimuli sequentially without clearing the screen and only update the screen after the last stimulus:

      exp = expyriment.design.Experiment(name="TASK")
      expyriment.control.initialize(exp)
      
      block_one = expyriment.design.Block(name="activation")
      var = expyriment.design.Trial()
      stim1 = expyriment.stimuli.TextLine(text=words[key][0], position=(0,200),text_size=42)
      stim2 = expyriment.stimuli.TextLine(text=words[key][1], position=(-250,-250),text_size=42)
      stim3 = expyriment.stimuli.TextLine(text=words[key][2], position=(250,-250),text_size=42) 
      stim1.preload()
      stim2.preload()
      stim3.preload()
      var.add_stimulus(stim1)
      var.add_stimulus(stim2)
      var.add_stimulus(stim3)
      block_one.add_trial(var)
      exp.add_block(block_one)
      
      expyriment.control.start()
      
      for block in exp.blocks:
         for trial in block.trials:
             trial.stimuli[0].present(update=False)
             trial.stimuli[1].present(clear=False, update=False)
             trial.stimuli[2].present(clear=False)
             exp.clock.wait(2000)
      
      expyriment.control.end()
      

    Hope this helps.

    Thanked by 1Julliette

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

  • JullietteJulliette Posts: 5

    Thank you for your complete answer.
    It's a pleasure to hear your comments and thank you for your helps.

  • fladdfladd Posts: 69

    Glad I could help!

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

Sign In or Register to comment.