Howdy, Stranger!

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

Supported by

[solved] How to repeat a particular trial until correct before moving on to next trial?

edited August 2013 in OpenSesame

Hi, how can I repeat a particular trial or question until a correct response is obtained (e.g., participants must keep trying question 1 until they get it correct before they can move on to question 2)? Are there any examples of how this has been implemented? Thanks very much.

Comments

  • edited 4:30AM

    Hi,

    You can add a repeat_cycle plug-in (typically) to the end of the trial_sequence. This plug-in has a 'Repeat if' statement, which you can set to any arbitrary criterion. For example, if the trial_sequence contains a keyboard_response item, and you want to repeat the trial if the response was incorrect, you can set the 'Repeat if' statement to [correct] = 0.

    Best wishes,

    Lotje

  • edited 4:30AM

    Hi Lotje,

    Thanks for the reply. The repeat_cycle plug-in repeats all the incorrect cycles AFTER all cycles have been completed, but what I want is to repeat a particular cycle immediately. So instead of cycle 1, 2, 3, 4, 5, repeat 1, 2, I want it proceed this way 1, 1, 2, 2, 3, 4, 5. Any idea how to accomplish that? Thanks again.

  • edited 4:30AM

    Hi,

    I see what you mean. You can immediately repeat an error trial by:

    1.) Appending an inline_script item to the very end of your trial sequence:

    image

    2.) And placing the following code in its Run phase tab:

    # If participant gave an incorrect response:
    if self.get('correct') == 0:
        # Prepare the whole trial sequence (here called
        # 'trial_sequence') again:
        exp.items['trial_sequence'].prepare()
        # And run it again:
        exp.items['trial_sequence'].run()
    
    

    You can find a simple example experiment here (download, change the extension from .txt into .opensesame and open as normally):

    I hope this helps!

    Best,

    Lotje

  • edited 4:30AM

    Hi Lotje,

    That worked brilliantly! Thanks very much!

  • edited 4:30AM

    I am using this code to do something similar in my experiment. It does repeat the current trial but it also seems to leave off a trial at the end. That is if I have 10 questions, this will repeat say question 1 once but then only go to question 9. I assume this is because it is using up one of the predefined cycles to repeat this trial. Is there a way to hold this cycle constant until the trial has been answered successfully?

  • edited 4:30AM

    I am using this code to do something similar in my experiment. It does repeat the current trial but it also seems to leave off a trial at the end. That is if I have 10 questions, this will repeat say question 1 once but then only go to question 9. I assume this is because it is using up one of the predefined cycles to repeat this trial. Is there a way to hold this cycle constant until the trial has been answered successfully?

    Repeating a trial, as described above, shouldn't result in skipping another trial. So presumably something else is going wrong here. Could you describe in more detail how you have implemented this exactly?

    Cheers,
    Sebastiaan

    There's much bigger issues in the world, I know. But I first have to take care of the world I know.
    cogsci.nl/smathot

  • edited 4:30AM

    Thanks for the reply. I have checked the sample code and indeed it doesn't do what my program is doing. I can't immediately see what the experiment is doing wrong but I'll keep analyzing it and report back if I find anything that might be helpful to others. For now, I've started with a fresh experiment and gotten it working correctly.

  • Hello! I am making a discrimination reversal task on a touch screen for dogs to participate in. It is a two choice task, with two stimlui being randomly presented together on the left and right side of the screen. The dog must learn to discriminate between the two objects to receive a food reward. I used the inline script given above to allow for a trial to repeated if a the subject makes an incorrect choice. However, I want to repeat a trial only once if they chose the wrong choice (or don't make a choice). So essentially it is giving the subject a second chance to choose or not choose the positive stimulus. So, for example, if the subject chooses the negative stimulus, the same trial (let's say with the negative stimulus on the left side and the positive stimulus on the right side) will be ran once before moving on two the next trial (which will present the neg stimulus and positive stimulus on the left or right side randomly). I am very new to opensesame and python so I am not sure how to code for this. Any help is greatly appreciated!!

  • Hi Jackie,

    I think a puppy deserves more than a single chance to right a wrong ;-) But to answer your question, I would write a simple inline_script that executes the trial_sequence again, but only if the response was incorrect and the trial was not repeated before.

    if not var.correct and not var.repeated:  # 0 == False
        var.repeated = 1
        items.execute('trial_sequence')
    

    This requires that the variable repeated is set to 0 in the block_loop.

    I attached a simple example experiment that illustrates the idea.

    Cheers!

    Sebastiaan


    There's much bigger issues in the world, I know. But I first have to take care of the world I know.
    cogsci.nl/smathot

  • Hi Sebastiaan,


    It works perfectly! Thank you SO MUCH!!! The pups will appreciate it too :-)


    Jackie

Sign In or Register to comment.