Hi, if anyone has any ideas I would be very grateful.
I have seen some discussion that the function itself doesn’t work position-property-of-bufferimagestim-isnt-used-correctly, but I’m not 100% sure whether it is my code or the function.
my code is below:
def present_ss11_hor_str(starting_x, target_starting_y):
ss11_max_time = int(((win_width / 2 - long_box_width) + abs(starting_x)) / speed)
ss11_time = random.randint(min_time, ss11_max_time)
# draw stim to buffer
ss11_hor_str_num = 4
ss11_hor_str_black = int(ss11_hor_str_num / 2)
ss11_hor_str_height = ss11_box_height / ss11_hor_str_num
ss11_hor_str_width = ss11_box_width
ss11_white = visual.Rect(win, width=ss11_box_width, height=ss11_box_height, fillColor=ss11_rect_color, units='pix')
# Create a list to hold the stripe stimuli
stripes = []
for i in range(ss11_hor_str_black):
ss11_hor_str = visual.Rect(win, width=ss11_hor_str_width, height=ss11_hor_str_height, fillColor=ss11_stripe_color, units='pix')
ss11_hor_str.pos = (0, (2 * (i * ss11_hor_str_height) - (ss11_hor_str_height * ss11_hor_str_num / 2) + (ss11_hor_str_height * 1.5)))
stripes.append(ss11_hor_str)
ss11_hor_str_stim = visual.BufferImageStim(win, stim=[ss11_white] + stripes, pos = (0.5,0.2))
if starting_x < 0:
for frameN in range(ss11_time):
ss11_hor_str_stim.pos = (starting_x, target_starting_y)
ss11_hor_str_stim.draw()
starting_x += speed
win.flip()
elif starting_x >= 0:
for frameN in range(ss11_time):
ss11_hor_str_stim.pos = (starting_x, target_starting_y)
ss11_hor_str_stim.draw()
starting_x -= speed
win.flip()
clear_screen()
my window units are in pix, everything else in my code is in pixels. The problem is that the bufferstim is drawn at 0,0 and doesn’t move. If I leave a line in to print the position I can see it is being updated correctly. I have also tried changing the position to normalised units to no avail.
If it is the BufferImageStim function that is broken, does anyone know a way around it?
Any help massively appreciated!