Randomization without consecutive critical items

If this template helps then use it. If not then just delete and start from scratch.

OS (e.g. Win10):
PsychoPy version (e.g. 1.84.x):
Standard Standalone? (y/n) If not then what?:
What are you trying to achieve?:

Hi, I am trying to devise the experiment with the text stimuli.
While doing so, I do not want my critical stimuli to occur in a row.

For instance, the sequence of the stimuli should be something like:
Control - “Critical” - Control - Control - “Critical” - Control - “Critical” - Control - Control - so on;

Controls can occur in a row, but Criticals should not!!

Data frame in excel file is like this:
Item Type Stimulus
1 Critical sentence …
2 Critical sentence …
3 Critical sentence …
4 Control sentence …
5 Control sentence …
6 Control sentence …
7 Control sentence …
8 Control sentence …

I have searched and read some writings regarding similar issues, but those solutions didn’t work.
Can anyone help me with this? Eventually, it should be run in the Pavlovia.

Related link are also welcome!! Thanks!!

What did you try to make it work?:

What specifically went wrong when you tried that?:
Include pasted full error message if possible. “That didn’t work” is not enough information.

Hello R_S

do you need randomization? Otherwise bring the sentences in the order you want and set the loop to sequential instead of random.

If you need randomization, you will need some code. One brute-force approach to pseudo-randomization is to randomize the list and check whether your conditions are met. So, you need to check whether a critical item at position i is not followed by a critical item at position i+1.

Best wishes Jens

Thank you for the response.
Yes, I do need the randomization.I have 32 critical items and 64 control items, and every participant in the experiment should get a different order.

I read the following post, but I do not know how to use it for mine.: Randomisation with constraints - #9 by JensBoelte

The way I understood this is

  1. import the stim xlsx.
  2. randomize the order of the stims.
  3. put the logic to say “i and i +1 or i and i - 1” should not have the same label in Type such as Critical, otherwise randomize the order of the stim.
  4. when it satisfies the logic in 3, it starts the experiment.

Here is the dataframe again:
Data frame in excel file is like this:
Item Type Stimulus
1 Critical sentence1 …
2 Critical sentence2…
3 Critical sentence3 …
4 Control sentence4 …
5 Control sentence5 …
6 Control sentence6 …
7 Control sentence7 …
8 Control sentence8 …

so on

96 Control Sentence96

But I do not know how to code them, can you help with this? step by step?

What I do is sent a minimum and maximum gap between critical items (which I call targets in prospective memory tasks) and use interleaved lists (see my online demo).

Hello,

I would go with @wakecarter 's approach. I tried a brute force approach but found out that it might take some time to generate the intended distribution. I wouldn’t use it in an experiment. Participants might thinks that the experiment did not start properly. It only worked in a reasonable time when there were much more control items than critical items.

Best wishes Jens