I have 2 types of stimuli (i.e. Stimuli A and Stimuli B) for 2 decision tasks. There are 200 Stimuli A and 20 Stimuli B. I have made two loops so that 1 stimuli B (random) can appear after every 10 stimuli A (sequential). I added the code:
myCount = 0
myCount = myCount + 1
if myCount%10==0 and myCount>0:
Loop1.finished = True
However, the first 10 stimuli kept repeating without progressing to the next 10 stimuli. How can I fix the code so that the whole list of stimuli can be presented?
Hello,
Can you show us the flow of your experiment?
I donât understand the whole picture.
Thanks.
Can you please share the properties/settings of Loop1 and Loop2?
I see the problem.
The loop doesnât have any indication to start from a row other than the first one.
Did you try modifying the Selected rows option?
For example, something like that might work:
# Selected rows (inside the Loop1 properties):
$Loop1.thisN + Loop2.thisN * 9
# Selected rows (inside the Loop2 properties):
$Loop2.thisN + Loop2.thisN * 2
You probably need to modify the nReps and change the calculation of the selected rows, but it should give you a solid direction to the solution.
Let me know if you need more help ![]()
Thank you so much for your help!! Let me try to modify it now.
There is an error when I sync it to the palvolvia:
âTypeError: Cannot read properties of undefined (reading âthisNâ)â
thisN seems does not work in palvlovia
On which version of PsychoPy are you working?
The same thing happened to another user today:
Hi
trials.thisN worked with 2022.2.4 which I have installed.
Best wishes Jens
I am using 2021.2.3 version of Psychopy. I used the latest version 2023.1.1 to build the experiment before, but it was unstable and caused some errors in palvlovia. The older version seems to be more promising.
Thank you so much, Jens! I will install the 2022.2.4 version.
There is an easy workaround around it. I also mentioned it in the other thread:
What you can do is create a new variable that is equal to 0. Then each time the routine start/end, increase this variable by one. It works the same as thisN.
I used 2022.2.4 version but there is still an error in palvlovia TypeError: Cannot read properties of undefined (reading âthisNâ)
Regarding creating a new variable, should I insert the code in trial_1? I am not sure how to work on it.
Hey @wakecarter , do you know if the thisN work on this version?
Thanks
Yes. According to my crib sheet it works from 2021.2
I tried to put the string $Loop1.thisN + Loop2.thisN * 9 in âselected rowâ option of Loop 1, but there was TypeError: Cannot read properties of undefined (reading âthisNâ) in palvlovia. Does it mean that I did not define this variable in the JS code?
Loop1.thisN doesnât have a value in the definition of Loop1
Thank you so much! My intended flow is:
Stimuli A: 0-9 (loop1)
Stimuli B: random 1 (loop2)
Stimuli A: 10-19 (loop1)
Stimuli B: random 1 (loop2)
Stimuli A: 20-29 (loop1)
Stimuli B: random 1 (loop2)
I have never tried to modify Selected rows options before, so I am not quite sure how I should modify to get what I want.
Have you put 3 reps for loop1?
Put 1 rep for loop1 and add an outer loop0 which sets the nReps for loop1


