How to use .txt file to assign order to stimuli presentation?
Hello!
I am a beginner at Python. I am trying to create an experiment with a training/priming phase, and then a forced choice testing phase.
For the training phase, I have a .txt file that contains a "template" (a list of 700+ items) for the ordering of my stimuli. During the training phase, the participants will see a sequence of eight (8) randomised words individually, but over 700 times within a fixed order as laid out by the template.
The template is kind of like so:
[a0]
[a1]
[a2]....
What I need to do is randomise the word list and reassign the corresponding template items for each participant. For example, with the words orange, green, and blue; participant 1 one would have [a0] = orange, [a1] = green, [a2] = blue, participant 2 would have [a0] = blue, [a1] = orange, and [a2] = green.
So far in the prepare phase of an inline_script I have to import my .txt file:
import numpy as np
nonword_train = np.loadtxt(exp.get_file("training_template.txt"), dtype=str)
I apologise if this is not very clear. I would appreciate any help as I am quite lost.
Comments
Hi,
I am not sure whether I entirely understand what you want to accomplish. So you have eight different words in total, and present them in a random order for 700 times in total. Is this correct? Or what information do you get from the template?
Generally, if you want to control stuff happening across participants, you can use the variable
var.subject_nr. So here a little example how to go about that:Btw. If you are new to Python, I can only recommend that you spend some extra time now to learn Python before you proceed programming experiments. Even if it slows you down now a little, you will see that you'll be much quicker and better solving problems in the future. Here a link to some resources.
Eduard
Hi Eduard,
Thank you so much for taking the time to respond. I will definitely have a look at the Python resources.
The .txt template is the order in which the stimuli should be presented in the training phase. It provides a fixed order for the presentation of 700 trials. So I have eight different words, that should be presented in the fixed order as defined by the .txt file. Here is a segment of the .txt file:
So e.g. [a0] will always = apple for participant 1, but banana for participant 2. [b1] = watermelon for participant 1, but kumquat for participant 2. I hope this clarifies things a little.
Is there a way for me to import/load the .txtfile to fix the order of presentation, but randomise the stimuli for each participant? Additionally, would I be able to carry over the values of [a0], [a1], [b0] etc, for each participant into the testing phase (e.g. have [a0] be banana for participant 1 in both the training phase and the testing phase) ?
I think probably the easiest would be to define the mapping in the beginning of the experiment, and then replace the items. For example:
Hope this helps.
Eduard