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?
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"
else:
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.
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:
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.
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?