# Self paced reading task

**URL:** <https://discourse.psychopy.org/t/self-paced-reading-task/22135>\
**Category:** Builder\
**Created:** [April 8, 2021, 11:27am UTC](https://discourse.psychopy.org/t/self-paced-reading-task/22135 "2021-04-08T11:27:00Z")\
**Posts on this page:** 20\
**Page:** 2

<div class="post-metadata">

**Author:** ![Zeinab\_Alipour](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/zeinab_alipour/32/15526_2.png) [@Zeinab\_Alipour](https://discourse.psychopy.org/u/Zeinab_Alipour)\
**Post date:** [April 10, 2021, 8:10am UTC](https://discourse.psychopy.org/t/self-paced-reading-task/22135/21 "2021-04-10T08:10:15Z")

</div>

Online? not yet. I entered the code right after the time that you mentioned:  
if ‘space’ in keys:  
wordNum+=1  
thisExp.addData(‘Word’+str(wordNum),t)  
_Exp.nextEntry()_  
if wordNum==nWords:  
continueRoutine=False

and this is the error I receive:  
NameError: name ‘Exp’ is not defined

Wow! thank you for sharing

> [@wakecarter](#):
>
> [free-recall.psyexp](https://discourse.psychopy.org/uploads/short-url/8UzjjhuGUj3VC0Q0FmuytvoANjF.psyexp) (42.0 KB)

But man, this is so detailed. should i use the free-recall section codes?

---

<div class="post-metadata">

**Author:** ![wakecarter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/wakecarter/32/5753_2.png) [@wakecarter](https://discourse.psychopy.org/u/wakecarter)\
**Post date:** [April 10, 2021, 8:24am UTC](https://discourse.psychopy.org/t/self-paced-reading-task/22135/22 "2021-04-10T08:24:04Z")

</div>

thisExp.nextEntry()

Not Exp.nextEntry()

Search for Free Recall on Pavlovia for the most recent version (with more comments) but it probably has too much code for you since it allows up to 20 words in two columns in a single page

> **[Pavlovia](https://pavlovia.org/vespr/free-recall)**
>
> The place for the wide community of researchers in the behavioural sciences to run, share, and explore experiments online

---

<div class="post-metadata">

**Author:** ![Zeinab\_Alipour](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/zeinab_alipour/32/15526_2.png) [@Zeinab\_Alipour](https://discourse.psychopy.org/u/Zeinab_Alipour)\
**Post date:** [April 10, 2021, 2:02pm UTC](https://discourse.psychopy.org/t/self-paced-reading-task/22135/23 "2021-04-10T14:02:44Z")

</div>

Oops, working now. But still it shows the RT in a cumulative manner; the only difference is that now it’s staircase-wise.

 ![staircase](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/0/6/06c5f06ba0715b77170d8626ea4588fd19284841.jpeg)  
Thank you but except your experiment, I couldn’t find another free recall task except for a weird smiley face experiment. I will watch some tutorials on YT and hopefully, I can build one editable textbox. Let’s see where it goes

---

<div class="post-metadata">

**Author:** ![wakecarter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/wakecarter/32/5753_2.png) [@wakecarter](https://discourse.psychopy.org/u/wakecarter)\
**Post date:** [April 10, 2021, 4:58pm UTC](https://discourse.psychopy.org/t/self-paced-reading-task/22135/24 "2021-04-10T16:58:02Z")

</div>

The reason for the staircase is because the column names are all different. You want them to all me the same, not Word 1,2,3,etc.

For the difference you need to either reset the clock or calculate the difference between the current time and the previous one.

---

<div class="post-metadata">

**Author:** ![Zeinab\_Alipour](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/zeinab_alipour/32/15526_2.png) [@Zeinab\_Alipour](https://discourse.psychopy.org/u/Zeinab_Alipour)\
**Post date:** [April 11, 2021, 6:19am UTC](https://discourse.psychopy.org/t/self-paced-reading-task/22135/25 "2021-04-11T06:19:49Z")

</div>

dear @wakecarter,  
I searched for it  
[https://www.psychopy.org/api/core.html](https://www.psychopy.org/api/core.html)  
but I’m wondering which code to insert…

---

<div class="post-metadata">

**Author:** ![wakecarter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/wakecarter/32/5753_2.png) [@wakecarter](https://discourse.psychopy.org/u/wakecarter)\
**Post date:** [April 11, 2021, 6:39am UTC](https://discourse.psychopy.org/t/self-paced-reading-task/22135/26 "2021-04-11T06:39:40Z")

</div>

To create a clock you need

myClock=core.Clock() for Python and myClock=new util.Clock() for JS. Use a Both code component.

To reset your clock use myClock.reset()

To read your clock use myClock.getTime()

Both of these are fine in auto code components

---

<div class="post-metadata">

**Author:** ![Zeinab\_Alipour](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/zeinab_alipour/32/15526_2.png) [@Zeinab\_Alipour](https://discourse.psychopy.org/u/Zeinab_Alipour)\
**Post date:** [April 11, 2021, 6:55am UTC](https://discourse.psychopy.org/t/self-paced-reading-task/22135/27 "2021-04-11T06:55:08Z")

</div>

Thanks for bearing with me  
I did insert the codes in each routine, but still no difference in the data file. Staircase-wise and cumulative. Same old same old. Thank you anyway ☘

---

<div class="post-metadata">

**Author:** ![wakecarter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/wakecarter/32/5753_2.png) [@wakecarter](https://discourse.psychopy.org/u/wakecarter)\
**Post date:** [April 11, 2021, 7:13am UTC](https://discourse.psychopy.org/t/self-paced-reading-task/22135/28 "2021-04-11T07:13:03Z")

</div>

> [@Zeinab\_Alipour](#):
>
> thisExp.addData(‘Word’+str(wordNum),t)

Have you changed the above to thisExp.addData(‘Word’,myClock.getTime()) followed by myClock.reset() ?

If you have then what are you doing to refresh the cache? Sorry, ignore that bit since you’re running it locally. Changes you make should definitely be used so if they aren’t then I have to wonder how you are running the experiment.

---

<div class="post-metadata">

**Author:** ![Zeinab\_Alipour](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/zeinab_alipour/32/15526_2.png) [@Zeinab\_Alipour](https://discourse.psychopy.org/u/Zeinab_Alipour)\
**Post date:** [April 11, 2021, 7:20am UTC](https://discourse.psychopy.org/t/self-paced-reading-task/22135/29 "2021-04-11T07:20:46Z")

</div>

if ‘space’ in keys:  
wordNum+=1  
‘Word’,myClock.getTime()  
thisExp.nextEntry()  
if wordNum==nWords:  
continueRoutine=False

Like this?

> [@wakecarter](#):
>
> thisExp.addData(‘Word’,myClock.getTime())

Cuz when I insert the whole line it gives a syntax error

---

<div class="post-metadata">

**Author:** ![Zeinab\_Alipour](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/zeinab_alipour/32/15526_2.png) [@Zeinab\_Alipour](https://discourse.psychopy.org/u/Zeinab_Alipour)\
**Post date:** [April 11, 2021, 7:23am UTC](https://discourse.psychopy.org/t/self-paced-reading-task/22135/30 "2021-04-11T07:23:55Z")

</div>

I’m in a trial and error phase right now. I’m building the whole thing in PsychoPy, checking, re-checking the data to see how it works  
Then, I’m going to push it to Pavlovia by pressing a button. I assume this is how works

Unless, you are an expert in coding and you can figure out what’s wrong by checking the Console and stuff like that. right?

---

<div class="post-metadata">

**Author:** ![wakecarter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/wakecarter/32/5753_2.png) [@wakecarter](https://discourse.psychopy.org/u/wakecarter)\
**Post date:** [April 11, 2021, 7:24am UTC](https://discourse.psychopy.org/t/self-paced-reading-task/22135/31 "2021-04-11T07:24:37Z")

</div>

You need the whole line with the reset on the following line if you don’t want cumulative time.

Delete the smart quotes and replace them with dumb quotes.

---

<div class="post-metadata">

**Author:** ![Zeinab\_Alipour](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/zeinab_alipour/32/15526_2.png) [@Zeinab\_Alipour](https://discourse.psychopy.org/u/Zeinab_Alipour)\
**Post date:** [April 11, 2021, 7:35am UTC](https://discourse.psychopy.org/t/self-paced-reading-task/22135/32 "2021-04-11T07:35:58Z")

</div>

Hi again  
The syntax error is solved. Now it’s asking me to define the clock. I have written every code related to clock under

> [@wakecarter](#):
>
> thisExp.addData(‘Word’,myClock.getTime())

Currently, Each Frame of mine is like this:  
if ‘space’ in keys:  
wordNum+=1  
thisExp.addData(“Word”,myClock.getTime())  
myClock=core.Clock()  
myClock.reset()  
thisExp.nextEntry()  
if wordNum==nWords:  
continueRoutine=False

---

<div class="post-metadata">

**Author:** ![wakecarter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/wakecarter/32/5753_2.png) [@wakecarter](https://discourse.psychopy.org/u/wakecarter)\
**Post date:** [April 11, 2021, 7:56am UTC](https://discourse.psychopy.org/t/self-paced-reading-task/22135/33 "2021-04-11T07:56:17Z")

</div>

> [@Zeinab\_Alipour](#):
>
> myClock=core.Clock()

This goes in Begin Experiment.

Read your code from top to bottom. You are currently defining the clock AFTER you first save its value

---

<div class="post-metadata">

**Author:** ![Zeinab\_Alipour](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/zeinab_alipour/32/15526_2.png) [@Zeinab\_Alipour](https://discourse.psychopy.org/u/Zeinab_Alipour)\
**Post date:** [April 11, 2021, 8:08am UTC](https://discourse.psychopy.org/t/self-paced-reading-task/22135/34 "2021-04-11T08:08:20Z")

</div>

Yeaaah, you are right. It didn’t make sense

 ![excel(2)](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/5/5/550f56737a4742607be07952abf7856169fb4530.jpeg)  
It’s working perfectly now! Just wanted to thank you. You re a saint to answer all these questions 🌷

---

<div class="post-metadata">

**Author:** ![wakecarter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/wakecarter/32/5753_2.png) [@wakecarter](https://discourse.psychopy.org/u/wakecarter)\
**Post date:** [April 11, 2021, 8:29am UTC](https://discourse.psychopy.org/t/self-paced-reading-task/22135/35 "2021-04-11T08:29:25Z")

</div>

Finally, add another reset in Begin Routine to correct the RT for your first word.

---

<div class="post-metadata">

**Author:** ![Zeinab\_Alipour](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/zeinab_alipour/32/15526_2.png) [@Zeinab\_Alipour](https://discourse.psychopy.org/u/Zeinab_Alipour)\
**Post date:** [April 11, 2021, 8:43am UTC](https://discourse.psychopy.org/t/self-paced-reading-task/22135/36 "2021-04-11T08:43:50Z")

</div>

Wow, thx for looking at it with such critical eye!

 ![3](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/9/d/9da8a95b2bf4dcc8d8267cabf5feab8d42af6258.jpeg)  
It’s perfect now. Thank you, I’m learning a lot ☘

---

<div class="post-metadata">

**Author:** ![Zeinab\_Alipour](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/zeinab_alipour/32/15526_2.png) [@Zeinab\_Alipour](https://discourse.psychopy.org/u/Zeinab_Alipour)\
**Post date:** [April 25, 2021, 6:17am UTC](https://discourse.psychopy.org/t/self-paced-reading-task/22135/37 "2021-04-25T06:17:19Z")

</div>

Dear @wakecarter,  
i know it’s been long, but the question I have is with regard to this discussion, hence, I posed it here. Remember how I wanted the output of the excel to look like this?(previous chat) Well, it appears the very first format works better for data analysis. So i went through the previous codes and I could pull it off and come up with this

 ![xlxx](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/8/5/8579cc0439dde4b58045f0a70ed82a663f3250e3.jpeg)  
But again the RT for each word is recorded in a cumulative way. And look at my code, i did insert the reset code; Idk why this happened:  
**Begin Experiment:**

```auto
myClock=core.Clock()

```

**Begin Routine:**

```auto
words=Sentence.split(' ')
nWords=len(words)
wordNum=0
oldWordNum=-1
phrase=' '
event.clearEvents()
myClock.reset()
win.color = "white"
win.flip()

```

**Each frame:**

```auto
if wordNum>oldWordNum:
    phrase+=words[wordNum]+' '
    text.text=words[wordNum]
    oldWordNum=wordNum

keys=event.getKeys()
if 'space' in keys:  
    wordNum+=1
    thisExp.addData("Word",myClock.getTime())
    myClock.reset()
    thisExp.nextEntry()
    if wordNum==nWords:
        continueRoutine=False

```

What i want is a **noncumulative** RT for _each word_. I’d appreciate any helpful comment of yours.

Regards

---

<div class="post-metadata">

**Author:** ![wakecarter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/wakecarter/32/5753_2.png) [@wakecarter](https://discourse.psychopy.org/u/wakecarter)\
**Post date:** [April 25, 2021, 6:42am UTC](https://discourse.psychopy.org/t/self-paced-reading-task/22135/38 "2021-04-25T06:42:29Z")

</div>

The code you’ve given can’t produce the output you’ve posted. You need the following:

**Begin Experiment:**

```auto
myClock=core.Clock()
# myClock=new util.Clock() on JS side of Both component if you want it to work online

```

**Begin Routine:**

```auto
words=Sentence.split(' ')
nWords=len(words)
wordNum=0
oldWordNum=-1
phrase=' '
event.clearEvents()
myClock.reset()
win.color = "white" # Does this work online?
# Don't use win.flip() in Builder

```

**Each frame:**

```auto
if wordNum>oldWordNum:
    phrase+=words[wordNum]+' '
    text.text=words[wordNum]
    oldWordNum=wordNum

keys=event.getKeys()
if 'space' in keys:  
    wordNum+=1
# Add wordNum to the following line as shown to give each column a unique name.
    thisExp.addData("Word"+str(wordNum),myClock.getTime())
    myClock.reset()
# Don't use thisExp.nextEntry() if you want data on the same line
    if wordNum==nWords:
        continueRoutine=False

```

---

<div class="post-metadata">

**Author:** ![Zeinab\_Alipour](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/zeinab_alipour/32/15526_2.png) [@Zeinab\_Alipour](https://discourse.psychopy.org/u/Zeinab_Alipour)\
**Post date:** [April 25, 2021, 7:42am UTC](https://discourse.psychopy.org/t/self-paced-reading-task/22135/39 "2021-04-25T07:42:45Z")

</div>

Thank you @wakecarter,  
works perfectly now. But just a quick Q:

> [@wakecarter](#):
>
> `myClock=new util.Clock()`

thank you kindly for the online tips and tricks. But when I run it with this code of clock it collapses, and the error says: you need to define your clock.  
I rummaged PsychoJS but couldn’t find anything. I thought we need to define clocks in begin experiment so I’m totally clueless in this. Any ideas?

---

<div class="post-metadata">

**Author:** ![wakecarter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/wakecarter/32/5753_2.png) [@wakecarter](https://discourse.psychopy.org/u/wakecarter)\
**Post date:** [April 25, 2021, 7:47am UTC](https://discourse.psychopy.org/t/self-paced-reading-task/22135/40 "2021-04-25T07:47:02Z")

</div>

Please show your Both code component.

[Previous page](https://discourse.psychopy.org/t/self-paced-reading-task/22135.md?page=1)

[Next page](https://discourse.psychopy.org/t/self-paced-reading-task/22135.md?page=3)
