Since 2015, and with Michael’s precious help (https://groups.google.com/forum/#!topic/psychopy-users/sjX7_Oa_WXc), I’ve been using this self-paced moving window paradigm successfully, but now I want to add a time limit of 2 seconds (for instance).
The original Script is this:
# Insert a code component within the relevant routine. # at "begin routine" tab, put some code something like this: sentenceList = sentence.split() # this breaks your sentence's single string of characters into a list of individual # words, e.g. 'The quick brown fox.' becomes ['The', 'quick', 'brown', 'fox.'] # keep track of which word we are up to: wordNumber = -1 # -1 as we haven't started yet # now define a function which we can use here and later on to replace letters with 'x': def replaceWithX(textList, currentWordNumber): xSentence = '' for index, word in enumerate(textList): # cycle through the words and their index numbers if index != currentWordNumber: xSentence = xSentence + 'x' * len(word) + ' ' # add a string of x characters else: xSentence = xSentence + word # except for the current word return xSentence # yields the manipulated sentence # now at the very beginning of the trial, we need to run this function for the # first time. As the current word number is -1, it should make all words 'x'. # Use the actual name of your Builder text component here: yourTextComponentName.text = replaceWithX(sentenceList, wordNumber) # In the Builder interface, specify a "constant" value for the text content, e.g. # 'test', so it doesn't conflict with our code. # Then in the "Every frame" tab, put in some code like this so that you check the keyboard every time the screen is refreshed (at typically 60 Hz), and alter the text stimulus appropriately: keypresses = event.getKeys() # returns a list of keypresses if len(keypresses) > 0: # at least one key was pushed if 'space' in keypresses: wordNumber = wordNumber + 1 yourTextComponentName.text = replaceWithX(sentenceList, wordNumber) elif 'esc' in keypresses: core.quit() # I think you'll need to handle quitting manually now.
I’d like to change the script as to allow something like: the participant either presses the SPACE or (if not), after 2 seconds, the word/segment disappears and the next word appears. Is it possible?
Thank you for your time.