Hi all,
I’m completely new to PsychoPy (and any sort of coding), and would really appreciate any sort of help!
My experiment is recall memory test.
The design is a within-subjects design, where participants will be shown images across 4 different task instructions (blocks). These images vary based on whether they are low in number of objects or high in number of objects. There will be 16 trials in each block, where each trial is the display of an image. Each block will show a total of 8 ‘low’ images, and 8 ‘high’ images. I have a list of 32 images for ‘low’ and a list of 32 images for ‘high’, in total.
I would like to vary the block order so that it is counterbalanced, and also would like to use all 64 images once only in the entire experiment, but randomise the order in which it appears to each participant while still maintaining the structure of 8 ‘low’ images and 8 ‘high’ images per block.
Therefore, I would like to present 16 images in each block, randomly choose 8 out of the 32 images from the ‘low’ object file, and 8 out of the 32 images from the ‘high’ object file, without using the images again in a later block.
After sifting through the forum, the closest solution i could find was how to create a new condition file for each run. However, this meant that the same 16 images after being randomly selected from the 2 files would be shown across all blocks, just in a random order.
This is the code in question:
import pandas as pd
fileName = ['LowVSTM.csv', 'HighVSTM.csv']
conditionFile = pd.DataFrame(columns=['painting']) # where 'painting' is the column name for your images
for files in fileName:
myDat = pd.read_csv(files) # Get conditions file
myDat = myDat.sample(frac=1).reset_index(drop=True) # Shuffle the dataframe
myDat = myDat.head(8) # Take first 8 rows from sheet
conditionFile = conditionFile.append(myDat) # Append to new conditions file variable
conditionFile.to_csv("randPainting.csv", index=False) # Save to new csv file for use in the loop handler.
(from Randomly Select from Multiple Conditions files)
Can somebody please point me on the right track and let me know if my design can even use this code?
Please let me know if further information is needed to clarify this as well.
Again any help will be greatly appreciated! Thank you!
Alice