Howdy, Stranger!

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

Supported by

[solved] Display rt in Feedback

edited February 2013 in OpenSesame

Hi,

I have a very basic question.

If I want to display the trial response time in my feedback, how do I do it?
For instance:

draw textline 0 -164 "Temps4: [avg_rt]" 

is working

But

draw textline 0 -164 "Temps4: [response_time]

is not (and I want the response time for the current trial)

I tried everything I could think about:
draw textline 0 -164 Temps1: [exp.get(response_time)]
draw textline 0 -164 Temps1: [exp.get(response_time_keyboard_response)]
etc.

Unfortunately nothing worked...

Best regards,

Comments

  • edited 12:17PM

    Hi Boris,

    In your second piece of OpenSesame code

    draw textline 0 -164 "Temps4: [response_time]

    you don't end the to-be-displayed string with double quotes. It should be:

    draw textline 0 -164 "Temps4: [response_time]"

    Could that just be it? Or is that a typo in the forum post and not in your actual script?

    Another thing that comes to mind is that you're trying to use a sketchpad item (rather than a feedback item) to display the trial response feedback. A sketchpad is constructed during the prepare phase of the trial sequence, and its content can therefore not depend on what happens later on in the sequence (e.g. during response collection). Feedback items, on the other hand, are constructed during the run phase of the sequence and therefore can depend on values (such as 'response' and 'response_time') that are collected just before.

    If those suggestions do not solve your problem, don't hesitate to post again!

    Best,

    Lotje

    Lotje van der Linden - http://www.cogsci.nl
    FACEBOOK

  • edited 12:17PM

    Another thing that comes to mind is that you're trying to use a sketchpad item (rather than a feedback item) to display the trial response feedback. A sketchpad is constructed during the prepare phase of the trial sequence, and its content can therefore not depend on what happens later on in the sequence (e.g. during response collection). Feedback items, on the other hand, are constructed during the run phase of the sequence and therefore can depend on values (such as 'response' and 'response_time') that are collected just before.

    That was the crucial point ! As sketchpad are very often used in the examples, I used sketchpads and this was my mistake...

  • edited 12:17PM

    Another problem is that when I want to store the "response_time" in a variable in an inline (even in the "Run Phase" tab), it is not possible...
    For instance

    Somme = Somme + response_time

    is returning:
    NameError: name 'response_time' is not defined
  • edited February 2013

    Hi boris,

    variables in your loop tables, or feedback variables like response_time are set in self.experiment. They are not immediately accessible within your inline_script items, but you can 'get' and 'set' them using the experiment object

    rt = self.experiment.get("response_time")
    somme = somme + rt
    

    or

    exp.get("response_time") # you can use exp, instead of self.experiment
    somme += rt # x += 1 is equivalent to x=x+1
    

    Note that if you want 'somme' to be available throughout the experiment as well, you should consider setting it using exp.set(), or defining it as global.

    see: http://osdoc.cogsci.nl/usage/variables-and-conditional-qifq-statements/#getting-and-setting

  • edited February 2013

    I think I found a solution to the previous problem

    This code is passing (but I do not know if Somme is correctly update)

    Somme = Somme + self.get('response_time')

    Then, at the end of the block I compute

    global CountMot, Somme, Moy

    Moy = Somme / CountMot

    And , finally in my feedback I'd like to display Moy but that is not possible
    OS is returning:

    Description: Variable 'Moy' is not set in item 'feedback'.

    My script is there:
    https://docs.google.com/file/d/0B-sE9ac1ksCAS3V1Q3NtU1ZIcDA/edit?usp=sharing

  • edited 12:17PM

    Hi,

    Making variables global is only useful for future use within another inline_script item. For future use of a given variable in the interface (such as feedback items, but also, importantly, your logger item), you should set the variable like so:

    exp.set("moy", moy)

    After doing so, the square-bracket method in the interface will work.

    As Wouter also pointed out, more info about getting and setting variables can be found here:

    Does this help?

    Best,

    Lotje

    Lotje van der Linden - http://www.cogsci.nl
    FACEBOOK

  • edited 12:17PM

    It works perfectly. Thank you very much !

    The idea that you need to separate "inline" and "graphical interface" is not easy to get for beginners...

    Then I had a new very naive problem:
    I want to have an "if statement" in my inline

    I wrote:


    global CountMot, Somme, Moy, CountJuste
    Somme = Somme + self.get('response_time')
    CountMot = CountMot + 1 if exp.get('correct') == 1
    CountJuste = CountJuste + 1

    and got
    SyntaxError: invalid syntax on my if statement
    I tried various things but nothing worked.

  • edited 12:17PM

    Hi Boris,

    The first line of your if-statement should end with a colon, like so:

    if exp.get('correct') == 1:

    For more info on conditional statements in Python, see:

    Lotje van der Linden - http://www.cogsci.nl
    FACEBOOK

  • edited 12:17PM

    Thank you !

Sign In or Register to comment.