| Reference | Downloads | Github

Words skipping problem in a self-paced reading experiment

PsychoPy v 1.85.6
OS X El Capitan, Version 10.11.6

Experiment Design: A Self-paced reading experiment in Chinese (font „Songti SC“, works well in Mac); The participants press space key after a signal and begin to read a stimulus sentence word by word (one character or two characters) by pressing the space key. Then a judgment question follows by pressing the left or right key.

PROBLEM: Some stimuli only display the first several parts. I have 8 segments for each sentence (I use a space between each segment in the xlsx file) and the reaction time for each key press for each segment is marked as IRI-0, IRI-1, … IRI-6, IRI-7. Some sentences just show the first several parts and then skip to the question, which leaves blank for the skipped segments in the records:

The last two parts (IRI-6, IRI-7, red marked ) were skipped and it seems like a complete reaction time for the whole sentence was recorded under “key_resp_1.”. This error occurs accidentally to different sentences. BUT there is no such error when I transferred the code to a window computer!!! I need to do this experiment in Mac because in Window the characters display in different fonts with “Songti SC”. And I can find a solution for it, neither.

Could anyone help me or give me a hint? I appreciate it a lot!

I added three parts to the code following!topic/psychopy-users/sjX7_Oa_WXc. Thanks to Michael. I´m not sure if that helps, but I put it here:

t = 0
trialClock.reset()  # clock
frameN = -1
continueRoutine = True
# update component parameters for each repeat
# add 1------------------------------------------------------------------------
sentenceList = S1.split()
Nwords = len(sentenceList)
print Nwords,' words'
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 + '--' * len(word) + ' ' # add a string of x characters 
            xSentence = xSentence + word # except for the current word 

    return xSentence # yields the manipulated sentence 

# add 1------------------------------------------------------------------------
key_resp_1 = event.BuilderKeyResponse()
# keep track of which components have finished
trialComponents = [text, key_resp_1]
for thisComponent in trialComponents:
    if hasattr(thisComponent, 'status'):
        thisComponent.status = NOT_STARTED
# add 2------------------------------------------------------------------------
text.text = replaceWithX(sentenceList, wordNumber) 
# add 2------------------------------------------------------------------------

# -------Start Routine "trial"-------
while continueRoutine:
    # get current time
    t = trialClock.getTime()
    frameN = frameN + 1  # number of completed frames (so 0 is the first frame)
    # update/draw components on each frame
    # *text* updates
    if t >= 0.0 and text.status == NOT_STARTED:
        # keep track of start time/frame for later
        text.tStart = t
        text.frameNStart = frameN  # exact frame index
    # *key_resp_1* updates
    # add 3------------------------------------------------------------------------
    keypresses = event.getKeys() # returns a list of keypresses 

    if len(keypresses) > 0: # at least one key was pushed 

        if 'space' in keypresses: 
            thisResponseTime = t # the current time in the trial
            wordNumber = wordNumber + 1 
            if wordNumber < len(sentenceList): 
                if wordNumber == 0: # need to initialise a variable: 
                    timeOfLastResponse = 0 
                # save the inter response interval for this keypress, 
                # in variables called IRI_0, IRI_1, etc: 
                thisExp.addData('IRI_' + str(wordNumber), thisResponseTime - timeOfLastResponse) 
                timeOfLastResponse = thisResponseTime 

        # update the text by masking all but the current word 
                text.text = replaceWithX(sentenceList, wordNumber)
                continueRoutine = False
        elif 'escape' in keypresses: 
    # add 3------------------------------------------------------------------------