# Randomisation of word stimuli

**URL:** <https://discourse.psychopy.org/t/randomisation-of-word-stimuli/28155>\
**Category:** Builder\
**Tags:** randomization\
**Created:** [March 23, 2022, 10:50am UTC](https://discourse.psychopy.org/t/randomisation-of-word-stimuli/28155 "2022-03-23T10:50:30Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![memoire\_ulb](https://avatars.discourse-cdn.com/v4/letter/m/aeb1de/32.png) [@memoire\_ulb](https://discourse.psychopy.org/u/memoire_ulb)\
**Post date:** [March 23, 2022, 10:50am UTC](https://discourse.psychopy.org/t/randomisation-of-word-stimuli/28155/1 "2022-03-23T10:50:30Z")

</div>

OS : Win10  
PsychoPy version : 2022.1.1  
Standard Standalone? yes

What are you trying to achieve?: Hello, I am new at PsychoPy and am just discovering the programme. I would like to create a modified version of a Go/noGo task. For this I wish to use 3 categories of 20 words each as my stimuli. For each experimental block, I would like to randomly select either 5 or 15 words from a pool of 20 words which would be randomly selected without being repeated within a block.

What did you try to make it work?: I have looked on other forums to see if someone else has asked the question but being new I don’t know where to start. Is this possible to do using only builder mode or would I have to add it in code ?

What specifically went wrong when you tried that?: nothing went wrong since I don’t know where to begin. I hope to find a step by step explanation of how to go about creating something like this. Thank you very much in advance !

---

<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:** [March 24, 2022, 2:39pm UTC](https://discourse.psychopy.org/t/randomisation-of-word-stimuli/28155/2 "2022-03-24T14:39:47Z")

</div>

This is a recent thread doing a similar thing.

> [@Randomizing and picking a specific number of trials in a larger trial pool](https://discourse.psychopy.org/t/randomizing-and-picking-a-specific-number-of-trials-in-a-larger-trial-pool/28008):
>
> Hello everyone, I have a question concerning my dot probe experiment. In this experiment, I´m using words instead of pictures as you can see in this excel sheet Because my research focusses on the attentional bias of people with misophonia, I am using these trial-types: neutral-neutral (Baseline) misophonic-neutral negative-neutral My problem is that I`m replicating another experiment, which was programmed with Inquisit. Because of the replication, I have to combine every word p…

To randomly select 5 or 15 rows from three sets of 20 in a single loop will definitely need a code component, but you should start with Builder and then customise it.

---

<div class="post-metadata">

**Author:** ![memoire\_ulb](https://avatars.discourse-cdn.com/v4/letter/m/aeb1de/32.png) [@memoire\_ulb](https://discourse.psychopy.org/u/memoire_ulb)\
**Post date:** [March 24, 2022, 4:26pm UTC](https://discourse.psychopy.org/t/randomisation-of-word-stimuli/28155/3 "2022-03-24T16:26:14Z")

</div>

Thank you for your response ! I will have a look to see if I can find some answers.

---

<div class="post-metadata">

**Author:** ![memoire\_ulb](https://avatars.discourse-cdn.com/v4/letter/m/aeb1de/32.png) [@memoire\_ulb](https://discourse.psychopy.org/u/memoire_ulb)\
**Post date:** [April 12, 2022, 12:17pm UTC](https://discourse.psychopy.org/t/randomisation-of-word-stimuli/28155/4 "2022-04-12T12:17:35Z")

</div>

Hello, a friend of mine developed the following code (see images) in order to run my experiment. I have two categories of words from which I have to select my final list of words to present :

1. neutre (= mots\_go)
2. trauma (= mots\_no\_go)

The idea is for the programme to select 15 words from the “neutre” category (mots\_go) and 5 words from the “trauma” category (mots\_no\_go). These words are then put together in a final word list and the order of these words is then randomised. There will therefore be a final list of 20 words which have been randomly selected from each of the two category following the proportion of 15:5 respectively.

The reason why I also specified that words are either “mots\_go” and “mots\_no\_go” is becaused there will be different blocs during my experiment and the category of words will become either “mots\_go” (meaning 15 words will be selected from the list) or “mots\_no\_go” (meaning 5 words will be selected from the list).

The problem is that when I try to run the experiment, the following message appears : Alert 4210:JavaScript Syntax Error in ‘Before JS Experiment’ tab. See ‘Line 1: Unexpected token’ in the ‘Before JS Experiment’ tab.  
For further info see [4210: Probable syntax error detected in your JavaScript code — PsychoPy v2022.1.2](https://psychopy.org/alerts/4210.html)

However, I do not seem to see where the problem is. Could someone help me figure it out ? Thank you !

 ![code1](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/a/3/a32f6893c631b6922efbb66c30a6cfcc98d92929.jpeg)  
 ![code2](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/9/d/9d482da2fcac2f99a537934e896e7807fd36e2cd.jpeg)

this is the java translation :

 ![java1](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/f/5/f5b51c9fd15ee8c8b2b5062c646a34e3afb6a1c5.jpeg)  
 ![java2](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/f/1/f1adc801c4d7157e7e0baff34863e73ef7ee4285.jpeg)

---

<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 16, 2022, 7:48am UTC](https://discourse.psychopy.org/t/randomisation-of-word-stimuli/28155/5 "2022-04-16T07:48:44Z")

</div>

You are trying to import Python libraries online. I’d recommend that you read my crib sheet.
