I am creating an experiment wherein I use lists of words, which are created and checked using a code component. The end result is a list with 180 words per condition to be used across the experiment.
I then have a set of counterbalance excel sheets with the nReps of each block. Each block shows 60 of the words.There are 4 conditions (with accompanying lists) and each block is shown 3 times.
I am having two issues.
The first being, that the block does not move onto the next set of words. For example it uses the first 60 words, but when that block appears again it starts back from the first word, rather than word 61. I have tried to combat this by using .pop(0) to remove the words from the list as they’re used.
I believe this has caused the second problem, where I am getting the list index error. It runs fine until it gets to the 3rd block of a condition. Using print statements, the length of the list at this point is 60 (enough to run the block). When the count gets down to a length of 30, I get the index error. It’s confusing me as the list still has 30 words available.
I am using this code in a text component to display the words from the list
$word[block1_loop.thisN]
I’m not sure if the error is with the counterbalance, or with how I am removing words from the list.
When you use pop the list gets shorter. If I understand you correctly you have a list of 60 words and on each iteration you use one near the beginning and delete one from the end. After 30 iterations you now have a list with 30 items and you are asking for the 31st item.
I am using .pop(0) to delete the word from the start of the list rather than the end. I have also tried del word[0] but found I was having the same error.
I’ll try reworking the .pop() command and see if that works.
I am making the list shorter on purpose by removing the first item in the list so that it cannot show up again. This issue is that I get the index error as soon as there are 30 items left, even though it could run through those 30 items and finish the block.
I am wondering if there’s another way to work it. For example if I have:
list = [1,2,3…180]
The first 60 will show 1-60. It moves to the next block etc. When it moves back to using that list it currently uses 1-60 again. Is there a way to get it to move on without using pop or del?
I don’t think your solution will work just because of how the experiment is setup. I’ve attached a screenshot below.
There are multiple lists involved. Because of this it doesn’t work well with excel sheets which is why I have made the lists using code. The list items for the target are different to the rest, but also need to be randomised, so coding it was simpler.
The experiment itself runs completely fine up until the index error. I just don’t know why there’s an index error, when there’s still list items available to Python to pull from.
Anyway, you seem to be reusing routines, nonword_word, pseudoword_word etc., which may indicate that you are working against the design principles of PsychoPy. Having multiple routines makes it much more difficult to debug the experiment and to analyse the data, as the variables collected in each routine all go into their own column in the data file. Try to use as few routines as possible.
But I do not know enough about your experiment to be sure.
There is no such loop in the flow you posted. Where is it?
I guess you need to show us how you created the lists, randomized them and assigned them to stimuli.
Was just from trying to test a smaller version of the experiment.
The multiple routines are fine for what we need it for, as each one contains a different set of lists.
I create the lists by:
words = [word1,...]
nonwords = [nonword1...]
shuffle(words)
shuffle(nonwords)
#Create empty lists for NWW condition
nwwdis1=[]
nwwdis2=[]
nwwdis3=[]
nwwdis4=[]
nwwtarget=[]
#Create list population for NWW
nwwdis1 = nonwords [0:180]
nwwdis2 = nonwords [180:360]
nwwdis3 = nonwords [360:540]
nwwdis4 = nonwords [540:720]
nwwtarget = words [0:180]
Then a similar process for the other blocks. Except pww uses words[180:360]. nww is where the index error occurs, however I believe this is just because it’s the first one to be shown for the third time.