OS : MacOS 10.15.3
PsychoPy version : 2020.2.5
Standard Standalone? (y/n) If not then what?: Y
**What are you trying to achieve?: randomized partial loops
Hello! I am a beginner in PsychoPy helping on an Interpretation Bias Experiment. The experiment presents participants with an ambiguous sentence and then with a word which they will press the left key for if it is related or the right key for if it is unrelated. Our conditions doc has 96 conditions and 2 parameters with 48 different sentences (each sentence is listed twice with a related word and an unrelated word). The current loop is random with one repetition.
Our goal is that, each time a participant completes the experiment (they will complete it up to 5 times depending on the group they are assigned too), they will receive only 24 conditions for this loop. Of those conditions our goal is to include repeat sentences in the same trial and for them to receive new conditions on the next trial.
My questions are related to the “trial” segment of the experiment shown in the photo attached
What did you try to make it work?:
On the random loop, nReps$ box I entered “0.25” as an attempt to get only 24 of the 96 conditions to show. I am unsure how to approach designating the identical conditions (sentences) with the different parameters (related/unrelated words) so that they are mutually exclusive and one does not appear if the other is shown.
What specifically went wrong when you tried that?:
When I ran the experiment in this way it exited out right when the loop was supposed to start. There was no error message.
Sounds like you are pretty close - except that you want the ‘selected rows’ option rather than the ‘nReps’ option - you could use this to sample 24 rows from your conditions file - does this sound similar to what you need?
Thank you so much for your help! I tried placing “24” and after that “1-24” in the “selected rows” option but each time the experiment quit when it got to that loop with no error message. Would you have any advice on trouble shooting this?
I was also wondering if there is a way to make certain conditions mutually exclusive so that the duplicate conditions with different answers do not appear in the same trial?
it is 0:24. See the help that comes with PsychoPy.
Thank you so much! It ran with that! Although, I was wondering if there is there a way to get it to randomly select 24 out of the 96 conditions rather than randomizing the first 24 so that on subsequent trials participants can get a wide range of conditions. Thanks again!
yes, you need some code. Do you want to run the experiment online? If you search the forum for randomize, randomization aso. you find some solutions.
a dummy experiment might point you in the proper direction.
index = 
for i in range(96):
index1 = index[0:24]
place this code in a code element in the begin experiment tab of a routine. Insert a new routine. Surround it by a loop. Refer to index1 in “Selected rows” of your trial loop with $index1. Set loop type to sequential.
Stimuli.xlsx (9.2 KB) Test.psyexp (9.4 KB)
Thank you so much! That did it! I was also wondering if you knew of a way to get conditions to be mutually exclusive? So for instance I have duplicate conditions with different words attached to them and I am interested in having two of the same not show up in the same run of the experiment. I’m attaching the conditions file as well. Let me know if you have any ideas and thanks again!
[ConditionsInterp.xlsx (11.7 KB) ](https://)
I need to understand you experiment better. One participant will see 24 sentences, 12 per condition (related, unrelated). A sentence should be presented only once, either in the related or the unrelated condition, right? Do you want an even distribution of the sentences across participants? That is, sentence 1 is presented as often as sentence 2 but to different partifcipants in the experiment? As a matter of fact this is best achieved by using different stimulus files (or different rows in one stimulus file) which for instance depend on participant number or group number. Using different stimulus files allows you to control for duplicate sentences (aka conditions in PsychoPy).
Yes! Currently I have the sentences themselves defined as the conditions so that may be the issue. I would like an even distribution across participants! Just to clarify, are you recommending I create different excel files for each participant? Would you be able to speak a bit more as to how I could use these to control for duplicate sentences? Thank you so much for all your help! It’s greatly appreciated!
no, you don’t need one excel-file for each participant. You need four excel-files, each containing 24 sentences, 12 related and 12 unrelated (I assume that you want to have an even number of related and unrelated sentences as well). Then you read the stimulus file depending on your participant number (only numbers please)
stimfile1.xlsx (8.6 KB) stimfile2.xlsx (8.6 KB) stimfile3.xlsx (8.6 KB) stimfile4.xlsx (8.6 KB) Test.psyexp (7.3 KB)
Thank you! Just want to clarify one more time. With this setup would I be confining each participant to a singular set of conditions each time they complete the experiment? Is there a way to get the stimulus files to rotate for them each time they take it? For example, If Participant 1 completes the experiment everyday for 4 days, the first day they would get the first set of conditions, the second day the second set, and so on.
Also, this is a logistical question but where do I upload the four separate stimulus files so that Psychopy can read them all and determine which to show? Under “conditions” I’m only able to upload one file.
Thank you so much!
you are correct, this approach confines each participant to a singular set of sentences each time they complete the experiment. If you want that each participant, complete a different set of sentences each day, introduce a parameter in Experiment settings -> Experiment Info, for instance “list”. Change the code element to
if int(expInfo['list']) %4 == 0:
stimfile = "stimfile4.xlsx"
elif int(expInfo['list']) %3 == 0:
stimfile = "stimfile3.xlsx"
elif int(expInfo['list']) %2 == 0:
stimfile = "stimfile2.xlsx"
stimfile = "stimfile1.xlsx"
Then, the stimulus list ist selected on the basis of the parameter list. You might want to store the list in your data file (endRoutine)
Yes, when uploading (syncing) your experiment with Pavlovia, all four stimulus-files will be uploaded (or upload them manually). You do not specify any file under “conditions” but refer to the variable “stimfile” .
Thank you! I am unable to find a ’ experiment info’ box under experiment ‘settings’ where I would be able to paste the code element. Would you be able to direct me further on where to paste this? Thanks again!
Edit experiment settings → Experiment settings → then add list to Experiment info
you don’t paste the code element in eperiment info box. You paste the code in a code element starting the experiment begin. Take a look at the example experiment I uploaded.
In the “Experiment info” box you only define variables, Most of the time you define demographic variables that you like to register. But you can also define other variables which you use to control the flow of your experiment as I suggested
Thank you for the clarification and your continued patience! When I paste that code in the “begin experiment” section and run the experiment I got the following error message:
“Traceback (most recent call last):
File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.6/psychopy/app/runner/scriptProcess.py”, line 123, in whileRunningFile
File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.6/psychopy/app/runner/runner.py”, line 514, in onProcessEnded
File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.6/psychopy/app/runner/scriptProcess.py”, line 140, in onProcessEnded
AttributeError: ‘NoneType’ object has no attribute ‘stdOut’”
Do you have any recommendations for this? Thanks again!