# -------Start Routine "feedback"-------
while continueRoutine and routineTimer.getTime() > 0:
# get current time
t = feedbackClock.getTime()
frameN = frameN + 1 # number of completed frames (so 0 is the first frame)
# update/draw components on each frame
# *happy_face* updates
if t >= 0.0 and happy_face.status == NOT_STARTED:
# keep track of start time/frame for later
happy_face.tStart = t
happy_face.frameNStart = frameN # exact frame index
happy_face.setAutoDraw(True)
frameRemains = 0.0 + 1.0- win.monitorFramePeriod * 0.75 # most of one frame period left
if happy_face.status == STARTED and t >= frameRemains:
happy_face.setAutoDraw(False)
# *text_2* updates
if t >= 1 and text_2.status == NOT_STARTED:
# keep track of start time/frame for later
text_2.tStart = t
text_2.frameNStart = frameN # exact frame index
text_2.setAutoDraw(True)
frameRemains = 1 + 1.0- win.monitorFramePeriod * 0.75 # most of one frame period left
if text_2.status == STARTED and t >= frameRemains:
text_2.setAutoDraw(False)
Set your happy_face image component to constant. By having it update on every repeat, with no image, you will be overwriting any image you set - see the code:
####### You attempt to set your image ###########
if key_resp_2.corr and correctAns == 'return':
happy_face.setImage('o.bmp')
# Incorrect ('None') response to female face + stem
elif not key_resp_2.corr and correctAns == 'return':
happy_face.setImage('o.bmp')
# Correct ('None') response to any face + any word except above
elif key_resp_2.corr and correctAns == 'None':
message = ''
# Inorrect ('return') response to any face + any word except above
elif not key_resp_2.corr and correctAns == 'None':
happy_face.setImage('x.bmp')
happy_face.setOpacity(1)
happy_face.setPos((0, 0))
happy_face.setSize((0.5, 0.5))
happy_face.setOri(0)
########################
happy_face.setImage('') # Here you have had your image overwritten - so it will not work
########################
Now it shows incorrect feedback (black picture) when I don’t respond to female + arts related words.
Also I noticed once I press the Enter key for female + STEM word, it shows red image for subsequent trials as well where I don’t respond at all. The number of subsequent trials for which it shows such feedback is not fixed, one time it was 4 subsequent trials and the other time it just one subsequent trial.
Yes, I made the picture change depending on the condition, for demonstration.
The red image persists on some trials because one of your conditions does not set the image, but changes the message variable. What you will want to do in this condition, is set the image to a blank image. e.g.,
# Correct ('return') response to female face + stem
if key_resp_2.corr and correctAns == 'return':
happy_face.setImage('red.png')
# Incorrect ('None') response to female face + stem
elif not key_resp_2.corr and correctAns == 'return':
happy_face.setImage('black.png')
# Correct ('None') response to any face + any word except above
elif key_resp_2.corr and correctAns == 'None':
happy_face.setImage('blank.png')
# Incorrect ('return') response to any face + any word except above
elif not key_resp_2.corr and correctAns == 'None':
happy_face.setImage('orange.png')
In an another task, I am trying to randomize the trials in a block before the start of the experiment. In total I have 20 pictures and 20 occupation words. I want to randomize their pairing in the following way:
10 female faces are paired with 10 STEM occupation words
The rest 10 female faces are paired with 10 Art occupation words.
In the block there are 20 trials and none of the faces or words are repeated within each block.
In the whole task, there are 3 blocks and the association between the face and the word remains the same across all 3 blocks.
I tried modifying a code provided to me by @dvbridges but the problem is that the faces and words are repeated within each block. I don’t want that to happen so how can I ensure that within each block all 20 faces paired independently with the 20 occupation words are presented, without any repetition of face or occupation word?
Following is the modified code and I have also enclosed my stimuli file:
import pandas as pd
stim = pd.read_csv('stimuli_gen.csv') # Get stim
cFaces = list(stim['c_faces'])
sFaces = list(stim['s_faces'])
stemWords = list(stim['stem_words'])
artWords = list(stim['art_words'])
# Create dict to store face-word pairs
stimDict = {'faceStim': [], 'wordStim': []}
# stim numbers
stimNumbers = [10, 10]
stimFaces = [cFaces, sFaces]
stimWords = [stemWords, artWords]
for index, block in enumerate(stimNumbers):
for trials in range(block):
# randomize order of faces and words
shuffle(stimFaces[index])
shuffle(stimWords[index])
stimDict['faceStim'].append(stimFaces[index][0])
stimDict['wordStim'].append(stimWords[index][0])
newStim = pd.DataFrame(stimDict)
newStim.to_csv('newStim.csv', index=False)
Since this is really urgent so I would appreciate @dvbridges your help a lot!
for index, block in enumerate(stimNumbers):
shuffle(stimFaces[index])
shuffle(stimWords[index])
for trials in range(block):
stimDict['faceStim'].append(stimFaces[index][trials])
stimDict['wordStim'].append(stimWords[index][trials])