OS (e.g. Win10): Windows11
PsychoPy version (e.g. 1.84.x): Builder 2023.2.3
Standard Standalone? (y/n) If not then what?: Y
What are you trying to achieve?:
Hi everyone,
I’ve created an Experiment using the Builder and code components in which a tone is played out of speakers from a random location in front of the participant. After the tone, the participant must select the corresponding “virtual” region in space (via Mouse click) on the computer screen. This “virtual” selection space are two rectangles (left and right “fields”) containing 8 hidden boxes in both (16 total selection options) and every two boxes account for 1 location (i.e., if a tone is played from the furthest left location then the correct corresponding boxes would be the furthest left and second-furthest left). When the region selected is correct, that box will change to a green fill color and will return to the background (hidden) color prior to the next trial; this same processes occurs for incorrect selections, but the selected box turns briefly red instead. There are 8 blocks of 48 trials. I’m having one major issue with this experiment that I have not been able to solve for weeks of trial and error and searching the web and these forums. In the last trial of each block, the feedback (whether it is green or red) does not display, and instead, carries over and is shown on the first trial of the next block.
What did you try to make it work?:
I have essentially tried everything to my knowledge. I’ve tried adding a trial count to terminate the loop after a certain count is reached, I’ve tried to move portions of code under Each Frame to Begin Routine and/or End Routine. I’ve also tried to remove the Waiting component, increase the time for the feedback to appear, as well as the time associated with the color returning to “none” or in this case, “hidden.” The trial routines (Trial_RR/LR) which contain all the stimuli and code sits in a larger loop with a “break” routine. Even by removing this larger loop, the problem persists.
There are no error messages associated with this. Any help, feedback, or suggestions on how I could possibly fix this would be immensely appreciated. Thank you very much! Below is the code component and a screenshot of the Experiment Flow.
##Begin Experiment##
MyScore = 0
##Begin Routine
clicked_things = []
waiting = False
timer = core.Clock()
ITI = random() * (1.5 - 1.0) + 1.0
thisExp.addData('ITI', ITI)
##Each Frame
#Clickable Stimuli:
clicks = [L1, L2, L3, L4, L5, L6, L7, L8, R1, R2, R3, R4, R5, R6, R7, R8]
clicks2 = [R1, R2, R3, R4, R5, R6, R7, R8]
#Check if mouse click occurred in the list of clicked things
for clickable in clicks:
if Mouse.isPressedIn(clickable):
clicked_things.append(clickable.name)
clickedN = 0
for clickable in clicks:
if clickable.name in clicked_things:
clickedN += 1
#Time after click
if clickedN == 1 and not waiting:
waiting = True
startTime = t
elif clickedN == 1 and waiting:
if t > startTime + 0.200:
continueRoutine = False
# "Resetting" each trial
if Mouse.isPressedIn(clickable):
timer.reset()
for clickable in clicks:
if timer.getTime() >= .300:
clickable.color = 'none'
##End Routine
#Correct/incorrect box-to-sound
if Mouse.clicked_name[0] == CorrAns1 or Mouse.clicked_name[0] == CorrAns2:
correct = 1
else:
correct = 0
####Change hidden boxes####
#Correct click -> Green
for clickable in clicks:
if clickable.name in clicked_things and correct == 1:
clickable.color = 'green'
#Correct click in Rewarded Field - Reward Point Tracker
for clickable in clicks2:
if clickable.name in clicked_things and correct == 1:
MyScore = MyScore+1
#Incorrect click -> Red
for clickable in clicks:
if clickable.name in clicked_things and correct == 0:
clickable.color = 'red'
#Stores data column in excel sheet
thisExp.addData('correct_answer', correct)
thisExp.addData('RT', t)