Independently randomize a variable

OS : Win10
PsychoPy version 3.6.6
Hi,

I am designing an experiment with few conditions by using builder. the experiment has few conditions

  1. randomize the number variables
  2. randomize the letter height of number shown.
  3. Response when participants got the answer correctly.

My problem is the randomize the letter height. The letter height is shown in the condition file with number. However, the letter height did not randomize, it always paired with the randomized number.

I had attached few photos to have clearer picture:


I had set the letter height to “set every repeat”, but it does not randomize independently.

Hopefully anyone may help with this by using builder mode.

Hello,

PsychoPy always randomizes row-wise. How many random sizes do want to realise? How many numbers do you want to show?

You could simply make combinations of all your numbers and all your sizes in your Excel-file and have that randomized by PsychoPy.

Best Jens

Thank you so much for your reply.

This is the excel file with my 3 parameters:

I need to randomize the number and size, whereas corrAns is for the response set for participants. As you suggested that make combination in Excel-file and have that randomized by PsychoPy, may I have more details about how to execute this?

You need to more specific how you want to randomize numbers and sizes? The following example would show each number twice but each time in a different size

number size corrAns
1 0.05 space
2 0.05 space
3 0.07 space
4 0.07 space
5 0.2 space
6 0.3 space
7 0.5 space
8 0.8 space
9 1 space
1 1 space
2 0.8 space
3 0.5 space
4 0.3 space
5 0.2 space
6 0.07 space
7 0.07 space
8 0.05 space
9 0.05 space

Or do you simply want to present each number once but the size randomly assigned to it? Do all sizes have to appear?

Best Jens

yes, you are right!

Each number would only appear once but in a random sequence, and all sizes have to appear in a random sequence like your example.

  • Delete the “size” column from your spreadsheet.
  • Insert a Code component (from the custom component panel).
  • In its “Begin experiment” tab, insert something like this to create a new random order every time the experiment is run:
sizes = [0.05, 0.05, 0.07, 0.07, 0.2, 0.3, 0.5, 0.8, 1]
shuffle(sizes)
  • In the “Begin routine” tab, put something like this to select the value for the current trial and make sure it is recorded in the data file (because it isn’t in the conditions file any more, you become responsible for manually recording it in the data):
size = sizes.pop()
thisExp.addData('size', size)

Make sure the code component appears above any stimulus component that wants to use the size variable, so that the latter gets access to the current value.

Thank you so much! The code is able to randomize the sizes now!

How about I would like to present the numbers more than once when I run the experiment? Like you have suggested, but the number would you in a random sequence and the sizes in a random sequence.

number size corrAns
3 0.05 space
4 0.05 space
6 0.07 space
4 0.07 space
1 0.2 space
7 0.3 space
9 0.5 space
8 0.8 space
9 1 space
2 1 space
3 0.8 space
9 0.5 space
1 0.3 space
8 0.2 space
6 0.07 space
4 0.07 space
7 0.05 space
5 0.05 space

Hello,

to show your numbers more than once, you simply increase the number of loop repetitions from 1 to x. x being the number of iterations. Do you intend to have a specific distribution of sizes and numbers? Should each number occur in each size or is this of no relevance?

Best Jens

Hi,

I had increased the nResp to 3 (as per picture), but all the number just showed once.

There are no specific rules for it.

Regards,
Khai Ling

You would also need to make the list of sizes grow by the same amount, as otherwise an error will occur when you try to pop the tenth size from the list, which is defined to only have 9 indices:

sizes = [0.05, 0.05, 0.07, 0.07, 0.2, 0.3, 0.5, 0.8, 1] * 3

That will give you a list of 27 elements, which should correspond to the 27 trials you get by repeating your nine row conditions file three times.

Hi Jens,

I am so grateful and happy as all the problems are solved!

Thanks for being so helpful. Really thank you!

Best wishes,
Khai Ling

Hello Khai Ling

@Michael deserves the credit :wink:

Best Jens

1 Like

Hi, @Michael.

Thank you so much. Both of you really helped me out for my 1st psychopy experiment designed.

Thanks a lot!