Upper limit for using the stimuli

Hi all,
I am building an experiment and was wondering - is it possible somehow set upper limit for one variable (word as a stimuli) in the whole experiment? In other words, I have list of 200 words, all of them should be randomly but equally distributed between all participants (one participant will have only some smaller set of stimuli-words). However, I would like to tell PsychoPy to stop offering a word in the new trials if it was already used, let’s say, 20x in the previous trials by previous participants. Hope it makes sense. I am not that advanced in coding but I am willing to try anything
Thanks!

I think there are two ways of doing this.

1. Divide your words into fixed (potentially overlapping) subsets and make sure you assign equal participants to each group.

2. Check and record the use of each word and skip if a maximum number of presentations has been reached.

How you do these will be different offline and online. Please could you confirm that you are running your experiment locally?

Thank you for your reply. The second option seems that might work on what I am trying to do. The thing is that I have three “blocks” made by loop that use the same words but with different condition so in each block, there is different question related to the words (1 - how well you express X vocally, 2 - how well you express X in gesture, 3 - how well you express X multimodally), but the words are essentially the same in all 3 blocks. What I need is that in each of this block, the word will appear, let’s say, in total 20x - which means, that at the end, for each word I will have 20 answers for each 1-vocal, 2-gestural, 3-multimodal mean of expression.
The experiment will run online only. If the second option is still appliable, could you please give me a hand?
Thanks for the feedback

Online, the solution for the second option would be to use the shelf. I haven’t done much with the shelf yet, but I think this would be a fairly simple project for me to use as a demo. For the demo my thought is to have a list of items (e.g. the numbers one to twenty in words), presenting five at random along with the total number of times that word has been presented across participants, and skipping if that number reaches a specified threshold. Does that sound like it would help you?

Thank you, I will take a look on the documentation and get back if any problem occurs. Do I understand correctly that this exhaustion condition is done only on Pavlovia server and not in the Builder/Coder? And if not, could you navigate me towards the right steps to do? Thanks

Here’s the documentation for the shelf. You create a shelf dictionary using Pavlovia and then use code components in Builder to make changes.

https://psychopy.org/online/shelf.html#usingshelf

Here’s my new demo (the first I’ve done with the shelf).

Presentation Cap code | try it

Uses the shelf to cap the maximum number of times a given item will be shown across participants. Checking and updating the shelf takes a little time - especially if an item needs to be skipped, so this experiment displays a fixation cross for 1 frame plus that time.

My shelf code seems to be taking about 850ms.

``````presentationCount = await psychoJS.shelf.getDictionaryFieldNames({key: ["presentation-cap"]});

if(!presentationCount.includes(Item)){
psychoJS.shelf.setDictionaryFieldValue({key: ["presentation-cap"], fieldName: Item, fieldValue :1});
count = 1;
nTrials += 1;
}else{
//increase the number of sessions completed by this participant
count = await psychoJS.shelf.getDictionaryFieldValue({key: ["presentation-cap"], fieldName:Item, defaultValue:'no sessions detected'});
count = count + 1;
if ((count > Number.parseInt(expInfo["presentation limit"]))) {
continueRoutine = false;
} else {
nTrials += 1;
psychoJS.shelf.setDictionaryFieldValue({key: ["presentation-cap"], fieldName: Item, fieldValue :count});
}

}
``````

Hey, I finally got to that and thanks, it seems to work. Thank you very much!

1 Like

Hi @wakecarter ,
I just wanted to let you know, that I found a bug (or an error) in this solution, especially when combined with code for ending routine after N number of stimuli presentation. So I have presentation cap for each word set on 20, 3 blocks, and each block ends after presenting 20 stimuli too. In the end of the experiment, when lots of words were close to having ‘20’ in the dictionary, I notice that the experiment skips them, but mark them as the stimuli in data .csv, just without rating, and go on another, but the block ends after 20 stimuli presentations, including those which were skipped. I attach test .csv so you can see that in expressibility.response some of the words have rating (those were shown), and some of them don’t - those were skipped because they were presented more than 20x already, but still are documented as being use here

I finished the experiment with handling the problem manually, but would still be interested in fixing it
bug.csv (12.3 KB)

Hi.

In my solution I use the following code to increase the value of nTrials

``````if(!presentationCount.includes(Item)){
psychoJS.shelf.setDictionaryFieldValue({key: ["presentation-cap"], fieldName: Item, fieldValue :1});
count = 1;
nTrials += 1;
}else{
//increase the number of sessions completed by this participant
count = await psychoJS.shelf.getDictionaryFieldValue({key: ["presentation-cap"], fieldName:Item, defaultValue:'no sessions detected'});
count = count + 1;
if ((count > Number.parseInt(expInfo["presentation limit"]))) {
continueRoutine = false;
} else {
nTrials += 1;
psychoJS.shelf.setDictionaryFieldValue({key: ["presentation-cap"], fieldName: Item, fieldValue :count});
}

}
``````

I then end the loop using

``````if ((nTrials > 4)) {
trials.finished = true;
}
``````

The loop will also end if all 26 letters have been checked and 5 have not been found below the presentation cap. Are you getting the issue because fewer than 20 words are below your presentation cap? If so then what would you like to happen?

Hm, I had the trials.finished = true in different code component with different syntax so probably it didn’t do the same.

``````myCount = myCount + 1
if myCount > 19:
trials.finished = True;
myCount = 0
``````

you used count, while I myCount (because I did the trial limit before the presentation cap and didn’t realize it might be bugging) so I guess that’s what was missing!

Thanks for clarification!

You are increasing myCount, irrespective of whether the Item is shown or not.