Hi, I am trying to show the correct response but my loop has 3 different conditions.
If the cue appears in the middle or both sides, or if there is no cue, the target may aleatory appear on the upper or lower monitor’s side. However, if the cue appears on top, the target must appear on top, if the cue appears on the lower, the target must appear in the lower part of the monitor.
I could not manage to get the correct answers, no matter what I press it returns as correct.
# All possible cues
cuestim = {}
cuestim["blank"] = ImageStim(disp, size=(300,300), image="blank.png")
cuestim["centre"] = ImageStim(disp, size=(300,300), image="centre.png")
cuestim["upper"] = ImageStim(disp, size=(300,300), image="upper.png")
cuestim["lower"] = ImageStim(disp, size=(300,300), image="lower.png")
cuestim["both"] = ImageStim(disp, size=(300,300), image="both.png")
tarstim = {}
tarstim ["upcongLeft"]= ImageStim(disp, size=(700,700), image="upcongLeft.png")
tarstim["upcongLeft"].correctAns = "left"
tarstim ["upcongRight"]= ImageStim(disp, size=(700,700), image="upcongRight.png")
tarstim["upcongRight"].correctAns = "right"
tarstimup = {}
tarstimup ["upcongLeft"]= ImageStim(disp, size=(700,700), image="upcongLeft.png")
tarstimup["upcongLeft"].correctAns = "left"
tarstimup ["upcongRight"]= ImageStim(disp, size=(700,700), image="upcongRight.png")
tarstimup["upcongRight"].correctAns = "right"
tarstimdown = {}
tarstimdown ["downcongLeft"]= ImageStim(disp, size=(700,700), image="downcongLeft.png")
tarstimdown["downcongLeft"].correctAns = "left"
tarstimdown ["downcongRight"] = ImageStim(disp, size=(700,700), image="downcongRight.png")
tarstimdown["downcongRight"].correctAns = "right"
# Create an empty list to contain the training trial
training = []
# Loop
for cueside in CUELOCS:
for tarside in TARLOCS:
for soa in SOAS:
for tar in TARGETS:
for tarsideup in TARLOCSUP:
for tarsidedown in TARLOCSDOWN:
# Training dictionary
trialtraining = {"cueside":cueside, "tarside":tarside,"tarsideup":tarsideup,"tarsidedown":tarsidedown, "target":tar, "soa":soa}
# add the trial dictionary to the list
training.extend (TRAININGREPEATS * [trialtraining])
# Randomise
random.shuffle (training)
And this is the loop
# Loop TRAINING
for trial_, trial in enumerate(trials):
if trial_ == 5:
break
# Draw the fixation mark and the cues
imgfix.draw()
cuestim[trial["cueside"]].draw()
cueonset = disp.flip()
wait (CUETIME)
# Draw the fixation mark
imgfix.draw()
# Draw a target stimullus
if cuestim[trial["cueside"]] == cuestim["upper"]:
tarstimup[trial ["tarsideup"]].draw()
elif cuestim[trial["cueside"]] == cuestim["lower"]:
tarstimdown[trial ["tarsidedown"]].draw()
else:
tarstim[trial ["tarside"]].draw()
# Wait for a response
resplist = waitKeys (maxWait=float("inf"), keyList = ["left", "right"],timeStamped = True)
# Select the first response from the response list
response, presstime = resplist[0]
# Check if the response was correct
if response == tarstim [trial ["tarside"]].correctAns:
correct = 1
elif response == tarstimup [trial ["tarsideup"]].correctAns:
correct = 1
elif response == tarstimdown [trial ["tarsidedown"]].correctAns:
correct = 1
else:
correct = 0