# Randomizing in Self Paced Reading

**URL:** <https://discourse.psychopy.org/t/randomizing-in-self-paced-reading/44664>\
**Category:** Builder\
**Created:** [April 24, 2025, 2:01pm UTC](https://discourse.psychopy.org/t/randomizing-in-self-paced-reading/44664 "2025-04-24T14:01:39Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![bilge\_ilhan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/bilge_ilhan/32/44354_2.png) [@bilge\_ilhan](https://discourse.psychopy.org/u/bilge_ilhan)\
**Post date:** [April 24, 2025, 2:01pm UTC](https://discourse.psychopy.org/t/randomizing-in-self-paced-reading/44664/1 "2025-04-24T14:01:39Z")

</div>

Hi everyone,  
I’m trying to create a self-paced reading experiment on Psychopy. I have 24 experimemtal sentences, 24 experimental yes/no questions regarding the experimental sentences and 24 filler sentences. The sequence of the items should be; first experimental sentence (word by word), second experimental question (not word by word), third filler sentence.  
So we can say that each set consists of 3 different sentences.  
I want these sets to be randomized.  
When I select “random” within the loop, All of the words in the set list are randomized and the experiment becomes meaningless. All the words in my Excel sheet appear random. But I want my sets to be randomized, which means one meaningful sentence, one meaningful question and one meaningful filler.  
I hope I expressed myself clearly.

Thank you

---

<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 24, 2025, 5:44pm UTC](https://discourse.psychopy.org/t/randomizing-in-self-paced-reading/44664/2 "2025-04-24T17:44:57Z")

</div>

Should question 1 always go with experimental question 1? And filler 1? Or should they all be randomised independently?

---

<div class="post-metadata">

**Author:** ![bilge\_ilhan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/bilge_ilhan/32/44354_2.png) [@bilge\_ilhan](https://discourse.psychopy.org/u/bilge_ilhan)\
**Post date:** [April 25, 2025, 9:38am UTC](https://discourse.psychopy.org/t/randomizing-in-self-paced-reading/44664/3 "2025-04-25T09:38:45Z")

</div>

Yes, experimental sentence 1 should always go with the experimental question 1 because each sentence has its own yes/no question. They are interrelated. Yes/no questions’ content is about the sentence that is previously shown. But filler sentences can be randomized independently since they are independent sentences from the experiment.  
Let’s make this more clear;  
Let’s say the experimental sentence 1 is: Humans have a complicated logic system.(These words should appear on the screen word by word.)  
Experimental yes/no question would be: Do humans have a complicated logic system? (Doesn’t have to appear word by word)  
Then comes the filler sentence (totally random): I saw a cat today. (Doesn’t have to appear word by word)  
And then the experiment goes on with the 2nd sentence, its question and filler. And so on.  
The problem is I can do this sequentially but not random. For example, I want the 14th sentence, its question and filler to appear first in the experiment, then let’s say 20th sentence, its question and filler, then 2nd sentence, its question and filler. I want these sets to be randomized.  
There could be a problem both in my Excel sheet and Psychopy. I’m not sure.

I hope it’s more clear now.  
Thank you

---

<div class="post-metadata">

**Author:** ![JensBoelte](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/jensboelte/32/9060_2.png) [@JensBoelte](https://discourse.psychopy.org/u/JensBoelte)\
**Post date:** [April 25, 2025, 10:18am UTC](https://discourse.psychopy.org/t/randomizing-in-self-paced-reading/44664/4 "2025-04-25T10:18:48Z")

</div>

Hello @bilge_ilhan

How did you set up your Excel sheet? I assume a column for each kind of stimulus?

You could have a look at [PsychoPy Online Demos](https://discourse.psychopy.org/t/psychopy-online-demos/22319#p-68729-independent-randomisation-codehttpsgitlabpavloviaorgvesprindependent-randomisation-try-ithttpsrunpavloviaorgvesprindependent-randomisation-14) for a way to realize independent randomization.

Best wishes Jens

---

<div class="post-metadata">

**Author:** ![bilge\_ilhan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/bilge_ilhan/32/44354_2.png) [@bilge\_ilhan](https://discourse.psychopy.org/u/bilge_ilhan)\
**Post date:** [April 25, 2025, 10:57am UTC](https://discourse.psychopy.org/t/randomizing-in-self-paced-reading/44664/5 "2025-04-25T10:57:09Z")

</div>

Hi

This is how I arrange my Excel sheet;

 ![excel](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/1/0/109883e8d38a1ace072379aa49b38b718160d3e2.jpeg)

This is how I arrange PsychoPy;

 ![psychopyss](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/7/d/7d96c22486577dac201ef47c79673464673aaee2.jpeg)

The codes I use are;  
wordList = sentence.split()  
wordIndex = 0  
wordText.text = wordList[wordIndex] **on the Begin Routine screen.**

keys = nextKey.getKeys()  
if ‘space’ in keys:  
wordIndex += 1  
if wordIndex \< len(wordList):  
wordText.text = wordList[wordIndex]  
else:  
continueRoutine = False **on Each Frame screen.**

And then when I run the experiment, runner replies with;  
Traceback (most recent call last):  
File “C:\PsychoPy\lib\site-packages\psychopy\iohub\start\_iohub\_process.py”, line 118, in   
Computer.psychopy\_process = psutil.Process(psychopy\_pid)  
File “C:\PsychoPy\lib\site-packages\psutil\__init_\_.py”, line 319, in **init**  
self._init(pid)  
File "C:\PsychoPy\lib\site-packages\psutil\_init_.py", line 368, in \_init  
raise NoSuchProcess(pid, msg=msg)  
psutil.NoSuchProcess: process PID not found (pid=9060)  
################# Experiment ended with exit code 1 [pid:9060] #################

I have no idea what that means. And I have used AI for writing codes.  
What do you think?

---

<div class="post-metadata">

**Author:** ![JensBoelte](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/jensboelte/32/9060_2.png) [@JensBoelte](https://discourse.psychopy.org/u/JensBoelte)\
**Post date:** [April 25, 2025, 1:14pm UTC](https://discourse.psychopy.org/t/randomizing-in-self-paced-reading/44664/6 "2025-04-25T13:14:14Z")

</div>

Hello @bilge_ilhan

This is a different problem than the problem you mentioned above. AI is not very good at helping you to program PsychoPy-experiments.

> [@bilge\_ilhan](#):
>
> keys = nextKey.getKeys()

Where you define `nextKey`?

Do you allow other keys than `space`to end this routine? If not, you could just compare the number of presented words with the number of key presses.  
In Begin routine add

```auto
nWords = len(wordList)

```

```auto
if key_resp_1.keys: # is there any response yet
    wordNum = len(key_resp.keys)
    if len(key_resp_1.keys) == wordIndex & wordIndex < nWords:
        word = words[wordIndex]
        wordIndex += 1
if wordNum == nWords:
    continueRoutine=False
    word = " "

```

Best wishes Jens

---

<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, 2025, 2:28pm UTC](https://discourse.psychopy.org/t/randomizing-in-self-paced-reading/44664/7 "2025-04-25T14:28:49Z")

</div>

Try changing the Experiment Settings/Input to Psychtoolbox
