I am presenting sentences with different lengths. I am presenting them word by word.
- I generated a xlsx with the sentences in one column ($sentence)
- inserted a coder afterwards following instructions of a previous forum topic:
AT BEGIN ROUTINE:
# get the sentence for this trial and # split it into a list of words: words = sentence.split() # count them (the length of the list): numWords = len(words) # how long the text component should display for: totalDuration = numWords * 0.5 # time in seconds fixationDuration = 1.0 # put in whatever your actual fixation duration is currentWordIndex = -1 # will be useful later
AT EACH FRAME
# t is the time elapsed in the trial. # Calculate what word we should be up to by seeing how many # 500 ms periods have elapsed so far (& force it to be an integer): checkIndex = int((t-fixationDuration)/0.5) # see if we need to switch to a new word (including the very first one): if checkIndex != currentWordIndex: currentWordIndex = checkIndex text.setText(words[currentWordIndex]) # update to the current word
The presentation runs fine. However, I would like to send a trigger via parallel port at a certain word in the sentence, sometimes is the last word of the sentence but not always. I guess I should generate anothervariable in the xlsx file with the number of the word in each sentence that needs the trigger and then add it to the coder.
I am new to psychopy so any help is welcome
thanks a lot