Howdy, Stranger!

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

Supported by

[open] Ending experiment

edited March 2013 in OpenSesame

I am wondering if there is a way to stop/end the experiment after the participant answers, say like 3 answers correct (after a certain number of stimuli)?

Comments

  • edited March 2013

    I was reading this post but I am not able to find where the "Show advanced options" is (under 'loop'?) in Opensesame. When I create an inline_script before the beginning of the loop, do I type in all of these in the same inline_script?

    [correct_in_a_row] >= 10
    exp.set('correct_in_a_row', 0)
    if self.get('correct') == 1:
        exp.set('correct_in_a_row', self.get('correct_in_a_row')+1)
    else:
        exp.set('correct_in_a_row', 0)
    

    http://forum.cogsci.nl/index.php?p=/discussion/340/consecutive-correct-responses-detection/p1

    Thanks for your help!

  • edited March 2013

    Hi,

    The advanced-options functionality exists from OpenSesame 0.27 onwards (on Windows and Ubuntu) and can be found here:

    image

    If you're using an older version of OpenSesame you should upgrade to be able to use these options. Afterwards, you can proceed as described in the post you linked to. You shouldn't type all the code in a (single) inline_script, but that's explained in the previous post.

    Please let us know if you have any further questions!

    Best,

    Lotje

  • edited 2:10PM

    Thank you for your help, Lotje!

    I actually have a Macbook pro, and in the download page of opensesame, I wasn't sure if Mac users can update to 0.27?

  • edited 2:10PM

    I tried downloading opensesame 0.27 using a windows converter on my mac, but it seems to have errors. Is there another way to reach 10 correct answers in a row, without updating or having to use a windows computer?

  • edited 2:10PM

    Hopefully, there will be a Mac package for 0.27.1 soon, but for now you can accomplish the same thing using Run-if statements. Basically, you use [correct_in_a_row] < 10 as a 'Run-if' statement for all the items in your trial sequence. This will cause your trial sequence to be skipped when correct_in_a_row reaches 10. The downside of this approach is that the prepation phase is not skipped, so you will probably experience some lag due to all the trial sequences being prepared but not executed.

    Does that make sense?

    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 2:10PM

    Thanks so much Sebastiaan! It works now =). One other thing: Is there a way to post my experiments online so that other people can access them?

  • edited 2:10PM

    That's very generous of you!

    The best way to share an experiment on-line is probably by pasting the script into a Pastebin and sharing the link. This is script-only, unfortunately, but most other file sharing services will delete your file after a while.

    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 March 2013

    Hi,

    Just to add: After uploading your script to pastebin, other users can download it and than change the extension to '.opensesame'. After doing so, other OpenSesame users should be able to open the experiment like normally.

    As an example, see this experiment that I uploaded for your previous forum post:

  • edited 2:10PM

    Thank you so much for the Pastebin advice, Sebastiaan and Lotje! On a second thought, I am not quite sure if the "correct in a row" run-if works actually. I think it may not be stopping after 10 correct answers.. Is there something I am missing?

    image

  • edited March 2013

    Hi,

    The variable 'correct_in_a_row' is not a built-in OpenSesame variable. Sebastiaan meant that you have to declare this variable first, in an inline_script item.

    However, for your specific situation I think you don't even need to use the 'Run if' statements in the trial_sequence. You can just count the number of correct responses, and use this counter as a condition for running a next sequence, in the same inline_script item that we made for your previous question:

    More specifically, I advise you to:

    Firstly, append an inline_script at the very beginning of your experiment, and give the 'correct_in_a_row' variable a starting value, like so:

    # Give the counter a starting value:
    # We do this by using the experiment funtion exp.set():
    correct_in_a_row = 0
    
    # Make the variable available in other inline_script
    # items by making it global:
    global correct_in_a_row
    

    Secondly, adapt your current inline_script item (for shuffling the trial_sequence) to something like the following (see comments for a more detailed explanation):

    # Import the built-in Python module random.
    # See: http://docs.python.org/2/library/random.html#random.shuffle
    import random
    
    # Make a list containing the names of the small sequence items:
    small_sequence_list = ['s1', 's2', 's3', 's4']
    
    # Randomise the list by using the random.shuffle() function:
    random.shuffle(small_sequence_list)
    
    # Walk through the (randomised) list:
    for sequence in small_sequence_list:
    
        # Only continue if less than 10 responses in a row
        # were correct:
        if correct_in_a_row < 10:
    
            # Prepare the sequence item:
            exp.items[sequence].prepare()
    
            # Run the sequence item:
            exp.items[sequence].run()
    
        else:
            break
    
        # Check whether the previous response was correct.
        # If so, we add '1' to the counter:
        if self.get("correct") == 1:
            correct_in_a_row +=1
    
        # If not, correct_in_a_row is reset to zero.
        else:
            correct_in_a_row = 0
    
    # Finally, make the variable global again, for the next time
    # this inline_script is run.
    global correct_in_a_row
    

    After applying those suggestions, your overview area should look something like this (note especially the first inline_script item, at the very beginning of your experiment):

    image

    I uploaded a new example experiment here:

    Good luck and don't hesitate to post any further questions!

    Best,

    Lotje

  • edited 2:10PM

    Dear Lotje,

    Thank you so much for your help! I am still having trouble figuring out where I misspelled some things? (There is a quotation error..)

    image

    image

  • edited 2:10PM

    Hi,

    At first sight, your code seems fine. Could you perhaps paste the exact error message (from the debug window) here? To open the debug window, simply click on the red ladybug icon in the main toolbar.

    Many thanks,

    Lotje

  • edited 2:10PM

    Dear Lotje,

    Thank you for being patient. My error message is:

    image

  • edited 2:10PM

    This error is a Mac OS-specific issue with the way that line endings are encoded. I'm not sure what you can do to resolve it, as I don't have a Mac myself, but you can read in this discussion that putting something in both the run and the prepare phase might help (some dummy code, such as pass).

    This is quite a serious bug in the Mac OS package, and we're aware of it. For now, however, you either have to work around it, or use the Windows/ Linux package.

    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 2:10PM

    Hi Sebastiaan and Lotje, thanks for helping me. I was able to open this experiment on a Windows, and it works! The only problem is, my logger data logs everything except for the answer I am seeking the most: how long (how many tries) it takes to reach 10 correct in a row. I added some variables correct_cnt, but the logger always says N/A.

    image

    image

    image

    As a side note, I have opened this experiment on two computers (both windows), and on one computer, it says "out of memory" at the end of the experiment. I thought my computers had lots of memory, but maybe there is a way to expand it?

    Thanks so much!

  • edited 2:10PM

    Hi,

    To make an in-an-inline_script-defined variable available in the interface (e.g. the logger item) as well, you need to set the variable by using the experiment function exp.set() like so:

    exp.set("correct_cnt", correct_cnt)

    You need to do this every time you (potentially) updated the variable. So, for example, after you made the variables global at the end of the inline_script you posted:

    global incorrect_cnt
    global correct_cnt
    exp.set("correct_cnt", correct_cnt)
    exp.set("incorrect_cnt", incorrect_cnt)
    

    After doing so, the variable will have the appropriate values in your logger item.

    Does that make sense?

    Please, also read:

    Regarding your second question, are you perhaps using very large sound files?

    Best,

    Lotje

  • edited 2:10PM

    Thank you so much for all of your help, Lotje and Sebastiaan!

Sign In or Register to comment.