Randomisation of word stimuli

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 !

This is a recent thread doing a similar thing.

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.

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

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

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

this is the java translation :

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