Experiment coding help
Hi everyone.
As the title suggests I need a bit of help when it comes to creating my experiment and I am stuck in two places trying to write the code to do it.
One of my independent variables is set size between 5-8 where I want a sketch pad item to draw uniformly sized red circles that corresponds to the set size in random positions on the screen. So if the set size is 6 then 6 red dots will appear for 0.5 seconds.
The other area I am stuck is as follows. In my experimental condition another IV is whether the another sketchpad item is correct or not. The outline for the experimental condition is that the red dots will appear and then after a sketchpad item will say if it was odd or even with it either being correct or incorrect. So is there a way to make the vague, butchered idea of code below work for the 4 condition iterations?
if var.set_size = 5,7 and var.computer_correct = incorrect
show.sketchpad_item 'Even'
if var.set_size = 6,8 and var.computer_correct = incorrect
show.sketchpad_item 'Odd'
if var.set_size = 5,7 and var.computer_correct = correct
show.sketchpad_item 'Odd'
if var.set_size = 6,8, and var.computer_correct = correct
show.sketchpad_item 'Even'
P.S. as you can tell I'm not that familiar with coding but I really want to learn and I hope you can help
Comments
Hi,
This is a support forum. Being here in first place suggests that you need help. Please try to make more specific titles in future. Like that it will be easier for other users to find already existing solutions to their problems.
never late to start learning. Here we have provided a few links to improve your python skills: http://osdoc.cogsci.nl/3.1/manual/python/about/
As for your problem, a set size manipulation is a little annoying to implement with
sketchpad
s (not impossible though). The trick is to manipulate theshow_if
field for item 6/7/8 only to be true if the setsize is 6/7/ or 8. But then you have also to control the location on the screen and probably do some randomization. So, not very easy. I would recommend you try to implement your experiment with aninline_script
. Opensesame comes with example scripts (Tools --> examples). Some of them use python coding (e.g. the Theeuwes ask has even a set size manipulation), so you could try to use those approaches to apply to your problem (and learn coding in the mean time).Once you have this done, your second problem will be a piece of cake. The logic of your pseudocode looks fine, you would just have to implement it properly, for which you need to know some coding.
Is this enough information to get you started? I recommend you give it a try, even if it seems hard in the beginning you will gain much from it, and of course whenever you get stuck, we can help out.
Good luck,
Eduard
Hi Eduard, thanks for the help, I appreciate it.
I've learnt some basic python and I've had a go at using inline_script for drawing the red circles but I'm not getting very far. I can write the code to draw one circle in a fixed spot but I'm stuck on drawing more than one circle in random positions. I feel like I know the code for each one roughly, it is just integrating them all together in a way that python is able to run.
Do I have to define a new function to draw the variable then add it to code to create more than one red circle in random locations or am i getting the wrong end of the stick entirely?
wait. never mind I just had a eureka moment and I've managed to get it the red dot set size working.
On separate notes how do you make it so that the array generated in the inline_script only appears for a certain amount of time. would it be the clock function?
Also, can you use inline_script to "call" things from the file pool?
I have been beavering away and managed to generate some script to show it for a certain amount of time using a sleep and blank canvas method.
The last thing i need help with is writing my pseudo code properly so as to include drawing the red shapes as well. Would I have to define a new variable such as draw_circle and then add the correct pseudo code to that? Any help in the pseudocode would be most appreciated.
Thanks
Yes.
clock.sleep(1000) # sleeps for 1 seconds
Yes.
path = exp.pool[u'image_in_pool.png']
In general, you should have a look at our documentation. It gives plenty useful information about using Opensesame in different ways: http://osdoc.cogsci.nl/3.1/manual/python/canvas/
I don't quite get this question, but if you check out the documentation, I think you could find an answer. Alternatively, try to rephrase please.
Eduard
Hi Eduard, thanks for the help so far.
In terms of trying to rephrase the question I'll show you the code I have thus far and hopefully that gives an idea of what I want to do. The code is in the attached picture. In general I'm trying to show the word odd or even after displaying a random array of red dots. But the word odd or even is going to be wrong for some of the trials.
print is not showing anything on a canvas, but only in the debug window. You have to use canvas.text() to present a word on a canvas: http://osdoc.cogsci.nl/3.1/manual/python/canvas/#function-canvas46text40text-centertrue-xnone-ynone-max95widthnone-4242style95args41
Eduard
I've managed to get it working now.
I just want to say a massive thank you for the help and also creating such an amazing piece of software for free, it's absolutely amazing. Thanks