Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

NameError: name 'correct' is not defined and creating a feedback loop

I keep getting this error, when trying to create a Stroop task like scenario:


NameError: name 'correct' is not defined


Also, how do I create a feedback loop that responds to a certain keyboard response for a certain colour to show the word correct or incorrect?


Thank you in advance

Comments

  • Hi Mojole,

    Could you prpvide more information on your code? An error message is a good start, but in order to solve a problem, we also need to know what you are actually trying to do.

    Also, how do I create a feedback loop that responds to a certain keyboard response for a certain colour to show the word correct or incorrect?

    I am not sure what you mean with feedback loop. Generally, the beginner's tutorial explains the logic that can be used to show feedback that depends on the response. See point 6. Basically you have two text fields on the feedback item. One says correct and has the run if parameter [correct]=1, the other says "incorrect" and has the run if parameter [correct]=0. Does that clear things up?

    Eduard

    Buy Me A Coffee

  •   File "/Applications/OpenSesame.app/Contents/Resources/lib/python3.7/site-packages/libqtopensesame/misc/process.py", line 158, in run
        exp.run()
      File "/Applications/OpenSesame.app/Contents/Resources/lib/python3.7/site-packages/libopensesame/experiment.py", line 470, in run
        self.items.execute(self.var.start)
      File "/Applications/OpenSesame.app/Contents/Resources/lib/python3.7/site-packages/libopensesame/item_store.py", line 103, in execute
        self.run(name)
      File "/Applications/OpenSesame.app/Contents/Resources/lib/python3.7/site-packages/libopensesame/item_store.py", line 122, in run
        self[name].run()
      File "/Applications/OpenSesame.app/Contents/Resources/lib/python3.7/site-packages/libopensesame/sequence.py", line 51, in run
        self.experiment.items.run(_item)
      File "/Applications/OpenSesame.app/Contents/Resources/lib/python3.7/site-packages/libopensesame/item_store.py", line 122, in run
        self[name].run()
      File "/Applications/OpenSesame.app/Contents/Resources/lib/python3.7/site-packages/libopensesame/loop.py", line 387, in run
        self.experiment.items.execute(self._item)
      File "/Applications/OpenSesame.app/Contents/Resources/lib/python3.7/site-packages/libopensesame/item_store.py", line 103, in execute
        self.run(name)
      File "/Applications/OpenSesame.app/Contents/Resources/lib/python3.7/site-packages/libopensesame/item_store.py", line 122, in run
        self[name].run()
      File "/Applications/OpenSesame.app/Contents/Resources/lib/python3.7/site-packages/libopensesame/sequence.py", line 50, in run
        if self.python_workspace._eval(cond):
      File "/Applications/OpenSesame.app/Contents/Resources/lib/python3.7/site-packages/libopensesame/base_python_workspace.py", line 141, in _eval
        return eval(bytecode, self._globals)
      File "
    

    Does this help? Sorry I am a beginner and don't understand much of the terminology

  • followed by

    NameError: name 'correct' is not defined
    


  • Yes, the problem is that you don't use feedback items but sketchpads. The difference is critical when you want to present feedback. See here for more information.

    tl;dr: Sketchpad items are created before the response is collected, and therefore before the variable "correct" is being produced. Feedback items are created after response collection, and should therefore work.

    Does that help?

    Eduard

    Buy Me A Coffee

  • I have changed it to feedback items, but it still isn't working? it is showing the same error

  • Okay, then I suppose you have no correct_response defined. Can you share the experiment here?

    Buy Me A Coffee

  • how do I do that?

  • If you click on the paper clip you can upload a file here in the forum. YOu can also drag&drop the file right into the edit window here.

    Buy Me A Coffee

  • Oh yeah, now I see. Your run_if statements are wrong. Only the variable must be placed within the brackets, not the boolean operators. Replace

    [correct=1] with [correct] = 1and accordingly, the other run if statement.

    Once changed, it runs for me. Also for you?

    Eduard

    Buy Me A Coffee

  • Thank you!

    Yes that runs the program, but it comes up with incorrect everytime?

  • That just means your response is never correct. So probably some part of the logic with which you collect responses doesn't work as you want it too.

    Looking at your script two things caught my eye.

    1. the sketchpad "word" has a duration of keypress (meaning that a key has to be pressed before the next item is executed)
    2. the keyboard item has a timeout of 100 ms

    To measure response times, the common approach is to set the duration of the sketchpad to 0 and rather control via the keyboard_item how long the stimulus is going to be presented. However, the timout of 100 ms is extremely short. I don't think it is possible to respond within 100 ms, which means there is no response, which essentially means the response is correct (and therefore you only see the incorrect feedback).

    If you increase the timeout to at least 500 ms (better even more, or "keypress"), you will see that the feedback procedure works.

    Good luck,

    Eduard

    Buy Me A Coffee

Sign In or Register to comment.