Limiting the number of presentations of the stimulus in a stimulus set
Hello everyone,
I present a total of 5 stimuli in each trial from the high_arousal list and 1 stimuli from the neutral list in an invisible circle. My goal is to have a total of 12 trials. There are 30 photos in the high_arousal list and 12 in the neutral list. For the high_arousal list, each photo needs to be presented 2 times in total. In the Neutral list, I want the stimulus once presented and not to be presented again. I wrote various codes for this, but the codes I wrote do not work. I would be very grateful if you could help me to understand and solve the problem in my code. Since the experiment file is large, It is attached it with the Google Drive link.
Thanks in advance.
selected_high_arousal_images = []
limit = 2 * len(high_arousal)
completed_trials = 0
def select_high_arousal_image(high_arousal, selected_images, limit):
available_images = [img for img in high_arousal if img not in selected_images]
selected_image = random.choice(available_images)
selected_images.append(selected_image)
if selected_images.count(selected_image) > 2:
selected_images.remove(selected_image)
if len(selected_images) > limit:
selected_images.pop(0)
return selected_image
def select_neutral_image(neutral, selected_images):
available_images = [img for img in neutral if img not in selected_images]
selected_image = random.choice(available_images)
selected_images.append(selected_image)
return selected_image
while completed_trials < 12: # 12 deneme tamamlanana kadar döngü devam eder
selected_high_arousal_images = []
selected_neutral_images = []
# High arousal fotoğraflarını seç ve işlemleri yap
var.img2 = select_high_arousal_image(high_arousal, selected_high_arousal_images, limit)
var.img3 = select_high_arousal_image(high_arousal, selected_high_arousal_images, limit)
var.img4 = select_high_arousal_image(high_arousal, selected_high_arousal_images, limit)
var.img5 = select_high_arousal_image(high_arousal, selected_high_arousal_images, limit)
var.img6 = select_high_arousal_image(high_arousal, selected_high_arousal_images, limit)
# Neutral fotoğraf seç ve işlemleri yap
var.img1 = select_neutral_image(neutral, selected_neutral_images)
completed_trials += 1
https://drive.google.com/file/d/1gtaGi76M6_cCewP6sCgXhR9FrVss_j3D/view?usp=sharing
Comments
Hi @bssengul,
If I understand your design correctly, a simpler method would be to create a matrix where you store the names of the 60 (30x2) high arousal picture, shuffle it, then read from that matrix on every trial. Same idea with the 12 neutral pictures. Saves you from having to count how many times each picture has been used.
Best,
Fabrice.
Thank you, I also thought about it but it creates probability of showing same images in a same trial.
Hi @bssengul,
You're right, this is a slight difficulty, but it can be addressed using code making shure that the shuffling is repeated until there no repetition of the same high arousal picture among successive groups of 5 elements. Here's some Python code that does just that. Once the higharousla list is produced, then you just have to keep a counter going in your trial sequence to pull out the elements from that list as the task progresses, and you shouldn't get any repetition of the same picture with the same trial.
Hope this helps,
Fabrice.
Thank you much! I appreciate your help.
Best regards,
Beril