Howdy, Stranger!

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

Supported by

issues with accessing stimuli uploaded from file

edited September 2017 in OpenSesame

Dear all,

I'm new to OpenSesame and am currently trying to implement an experiment for my Master's thesis. It's going to be a language experiment using RSVP. A sentence is a trial and every word is presented after the other in the middle of the screen.

Here's my problem:
I'm loading the stimuli from a file in the block loop. Later on, I'm using an inline_script for the RSVP-part (following the advanced tutorial). I have issues accessing the stimuli. If I understood it correctly it should be saved in a 'dm'-variable. I tried to access it like below, but I get error messages all the time.

Any help is highly appreciated. Thanks a lot!

Best,
Robin

My code:

import random
import string 

##defining presentation time
var.word_dur = 345

##defining interstimulus rate
var.isi = 95

##defining sentence index
sentenceIndex = 0

##setting word_canvas_list
word_canvas_list = []

##saving stimulus in word_canvas_list
for word in enumerate(items.dm[sentenceIndex]):
    word_canvas = canvas()
    word_canvas.text(word)
    word_canvas_list.append(word_canvas)
    sentenceIndex += 1 

blank_canvas = canvas()

Comments

  • Hi Robin,

    It's simpler than you think, because OpenSesame automatically takes the variables from the DataMatrix, and sets them as experimental variables. So say that you have a column with the name word in the spreadsheet that you use as a source for the loop table, then you can refer to it as var.word. Does that make sense?

    Cheers!
    Sebastiaan

    There's much bigger issues in the world, I know. But I first have to take care of the world I know.
    cogsci.nl/smathot

  • Hi Sebastiaan,

    That sounds easy. I'm having whole sentences in a column. Do they behave like lists? So if I have a column 'sentence', can I index the first word with var.sentence[0]?

    Thanks!

    Robin

  • Hi Robin,

    No, a sentence specified in a loop would be a string (or strictly speaking a unicode object). To split this into separate words by spaces, you can simply use the unicode.split() method:

    my_word_list = var.sentence.split()
    my_first_word = my_word_list[0]
    

    Does that make sense?

    Cheers!
    Sebastiaan

    There's much bigger issues in the world, I know. But I first have to take care of the world I know.
    cogsci.nl/smathot

  • Hi Sebastiaan,

    Yes, it works now.

    Thanks a lot!

    Best,
    Robin

Sign In or Register to comment.