How easy is it to distribute a long list of trials among participants?

Here is my situation. I have ~10,000 potential trials. I would like to have them each responded to twice.

I thought to do this by creating one big conditions file with all 10,000 trials in a random order, and then all 10,000 again in a different random order.

I would like to do something like: give participant 1 rows 1:100, participant 2 rows 101:200 and so on.

I figure this should be doable, by somehow incrementing participant number, and have the rows that are presented be some function of the participant number?

I’m not asking for an exact explanation on how to do this, but I wanted to be sure that this was in the realm of possibility before I started really looking into it.

Participants will be taking part on Pavlovia.

At the moment your best option is to use my VESPR Study Portal and either set up 100 groups or use the consecutive participant number (which doesn’t account for abandonment).

@wakecarter Sorry, I never thanked you for the reply!

I’m wondering if it’s still the case that this is the easiest way to do this? I should add that I’ll be running the study on Pavlovia.

Yes, the VESPR Study Portal is still the best way to allocate to multiple groups while taking into account non-finishers.

There’s a link to a video, a post on this forum and some slides at the bottom of the admin page.

1 Like

Thanks so much! I watched the video and it seems like exactly what I would like!

I’m now trying to implement it in an experiment. I’ve done so by having multiple Excel files (i.e., one for each condition). Then in my loop, I have it set to choose a specific Excel file based on the group number. To do this, I have code at the beginning of the experiment like this:

theGroup = expInfo["Group"]

And them in my Loop, the conditions file is called:

$"Group" + theGroup + ".xlsx"

This works great when I run it on my computer, but when I try to upload it to Pavlovia, I get this error. It seems like it doesn’t like only having Group defined when a person begins the experiment? Do you have any advice on how to handle this (with the eventual goal of then interfacing with VESPR)?


Traceback (most recent call last):
  File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.6/psychopy/experiment/_experiment.py”, line 829, in findPathsInFile
  File “<string>”, line 1, in <module>
NameError: name ‘theGroup’ is not defined

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.6/openpyxl/reader/excel.py”, line 121, in _validate_archive
  File “zipfile.pyc”, line 1131, in __init__
  File “zipfile.pyc”, line 1198, in _RealGetContents
zipfile.BadZipFile: File is not a zip file

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.6/psychopy/app/builder/builder.py”, line 1344, in onPavloviaSync
  File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.6/psychopy/app/builder/builder.py”, line 793, in fileExport
  File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.6/psychopy/scripts/psyexpCompile.py”, line 74, in generateScript
  File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.6/psychopy/scripts/psyexpCompile.py”, line 247, in compileScript
  File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.6/psychopy/scripts/psyexpCompile.py”, line 219, in _makeTarget
  File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.6/psychopy/experiment/_experiment.py”, line 254, in writeScript
  File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.6/psychopy/experiment/flow.py”, line 309, in writeFlowSchedulerJS
  File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.6/psychopy/experiment/_experiment.py”, line 877, in getResourceFiles
  File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.6/psychopy/experiment/_experiment.py”, line 843, in findPathsInFile
  File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.6/psychopy/experiment/_experiment.py”, line 860, in findPathsInFile
  File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.6/psychopy/data/utils.py”, line 365, in importConditions
  File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.6/openpyxl/reader/excel.py”, line 174, in load_workbook
  File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.6/openpyxl/reader/excel.py”, line 124, in _validate_archive
  File “zipfile.pyc”, line 1131, in __init__
  File “zipfile.pyc”, line 1198, in _RealGetContents
zipfile.BadZipFile: File is not a zip file

It would also be nice to be able to have one Conditions file, and present a subset of rows based on Group Number (i.e., instead of having multiple conditions files). I wonder if this is possible?

I’ve tried doing something like this. Having this code run before the experiment:

theGroup = expInfo["Group"]
conditions = data.importConditions(Conditions.xlsx’)
Group1 = conditions[0:3]
Group2 = conditions[4:7]

And then, in my loop, setting Selected rows to: $"Group" + theGroup

But it doesn’t seem like this is correct.

Code is case sensitive. Try

theGroup = expInfo['group']

You might want to try nesting three files.such as condition1.xlsx condition2.xlsx and condition3

Thanks for getting back to me! I tried using lower case for “group” but it doesn’t help.

Also, when I take a look at the variable in my code it is upper case:

expInfo = {'participant': '', 'session': '001', 'Group': ''}

Sorry, I’m not sure what you mean exactly?

Personally, I prefer to use the selected rows field in the loop rather than have multiple spreadsheets to manage.

Okay, I will go this route! Is there any chance you could recommend a guide doing this sort of thing? (I.e., having rows selected based on group number)

If your expInfo variable is called group then you could have the following in a Begin Experiment code tab:

useRows = '' # Required to prevent an undefined error online
if expInfo['group'] == '1': # Note that expInfo values are strings.
     useRows = '0:4' # First four conditions
elif expInfo['group'] == '2':
     useRows = '4:8' # Second four conditions

Then in your loop set selected rows to $useRows

2 Likes

Thank you! It is working perfectly!

Just for my own understanding, is useRows = '' necessary because we have to create a variable before setting its value?

I think that the issue is one of scope. It seems that if a variable is first declared inside brackets (such as a loop or conditional clause) then it can’t be used outside those brackets. However, if it is given a value outside then it can tale values outside and inside.

You could set it to the rows for group 1 and only change that value for other groups.

1 Like