OS (e.g. Win10): Win10 PsychoPy version (e.g. 1.84.x): 2022.2.3 Standard Standalone? (y/n) If not then what?: y What are you trying to achieve?:
Hi everyone! I am programming an EEG experiment where sentences of varying length will be presented word by word with (and this is where it got tricky for me) a picture of the speaker above them. Each word is supposed to be presented for 200 ms + additional 30 ms per each letter. Importantly, however, I need a 500 ms interword interval during which the picture of the speaker must stay on the screen but no word will be shown.
I managed to achieve word-by-word presentation together with the picture but without the interword interval using this code:
Begin Routine
words = sentence.split()
numWords = len(words)
i = 0
frameCounter = 0
Each Frame
if i <= numWords-1:
text.setText(words[i])
frameCount = 29 + (len(words[i].split()) * int(0.03*144)) # my screen runs at 144 Hz, so 29 frames is about 200 ms, etc.
frameCounter+=1
if frameCounter == frameCount:
i+=1
frameCounter = 0
else:
continueRoutine = False
So my problem is adding the interword interval (500ms). I know I need to somehow add text.setText(" ") displaying for 72 frames but I can’t figure out how to do it. Any help will be greatly appreciated
Hi all,
I have tried this code to measure response time to word by word task response.
begin routine:
words = sentence.split()
i = 0
frameCounter = 0 #it all happens within the same routine so make our own counter
each frame:
Assuming you have loaded the current trial from your conditions file
Get all words from the columns like word_1, word_2, etc.
word_columns = [col for col in thisTrial.keys() if col.startswith(‘word_’)] # Dynamically fetch word columns
words = [thisTrial[word] for word in word_columns] # List of all words in the sentence
Initialize the currentWordIndex
currentWordIndex = 0
Initialize a list to store response times for each word
response_times = [None] * len(words) # Store response times for all words
Main loop to update the word display based on key press
while currentWordIndex < len(words): # Loop through all words
# Display the current word and get the time
text_desplay.setText(words[currentWordIndex])
text_desplay.draw()
win.flip()
start_time = core.getTime() # Start time when the word is shown
keys = event.waitKeys(keyList=['space', 'escape']) # Wait for key press
# If the spacebar is pressed, record response time for the current word
if 'space' in keys:
response_time = core.getTime() - start_time # Calculate response time
response_times[currentWordIndex] = response_time # Store the response time
currentWordIndex += 1 # Move to the next word
if 'escape' in keys: # To allow exiting the experiment early
core.quit()
After the loop, retrieve response times for all words
For example, you can save response times for target_word, after_word, last_word
thisExp.addData(‘TargetWordRT’, response_times[0]) # Assuming target is word_1 for example
thisExp.addData(‘AfterWordRT’, response_times[1]) # Assuming after word is word_2 for example
thisExp.addData(‘LastWordRT’, response_times[-1]) # Last word in the sentence
thisExp.nextEntry() # Move to the next entry in the data file
it worked well offline but not online
I got this error:
Unfortunately we encountered the following error:
ReferenceError: thisTrial is not defined
Try to run the experiment again. If the error persists, contact the experiment designer.
any help please?
Thank you!