psychopy.org | Reference | Downloads | Github

Self-paced reading task with YES/NO comprehension questions

Hi there. I am trying to build a self-paced reading task with YES/NO comprehension question on PsychoPy 3 Mac air.So far I created the task where all sentences are followed comprehension questions, which require participants to indicate YES/NO by pressing left arrow/right arrow. I have 80 sentences in total, but I only want 30 of them to be followed by comprehension questions. How can I achieve this by manipulating builder or coder? It would be mostly kind of you if you can give me some pointers. Thanking you in anticipation.

Hi @Shawna_Wang, you could have two routines in a loop. The first routine is the reading task, and the second routine contains the comprehension questions. As this point, the comprehension questions will always follow the reading routine. How you determine whether or not a comprehension question follows the reading is not clear. Do the comprehension questions always follow the same questions, or are the sentence-comprehension pairs randomised across participants?

1 Like

Hi, thank you for your reply. I already finished building the loop as u described. Here is the procedure I intend to achieve: firstly participants will be shown a sentence(Eg I had a good time yesterday.) This is a word-by-word self-paced reading. After that they were asked to answer a yes or no question regarding the sentence. I have already achieved the function. But the thing is I only want 30 of my 80 sentences to be followed by comprehension questions(not all sentences ). Also all the 80 sentences should appear in a random order.

How can I achieve this? Thank you so much.

Hi, thank you for your reply. I already finished building the loop as u described. Here is the procedure I intend to achieve: firstly participants will be shown a sentence(Eg I had a good time yesterday.) This is a word-by-word self-paced reading. After that they were asked to answer a yes or no question regarding the sentence. I have already achieved the function. But the thing is I only want 30 of my 80 sentences to be followed by comprehension questions(not all sentences ). Also all the 80 sentences should appear in a random order.

How can I achieve this? Thank you so much.

Any 30 questions in particular, or just any random 30 questions?

30 questions for 30 particular sentences. Thank you!

Ok, then you will need to add a column to your conditions file. Call it “followUp” (for follow-up question). In the column, give each trial a 0 or 1. Use 1 if you want a question to follow, and 0 if not. In your second routine, with the comprehension question, add a code component. In the “Begin Routine” tab of the code component, add:

if not followUp:
    continueRoutine = False

This means that whenever a 0 appears next to a question in your conditions file, the comprehension question routine will finish without actually presenting a question.

Regarding the randomisation of your trials, you set this in your loop (trial) handler when you add your conditions file. The default loop Type is random, so just have a look to make sure that is set correctly.

1 Like

Thank you. I followed your instruction and add if statement in the coder as you can see in the pic. I tried to run but the Error says “followUp” is not defined. How should I define it in this case?


Thank you in anticipation.

You may need to reload your conditions file in the loop, so it picks up on the new column in your conditions file. Try that and let me know. Btw, I meant to add the code into a code component, which should be in your qs routine.

Thank you.There are four columns in my condition file, and they are: Sentence/followUp/Question/CorrAns

I already uploaded the new file in the builder. But I don’t know how to add the code into the code component in the coder. It seems that every time when I want to edited the script of the extant builder, it would keep changing into the original script, and the coder and the builder do not seem to correspond. Can you tell me more specifically about how to add the code into the code component? Thank you!!

No problem :). When you run an experiment from Builder, it will create a new python file and use that to run the experiment. So, any changes you make to the actual Python code will be overwritten every time you run the experiment from Builder - also, when you change the file in Coder, it has no effect on Builder, it is a one way street and only Builder can affect the Coder output, not vice versa.

Builder has a component called the code component, allowing you to insert snippets of Python (or JavaScript) code into your script, that will not be overwritten every time your run the experiment. You add it to a routine the same way that you would add a keyboard, for example. The code component has a logo with an equation on, and you will find it in your right side of your screen, I think in the “Custom” set of components. Add the code component to the qs routine, in the trials loop.

When you open the code component, you have a dialog box with several tabs (as in the link I just posted above). You will want to add that code to the “Start Routine” tab.

After this, go to the trials loop and make sure you can see the “followUp” parameter listed under the field for the conditions file. IF you cannot, browse for the conditions file again and reselect it, then you should see the followUp param listed.

Thank you for your help! I finally figured out where to find the code component in the builder, and it worked well. Could you please help me with another problem? in my experiment, I want to create a counterbalance list, namely there will be 4 sentence conditions for each target. I want each participant to read only one of the four conditions for each target. How can I achieve this? Thanking you in anticipation.:grinning:

Thank you for your help! I finally figured out where to find the code component in the builder, and it worked well. Could you please help me with another problem? in my experiment, I want to create a counterbalance list, namely there will be 4 sentence conditions for each target. I want each participant to read only one of the four conditions for each target. How can I achieve this? Thanking you in anticipation.:grimacing:

Hi, I am having the same exact problem, but it is not working for me. I put the code component at the top of the Question routine, wrote the code in the begin routine tab and added and reuploaded the conditions files with the column followUp (0 or 1) but everytime there is no a question, the text “defaul text appears” it does not end the routine.

I am having also the same problem with my sentences (in a self-pace reading sentence task) which are of different lengths and everytime a cell is empty the “default text” text appears. I want Psychopy to ignore empty cells, but I cannot.

I tried using the code

if W1 ==''
   continueRoutine=False

but it is not working either