[solved] Choosing items based on values of a variable
Hey everyone,
I am still new to OpenSesame, so sorry if my question is silly!
In my procedure I am prerating 48 stimuli on the scale from 1 to 9 and wanted to choose only 12 stimuli which I will show in the next loop. The condition here is that the 12 stimuli I want to pick will be rated as closest to the value 5 on the scale from 1 to 9 as possible and have no idea how to do it.
#I set a dictionary for preratings
ratings = {}
#I am presenting the stimuli from the list 'CS.txt'
CS_item = CS.pop()
exp.set('CS_item', CS_item)
#Then, I get the ratings here
ratings[self.get("CS_item")] = self.get("response")
# I sorted them according to the ratings
sorted_ratings = sorted(ratings, key=ratings.get)
And here I am stuck...does anyone have an idea how to select only 12 stimuli that were rated as closest to the value 5 as possible on the 1-9 point scale?
Would really appreciate any feedback.
Thank you in advance!
Cheers,
Bori
Comments
Hi Bori,
If you have your list with ratings, you can subtract
5from each of them. What you get is a new list with values distributed between -4 and 5 centered around 0. Next, you can take the absolute values from each of those ratings and sort them. What you get is a list with the ratings sorted by their distance from 5 (from small to big).Does this help?
Eduard
Hi Eduard,
Thanks a lot!
I did exactly that and worked out perfectly!
Many thanks ☺️
Cheers,
Bori