| Reference | Downloads | Github

Complex randomization of different stimuli categories, learning - recognition task

**OS X El Capitan Version 10.11.6
**PsychoPy2 v1 1.85.6
**Standard Standalone? yes

What are you trying to achieve?:

My procedure has 2 parts:

  1. learning phase: 100 images of 5 different categories are presented (20 of each category) in random order; after each image question is presented (“Did the image contain an animal?”; answers [Y/N])
  2. recognition phase: 100 images are presented in random order (50 old images, already presented in learning phase <10 of each category> and 50 new <10 of each category> ); after each image the rating scale is presented <with values 1 - 6>.

Pictures in both phases should be randomize with keeping 2 conditions: category proportions and old/new status (in recognition phase)

What did you try to make it work?:

I have tried 2 options:

  1. I created exel file with 4 variable’s values: image, animal_correct ans, category.

Each picture ($ImageItem) is presented in study trial one by one:

I add Code Component at the beginning of the experiment (code_random). The code randomize the images order.

Begin Experiment

import random, xlrd

#randomize the seed

#stimulus File
infile ='image_stimuli_file.xlsx'

#num of study items
num_study = 100

#num of test items
num_test = 100

#total num of items
num_items = 150  

Begin Routine

#access the xls the stimulus file
inbook = xlrd.open_workbook(infile)
insheet = inbook.sheet_by_index(0)

#arrays for our stimuli
image= []
animalOdp= []
category= []

#read the stimuli from our sheet
for rowx in range(1, num_items+1):
    #read in the values of all columns on this row
    row = insheet.row_values(rowx)

    #print out the value of the column A for this row
    #print row[1]

    #saving the image to the image array

#create an image item list
stim_order = range(num_items)

#randomizes the order of the image array

#arrays for our final stimuli
image_item = []
old_new = []
animal_odp = []
category = []

#create in final stimulus list
for i in range(num_test):

    #assign an image item from an item list

      #determine the old/new status of items
    if i < 100:

I add Code Component also before the study trial (studyCode) in a study_loop:

Begin Experiment

#create a list of the order in which to show study items
study_order = range(num_study) 

#randomize the order of study list items 

#current study trial
study_trial = 0 

Begin Routine

#assigning the study item
ImageItem = image_item[study_order[study_trial]]

#increment the current study item counter
study_trial = study_trial + 1
  1. I created exel file - each column represents each category; each row is one trial (with 5 different categories). But give up this option as the first seems to work better.

What specifically went wrong when you tried that?:

Where I’ve got stuck:

  1. In option 1 I can’t figure out how to set proper category proportions in StudyTrial (to show 20 images of each category). Shall I add something to Code Component just before study trial or all my construction is wrong?

  2. Could you give me any hints how to present 50 old (10 of each category) and 50 new items (10 of each category) in TestTrial ?

I would really appreciate any advice on this.