[open] Libet's rotating spot clock - Intentional Binding Paradigm
Hi. I'm trying to make a rotaing spot clock like the one used in Libet's volition expermient, to use it to measure the Intentional binding effect. I got lots of help on this forum, reading other entrie on the subject. here.
http://forum.cogsci.nl/index.php?p=/discussion/38/solved-intentional-binding-paradigm-creating-animations/p1
I was able to make an inline code that displays the clock with a rotating red ball, marking the revolutions every 2560 ms and then to mark the time which a key is pressed ("z"). 1500 ms after the keypress, a synth sound plays, and the sound time is recorded. Then the clock is stopped a random range of time after. I'm missing the method to introduce the percieved time of the two events.
Although my code does the job, i think it's rather rough. I would appreciate if someone could look in to my code and maybe help me find a more elegant solution. thanks!
from openexp.canvas import canvas
from openexp.keyboard import keyboard
from openexp.synth import synth
from math import radians, atan2, sin, cos, degrees # Trigonometry to build rotating spot
import random, time
#initialize synth, sine wave
my_synth = synth(self.experiment, osc = "sine", freq = "b1", attack = 1, length = 200)
#initialice canvas and path of clock image
my_canvas = canvas(self.experiment)
my_canvas.show()
path = self.experiment.get_file("clock2.png")
#initialize keyboard
my_keyboard = keyboard(self.experiment, keylist = ["z"],timeout= 0)
clock_radius = 75 #radius of the clock spot.
speed = 140.625 # speed to make 1 turn of the clock in 2560 ms
start_t = time.time() - random.randint(0, 2560) # needed to make the startinf position of the clock random.
half_screen = 250.5 #had to do this to draw the circle relative to the center of the screen. I dont now if canvas can manage "center" relative coordinates.
press_time = 100000000000 #set this variables high enough, to avoid entering the conditions.
finish_time = 100000000000
delay = random.randint(2, 5)
while True: #start the clock
t = time.time() - start_t
dy = clock_radius * sin(radians(t * speed))
dx = clock_radius * cos(radians(t * speed))
my_canvas.clear()
my_canvas.circle(dx + half_screen,dy + half_screen,5, fill=True); my_canvas.image(path)
my_canvas.show()
mark = atan2(dy,dx)*10 + 15 # fix the result of the atan2 function to give clock marks
if mark < 0:
mark = (60 + mark)
key, f_time = my_keyboard.get_key()
if key==122: #mark the time of the key press
key_mark=mark
press_time=time.time()
if time.time() - press_time > 1.5: #set a 1.5s interval before synth play
my_synth.play()
sound_mark=mark
press_time = 100000000000000
finish_time=time.time()
if time.time() - finish_time > delay: #set a random (delay) interval before breaking
print key_mark, sound_mark
break
Comments
Hi Caiman,
Your code looks pretty good (and works), but I take it you're not satisfied with it? I don't understand the following:
What exactly do you want to achieve that the script isn't doing right now?
Furthermore, two minor tips:
Cheers,
Sebastiaan
Check out SigmundAI.eu for our OpenSesame AI assistant!
Thanks Sebastiaan.
The intentional binding effect is a "temporal compression" of the percieved time of the onset of an action and it's consequence. When a person is asked to retrospectively inform of the timing of 1.- an intentional movement and 2.- its consequence, in this case a sound , the movement is percieved later in time, and the sound is percieved before of their "real" timings. What's exiting about it, its that when there is no "intention" to move (as in passive movements), the effect is not seen, or you can see an inverse effect (the percieved time between the two conditions expand).
Im building a script that can ask de users for the perceived timing of the two events. I'm using the mouse module and I think i can get it to work. The user is asked to mark the position on the clock, when they percieved the urge to move, and then when they percieved the sound.
I would like to restrain de mouse movement to a certain area, maybe just the clock perimeter, for better accuracy. Is this possible?
Sound timing is important, if the delay is more or less the same for each try, it should'nt be a problem. Do you know another method for a more precise sound stimule? maybe using the system sound, as it doesn't require sound card processing?
here's the updated code.
Regarding a better (restrained) way to get the response, I was thinking you could draw a straight line from the center in the direction of the cursor. So basically the participant controls the arm of a clock with his mouse. What do you think? Something like this would do the trick:
Regarding the sound. There is a fixed delay and a random jitter. How big the jitter will be is hard to say (you'd need to test on a specific system), but it might be on the order of 20ms. You can reduce this (somewhat) by reducing the sound buffer size (see the back-end options in the general tab) to say 256, but you might get crackling in the sound.
Using the system beep, or a device attached to the serial/ parallel port should give you essentially perfect timing. I don't have a system beep myself (it's kind of old fashioned), so I cannot be of much assistance here. But maybe this will get you started: http://docs.python.org/library/winsound.html
Good luck!
Check out SigmundAI.eu for our OpenSesame AI assistant!
Thanks again Sebastiaan.
I've finally made the script work with your help. I had to fix de atan2 function with a "degrees" because it was giving me the numbers in radians, but once that was fixed it all ran well.
Now i'm trying to organize my expermient in order to run it in several blocks measuring different thing. One block that the user only estimates the time of key pressing, with no sound, other block with the estimation of only the sound, without the key press... etc.
My question now is if i can make an inline script at the begining of the experiment, to define the variables that are the same for all the blocks (like the clock_radius, the speed, etc) and then call them on the specific blocks.
Thanks for your help!
Sure, the following command in an inline_script will set a variable that is accessible throughout the experiment:
Alternatively you can edit the general script (General tab → Show script editor) and add something like the following to the top of the script:
Both methods will do the same thing.
Cheers!
Check out SigmundAI.eu for our OpenSesame AI assistant!
Hi Caiman. We have the same research interests, very well!
Actually, I developed a quite different code to creating the intentional binding paradigm. I use the PsychoPy backend, since it seems to be more precise. Moreover, I prefere to create in advance the various clock hand positions, and then to show them in sequence for each frame rate. In this way, the rotation of the clock and the milliseconds precision seem to be improved (but this is just my opinion). For example, the rotation appears more fluid. With the Psycho backend, the canvas module doesn't work well, so I had to use the 'visual' modules.
In my code, the subject judge the time by typing the seconds number. I use this method only because this is the same used by Haggard and coll. in their intentional binding studies. I also developed a code that allows the subject to manually positioning the clock hand at the disired position, but I don't use it for now. It would be interesting to verify if the two judgement methods determine different results (I guess not)...
I attach my code, apologizing very much for its length (Sebastian, I hope this isn't a problem, I have to use more than one post). It's only for one condition, in which the subject presses a key, hear a tone and judges the time. I hope this may be useful for you, Caiman, and for who will want to study the intentional binding. I would appreciate any suggestions about my code, if someone has the opportunity to test it.
Best,
Andrea
Hi Andrea,
First of all, thanks for sharing your code. I am trying to make a Libet paradigm as well, I am really doing just a traditional Libet experiment but adding an electrophysiological intervention. Your code works well -- would you mind if I modify it and use it for my experiment?
If so, would you mind sharing the code to manually position the clock hand to the desired position when reporting intention time?
Thanks again! You saved me a lot of hard work
Hi zak. Here the code you requested.
For various reasons, I don't use this method. I think one problem is that manually positioning the clock hand requires that the subject has to wait until the clock hand reaches the choosen position. I don't now if this may be a possible bias. On the other hand, if you increase the clock hand rotation speed, the judgement becomes less precise and the clock hand "slips out". So, I now prefer to ask the subject to comunicate the seconds position. BTW, this is the code, let me know if it works well.
Best,
Andrea
Thanks Andrea! I ended up coding something to use a mouse for the judgement phase, based on what Sebastiaan wrote but with psychopy mouse commands. It allows the subject to report the clock position by moving the mouse, but the hand is constrained to appropriate clock positions. Then it converts the x,y position of the hand at the click to clock position (this was slightly tricky). This method may be somewhat more accurate because the subject can report non-integer clock positions.
It also meant I could avoid buying a $5000 EEG-compatible fiber optic keypad! (though the fiber optic mouse is still $2000 :S)
Feel free to use it if you like, and thanks again for sharing.
Some other changes I made you might have noticed: I use a red dot instead of a white line for the hand. I also draw the clock face to an image buffer before drawing it. There is some loss of image sharpness but this was necessary because I added 1s tick marks, which made it run very slowly. I did it like this:
Hi Zak. In these days I'm attempting to improve the code that I used. Now, I also use BufferImageStim to draw the clock face, and it allows a faster presentation of the stimuli. This is the code that I use to create the clock face. I don't draw the 1s tick marks, but you can add them inside the loop. Then, I call the
clock_face.draw()
two consecutive times, when I have to draw it, because this make the clock face more clear.Best,
Andrea
Hi Andrea,
I'm not sure if you are still doing this experiment but I noticed a bug since I have been using the code. When converting the start point from a value (0-11) to a clock face value (5-60), the code says
if start_point == 0: start_point = 15 if start_point == 1: start_point = 10
etc.The problem with this is it says
if start_point == 1: start_point = 10
and then laterif start_point == 10: start_point = 25
. This means that every time the start point is 10, it is being recorded as 25 instead. The same problem occurs if the original start point is 5. It becomes 50 instead. This means the converted_judgement calculations are incorrect or ambiguous on 1/3 of trials (anytime the start point was 5, 10, 25, or 50)Just thought you should know, in case you did not find this bug yourself. You can fix it by simply moving the commands for if start_point = 5 and if start_point = 10 to the top of the list.
Hi zak. Thank you for reporting this bug. I had not noticed the problematic behavior of the code, because after I had posted here my experiment I modified it in order to make it more reliable. A change I made is just related to the selection of the start point of the clock hand and the subsequent conversion of the value in a clock mark number. I inserted a python dictionary with the various start points of the clock hand (the keys) and the relative converted clock marks (the values).
So, the start point is every time randomly choosen:
and used for the initial clock hand position. Then it is converted at the end of the code, before computing final data:
This appears more elegant.
Since they works well, I think I will share my final intentional binding experiments here in the next days. The only problem is that the instructions are in italian...
Specifically, I have developed both the classic version (from Haggard et al. 2002) and the probability version (from Moore and Haggard, 2008), in which the probability of occurrence of the tone is manipulated in two blocks. I'm using this latter experiment for my current research, since it distinguishes both predictive and retrospective components of the feeling of agency.
Cheers,
Andrea
Hi,
I am interested in using the Intentional Binding task. Will one of you by any chance be willing to share the code of the task with me or refer me to someone who might be able to help me?. unfortunately, my programming skills are poor, therefore it will assist me greatly.
Thanks a lot!
Ela
Hi ElaOren. Yes, of course, I can share the code with you once I get a bit of time. A question: are you interested in the original version of the intentional binding paradigm (Haggard et al. 2002) or in the modified version in which the probability of occurrence of the tone changes (Moore & Haggard, 2008)?
Hi Andrea, I'm very interested to the Libet clock paradigm and I would like to use it for some researches. Unfortunately I'm naive of the opensesame scripts. Can you help me?
Many thanks.
Fabio
Hi Fabio (are you italian, like me?). You can contact me at andreaepifani[at]gmail.com. I'll be glad to help you.
I'm also interested in finding an implementation of the Libet paradigm and this is the only only one I've found that I've managed to get to work. Unfortunately my programming skills are non-existent so I'm finding this all extremely taxing.
Hopefully embodiment doesn't mind if I send an email asking for the latest code, and if anyone else has used Opensesame for a Libet-style experiment I'd be really interested to hear about it!
Hi everybody,
I'm trying to replicate Libet's experiment using an openbci EEG, I tried embodiment's program using psychopy it gives me an error :
My knowledge in programming is very limited, if anyone can help ?
Thank you in advance.
Hi all,
I am hoping to do some simple (Haggard-style) Intentional Binding experiments with my final year dissertation students next academic year and I was wondering if any of you would be willing to share your OpenSesame script with me so I can edit it for my own ends?
Many thanks in advance,
Cai
Hi Cai,
Maybe you can email Fabian (email above). In case you haven't already done so.
Good luck,
Eduard
Dear all,
I am planning to use the Libet's Clock Task in my next research about intentional binding. I was able to reach Andrea, who was very kind in sending me his original script.
However, I have some questions:
1. I am running the experiment through an old version of OpenSesame (i.e., OpenSesame 3.2.8 Kafkaesque Koffka), and the task works. However, when a student of mine had tried to use the most recent version of OpenSesame, the task did not work. Has anyone recently used the script with an updated version of the software?
2. During the task, I can’t pause the experiment. When I try to do it, the experiment goes into a loop (the clock continues to move and it is unstoppable); this might be a problem considering that I plan to use it with patients.
Thank you,
Federica
Hi Federica,
It is probably best if you gave more information on the current implementation of the task. You can share the experiment, or the code.
What do you mean with "pausing the experiment"? Participants pressing a key to halt, and then another one to continue? Or building the experiment in a block/trial sequence?
Eduard