Mousetrap: stimuli image not showing
Hi everybody,
I have ran into a problem with my mouse tracking experiment.
Sometimes the stimuli (images) do not show. This happens at random trial numbers.
I have made buttons the size of the stimuli. When the stimuli do not show, you see a blank screen.
However, when you click the (invisible) buttons, so where the stimuli are supposed to be, you continue to the next trial and then the stimuli are visible again.
In a previous version of the experiment this problem does not occur. The only difference between the two experiments is that in the working one the mouse is not visible in a trial with a visual analogue scale and in the defective one the mouse is visible.
These are the scripts for these visual analogue scales:
Working experiment:
# import everything we need
from openexp.canvas import canvas
from openexp.mouse import mouse
# create the instances we need
my_canvas = canvas(self.experiment)
my_mouse = mouse(self.experiment, timeout=1)
# slider dimensions
slider_w = 500
slider_h = 10
slider_x = -slider_w/2
slider_y = -slider_h/2
# draw some text (this can be anything)
my_canvas.text("To what extent were your thoughts focused on or off the task just before this moment?<br><br>Please indicate a percentage where 100% indicates completely on-task and 0% completely off-task.", y=slider_y-200, font_size=30)
#draw options
my_canvas.text("0%<br>(Completely off-task)", y= slider_y+50, x= -250, )
my_canvas.text("100%<br>(Completely on-task)", y= slider_y+50, x= 250)
# draw the slider frame
my_canvas.rect(slider_x, slider_y, slider_w, slider_h)
# add a text below the bottom slider, telling participants to click to accept
my_canvas.text("Click your mouse to accept ...", y=slider_y+200)
# keep showing the interactive slider until a click has been made
clicked = False
while not clicked:
# determine the slider fill based on the mouse position
pos, time = my_mouse.get_pos()
x, y = pos
slider_fill = min(slider_w, max(0, x-slider_x))
# draw an empty rect within the slider frame, effectively resetting it
my_canvas.rect(slider_x, slider_y, slider_w, slider_h, fill=True, color=self.get("background"))
# draw the slider fill
my_canvas.rect(slider_x, slider_y, slider_fill, slider_h, fill=True)
# show the updated canvas
my_canvas.show()
# Poll the mouse for buttonclicks
button, position, timestamp = my_mouse.get_click(timeout = 1)
if button != None:
clicked = True
# save the slider's filling
slider_percent = 100.0*slider_fill/slider_w
exp.set("slider_percent", slider_percent)
Defective experiment:
my_canvas = canvas()
my_mouse = mouse(timeout=1)
my_mouse.show_cursor(True)
# Set slider dimensions. This assumes that 0,0 is the display center, which is
# the default in OpenSesame >= 3.
slider_w = 500
slider_h = 10
slider_x = -slider_w/2
slider_y = -slider_h/2
my_canvas.text("To what extent were your thought’s focused on or off the task just before this moment?", y=slider_y-200, font_size=30)
my_canvas.text("Click your mouse to accept ...", y=slider_y+200)
my_canvas.text("Completely off-task", y= slider_y+30, x= -350)
my_canvas.text("Completely on-task", y= slider_y+30, x= 350)
# Draw the slider frame
my_canvas.rect(slider_x, slider_y, slider_w, slider_h)
lifeCanvas = canvas()
while True:
# Determine the slider fill based on the mouse position
pos, time = my_mouse.get_pos()
x, y = pos
slider_fill = min(slider_w, max(0, x-slider_x))
lifeCanvas.clear()
my_mouse.set_visible()
lifeCanvas.copy(my_canvas)
# Draw some text (this can be anything)
# Draw the slider fill
lifeCanvas.rect(slider_x, slider_y, slider_fill, slider_h, fill=True)
# Draw the mouse cursor
lifeCanvas.show()
# Poll the mouse for buttonclicks
button, position, timestamp = my_mouse.get_click()
if button is not None:
break
# Set the slider response as an experimental variable
var.slider_percent = 100.0*slider_fill/slider_w
I hope someone can help me with this.
Best,
Dirk
Comments
Hi Dirk,
I would like to help with this problem, but I think that it would be easier to test if you could provide a demo version of the working experiment and a demo of the defective expriment (not just the slider code). Besides, have you tested both experiments with the same version of OpenSesame and mousetrap?
Best,
Pascal