psychopy.org | Reference | Downloads | Github

Presenting a screen only under certain conditions

I need help using an if else statement:

I have an encoding screen, after which participants are taken to another screen in the loop that is an attention check screen. However, I only want them to be taken to the attention check screen half the time, only when faces are presented during the encoding screen. On trials where there are no faces, I do not want them to be shown the attention screen. How would I achieve this?

To not show something in PsychoPy you need to either put it in a loop with nReps = 0 or put continueRoutine = False in Begin Routine.

How would i use the continueRoutine=False to only not present the attention check screen when there are no faces in the trial of when it is pulling a black box (which is how i have set up the no images)? It is presented in a random order mixed with faces and no faces so I cannot create a separate loop for it.

Hello _junaid123

what do you mean by attention screen, just a * or + before you present a face? What do you present when there is no face?

Best wishes Jens

@JensBoelte I have an experiment where I have 64 trials. In each trial participants see two money transfers (transfer to self, transfer to charity). In half the transfers, they see a face at the same time as the transfer. In the other half of the transfers they do not see a face, just the transfer values. They are then asked to accept or reject the transfer. My experiment reads from a excel sheet where I have all the faces and transfer conditions. For the conditions with no faces I have a black screen that is presented so that participants don’t see a face but only see the transfer conditions.

After they accept/reject their transfer they are taken to the next routine where they type in the name of the person they saw as a way to check their attention. However, I do not want them to be taken to this screen when I do not present a face and am only presenting the transfers, I only want the attention check screen to be presented when they see a face. I have tried to use to continueRoutine = false with no luck.

Please show your Begin Routine code in your Attention Check Routine so we can see how you are trying continueRoutine =False ?

@wakecarter

This is one way i tried it; so that when there was a black screen it would skip the routine. Another way I tried it was:

if Name = ‘Foodbank’
continueRoutine = False

I also tried adding an AttentionCheck column to my spreadsheet, where I had 0 as the value for all my rows with faces in it, and 1 with all my rows with no faces (just the black screen). then I tried this:

if AttentionCheck = 1
continueRoutine = False

I also tried adding a loop around attention check and then adding a spreadsheet that just had one column with attention check and did the same thing as I did in the above spreadsheet. Then I added code:
if AttentionCheck = 1
continueRoutine = False

This also did not work. In all the above examples I first tried putting the code in the Begin Routine and then also tried putting the code in the Every Frame section as well. This also did not work.

Even though you’re writing it for local use only, changing the code type to Auto will highlight syntax errors.

The syntax for if statements is

if Itemface == 'Blank screen':
     continueRoutine = False

@wakecarter

I set it to auto and found the syntax error; corrected it and still I get this error:

if Itemface=‘Blank screen’
^
SyntaxError: invalid syntax

Computers can’t cope with typos.

Look at what I wrote
Look at what you wrote

Spot the difference.

@wakecarter

I am not sure that a typo is the issue: Here is the actual code and the error message, I wrote exactly what you wrote in my code.


Might you have the old code somewhere else?

Got it Thanks! The experiment runs now but it still shows the attention check screen for all the trials and doesn’t skip over them.

Next step is

print('Itemface',Itemface)

above the if statement to see what values are actually occuring.

@wakecarter

The values occurring are the faces. When I ran the study I also saw the trials with no faces but these did not show up on the print screen.

What does (GCS) mean? That doesn’t look right for a path.

Does it ever say “Blank screen”?

@wakecarter GCS is the title of my study. I have the stimuli in a folder named Face Stimuli (GCS). The experiment runs perfectly, both the black images and the face images are pulled up. The issue I am having is that the continueRoutine doesn’t actually stop the attention check routine from appearing after a black image is presented.

Please could you show what the print statement shows for a blank screen?

@wakecarter The print statement doesn’t show anything for the blank screen (although it is still presented in my trials and functions perfectly).

Please could you should what your code component looks like now and upload your spreadsheet file?