Hi everyone,
Thanks in advance to whom will contribute to this discussion
OS: MacOS Ventura 13.1
What is the problem?
The border line (property .setBorderColor) of the imageStim object doesn’t show.
The task
I want to highlight the selected image in the screen by changing the color of the image border.
What did I try?
This is my function. After a left or right key is pressed, the corresponding image should be highlighted by a green border line.
def present_symbols(symbols, text):
global event_log, last_event
event_symbols = {
'trial_type': 'symbols & instruction',
'onset': globalClock.getTime(),
'filename': [symbol1_image, symbol2_image, instruction_text],
'corrAns': corr_ans,
'symbolPos': [symbol1_position, symbol2_position],
'block nr': block_num,
'trial nr': trial_num
}
record_event(event_symbols)
kb.clock.reset() # start the timer
print('And I print again the block nr:', block_num)
while True:
keys_sym = [] # empty list from previous events
# Draw stimuli
for stimulus in [image_symbol1, image_symbol2, instruction]:
stimulus.draw()
win.flip()
# Check keypresses
keys_sym = kb.getKeys(waitRelease=True)
if keys_sym:
print(keys_sym)
for key in keys_sym:
key_symbols = {'block nr': block_num, 'trial nr': trial_num, 'trial_type': 'key_press_sym', 'onset': globalClock.getTime(), 'duration': key.duration, 'response': key.name}
record_event(key_symbols)
if 'escape' in keys_sym:
core.quit()
if 'left' in keys_sym:
if symbol1_position == (-0.35, 0):
image_symbol1.setBorderColor('green')
image_symbol1.lineWidth = 4
print('Entering the loop but not showing')
else:
image_symbol2.setBorderColor('green')
image_symbol2.lineWidth = 4
print('Entering the loop but not showing')
for stimulus in [image_symbol1, image_symbol2, instruction]:
stimulus.draw()
win.flip()
core.wait(0.5) # give time to ppn to see chosen image
break
if 'right' in keys_sym:
if symbol1_position == (0.35, 0):
image_symbol1.setBorderColor('green')
image_symbol1.lineWidth = 4
print('Entering the loop but not showing')
for stimulus in [image_symbol1, image_symbol2, instruction]:
stimulus.draw()
win.flip()
core.wait(0.5) # give time to ppn to see chosen image
break
else:
image_symbol2.setBorderColor('green')
image_symbol2.lineWidth = 4
print('Entering the loop but not showing')
for stimulus in [image_symbol1, image_symbol2, instruction]:
stimulus.draw()
win.flip()
core.wait(0.5) # give time to ppn to see chosen image
break
return keys_sym # Return the keys_sym list
Extra
If anyone knows how to make this function more efficient (i.e. currently losing time on recording events), it would be appreciated
Thank you!