[Solved] Mouse : how to collect plural mouse response in one sequence
Hello,
Well, I'll try my best to be clear as possible. I'm sorry for the english that will follow !
So, we -our team on the project- want to make an plural modal-sensoriel experiment. We have 6 round items display in a circle like this :
where color are display (here black) randomly on the 6 items, one by one each 300ms, 5 times for the first sequence, 6 times the second to 10 times for the fifth sequence.
So what we want to do is, after the first sequence display, people can click on the items who have been colored and they have to do it in the right order. When they clicked on 5 items, it goes to the second sequence. Then for the second they'll have to click on 6 items to go on the third etc.
For the display of color that's ok, but I don't know how to do with mouse_responses.
I want to do something like this :
After the color displayed, it's time to the people to click on the right order of each item who colored. So when they click on an item, a counter save the click (if people click somewhere else, that doens't count), so that when it requires 5 click the counter will compare to it and let the experiment goes to the second sequence.
But I don't know how can click can be count when it click on a item or not.
Here was my first try, where I wanted button_cliked to dis-increment after clicks.
from openexp.mouse import mouse
from openexp.canvas import canvas
button_cliked=5 #(click available)
my_mouse = mouse(exp, visible=True)
my_canvas = canvas(exp)
while True:
button, position, timestamp = my_mouse.get_click()
if button != None and button_cliked==0:
break
pos, time = my_mouse.get_pos()
my_canvas.fixdot(pos[0], pos[1])
x, y = pos
my_canvas.clear()
if my_mouse.get_click()== True:
button_cliked=-1
my_canvas.text(button_cliked, y=50)
my_canvas.text('The cursor was at (%d, %d)' % (x, y), y=60)
my_canvas.show()
So if I want to do what I told before my first try, in order to calcul if the click is on an item or not, should I use canvas? "draw circle"? or widget but just after presentation, when asking people to click?
Here is the experiment; I put the code you saw on the ___inline_script.
Is there a way to do this?
Thanks a lot,
Sincerely
Zalian
Comments
Hi Zalian,
Thanks for taking the time to explain your problem clearly and in detail! That's really helpful, for me as well as for other people who may be facing the same problem.
Below you see a script that collects 5 mouse clicks, while checking whether these clicks are sufficiently close to a list of target positions. Although you'll probably want to tweak some aspects of the script, this is essentially what you need, right?
I have added code comments to explain what the script does, so please take a good look at those and try to figure out the logic of the script. Looking at your script above, you already know a bit of Python, so this shouldn't be too difficult.
Cheers!
Sebastiaan
Check out SigmundAI.eu for our OpenSesame AI assistant!
Dear Sebastian,
Sorry for answer so lately, but better late than never !
Thanks a LOT for your help. I understood everything and the code works properly.
We have now an other problem. We want sound to be play in same time a circle is colored, but I don't really know how to make the architecture...
I tried like this
So I change the sequence repeat to 1 and manually attribute color on one circle in each sketchpad like black grey grey grey grey grey for the first sketchpad and grey blue grey grey grey grey for the second etc.
But the sound is not sync with the displaying of a color...
How can I do it? I heard about PyAudio but that's sound difficult...
I'm sorry, I'd maybe rather made an other topic?
Thanks a lot again Sebastian !
Zalian
Hi Zalian,
In principle, this should work. If you find that sound is lagging, which is indeed a known problem, then you can try tweaking the sampler-back-end settings (General tab → Back-end settings → Sampler). Notably, reducing the buffer size, sampling frequency, and sampling size should reduce temporal jitter, although it also increases the risk of sound distortions. (It's a trade-off.)
What kind of temporal accuracy are you aiming for? If a jitter of something around 30 ms is acceptable, then you should probably be fine.
Cheers,
Sebastiaan
Check out SigmundAI.eu for our OpenSesame AI assistant!
Hi Sebsatiaan,
Thanks for your help again !
We find a solution much better : the parallel function that can execute plural item in one time !
A new problem appear, with the inline_script.
We would like to save the order people clicked on each circle. So here what I did :
But I don't know why, I can't execute the code !!! The blue dotted line appear like this and make my code bug....... How can I fix it??
Thanks again
Well I'm back. I tried with the new version 2.8.0 but it wasn't working either...
So I just re-write all my code without copy/paste and it's now working. But that's very tiresome anyway !
PS : I saw somewhere that they were indent problem with MAC. I'm on windows 7, just to say.
Hi Zalian,
You cannot mix and match tab-based indentation and space-based indentation in Python. If you do, for example by pasting a script from a webpage, you'll get a syntax error like the one you're seeing.
This is inherent to Python and not a bug in OpenSesame. It is a bit annoying though, but what you can do, for example, is replace all occurrences of four spaces with a single tab using the search-replace function in OpenSesame (or another editor).
Cheers!
Sebastiaan
Check out SigmundAI.eu for our OpenSesame AI assistant!
Hello !
My bad Sebastiaan. I had tried to use the replace function as you say but still didn't work.
Our program is now working but there's still one problem which is actually pretty annoying.
I put logger at each end of modalite (you can see below the first modalite), but it didn't write any count time.
I also upload the .cvs that you can see how the log have worked.
http://demo.ovh.eu/fr/09b0cb047a07edcc81f309e1d98d0108/
I tried only with the 1ere_modalite and put other in "never", but I can see that the logger save everything, also others who are "never" launch..
I guess the problem is because of the "architecture" of our program?
How can I do for this? Do I need to use inline_script again with some times functions or something?
Edit : I forgot to explain exactly what we would like: we would like the time people do when they have to click on the items (during each whole inline_script), and time between each click if it's possible.
Thanks again for your answer Sebastiaan !
Hi Zalian,
Do I understand correctly that you want to log the timestamps of the mouse clicks that you're collecting in the
inline_script
? To do so, you have to savetimestamp
explicitly as an experimental variables usingexp.set()
(just like you did with theclick_[n]_x
variables), like so:Does that make sense?
Note that the timestamp is the absolute timestamp, usually measured from the beginning of the experiment (but that depends on the back-end).
Cheers,
Sebastuaab
Check out SigmundAI.eu for our OpenSesame AI assistant!
Hi,
Ok, I think I get it. But, I still don't understand something which may be easy.. How do I use this timestamp?! How do I convert it to real time? How do I know "the beginning of the experiment?"
I hope this is the last time, I don't want to bother you anymore Thanks a lot anyway !!
Edit : I did read the doc on timing, search on the forum, I've tried to understand the values of timestamp, to convert it, but I still not get it. How do I read and use this timestamp?
Every event has a timestamp (always in ms). So, for example, if you want to know the interval between two clicks, you simply subtract the timestamp of the first click from the timestamp of the second click. And if you want to know the time between the presentation of a
sketchpad
and the moment that the user clicked, you subtract the timestamp of thesketchpad
(i.e. thetime_[item name]
variable) from the timestamp of the mouseclick. Etcetera. You can do this either on-line, in the experiment, or afterwards when analyzing the data.Does that make sense? The absolute time is usually not important, you're just interested in the time difference between two events, which you can get by subtracting timestamps.
Check out SigmundAI.eu for our OpenSesame AI assistant!
Hello !
Here I am again, 2 month later lol
Just to say thank you, you helped us a lot. We had a nice working experiment thanks to you !
I just give you 5€ for your software and for your help
Bye !
Thank you for your donation, and glad to hear you got things working! :-)
Check out SigmundAI.eu for our OpenSesame AI assistant!