Sorry if this is documented somewhere or if this question is repeated, and I would really appreciate if you can point me to the right place, as I thought what I’m trying to do should be common…
Description of the problem: basically I want to dynamically generate stimuli based on subjs’ prior responses
Specifically,
in trial i, a subj will make a choice between 2 items, such as apple vs orange (two items sampled randomly), and let’s say that this subj picked apple
in some subsequent trial i+k, this subject will choose between apple vs. watermelon (a new item, sampled randomly)
in general, every trial either contain 2 novel items, or 1 novel item + 1 old item that subjs picked previously
How do I do that? I think I need a variable to track items that were selected before, but I couldn’t find documentation about this, and a friend of mine who uses psychopy is also not exactly sure how to achieve this. We also thought about writing to and reading from a csv that track selected items, as psychopy can define a list of trials using an external csv. Is this the recommended approach?
Generally speaking what you’re doing is the same as making a feedback trial, but instead of providing feedback you’re just taking the response and using it to fill in a stimulus. It should be fairly straightforward to use code components and either store the response to a separate variable, or actually access the data from the previous trial directly (the first link shows how to do this in Python, and the auto->JS translator in the code component can probably make it work the same way online as well).
You can’t write to an external CSV online. Append to a list and then read / pop from it in a later loop. A loop doesn’t need to have a spreadsheet. Some of my online demos use this kind of technique. Take a look at Repeat Subset
Thank you both so much wakecarter and jonathan.kominsky (somehow new users can’t @ other users) ! These resources are super helpful!
Just another quick question: one additional thing I also need which isn’t obvious by looking at these resource is that for every trial, I need to randomly decide whether to …
a. generate two random items / stimuli
b. generate one random item + randomly sample an old item, from the set of selected items in the past
In pychopy, is it possible to dynamically decide between these 2 trial types? The complexity is that optional b it is not always possible (e.g. if people haven’t selected any item). At the start of each trial, I need to flip a coin to decide whether to do trial type a or trial type b, but if b is not possible, trial type a will be presented.
I would really appreciate it if you could point me to something that does this! Thank you so much ahead!
I don’t have a perfect example offhand but there are two general ways I can think of doing this:
Have both types in a normal trial loop with a safeguard. That is, have a code component in your “begin routine” tab that checks the list of old items and if there isn’t a valid option, moves things around in the loop’s trialList to replace it with a valid trial.
Do everything with code components in the “begin routine” tab: First check if there are valid old responses, if so do a coin flip to see which type of trial to present, then select stimuli from the list of random words and the list of old words, or two stimuli from the list of random words.