In the experiment, a person has to press the space bar when he sees a certain picture. When I try to save the results, nothing works, or only the last name of the picture is saved. also, the time in which one picture passes and the time of pressing the space bar are not saved. it seems to me that the problem is in the loop, because it saves the last value, but I have already tried copy and deepcopy.
path = r"D:\psychopy\code\correct\code1"
random_filename = random.choice([
os.path.join(path, x) for x in os.listdir(path)
if os.path.isfile(os.path.join(path, x))
img1 = visual.ImageStim(win, random_filename)
img1.autoDraw = True
img1.autoLog = False