Howdy, Stranger!

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

Supported by

Mixed RSVP (letters and pictures)

Hi all,
How can I use the inline script to create
1.a list that contains 20 pictures from class1 , 20 pictures from class2, and 20 letters (RSVP(60)).
2.run the RSVP randomly with T1 always a picture ( from class 1 or 2 ), and in between T1 and T2(letter), only letters.
3.T2 appears in 3 possible places, and 3 possible lags.

Gily

Comments

  • Hi Gily,

    Try that:

    import random
    
    # First step define the stimulus list
    # define the stimuli, either by hand or in a different way
    pic_1 = ['class1_1.jpg','class1_2.jpg','class1_3.jpg']
    pic_2 = ['class2_1.jpg','class2_2.jpg','class2_3.jpg']
    letters = ['a','b','c']
    
    # shuffle each list
    random.shuffle(pic_1)
    random.shuffle(pic_2)
    random.shuffle(letters)
    
    # I just set the indices where the target should appear by hand. If you have variable for that, use that one
    no_trials = 9 # no stimuli
    t1_idx = 3
    t2_idx = 6
    no_items_inbetween = (t2_idx-1) - t1_idx # how many items between the targets?
    
    stimuli = []
    stimuli.append(random.choice([pic_1,pic_2]).pop()) # choose T1
    for i in range(no_items_inbetween):
        stimuli.append(letters.pop()) # add the intermediate letters
    stimuli.append(letters.pop()) # add the target 2
    
    rest_stimuli = pic_1 + pic_2 + letters
    random.shuffle(rest_stimuli)
    # add the stimuli before target 1
    for i in range(t1_idx):
        stimuli.insert(0,rest_stimuli.pop())
    # add the stimuli after target 2
    for i in range(len(rest_stimuli)):
        stimuli.append(rest_stimuli.pop())
    
    # now stimuli list is finished
    stimuli_container = [pic_1,pic_2,letters]
    
    # second step draw these stimuli on canvas
    canvasses = [] # prepare a list for all the canvasses
    
    for i in range(no_trials):
         cv = canvas()
         if '.jpg' in stimuli[i]: # check if it is an image or a letter
              cv.image(exp.pool[stimuli[i]],x = 0, y=0)
         else:
              cv.text(stimuli[i], x= 0, y= 0)
         canvasses.append(cv)
    
    ## 3. step: present them
    
    for cv in canvasses:
         cv.show()
         clock.sleep(20)
    
    

    I haven't tested the code, there might some typos be in there, but the general logic should bring you places, I hope. Let me know if anything is unclear.

    3.T2 appears in 3 possible places, and 3 possible lags

    What do you mean with places? locations on the screen? Then manipulate the x and y of the letter.

    Best,
    Eduard

  • HI Eduard,
    WOW:) YOU ARE A KING
    ."places"=position in the RSVP.
    I'll work on it and update you
    many thanks!!
    GILY

Sign In or Register to comment.