Randomization of SOA and block order

Hi,
Thanks for the great program.
I’m designing a primed picture naming experiment in which I have some conditions.
There are 4 blocks of different trials that I need to randomize them, both within block and between blocks. The first two blocks are related to one condition and the second two are related to another condition. So I need to make three randomization types. With responses to questions and videos, I discovered that I need to make a loop for each of the blocks and set them random. Then I should make a loop for each of my two blocks and then make a loop around all the four blocks. This way, I should define my condition excel file including the name of my blocks. But doing so, my experiment doesn’t run. Or if it runs, it makes a repeat of the loops and doesn’t make them random. Neccessary to mention is that the trials of each block are different from one another. With prime words and target pictures.

Another point is that there are two SOA durations in the experiment which is going to be random too for each block; i.e. a group of participants receive the first block with a short SOA and the second group with a long SOA, then for the second block it would be the reverse, and so forth.

How should I define it in the experiment so that it doesn’t need to design two or maybe 4 different experiments for each SOA and also for the randomization matter.
I’m new to psychopy and have no coding background.
Useful information may be that I use windows (10), PsychoPy version (2020.2.4 win64) and Standard Standalone.

I really appreciate your helps in advance.

Hello,

do you mind posting a toy version of your Excel-file(s)?

Cheers Jens

Dear Jens
sure, I appreciate the time you take.
these are the toy excel files for the first and second blocks. and also the choose block condition file.
2
3
1

Hi farbia that’s for this! Please could you are share a screen shot of your “flow” section on the builder so that we can see the trial structure?

On trials where it doesn’t run, do you get an error message in your runner view?

If so please can you share that?

Becca

Hi Becca
this is the flow


No I don’t get any error message in the runner view.
Fariba

If Eblock1 and Eblock2 contain the same components (but the attributes of those component are diff for each block e.g. PrimeStim) then you only need a single block routine rather than 2. The first loop will go around that block and have the variable $CondsFile in the “conditions” field. The second loop will go around that loop (as you have already)

Becca

The blocks contain totally different components.

Fariba

Hello Fariba

small comments on your toy Excel files. Use “/” instead of “” in your file paths. Your pictures are missing file-extensions. Do you add those with a code element? All columns should have column-name or simply deleted the column containing 1-4.

So, I gues that the loop chooseBlock1 and chooseBlock2 are set to random so that they cycle randdomly through EBlock1 and Eblock2 (again file extensions are missing; Do you add them?) which are also set to random. That does not work?

Regarding SOA, either you add a SOA column to your excel file or you add some code at the beginning of the experiment. This code element sets the soa for each block depending on the participant number. Something like the following:

if int(expInfo['participant'])%2 == 0:
    soaBlock1 = 100
    soaBlock2 = 1000
else:
    soaBlock1 = 1000
    soaBlock2 = 100

Cheers Jens

Dear Becca
Thanks for your response. This is actually the appropriate way to make the presentation of the two blocks randomly possible.
Fariba

Hi Fariba,

Ah yes, your question is much clearer now. You will be please to hear that we now have a demo of how to do this and have updated our documentation to discuss counterbalancing a several routines with different components :slight_smile:

Here is a demo that should do what you need (download the files and save in the same folder):

randomBlock.psyexp (12.3 KB) conditions.xlsx (8.5 KB) conditionsA.xlsx (8.5 KB) conditionsB.xlsx (8.5 KB)

Here are some other useful threads:

  1. The demo made for you above is actually adapted from this question here Sequence of routines based on slider response - #6 by Becca

  2. If you want to fully counterbalance several blocks/routines with different components aee here for a thread on how to counterbalance several blocks containing different components:
    Using variables in completed URL to direct to next PsychoPy expt - #8 by Becca

This documentation will soon be available at Running and sharing studies online — PsychoPy v2021.2

Hope this helps,
Becca

My dear @Becca , thanks for your response but what seems to be relevant in my case is your first suggestion to link all the conditions files to only one block. since they are not reflecting different tasks or components as you said. But I need to make an experiment for each language to be performed on different occasions. However, each of them should be randomized. what I did was that I defined 2 conditions files for two different conditions (group A and B) then another conditions file including both groups and entered ‘$“Group”+expInfo[‘Group’]+".xlsx"’ into the conditions field (with a new field in the experiment GUI setting). But the ‘ok’ button gets inactive and then the experiment doesn’t run. with this error:
File “C:\Users\Novin\Desktop\psychpractice\last_lastrun.py”, line 49, in
filename = thisDir + os.sep + u’data/%s%s_%s’ % (expInfo[‘participant’], expName, expInfo[‘date’])
KeyError: ‘participant’
Even doing so, I couldn’t make SOA randomization.
I also tried a new way. I defined an excel table consisting of group A and B conditions and the two SOA conditions, say 50 and 100 msec.(left at last with four condition rows). But I don’t know how to set the ‘duration’ box for my stimuli and the ‘start’ box for the next related target stimuli!
Maybe I’m going all the solutions halfway, but I don’t know how to fix it…
thanks for your time.

Hello Jens

Thanks for the help.
My images are not missing files and the experiment could find them if I don’t add new conditions to it.
but how can I mix this condition (SOA: if int(expInfo['participant…) with the counterbalancing of blocks?

Aha I see, my apologies, the participant key error means that you are missing the ‘participant’ field from your experiment settings - are you able to make sure you keep that field?

Becca

Hello Fariba,

in your Excel toy-example you write, for instance

F:\test\EPics\circle.

This pointer to a file is missing a file extension such as *.jpg, *.png or whatever file-format you are using for your pictures. PsychoPy makes a best guess to find the file. I suggest to change the point to your file to, for instance

F:/test/EPics/circle.jpg.

if this is the file-format you are using. But that seems to be a minor problem at the moment.

It would help if you uploaded a toy-vesion of your experiment or granted access to a copy on Pavlovia.

CU Jens

Oh sorry. It was actually corrected at once, when I first ran the exp… since it was just a toy version.
But unfortunately I haven’t yet granted getting Pavlovia.
Thanks anyway.
Fariba

Hi @JensBoelte,
How can I share it with you here? Does changing it to a .rar file help? Can I upload it this way?

Simply upload your *.psyexp, your *.xlsx files and the relevant material files using the upload-button in this forum.
grafik

Best Jens

Sure. Thanks a bunch

toyexp.psyexp (18.0 KB)
conditions.xlsx (7.9 KB)
EnglishBlock1.xlsx (8.2 KB)
EnglishBlock2.xlsx (8.2 KB)

These make the first draft of the experiment without adding any components yet.
What I actually need to create is: 1) counterbalancing the presentation of EnglishBlock1 and EnglishBlock2, and 2) change the presentation of time of the PrimeStim from block to block and from participant to participant. It is now set to 0.05 sec, but it is just a fixed number for the two blocks, while, it should be actually 0.05 for EnglishBlock1 and 0.1 for EnglishBlock2 for participant 1 and 0.1 for EnglishBlock1 and 0.05 for EnglishBlock2 for participant 2.

I also tried this type of conditions file:
conditions1.xlsx (9.1 KB)
But it seems to be wrong. since only the first block is actually included in the column Blocks or SOA. and as I said when entered ‘$“Group”+expInfo[‘Group’]+".xlsx"’ into the conditions field (with a new field in the experiment GUI setting for group info), the ‘ok’ button gets inactive.

That’s ok dear @Becca .
Thanks for your point. I seriously didn’t know this field is essential, so I included a participant field. The error didn’t appear anymore. But the same thing was with the conditions field.