psychopy.org | Reference | Downloads | Github

Error in feedback - self-paced reading exp

OS: OSX El Capitan 10.11.6
PsychoPy version: 1.84.1
Standard Standalone? (y/n): Yes
**What are you trying to achieve?: To provide feedback after the participant enters a YES / NO response in post-stimulus comprehension questions.

**What did you try to make it work?: Read the manual and tried to check if there is something wrong with the coding.

**What specifically went wrong when you tried that?: Comprehension questions and feedback appear at the same time on the screen. It seems the feedback text is not properly linked to the previous response command.

-------Start Routine “question_1”-------

while continueRoutine:
# get current time
t = question_1Clock.getTime()
frameN = frameN + 1 # number of completed frames (so 0 is the first frame)
# update/draw components on each frame

# *text_4* updates
if t >= 0.0 and text_4.status == NOT_STARTED:
    # keep track of start time/frame for later
    text_4.tStart = t
    text_4.frameNStart = frameN  # exact frame index
    text_4.setAutoDraw(True)

# *key_resp_question1* updates
if t >= 0.0 and key_resp_question1.status == NOT_STARTED:
    # keep track of start time/frame for later
    key_resp_question1.tStart = t
    key_resp_question1.frameNStart = frameN  # exact frame index
    key_resp_question1.status = STARTED
    # keyboard checking is just starting
    key_resp_question1.clock.reset()  # now t=0
if key_resp_question1.status == STARTED:
    theseKeys = event.getKeys(keyList=['y', 'n'])
    
    # check for quit:
    if "escape" in theseKeys:
        endExpNow = True
    if len(theseKeys) > 0:  # at least one key was pressed
        key_resp_question1.keys = theseKeys[-1]  # just the last key pressed
        key_resp_question1.rt = key_resp_question1.clock.getTime()
        # was this 'correct'?
        if (key_resp_question1.keys == str(u'y')) or (key_resp_question1.keys == u'y'):
            key_resp_question1.corr = 1
        else:
            key_resp_question1.corr = 0
        # a response ends the routine
        continueRoutine = False


# *Feedback_1* updates
if t >= 0.0 and Feedback_1.status == NOT_STARTED:
    # keep track of start time/frame for later
    Feedback_1.tStart = t
    Feedback_1.frameNStart = frameN  # exact frame index
    Feedback_1.setAutoDraw(True)
if Feedback_1.status == STARTED:  # only update if drawing
    Feedback_1.setText(msg, log=False)

# check if all components have finished
if not continueRoutine:  # a component has requested a forced-end of Routine
    break
continueRoutine = False  # will revert to True if at least one component still running
for thisComponent in question_1Components:
    if hasattr(thisComponent, "status") and thisComponent.status != FINISHED:
        continueRoutine = True
        break  # at least one component has not yet finished

# check for quit (the Esc key)
if endExpNow or event.getKeys(keyList=["escape"]):
    core.quit()

# refresh the screen
if continueRoutine:  # don't flip if this routine is over or we'll get a blank screen
    win.flip()

-------Ending Routine “question_1”-------

Coding is not my business. I’d appreciate it if you could guide how to work this out.

Thank you very much for sharing this wonderful app.

Since you’d prefer to work in the builder, what did you enter as the properties for those stimuli? How did you tell it to show the feedback after the first stimulus? Based only on the screenshot of your flow, it looks like both text stimuli are set to display the entire time.

Especially if they don’t have to enter any kind of response during the feedback, I think the easiest way would be to make a separate routine for the feedback, and in your flow, put it right after the stimulus.

The next step is to the get the feedback to know whether their answer was correct, and to know what text to display. Please tell us a little more about your variables and your conditions file and we can try to help.

Hi Daniel, thanks for your reply.
Below I show you how the variables are set for this routine in the flow. In text_4, a comprehension question is asked and the participant presses Y or N (Yes or No). The key press is stored and the correct answer is already given in the setup.

As you can see, I entered a code at the beginning of the routine to show the text contained in $msg. When I run the experiment and text_4 appears, the text from $msg overlaps at the same time on the screen.

If the answer is correct, a feedback message as “Correct!” should appear. If the entered value is not correct, a feedback message as “Failed to respond” should appear. Find below the code.


if len(key_resp_question1.keys)<1:
msg = “Failed to respond”
elif resp.corr:#stored on last run routine
msg = “Correct! RT:%.3f” %(resp.rt)
else:
msg = “Oops! That was wrong”


_Question_1 routine:

text_4

key_resp_question1

I hope it clarifies what I have been doing. I will try the workaround you suggested.
I look forward to your reply.

Best,

code

feedback_1

You should look at the stroopExtended demo, it has exactly what you’re asking for. Look at the trial and feedback routines, and look at the conditions file to understand everything it does.

And as to why your code isn’t working (which will hopefully become clear as you mess with the demo):

First, you have set the start time of all of the text elements to be 0, which means all of the text components will show at the same time when the routine starts. This would not be a problem if the text and the feedback were in different routines, and then your code about changing the message should work, because it depends on there being a sequence:

First routine: Show text -> get keypress
Feedback routine: (read keypress from first routine (that’s what “resp.corr” is doing in your code) -> set text for feedback -> show feedback text

Right now your sequence is:
Show text and Feedback at the same time (we can’t set the text before display since we haven’t gotten the keypress yet!)

Thank you very much for your help, Daniel.

I followed your advice and copied the same routine of the stroopExtended demo. I just made some changes in the code and it worked perfectly.

Best,

Marcos

Hello,

I am trying to set up a self-paced reading experiment. I’ve followed the recommended steps yet I keeping getting an error message when I try to run the experiment. I’m using StandalonePsychoPy-1.84.2-win32.exe on Windows 8.1. I’m attaching a screenshot of the error message.

Any help with this would be much appreciated as I really don’t know how to solve this problem.

Many thanks,

Roopa

The error message tells you exactly what the problem is: you haven’t correctly specified the path to your conditions file.

Inspect the path for the (hopefully obvious) error in specifying the correct folder.