Hi Katie,
> My trial will be: step 1: display a picture until keyboard response, step 2: keyboard response (was the picture in the original or not - y/n)
> my picture stimuli are small cutouts from larger pictures, 36 are from the original and 36 are from a different picture by the same artist. I want to display a random 10 of the 36 original cutouts, and a random 10 of the 36 cutouts from another picture.
> Congruence refers to whether they were in the original picture or not (original picture = consistent, other picture = inconsistent) - I only added this because I used the Navon task demo as a base for this experiment, so perhaps in my case it is not needed.
> corrAns refers to the key that the participants should press to give a correct answer on whether the picture has already been seen: y for yes, n for no.
That is now very clear: we need to sample randomly from your picture filenames but also retain a balance between consistent and inconsistent. In essence, we need a Code component that will run at the start of the experiment. It will do this sampling and balancing, and then write out a new conditions file on every run of the experiment. It is this custom-created conditions file that you will point your loop to.
You should create two separate CSV files, containing the filenames and a consistency value. Each will be 36 rows. Call them, say:
consistentPictures.csv
inconsistentPictures.csv
The first would look like this:
picture,corrAns
1.png,y
2.png,y
etc
And the second like this:
picture,corrAns
36.png,n
37.png,n
etc
Then add a Code component to your trial routine. In the "Begin experiment" tab, paste something like this (NB THIS IS ENTIRELY UNTESTED CODE):
# read in the conditions:
newConditions = [] # define an initially empty list
for fileName in ['consistentPictures.csv', 'inconsistentPictures.csv']:
conditions = data.importConditions(filename) # create a list of dictionaries
shuffle(conditions) # randomise their order
conditions = conditions[0:9] # select just ten of them
newConditions.append(conditions)
# will end up as 20 randomly selected but balanced-for-consistency trials
# write out the conditions for this run of the experiment
header = newConditions[0].keys() # get the header labels
with open('newConditionList.csv','w') as file: # create a new CSV file
output = csv.DictWriter(f, header) # arrange to write our dictionaries to it
output.writeheader()
output.writerows(newConditions)
You should now have a file called newConditionList.csv, containing 20 rows of filenames and corrAns values. Put that filename in your loop, and set it to run randomly.
> The actual conditions of my experiment are eye movement vs no eye movement, and pictures vs words, but as they are between factors, the words condition will be a separate experiment file, and I will probably create the eye movement on another program, as i do not know how to make a moving dot on Psychopy.
That should be straightforward in PsychoPy (it's what I mainly use it for).
Regards,
Michael