[solved] show sketchpad for set time even if response is made and feedback arrives
Hi, I a very similar problem to the one exposed here, but from that description I din't unedrstand how it has been solved and since it was marked as "solved" I thought to open a new post.
Basically, I need that during a single trial, lasting for expample 6 sec, the subject should be able to give mouse responses and receive a different feedback (visualize an image for 500ms) for each response without ending the trial until 6 sec elapsed.
This is the inline code that follows a sketchpad (named 'choice') which lasts 0 sec, in which different squares are visualized as possible choices. The subject is required to choose with a mouse-click on one:
from openexp.mouse import mouse
my_mouse = mouse(exp)
my_mouse.set_visible()
my_mouse.set_pos(pos=(660,260))
my_mouse.set_buttonlist( [1] )
my_mouse.flush()
trial = exp.get('choice_cond')
button, position, timestamp = my_mouse.get_click()
x, y = position
from openexp.canvas import canvas
my_canvas = self.copy_sketchpad('choice')
uno = exp.get_file(u'/media/File/experiment/stim/O1.jpg') # feedback one
due = exp.get_file(u'/media/File/experiment/stim/O2.jpg') # feedback two
delay = 500
if trial == (12):
if x > (114) and x < (294) and y > (300) and y < (480):
exp.set('response', 1)
exp.set('response_____keyboard_response', "R1")
# show the appropriate feedback
my_canvas.image(uno, center=True, x=None, y=600, scale=0.1)
my_canvas.show()
if x > (432) and x < (612) and y > (300) and y < (480):
exp.set('response', 1)
exp.set('response_____keyboard_response', "R2")
# show the appropriate feedback
my_canvas.image(due, center=True, x=None, y=600, scale=0.1)
my_canvas.show()
if (x < (114) and x > (294)) or (x < (432) and x > (612)) and (y < (300) or y > (480)):
exp.set('response', 0)
self.sleep(6000) # to make each trial end after 6 sec
I've tried to use self.sleep() after my_canvas.image to set the duration of this image but, of course, it ends the whole canvas.
I know there is probably more than one wrong thing in this script, but I cant' figure it out!Please help!
Thanks!
Comments
I have improved the code in this way and it seems to work:
is this the best solution?
I hope it can be helpful for someone!
Hi Sara,
Depending on what you want to do, you seem to have come up with a very good solution. Keep in mind that with your script, the interaction continues to run after the first click. This means that participants can alter their choice after clicking.
If you do not want to do so, the following example shows a single-click-and-wait procedure:
Actually, I do want them to click several times (and, thus, make more than one choice) during a certain time interval while visualizing the same sketchpad) and subsequently go to the next trial. Thus, in this case, I don't need to reset the screen or to show a blank screen.
I did not specified that, in this task, there are several buttons and in each trial two of them are available.
Than you for the optimized script. By looking at it I have improved some things in mine!
Excellent! I just included the script for the single button responses for future reference, it was by no means a comment on your design
Good luck with testing!