Howdy, Stranger!

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

Supported by

[solved] repeat cycle

edited May 2015 in OpenSesame

Hi all,

I'm programming an experiment in which I need to repeat a loop until the accuracy is 100%.

I have a loop with 21 trials presented randomly. The 21 trials are divided in 7 condition composed by three trials each.
For each condition (by using some inline script) I have defined a variable for recording and updating the accuracy of the three trials (so from 0 to 3). Thus far everything works fine.

What I'd like to do is to repeat the conditions (all of the three trials) in which the participant has make at least one error.
I have tried with a repeat_cycle by in this case all the 21 trials are repeated.

How can I solve this problem? Is there any way to repeat only some conditions by picking up only the corresponding trials and not the entire list?

Thank you in advance!
Cheers,
Andrea

Comments

  • edited 10:04AM

    Hi Andrea,

    Is your experiment random on trial level or only on condition level? I mean, are the 3 trials of one conditions always presented after each other, or are all 21 trials presented in a mixed fashion in the initial round?

    If they are blocked, you do something like this:

    1) In a loop item, select the condition you're going to run
    2) Within this loop, you put an inline_script running each trial of a condition in a while loop. So, while accuracy != 100: run_trial, or something similar

    Was this helpful?

    Let us know if you need more detail.

    Eduard

    Buy Me A Coffee

  • edited 10:04AM

    Hi Eduard,

    My experiment is random on a trial level, so that my 21 trials (3 for each condition) are presented totally random. I have only one loop (and the same sequence) for all the trials.

    For example, I need to pick up only three out of the 21 trials of the original loop.

    Could your suggestion work also in this case?
    Anyway, I'll try and I'll let you know!

    Thank you so much!

  • edited 10:04AM

    Hi Eduard,

    I've tried your suggestion but it doesn't work: using the while loop the experiment presents only the first trial of the first condition to infinity.

    How can I do?

    Thanks,

    Andrea

  • edited April 2015

    Hi Andrea,

    My experiment is random on a trial level, so that my 21 trials (3 for each condition) are presented totally random.

    This makes things a bit more complicated, but it still is doable. Here a (very general) way of doing it (sorry for the lack of detail).

    1) First you ran your initial loop and sequence in a rather basic way (all 21 one trials randomly). It is super important that you keep track of the accuracy of each condition. For example you can use a dictionary, with the conditions as keys and the number of total trials, accurate trials and average accuracy as values (Don't forget that you would have to initialize the dictionary somewhat earlier in your script.

    # intialization a dict with a list of [correct trial, total trials, accuracy]
    accuracies = dict(cond1 = [0,0,0],cond2= [0,0,0],...,cond7=[0,0,0]) 
    
    # later in your loop
    # assuming 'cond' has a value that equals one of the keys in a dict, e.g. cond1
    
    accuracies[cond][1] += 1 # updating trial count
    if correct:    accuracies[cond][0] += 1 # updating correct count (NOT PROPER CODE!)
    # average accuracy. Watch out to do a proper division (don't divide integers!)
    accuracies[cond][2] = float(accuracies[cond][0]) / accuracies[cond][1] 
    

    It might also be handy to keep track of other trial information, like which stimuli were drawn, etc.

    2) Now the tricky part begins. You have to decide which of the conditions need a repetition and create a new loop on the fly. I recommend doing it in an inline_script, because you have more freedom there. The idea is to select every condition that needs a redo and put its trials into the new pool. This procedure should then be repeated until the pool is empty, so every condition has 100% accuracy

    import random
    
    while True:
        # trials will contain all trials that need to be run again
        trials = []
        # conditions is a list with all your conditions
        for cond in conditions:
            if accuracies[cond][2] != 100:
                trials.append([list_with_all_trial_information])
    
        # now trials contain all information about trials to be repeated
        # shuffle it
        random.shuffle(trials)
    
        # and present the stimuli
        # this depends on your design. Check out the canvas function documentation
        # if you're unsure about how to do it
    
        for trial in trials:
            run(trials) # or whatever
            # while running to update the accuracy dictionary accordingly. Otherwise
            # you won't change anything.
    
        # finally you have to include a possibility to break the loop
    
         if all_accuracies == 100:
             break
    
    

    Does this help?

    Good luck,

    Eduard

    Buy Me A Coffee

  • edited 10:04AM

    Hi Eduard,

    thank you so much for your help. I'm working on it but I have some troubles in appending the trial: which information do I need to put in this line?

    trials.append([list_with_all_trial_information]) 
    

    Thanks again,

    Andrea

  • edited 10:04AM

    Hi Andrea,

    Every information that you need to show your stimuli. This can be anything, but boils down to What, How, When and Where. What your goal is in the second loop (the one in which you repeat the conditions that haven't 100% correct, is to show the same trials again, right? So, you have to make sure that you know what to present.

    Does this make sense?

    Eduard

    Buy Me A Coffee

  • edited 10:04AM

    Hi Eduard,

    thanks to your suggestion I have figured out that problem, so that I have created a new list that the include all the trials I need to repeat.

    However I can't display the new trials; I've tried with

    for trial in trials
         exp.items['sequence'].prepare()
         exp.items['sequence'].run()
    

    but it doesn't work. The sequence is exactly the same of the previous loop (basically I have created a second loop with the same sequence and at the beginning of this new sequence I have inserted the inline_script for selecting only the trials I need)....is it right? Or I need to specify the entire sequence in the inline_script?

    Moreover, I'm not sure of the right position of the inline_script....

    Thanks again,

    Andrea

  • edited 10:04AM

    Hi Eduard,

    sorry for bother you again (I'm quite new of Opensesame and Phyton code in particular)!
    I've tried in a second way to do it: instead of randomize the 21 trials, I've randomized only the condition level.
    I've created one big loop that contains 7 small loops (one for each condition) of 3 trials each. I've used an inline code to keep track of the accuracies as you suggested.
    At the end of the big loop I've inserted a repeat_cycle plug-in that re-runs the big loop only if one of the accuracies is not 100% (and re-runs only the small loop in which the accuracy is less than 100%).

    Everything works fine but there is only one problem: when all the accuracies are 100% (and so the repeat cycle should stop) the experiment remains freeze on the last screen of the last trial, and does not continue to the next phase. The only way I can stop the experiment is to press the esc button.

    How can I solve this? Is it an error in the repeat_cycle plug-in?

    Thank you so much again,
    Andrea

  • edited 10:04AM

    Hi Andrea,

    Sorry for not having responded earlier.

    Your problem sounds, that you haven't defined a break criterion. Would you mind sharing your experiment with us, or at least your settings for the repeat_cycle plugin? Without more information it's hard to offer a solution.

    Thanks,

    Eduard

    Buy Me A Coffee

  • edited 10:04AM

    Hi Eduard,

    No problem!!! I figured it out! It was a problem in the break criterion.
    I've replaced the repeat_cycle plug-in with an inline_script in which for each condition I've used a while:

    while self.get('accuracy condition 1') != 3:
        exp.items['condition1'].prepare()
        exp.items['condition1'].run()
    

    Thank you so much!!

    Andrea

  • edited 10:04AM

    Good to hear.

    Eduard

    Buy Me A Coffee

Sign In or Register to comment.

agen judi bola , sportbook, casino, togel, number game, singapore, tangkas, basket, slot, poker, dominoqq, agen bola. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 50.000 ,- bonus cashback hingga 10% , diskon togel hingga 66% bisa bermain di android dan IOS kapanpun dan dimana pun. poker , bandarq , aduq, domino qq , dominobet. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 10.000 ,- bonus turnover 0.5% dan bonus referral 20%. Bonus - bonus yang dihadirkan bisa terbilang cukup tinggi dan memuaskan, anda hanya perlu memasang pada situs yang memberikan bursa pasaran terbaik yaitu http://45.77.173.118/ Bola168. Situs penyedia segala jenis permainan poker online kini semakin banyak ditemukan di Internet, salah satunya TahunQQ merupakan situs Agen Judi Domino66 Dan BandarQ Terpercaya yang mampu memberikan banyak provit bagi bettornya. Permainan Yang Di Sediakan Dewi365 Juga sangat banyak Dan menarik dan Peluang untuk memenangkan Taruhan Judi online ini juga sangat mudah . Mainkan Segera Taruhan Sportbook anda bersama Agen Judi Bola Bersama Dewi365 Kemenangan Anda Berapa pun akan Terbayarkan. Tersedia 9 macam permainan seru yang bisa kamu mainkan hanya di dalam 1 ID saja. Permainan seru yang tersedia seperti Poker, Domino QQ Dan juga BandarQ Online. Semuanya tersedia lengkap hanya di ABGQQ. Situs ABGQQ sangat mudah dimenangkan, kamu juga akan mendapatkan mega bonus dan setiap pemain berhak mendapatkan cashback mingguan. ABGQQ juga telah diakui sebagai Bandar Domino Online yang menjamin sistem FAIR PLAY disetiap permainan yang bisa dimainkan dengan deposit minimal hanya Rp.25.000. DEWI365 adalah Bandar Judi Bola Terpercaya & resmi dan terpercaya di indonesia. Situs judi bola ini menyediakan fasilitas bagi anda untuk dapat bermain memainkan permainan judi bola. Didalam situs ini memiliki berbagai permainan taruhan bola terlengkap seperti Sbobet, yang membuat DEWI365 menjadi situs judi bola terbaik dan terpercaya di Indonesia. Tentunya sebagai situs yang bertugas sebagai Bandar Poker Online pastinya akan berusaha untuk menjaga semua informasi dan keamanan yang terdapat di POKERQQ13. Kotakqq adalah situs Judi Poker Online Terpercayayang menyediakan 9 jenis permainan sakong online, dominoqq, domino99, bandarq, bandar ceme, aduq, poker online, bandar poker, balak66, perang baccarat, dan capsa susun. Dengan minimal deposit withdraw 15.000 Anda sudah bisa memainkan semua permaina pkv games di situs kami. Jackpot besar,Win rate tinggi, Fair play, PKV Games