# New routine for each trial with different text?

**URL:** <https://discourse.psychopy.org/t/new-routine-for-each-trial-with-different-text/9848>\
**Category:** Builder\
**Tags:** randomization\
**Created:** [November 11, 2019, 5:02pm UTC](https://discourse.psychopy.org/t/new-routine-for-each-trial-with-different-text/9848 "2019-11-11T17:02:14Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![lcrible](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/lcrible/32/6233_2.png) [@lcrible](https://discourse.psychopy.org/u/lcrible)\
**Post date:** [November 11, 2019, 5:02pm UTC](https://discourse.psychopy.org/t/new-routine-for-each-trial-with-different-text/9848/1 "2019-11-11T17:02:14Z")

</div>

**OS** : Win10  
**PsychoPy version** : v3.2.4  
\*\*Standard Standalone? \*\* : yes  
**What are you trying to achieve?:**  
I’m building my first experiment. It’s a self-paced reading study, measuring keypress response times after reading sentence chunks at the participant’s own pace. I started to create the Flow of my experiment but I want to make sure I’m doing it in the most efficient way, i.e. whether I can simply copy routines instead of creating new ones for each trial.

**What did you try to make it work?:**  
So far, I have a flow that looks like this (picture below)

 ![image](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/0/b/0bc145a45423aad8e02f6ccaeb70f37517c24a30.png)

So I have a first loop “trial” with the self-paced reading task and text (called from an Excel file). This loop is included in a second loop, together with a “break” routine that separates each trial. Some trials also have a third component (comprehension question) after them - I actually have problems with this but will ask them in a different post. I did this for all the trials and filler items (so far only 3 of each but I will end up with 40 stimuli + 60 fillers…), creating new routines and new loops all the time (except the “break” component, which is always the same).

All trials are then grouped in a big loop set to random order so that stimuli and fillers would be mixed.  
Of course each trial has to display a different text. Stimuli and fillers come from two different Excel files, but I could merge them if necessary.

Am I doing this right ?

**What specifically went wrong when you tried that?:**  
It works that way but I will end up with 100 different routines, and I’m not sure this is the most efficient way there is.

Thanks a lot !

---

<div class="post-metadata">

**Author:** ![Michael](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/michael/32/16_2.png) [@Michael](https://discourse.psychopy.org/u/Michael)\
**Post date:** [November 11, 2019, 9:41pm UTC](https://discourse.psychopy.org/t/new-routine-for-each-trial-with-different-text/9848/2 "2019-11-11T21:41:42Z")

</div>

> [@lcrible](#):
>
> It works that way but I will end up with 100 different routines, and I’m not sure this is the most efficient way there is.

Whoa there… Do you understand what loops actually do? Their pros is to repeatedly cycle over a routine. So ideally to present 100 trials, you would have a single loop that cycles 100 times over one or more enclosed routines. You certainly didn’t want 100 copies of your routines.

---

<div class="post-metadata">

**Author:** ![lcrible](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/lcrible/32/6233_2.png) [@lcrible](https://discourse.psychopy.org/u/lcrible)\
**Post date:** [November 11, 2019, 10:18pm UTC](https://discourse.psychopy.org/t/new-routine-for-each-trial-with-different-text/9848/3 "2019-11-11T22:18:37Z")

</div>

Thanks Michael. I thought so, but then I’m not sure how to structure the input file. It’s not a word-by-word task but segment-by-segment and the sentences are not cut at exactly the same places across trials or at a regular symbol. Here are some examples :  
S1 / Mary doesn’t like to live in the city and / Paul wants to move to the country side  
S2 / Sue doesn’t go to cheap hotels and / Tom always stays in fancy resorts

Is there a way that I could instruct the loop to move to the second part after a key press?  
Grateful for any advice

---

<div class="post-metadata">

**Author:** ![Michael](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/michael/32/16_2.png) [@Michael](https://discourse.psychopy.org/u/Michael)\
**Post date:** [November 13, 2019, 5:18am UTC](https://discourse.psychopy.org/t/new-routine-for-each-trial-with-different-text/9848/4 "2019-11-13T05:18:20Z")

</div>

This is fine. Let’s take this one step at a time. Construct your conditions file with just one column for your sentences, so it will look like this, with a variable name (say, `sentence`) at the top, and one complete sentence per row below it):

```auto
sentence
Mary doesn’t like to live in the city and / Paul wants to move to the country side
Sue doesn’t go to cheap hotels and / Tom always stays in fancy resorts
# etc

```

In a Builder file with just one loop (connected to that conditions file) containing just one routine (with a text stimulus and a keyboard component), can you get it to cycle through, showing each complete sentence per trial, moving on after a key press?

If this is not straight forward, just work through this 15 minute demo, which explains the basics (and a bit more):

Once you have this going with the complete sentences, I can show you easily how to extend that to split each sentence up at the `/`, but let’s walk before we can run.

---

<div class="post-metadata">

**Author:** ![lcrible](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/lcrible/32/6233_2.png) [@lcrible](https://discourse.psychopy.org/u/lcrible)\
**Post date:** [November 13, 2019, 10:08am UTC](https://discourse.psychopy.org/t/new-routine-for-each-trial-with-different-text/9848/5 "2019-11-13T10:08:02Z")

</div>

Hi Michael, thanks again for your help. I found a solution close to what you’re suggesting somewhere else on this forum ([Keyboard doesn't response in the second added routine](https://discourse.psychopy.org/t/keyboard-doesnt-response-in-the-second-added-routine/5646)), with symbols separating the chunks and a code component to instruct the split. It’s working now! (Not sure how to “close” this topic). Thank you.
