psychopy.org | Reference | Downloads | Github

Loop sometimes works but not consistent


#1

OS (e.g. Win10): Win10
PsychoPy version (e.g. 1.84.x): 3.0.2
**What are you trying to achieve?:**I am doing a simple emotion recognition experiment. Participants see a photo of a face and then see 6 different emoticons and pick the emotion felt in the photo.
There is a practice trial for 2 photos.
Then the real trials.

What did you try to make it work?: I managed to get the practice file part working so I moved on to include the real file part too. This is what the flow looks like:
image

What specifically went wrong when you tried that?: There is no error message but the loops (both) aren’t working properly. Different things happen each time I run it. Sometimes the practice trial loop works fine but the next loop doesn’t work. Sometimes the practise loop also doesn’t work. Often the exeriment skips the emoticon choice array and just shows one photo after another.
I can’t tell what I have done to my loops to make this happen but maybe someone else can?

Here is the set up for the practice loop:
image

Code used-
Begin routine: currentPic = core.MonotonicClock(start_time=None)
Each frame: if next_click.isPressedIn(pracImage):
continueRoutine = False
End routine: thisExp.addData(‘CurrentPic’, currentPic.getTime())

image
image
image
image

Code used-
Begin routine: currentStim = core.MonotonicClock(start_time=None)
Each frame: if Mouse_practise_Press.isPressedIn(Mouse_practise_happy):
continueRoutine = False
thisExp.addData(‘Selected_emotion’, ‘happy’)
elif Mouse_practise_Press.isPressedIn(Mouse_practise_sad):
continueRoutine = False
thisExp.addData(‘Selected_emotion’, ‘sad’)
elif Mouse_practise_Press.isPressedIn(Mouse_practise_angry):
continueRoutine = False
thisExp.addData(‘Selected_emotion’, ‘angry’)
elif Mouse_practise_Press.isPressedIn(Mouse_practise_disgust):
continueRoutine = False
thisExp.addData(‘Selected_emotion’, ‘disgust’)
elif Mouse_practise_Press.isPressedIn(Mouse_practise_fear):
continueRoutine = False
thisExp.addData(‘Selected_emotion’, ‘fear’)
elif Mouse_practise_Press.isPressedIn(Mouse_practise_surprise):
continueRoutine = False
thisExp.addData(‘Selected_emotion’, ‘surprise’)
End routine: thisExp.addData(‘CurrentStim’, currentStim.getTime())

image

The set-up is the same for the real trials:
image
image
image

But this time the photo code is:
Begin routine: currentPic = core.MonotonicClock(start_time=None)
Each frame: if next_click.isPressedIn(realImage):
continueRoutine = False
End routine: thisExp.addData(‘CurrentPic’, currentPic.getTime())

And the emoticon code is:
Begin routine: currentStim = core.MonotonicClock(start_time=None)
Each frame: if mousePress.isPressedIn(Mouse_happy):
continueRoutine = False
thisExp.addData(‘Selected_emotion’, ‘happy’)
elif mousePress.isPressedIn(Mouse_sad):
continueRoutine = False
thisExp.addData(‘Selected_emotion’, ‘sad’)
elif mousePress.isPressedIn(Mouse_angry):
continueRoutine = False
thisExp.addData(‘Selected_emotion’, ‘angry’)
elif mousePress.isPressedIn(Mouse_disgust):
continueRoutine = False
thisExp.addData(‘Selected_emotion’, ‘disgust’)
elif mousePress.isPressedIn(Mouse_fear):
continueRoutine = False
thisExp.addData(‘Selected_emotion’, ‘fear’)
elif mousePress.isPressedIn(Mouse_surprise):
continueRoutine = False
thisExp.addData(‘Selected_emotion’, ‘surprise’)
End routine: thisExp.addData(‘CurrentStim’, currentStim.getTime())

Can anyone see why any of this would mean some routines are skipped in the loops sometimes?

Thanks!


#2

You can just edit your existing post as above, to make it readable. NB this isn’t just cosmetic: we need to be able to see if the indentation is correct, which is currently invisible.