Howdy, Stranger!

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

Supported by

Randomise, but force 1st item per talker to be a filler

Hello,

OpenSesame is a such a cool program! I'm currently trying to set up an experiment in which the participants are confronted with three different talkers. Each talker utters a variety of sentences, among which some fillers. I'd like for the order of presentation to be essentially random but with the constraint that the first sentence heard per talker is a filler.

Here's a slimmed down stimulus list.

SentenceID Talker SentenceType
S1 A filler
S2 A filler
S3 B filler
S4 B filler
S5 C filler
S6 C filler
S7 A target
S8 A target
S9 B target
S10 B target
S11 C target
S12 C target

Permissible orders include:

  • S1, S7, S6, S8, S3 etc.
  • S4, S3, S9, S1, S11 etc.
  • S1, S3, S6, etc.

There's no need for the first three items to be fillers by different talkers, just for each talker's first item to be a filler.

Non-permissible orders include:

  • S7 etc. (Talker A is introduced with a target rather than with a filler.)
  • S1, S8, S9 (Talker B is introduced with a target rather than with a filler.)

Any suggestions? Thanks for your time and effort!
Jan

Comments

  • edited February 2018

    Hello,

    I haven't fully implemented the following solution in OpenSesame yet, but this Python code generates lists that satisfy the constraint (see OP):

    # This script generates a pseudorandom order of stimuli.
    
    # We need the shuffle function from the random library.
    from random import shuffle
    
    item_list =     [("S1", "A", "filler"),
                     ("S2", "A", "filler"),
                     ("S3", "B", "filler"),
                     ("S4", "B", "filler"),
                     ("S5", "C", "filler"),
                     ("S6", "C", "filler"),
                     ("S7", "A", "target"),
                     ("S8", "A", "target"),
                     ("S9", "B", "target"),
                     ("S10", "B", "target"),
                     ("S11", "C", "target"),
                     ("S12", "C", "target")]
    
    # Restrictions on randomisation:
    # - The first stimulus for each talker (second column) needs to be a filler.
    
    # Pick the first stimulus. This needs to be a filler.
    items_notpicked = item_list
    
    # Only retain the stimuli that may be picked, viz., filler items
    under_consideration = [row for row in items_notpicked if 'filler' in row[2]]
    # Shuffle these and take the first item
    shuffle(under_consideration)
    items_picked = [under_consideration[0]]
    
    # Remove the items picked from the available items, i.e., only
    # retain a row if it doesn't contain the sentenceID.
    sentences_selected = [i[0] for i in items_picked]
    talkers_selected = [i[1] for i in items_picked]
    items_notpicked = [i for i in items_notpicked if not i[0] in sentences_selected]
    
    for items in range(len(items_notpicked)):
    # only consider filler items or sentences from talkers already selected
        under_consideration = [row for row in items_notpicked if ('filler' in row[2]) or (row[1] in talkers_selected)]
    # shuffle, take the first one, append to item list
        shuffle(under_consideration)
        items_picked += [under_consideration[0]]
    # update sentence and talker lists
        sentences_selected = [i[0] for i in items_picked]
        talkers_selected = [i[1] for i in items_picked]
        items_notpicked = [i for i in items_notpicked if not i[0] in sentences_selected]
    

    A couple of runs produced lists such as these:

    [('S5', 'C', 'filler'),
     ('S3', 'B', 'filler'),
     ('S9', 'B', 'target'),
     ('S11', 'C', 'target'),
     ('S4', 'B', 'filler'),
     ('S6', 'C', 'filler'),
     ('S12', 'C', 'target'),
     ('S10', 'B', 'target'),
     ('S1', 'A', 'filler'),
     ('S8', 'A', 'target'),
     ('S7', 'A', 'target'),
     ('S2', 'A', 'filler')]
    
    [('S5', 'C', 'filler'),
     ('S2', 'A', 'filler'),
     ('S4', 'B', 'filler'),
     ('S1', 'A', 'filler'),
     ('S12', 'C', 'target'),
     ('S9', 'B', 'target'),
     ('S8', 'A', 'target'),
     ('S11', 'C', 'target'),
     ('S7', 'A', 'target'),
     ('S10', 'B', 'target'),
     ('S3', 'B', 'filler'),
     ('S6', 'C', 'filler')]
    
    [('S6', 'C', 'filler'),
     ('S12', 'C', 'target'),
     ('S4', 'B', 'filler'),
     ('S5', 'C', 'filler'),
     ('S9', 'B', 'target'),
     ('S11', 'C', 'target'),
     ('S2', 'A', 'filler'),
     ('S3', 'B', 'filler'),
     ('S1', 'A', 'filler'),
     ('S10', 'B', 'target'),
     ('S8', 'A', 'target'),
     ('S7', 'A', 'target')]
    
  • Quick follow-up:At the end of the inline script, I've now added

    global sentences
    items_picked.reverse() # the "pop" method used later works from the back to the front,so just reverse the list here
    sentences = [i[0] for i in items_picked]
    global talkers
    talkers = [i[1] for i in items_picked]
    

    Then I used an inline script before the trial presentation with the following content:

    global sentences
    current_sentence = sentences.pop()
    global talkers
    current_talker = talkers.pop()
    
    exp.set("my_sentence", current_sentence)
    exp.set("my_talker", current_talker)
    

    my_sentence and my_talker can then be used in the trial's sketchpad.

    This seems to do the trick. Hopefully this is useful to other users. Thanks again for developing OpenSesame!

  • Hi Jan,

    nice that you sorted things out yourself. I haven't looked at your code in detail, but just a few small remarks.

    1) It shouldn't be necessary to declare your variables as globals. All the inline_scripts share a common workspace

    2) In a comment you say: # the "pop" method used later works from the back to the front,so just reverse the list here. Actually, you can specify which item should be popped from a list. The default value is -1 I believe, but if you pass 0 it will pop from the beginning.

    3) exp.set("my_sentence", current_sentence) can be replaces with var.my_sentence = current_sentence

    Hope this is a little useful to you.

    Good luck,

    Eduard

    Buy Me A Coffee

  • Very much so, thank you!

Sign In or Register to comment.