Self paced reading task


Here you are.

That should work online but not locally.

| myClock=core.Clock() | myClock=new util.Clock(); |

Alright. so the core.Clock code works for PsychoPy, locally
but if I push it on Pavlovia, I should define clock as new util.Clock, right?

1 Like

Dear @wakecarter,
remember how you told me not to insert

win.flip() in Builder? well, I deleted that, pushed the experiment to Pavlovia, and I receive this error:

  • ReferenceError: win is not defined

you knew sth was up when you said

well, you were right. It doesn’t work! Could you kindly tell me the reason behind this happening?

That’s the easy bit

win = psychoJS.window;

in Begin Experiment JS only as per my 2020 crib sheet

1 Like

thank you very much. Let me try the code. :tulip:

Hello Zeinab.
I am doing research in Farsi using Psychopy. How can I get help from you and ask you some questions related to this software?

Hi, I am new to psychopy, can you please give me your code to run self-paced reading task? i am new to coding as well as designing this task, it is absolutely important for my thesis. I will be highly obliged if you mail me at reachanwesha22@gmail.com

Self-Paced Reading code | try it | discussion thread

Based on code from my code snippets Google page and using sentences from @Zeinab_Alipour, this demo includes reading times for each word and an editable text box comprehension question. Variants include incremental phrase, central word, moving window and moving word.
Morys-Carter, W. L. & Alipour, Z. (2022, February 18). Self Paced Reading [Computer software]. Pavlovia. https://doi.org/10.17605/OSF.IO/S2FD6 .

2 Likes

Hi Zeinab
I have to learn moving window self paced reading task for my initially 20 sentences stimuli. But I dont know nothing about coding…Where to start from.?.It is a deadline issue for an assignment…

Hello @wakecarter I’m trying to create a moving window self-paced reading experiment through PsychoPy and Im using builder. Im new to Psychopy and it’s the first time Im learning how to code.

I pasted your Phyton code (begin routine/each frame) for the self-paced reading in each routine of my experiment.

There was a warning:

words=Sentence.split(’ ')

NameError: name ‘Sentence’ is not defined

19.6723 WARNING launchHubServer: If using the iohub mouse or eyetracker devices, fullScr should be True.

4.7344 WARNING Monitor specification not found. Creating a temporary one…

ioHub Server Process Completed With Code: 0

################ Experiment ended with exit code 1 [pid:10452] #################

I have routines called exp_sss, exp_ss1, exp_ss2, exp_ss3, exp_ss4, exp_ss5, exp_ss6, exp_ss7, exp_ss8, exp_ss9, exp_ss10, exp_qt, inside of a loop called Block 1. I will have the total of 16 blocks in this experiment.

The loop is connected to an excel file with word in each column labelled sss, ss1, ss2, ss3, ss4, ss5, ss6, ss7, ss8, ss9, ss10, ssqt.

In routine exp_sss there is a text component called expsss and its text field contains $sss. The column sss in excel is the fixation cross + and its duration is 2.0. From the routine exp_ss1 to the routine exp_ss10 the components are called expss(number) and its text field contains $name of the column. The routine exp_qt are the questions that are in the ssqt column.

Could you please, help me?

@wakecarter I will post a screen shot of the columns of my excel file. I would be very greatful if u could help me.

My code assumes that the full sentence is in a column called Sentence which gets split into words by that code.

1 Like

Thank you for the advice, @wakecarter I changed the way I presented in excel and wrote the full sentences in a collumn called Sentence. I upload my test file here.

However, I received a warning text_2.text=phrase
NameError: name ‘text_2’ is not defined

teste14.xlsx (9.4 KB)

Could you please help me?

Do you have a text component called text_2 ?

1 Like

I copied the code from the code snippets (self-paced reading) you posted for py:


Begin Routine
words=Sentence.split(’ ')

nWords=len(words)

wordNum=0

oldWordNum=-1

phrase=‘’

event.clearEvents()

Each Frame

if wordNum>oldWordNum:

phrase+=words[wordNum]+’ ’

text_2.text=phrase

text_2.text=words[wordNum]

oldWordNum=wordNum

keys=event.getKeys()

if ‘space’ in keys:

wordNum+=1

thisExp.addData(‘Word’+str(wordNum),t)

if wordNum==nWords:

continueRoutine=False



Should I exclude them?

text_2.text=phrase and text_2.text=words[wordNum] are alternative lines of code to either set the text of the text component called text_2 (change this if your text component is called something different) to the phrase up to the current word or just the current word.

1 Like

Thank you for reminding me about the tips. I tried to add the backticks, but it didnt allow me to add in the wole code, just sentence by sentence.
I changed the name of the text component in both lines of the code where was text_2. The experiment is running, however it is still in the center of the screen and its showing just the first word of each sentence. Do you have an idea what is happening?

Should I edit anything else in the code?

Try deleting text_2.text=words[wordNum] if you want to show the full phrase to that point.

You need three ticks for multi line code to preserve indents.

1 Like

I wrote three ticks in the previous line, but in the third one it changed just a single line.

I tried and deleted the text_2.text=words[wordNum]but it continued in the center and showing just the first word of the sentence.