Can I assign response keys differently to participants randomly?

Hello researches,

I want to build an experiment that has two different tasks but one pair of response keys (i.e., “A” and “B”)

For instance, participants will see a word on the half of the trials and a polygon shape in the other half of the trials and the task would be;
when you see a word “press A” if it has more than 5 letters, “press B” if it has less than 5 letters.
and when you see a polygon “press A” if it is a triangle, press B if it is a rectangle.

So there are 4 different combinations of response keys.

1st possibility word: “A” less, “B” more
polygon: “A” triangle, “B” rectangle.

2nd possibility word: “A” more, “B” less
polygon: “A” triangle, “B” rectangle.

3rd possibility word: “A” less, “B” more
polygon: “B” triangle, “A” rectangle.

4th possibility word: “B” less, “A” more
polygon: “B” triangle, “A” rectangle.

My question is, “Is it possible to assign 4 different possible corrAns randomly to participants?”
i.e., Participant 1 gets the 3rd, and Participant 2 gets the 1st possible answer keys!

Can I use any kind of code component to do this?

I hope I could ask my question clearly!

Thank you for the answers!

Yes. But the easiest thing to do would be to have four different conditions files, and select which one you want in the initial info dialog. This means that you can systematically balance the combinations across subjects, rather than relying on code to randomly assign them. i.e. add a field (called say, conditions) to the info dialog. At the start of each session, type in a label there for the file to use, and then put something like this in the loop dialog for the conditions file:

expInfo['conditions'] + '.csv'
2 Likes

Hi @Michael,

Would this also work if I want to assign participants different lists? so if I add a field that called list and the participant completes list_1 then in the loop I add expInfo['list_1'] + '.csv' then the condition file list_1 will be pulled for that participant?

What about if I rather give every participant a number (P1, P2, P3, etc.) and I want that for certain participants it goes to different lists (e.g., P1 list_1, P2 list_2, P3 list_1, etc.). I guess I create an excel file with a column for participants and a column for lists, but then what do I do, where do I upload that file and do I need a code or something?

Thanksss!

@Michael Thank you so much for your advice! It really fits what I needed.

I created 4 different condition files for all possible response keys combination (named 01, 02, 03, and 04) and created a dialog box called “conditions”. Actually I am planning to run the experiment in Pavlovia, therefore, should I ask the participant to fill the condition box as 01 or 03. Am I correct?

However, I did not understand following fully:

I copied and paste this to the loop that I usually put/attach condition file and it did not work.
Can you give more instructions about how to do that part?

Many thanks!!

Please always give details (e.g. an error message). But at a guess, that expression was missing the $ prefix that tells Builder to interpret the text as a Python expression rather than as a literal filename:

$expInfo['conditions'] + ‘.csv’

No, if the field is called list, then you type whatever you want in that field, and it will be used to build the filename. So if you type xxx111 into the field list, then:

$expInfo['list'] + '.csv'

would evaluate to xxx111.csv

No, you do it manually. You look up the person’s code, and type the filename to use for that person into the info dialog at the start of the experiment.

1 Like

Sorry, I should’ve thought about giving details about how it did not work. I am new here on the PsychoPy discourse. But as you suggest, by simply adding $ prefix I could run the experiment.

However, there is one detail I did not consider before. I will collect data on Pavlovia and participants will need to enter condition names (that corresponds condition file name) by themselves. This process can be tricky for participants. To be honest, we decided not to show an info dialog before the experiment. Therefore, randomly assigning participants to one of the 4 conditions can be easier for my data collection.
I would be really grateful if you can help me how to assigning participants in one of 4 conditions with code component as well.

Thank you so much!

Do you have access to Qualtrics or equivalent? I’m planning to assign participants to conditions in Qualtrics and then pass the condition or order variable to PsychoPy.

I randomly assign response keys by shuffling an array with the possibilities. Correct answer is then based on position in the shuffled array. This wouldn’t balance numbers exactly however.

Best wishes,

Wakefield

Unfortunately, I do not have access to Qualtrics or equivalent now.

But anyway, How could you pass the assigned conditions from Qualtrics to PsychoPy? Is it possible to do it without any manual process (i.e., participants do not need to enter condition number or participant number?

All best,

Emre

If you have a variable called, say, condition, in the PsychoPy Experiment info dialogue box (in addition to the standard participant) then you can send a variable in a URL using ?participant=x&condition=y. If all the experiment info variables have values then Pavlovia skips the box altogether.

@wakecarter Thank you so much!

I do not need to collect participant ID (I prefer to give participant ID after I collect data by the time day completed exp). So creating only condition dialog box in the PsychoPy Experiment info dialog and sending the URL of the experiment with adding the following

will automatically start the experiment? Am I correct?
I will have 4 different response conditions. As far as I understood, I need to create various links that correspond to each condition in total 4. Then send it to those links to participants?

I am a total newbie about this, so I might be asking simple questions!

You could call every participant 1, so add &participant=1&condition=1 for condition 1, &participant=1&condition=2 for participant 2, etc.

I’ve not yet used Pavlovia for real so I can’t say for sure, but I know the principle. You don’t need a ? if there is already a ? in the URL.

Best wishes,

Wakefield

@wakecarter thank you so much for the explanation!

This idea could work for me!

Best wishes,

Emre

and how do you send this URL to the participant? so Pavlovia gives you a fixed URL, are you saying that if you add this at the end of the URL this will automatically fill certain fields in the experiment info dialogue box?

Exactly

I tried but it didn’t work, I believe I might be doing it wrong, can you please give me an example on this URL, provided the field I wanna fill is List* and I want to fill that field with the number 6. Thanksss.

https://run.pavlovia.org/laurapissani/name_of_study/html

Better still please post what you tried so I can highlight the error.

OK, so this a real experiment and I want to fill the Participant* box in the dialog box with P46:

https://run.pavlovia.org/laurapissani/the_maze_5/&Participant*=P46/html

https://run.pavlovia.org/laurapissani/the_maze/html?Participant*=P46

/html is part of the URL
You need ? before the first variable and then & before further ones.

1 Like

IT WORKED! Thanks so much, this is genius!