| Reference | Downloads | Github

Selection and randomization of items in a SC-IAT

Hello! I am trying to build a SC-IAT by using psychopy, but I got some problems in randomizing the word items to present maintaining the proportion (i.e. in the first block with 7 positive_items, 7 name_items, 10 negative_items).

First, in the excel file I used only one column for word stimuli, where I wrote all together positive, negative and name items maintaining the proportion (so 7:10:7) and asked Psychopy to randomize the order and to show only one time the list in the first block.
That worked but it is not the randomization that I actually want. I would like to have a pull for each type of words in which there are a variable number of positive, negative and name words and ask the program to choose randomly only 7 positive and name_items, and 10 negative_ items and to show them in a randomized way.

I tried also in another different way, by using code. But no results and other problems
One code object in a start_Routine, where I uploaded the stimuli

##Import stimuli exemplars
exemplars_filename = 'stimuli.xlsx'
exemplars = data.importConditions(exemplars_filename) # Import stimuli exemplars

##Trial generation function
def generate_trials(trial_type_column, multiplier):
        a = dict()  # declare a dict to be populated
    for i in range(len(exemplars)):
        a[i] = [exemplars[i][trial_type_column]] * multiplier  
    a = a.values()  
    a = list(itertools.chain(*a))  # flatten the list of dicts into a list
    return a

A code in the test_Routine

##set the block length and the rows to pull from based on the current block 
if blocks.thisN == 0:
    trial_rows = "0:3"  # first row: name word, second: positive word, last: negative word
    n_block_repeats = 5   #5*3 = 15 trials 
    modified_list_multiplier = list_multiplier

In this way I could not maintain the proportion, because it shown 5 items each type of items

I would like to set something like

blocks.thisN == 0:
    trial_rows = "0"  # first row: name word
    n_block_repeats = 7
    modified_list_multiplier = list_multiplier
    trial_rows = "1"  # first row: positive word
    n_block_repeats = 7
    modified_list_multiplier = list_multiplier
    trial_rows = "2"  # first row: negative word
    n_block_repeats = 10
    modified_list_multiplier = list_multiplier

But obviously I can’t.

Hi. Can you explain a bit more of your design? e.g.

  • how many total words will be presented?
  • how many words will those be sampled from?
  • how many blocks will those trials be divided into?

You are probably right that this scheme would take code to implement, perhaps just creating a conditions file at the start of the experiment for Builder to use. It would probably be easiest if you could read the three types of words into three separate lists to work with.

Hi Michael,
I found a solution in excel, creating a second sheet in which I wrote three columns of items (variable number of items, one column for positive, one for negative and one for names). I used index and randbetween function and it worked.

But I’m curious and I would like to practise using code, so any suggest could be very useful.

  • there are four blocks: 24 items training, 74 items test, 24 items training and 74 items test, in the last two I changed the key for name items.

  • in the first block, I need 7 positive items, 7 name items and 10 negative items; in the second one 21 positive items, 21 name items and 30 negative items; in the last two the same, but this time 10 positive items, 7 name items and 7 negative items.

  • items are sampled from a variable pool of words (we can assume a pool of 20 positive/negative/name words, but it’s not important)

An example of the design

Block; Trials; Function; Left-key response; Right-key response;
1; 24; Practise; Positive and Name; Negative;
2; 72; Test; Positive and Name; Negative;
3; 24; Practise; Positive; Negative and Name;
4 ; 72; Test; Positive; Negative and Name;