Howdy, Stranger!

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

Supported by

inline script - repeat incorrect response trial

When the participant gives an incorrect response in a trial, that meets a specific criterion, I want the trial to be repeated one time only, and not repeat ad eternum if the participant does not give the correct answer.

The inline script code is as follows:

if (self.get('correct') == 0 and self.get('reward') ==1):
exp.items['block1_sequence'].prepare()
exp.items['block1_sequence'].run()

With this code the trial is repeated successively until a correct response is given.
I want the trial to just repeat once. How to do it?

Thanks in advance!

Comments

  • Hi,

    You can add another variable to your logical that is either True if the the trial is not repeated and False if it is repeated (or the other way around). The tricky part here is to find the right spot where to initialize this variable that it is reset to 0 before a new trial starts, but not if the trial is repeated. Without knowing your experimental structure, it is quite hard to help you with that.

    So, your code would then look something like that:

    # the variable rep_trial needs to be initialized earlier
    
    if (self.get('correct') == 0 and self.get('reward') ==1) and rep_trial == 1:
        rep_trial = 0
        exp.items['block1_sequence'].prepare()
        exp.items['block1_sequence'].run()
    

    Btw., from OpenSesame 3.0 on, you don't have to get variable values, the var object replaced it (see here).

    So, your code could also look like this:

    # the variable rep_trial needs to be initialized earlier
    
    if var.correct == 0 and var.reward ==1 and rep_trial == 1:
        rep_trial = 0
        var.block1_sequence.prepare()
        var.block1_sequence.run()
    

    Does this make sense?

    Eduard

    Buy Me A Coffee

Sign In or Register to comment.