| Reference | Downloads | Github

Reaction time greater than msg

PsychoPy version 1.85.2

I’m trying to make a message that says “too slow” if the response time is greater than 800ms. I’ve put the $msg in the text component and in the code component i’ve put:
if resp.rt>0.8:
…msg = “too slow”

but it’s saying too slow on all my responses. I’ve tried making it 2 and it still says my response time is too slow. I’ve also tried putting it in brackets and also tried resp.rt*1000>0.8 but it still says it for all responses?

Please help!

I got the same problem :frowning: Sb will help us?

In this case, it is likely that the variable is not set back to another value if the opposite condition is true. i.e. what should the feedback be if the response is not slow?

print(resp.rt) # temporary

if resp.rt > 0.8:
    msg = "too slow"
    msg = "nice and fast"

print(msg) # temporary

The print statements here are just temporary debugging aids to check that the values are what you expect and that the code logic is working.

1 Like

Thanks much for reply. It works!!!
May you give me example with images instead text?

Sorry, I missed this reply. You’ll need to give more details of what you need.

No problem. Currently, i solved problem with images. Now i’m trying to make that after 3 sec after no response from participant show text “No reaction” Here code:

if response.rt >= 1 and response.rt <= 1.4:
    msg = "Dobrze!"

elif response.rt > 0 and response.rt < 1:
    msg = "Za szybko!"

elif response.rt > 1.4 and response.rt < 3:
    msg = "Za późno!"

elif response.keys == [] and response.tStart > 3:
    msg = "brak reakcji"

You don’t say what the problem is.

But at a guess, in that final elif clause, you change to testing the (presumably constant) response.tStart rather than response.rt

Note also that if this is code intended to be used with Builder-generated code, then using win.flip() and core.wait() is not advised, unless you really know what you are doing. Both of them will disrupt Builder’s inherent screen drawing and event loop. In general, any code that needs to execute during a trial should be able to be completed within one screen refresh duration (typically 16 milliseconds). And Builder issues its own win.flip() once per cycle, so calling it your self can have unintended consequences on the rest of the Builder script.

1 Like

i would like to create experiment where participant estimate time of 1200 ms following a visual stimulus (white square) and press a key at correct time (CNV paradigm). Responses between 1000 and 1400 ms will be accepted as correct. Between 400 and 1000 ms after cue - early responses. Between 1400 and 2000 ms - late answers. In the case of correct trials, a green happy smiley and the word “correct” were presented. In the case of early/late trial a red sad smiley and the word “too early”/“too late” will be presented. The words “did not react” display if no response within 3000 ms after stimulus onset. Addiionally the intertrial interval randomize between 800 and 2200 ms. I got all pics. I go problem with bolded issue.

Have you known alternative code for my proposition?

Thanks for all!

And you haven’t responded to:

To get good value out of a forum like this, you really should read the responses people give and try to address what they suggest.