I have been trying for well over 2 weeks now in my off time to try and get this program to work. Unfortunately, it is winning
The goal is for a project that can take a sentence from a .csv, split the sentence into words, and then for every word display the word for 30 frames and then have the screen go black for 20 frames. Once the final word is said, it needs to push off into another text module.
Currently, I have a mess of code, made from putting together pieces of code from other individuals seeking help on the site. I think it might confuse the reader more if I paste all that nonsense than if we try to start from ground zero.
You need two loops around your routine. The outer loop is connected to your conditions file and Iām going to assume that you have a column in that called, say sentence, which contains your sentences, one per trial.
The inner loop is not connected to your conditions file but has a large nReps value that is larger than the number of words in your longest sentence (say, 100).
Insert a code component (from the ācustomā component panel). Make sure it is above your text component (you can change the vertical ordering of components by right-clicking on their icons).
In the ābegin routineā tab of the code component, put something like this:
# on the first iteration only:
if your_inner_loop_name.thisN == 0:
# break up the sentence variable into words:
sentence_list = sentence.split()
# get the next word:
current_word = sentence_list.pop(0)
Put $current_word in the ātextā field of your text stimulus component, set to update āevery repeatā.
Set that text component to have a duration of 30 frames, and add a black polygon stimulus to start at 30 frames and have a duration of 20 frames.
To terminate the inner loop when the last word has been shown, put something like this in the āend routineā tab:
if len(sentence_list) == 0: # no words leftā¦
your_inner_loop_name.finished = True
I now understand, when you said the routine needed 2 loops, you were referring to the actual flow loops. For some reason, I thought it was a coded loop. The way you described worked like a charm, and I am very grateful.
This is so awesome!! Helped me so much when creating the same type of N400 sentence reading/comprehension paradigm. The best thread I found for creating an ISI.