psychopy.org | Reference | Downloads | Github

Message when trials in a loop are not responded to

Hi all,

I’m trying to use a feedback message in a loop with multiple trials. However, I want a message to appear only when the participant didn’t answer within the provided time frame.
I was able to create a code (“code_4” in the attached screen shot) with the “message_pt” routine in my first loop in the screenshot. This displays a time-out message if there’s no response in the allowed time window, and it presents ‘nothing’ in all other cases (i.e. when someone responds, whether correctly or incorrectly, within the given time frame).
However, since I’ve set my “message_pt” properties to be 1.5s long (so that the time-out message appears for 1.5s before moving on automatically), I’ve noticed any not-late response to my trials triggers a blank screen for 1.5s (basically showing the ‘null’-message).

I’m positive there’s a way to skip the message routine completely rather than displaying nothing.
Would anyone have suggestions how I could change the code to only use the ‘message’ routine if there wasn’t a response during the allotted time frame of a trial?
Thanks so much!

The code I’m currently using (under “End Routine”):

if not key_resp_6.keys:
    msg = "You didn't respond in time. Moving on."
else:
    msg = ' ' 

Yep! Keep the message routine in the loop but give it its own nested loop. Set the number of repeats in the message loop to a variable (nReps is the canonical).

In your message text stim set the text to constant with your message.

In the code component, delete the null message line and change:

if not key_resp_6.keys:
    msg = "You didn't respond in time. Moving on."
else:
    msg = ' ' 

To:

if not key_resp_6.keys:
    nReps = 1

That should do it

Oli

Hi Oli,

Thanks so much for the kind response and suggestion!

I think I implemented exactly what you suggested (I used “$nReps” as a variable for the number of repeats in the message loop - see attached screen shot);
When I run the experiment and get to the first trial in the first loop and press a key as a response, the program freezes; when I quit the program, I get the following error message:

message_loop = data.TrialHandler(nReps=nReps, method=‘sequential’,
NameError: name ‘nReps’ is not defined

It sounds like the program doesn’t know how to interpret my $nReps variable. How/where would I need to define that or set it up for this to work?
Thank you so much for your help!

Oh yeah - thats because you need an initial value. Add nReps = 0 to the begin experiment tab

You’re right, I need an initial value! It seems to work with nReps = 0 in the begin Routine* tab (in the begin Experiment tab, the message appears for all following trials as soon as the message was triggered once, which seems to make sense).
Thank you so much!!