[solved] Use the images with highest mean score in likert scales in a experiment
I open a second topic because this question is quite different:
I have another question about my project. I will do the Visual pro task, for this I want to use 10 images of food (5 healthy and 5 unhealthy).
The first thing I want to do is to ask to the child 2 questions about 50 images:
- "To what extent you think this food looks attractive?" "not at all (likert scale) very much"
2 . "To me, this food is a temptation, difficult to resist eating it?" strongly disagree (likert scale) strongly agree
The second thing is, I would like that the software use the 10 images with highest mean score in the visual probe, automatically.
Is it possible?
I did not find any software yet possible to do it, and my supervisor advised to try OpenSesame.
Many thanks in advance,
Cheers,
Sandra
Comments
I don't know of any software you could use within OpenSesame, but there's always the option to use an inline_script (where you can use Python code to do whatever the heck you want).
Firstly, I think it'd work best if you were to name your pictures with a number (e.g. 0.bmp, 1.bmp, 2.bmp, ..., 49.bmp). After naming 'em correctly, you add your images to the file pool.
Next up, you can set up a loop-item, running a sequence. In this loop-item, you create a variable called 'picname' (or something similar). You set 50 cycles. In each of the rows you type in one number, starting from 0 and moving all the way up to 49.
Third, you add a sketchpad and a rating_scale to the loop's sequence. In the sketchpad, you click on the Image Tool, click on the place where you want to present your images (probably the middle of the sketchpad) and select the first image. You'll notice this image is now being presented on your sketchpad and if you were to run your experiment now, this very same image would be presented 50 consecutive trials.
Luckily, we have already set up a variable named 'picname' and we're going to use it to present a new picture. In the sketchpad, press the 'edit script' button. You'll notice a line saying this:
To present a different image each trial, change it to this:
So far so good, it's quite likely you already knew it could be done like this. But here's the thing: in Python, you can use numbers to address values stored in variables. Example: we have a variable named 'banana', which 'stores' the values 1, 2 and 3 (in Pyhon, this would be written as 'banana = [1,2,3]'). Now, if we would like to know what value is stored on the second place in 'banana', we can call 'banana[1]'. This would produce the answer 2. Notice how you call banana[1] for the 2 position. This is because Python starts counting at 0. That's exactly why we have begun counting at zero too, by the way! Were going to use inline scripting to store scores for the pictures, using a single variable 'score', with 50 positions containing the individual scores per picture.
After this, I'm going to ask you to add some code into inline_scripts. In this case, always do so within the 'run phase'!
To do so, insert an inline_script all the way to the beginning of the experiment. In this inline_script, type:
global scores # this is so our variable is callable throughout the entire experiment scores = {} # sets up an empty dictionary for picturenr in range(50): # runs for fifty times scores[picturenr] = 0 # adds a zero to our scores on every runThis creates a dictionary (a kind of list, to be short) containing fifty 0's.
Now, add an inline_script to your loop's sequence, right behind the rating_scale. In this one, you type:
global scores # this is so our variable is callable throughout the entire experiment scores[self.get("picname")] += int(self.get(“response”)) # this adds the response score to the total score for this particular pictureIn the main sequence (NOT in the loop's sequence!), behind the loop-item, add yet another inline_script. In this one, the actual sorting will take place:
global scores sortedscores = sorted(scores,key=scores.__getitem__, reverse=True) # sort our pictures, based upon the scores pictures = sortedscores[0:10] # select the first ten pictures self.experiment.set("picture0",pictures[0]) self.experiment.set("picture1",pictures[1]) self.experiment.set("picture2",pictures[2]) self.experiment.set("picture3",pictures[3]) self.experiment.set("picture4",pictures[4]) self.experiment.set("picture5",pictures[5]) self.experiment.set("picture6",pictures[6]) self.experiment.set("picture7",pictures[7]) self.experiment.set("picture8",pictures[8]) self.experiment.set("picture9",pictures[9])Lastly, insert another loop on the main sequence, right behind the last inline_script. In this loop, create a variable called 'picture' and set the number of cycles to 10. In the first row, type [picture0]; in the second row, type [picture1]; in the third row, type[picture2]; etc.
Then, in add a sketchpad to the sequence of your newest loop, press the 'edit script'-button and type the following:
Now, you should be set to go! Of course, you probably want to add some loggers, an introduction and maybe some instructions in between, but that's up to you!
Good luck!
Edwin