Hello all,
I met a problem that I don’t think I can solve it by myself. I am asking for your help sincerely.
I have a stimulus set. One stimulus set contains many object categories, and each categories consist of four pictures. The question is that I don’t know how to randomly select one picture in each trial as well as randomly select the object categories at the same time. If it need code to cope with, please inform me in details.
Here’s how my folder of the stimulus set looks like:
That works. Thanks sincerely!
However, I have another question about randomization. I have another stimulus set, which contains many object categories. The difference is that each object categories consists of eight object pictures. It is composed of 2 levels of exemplars, 2 levels of orientation, and 2 levels of materials(222=8). What’s more, the variable Feature(orientation, material) is a between-subject variable.That means, one group of subjects are tested with exemplar-orientation, the other group of subjects are tested with exemplar-material. The problem is that I don’t know how to present one single picture at a trial randomly.
Here’s how my folder of the stimulus set looks like:
Between subject variables are best set in the expInfo dialogue box (to ensure equal distribution of conditions). Random allocation in code is fine for some variables but can result in randomly having very different group sizes, especially in small studies.
Unless you want to commission someone to help you or do it for you then you should make your best attempt and show what you tried and what went wrong.
I think you are totally correct. I did’t have a clear thought about the problem.
Now let me make it clear.
In my condition file, there are eight pictures. I want the computer to randomly pick one from Pic1 to Pic4,or from Pic5 to Pic8(to control the Orientation variable). Then how to modifly the former codes to obtain the effect?
Thanks for your patient help.
I am not so good at codes. I have two stimulus sets. In the OE stimulus set, each object category has 4 object pictures; In the CAD stimulus set, each object category has 8 object pictures. I want to randomly pick pictures in the two stimulus set. I am going to create a code of nested loop. So based on the former code: thisPic=None picChoose=randint(0,4) if picChoose==0: thisPic=Pic1 elif picChoose ==1: thisPic=Pic2 elif picChoose ==2: thisPic=Pic3 elif picChoose ==3: thisPic=Pic4
I make some adjustments as the following:
Generating PsychoPy script...
############# Running: D:\psychopy\RWO_LTM\Exp1 - copy_lastrun.py ##############
75.0111 INFO Loaded monitor calibration from ['2021_02_20 15:59']
pygame 1.9.6
Hello from the pygame community. https://www.pygame.org/contribute.html
##### Experiment ended. #####
Generating PsychoPy script...
############# Running: D:\psychopy\RWO_LTM\Exp1 - copy_lastrun.py ##############
135.2939 INFO Loaded monitor calibration from ['2021_02_20 15:59']
pygame 1.9.6
Hello from the pygame community. https://www.pygame.org/contribute.html
##### Experiment ended. #####
Generating PsychoPy script...
############# Running: D:\psychopy\RWO_LTM\Exp1 - copy_lastrun.py ##############
294.3059 INFO Loaded monitor calibration from ['2021_02_20 15:59']
Alert 4205:Python Syntax Error in 'Begin Routine' tab. See ' elif picChoose ==1:
' on line number 6 of the 'Begin Routine' tab.
For further info see https://psychopy.org/alerts/4205.html
File "D:\psychopy\RWO_LTM\Exp1 - copy_lastrun.py", line 1092
elif picChoose ==1:
^
SyntaxError: invalid syntax
##### Experiment ended. #####
Generating PsychoPy script...
############# Running: D:\psychopy\RWO_LTM\Exp1 - copy_lastrun.py ##############
302.4314 INFO Loaded monitor calibration from ['2021_02_20 15:59']
Alert 4205:Python Syntax Error in 'Begin Routine' tab. See ' elif picChoose ==1:
' on line number 6 of the 'Begin Routine' tab.
For further info see https://psychopy.org/alerts/4205.html
File "D:\psychopy\RWO_LTM\Exp1 - copy_lastrun.py", line 1092
elif picChoose ==1:
^
SyntaxError: invalid syntax
##### Experiment ended. #####
Generating PsychoPy script...
############# Running: D:\psychopy\RWO_LTM\Exp1 - copy_lastrun.py ##############
308.3122 INFO Loaded monitor calibration from ['2021_02_20 15:59']
Alert 4205:Python Syntax Error in 'Begin Routine' tab. See ' elif picChoose ==1:
' on line number 6 of the 'Begin Routine' tab.
For further info see https://psychopy.org/alerts/4205.html
File "D:\psychopy\RWO_LTM\Exp1 - copy_lastrun.py", line 1092
elif picChoose ==1:
^
SyntaxError: invalid syntax
##### Experiment ended. #####
Could you give me some suggestions how to adjust the codes?
Thanks sincerely.
But also note that you specify stimulus_set = None and then immediately check the value of stimulus_set: there is not much point in that, as you’ve just set it to None.
This sort of code could also be much more concise, like this: