It looks like you're new here. If you want to get involved, click one of these buttons!
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)?
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
if self.get('correct') == 1:
Thanks for your help!
The advanced-options functionality exists from OpenSesame 0.27 onwards (on Windows and Ubuntu) and can be found here:
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!
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?
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?
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.
[correct_in_a_row] < 10
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.
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?
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.
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:
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?
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:
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
# 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:
# 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:
# Run the sequence item:
# Check whether the previous response was correct.
# If so, we add '1' to the counter:
if self.get("correct") == 1:
# If not, correct_in_a_row is reset to zero.
correct_in_a_row = 0
# Finally, make the variable global again, for the next time
# this inline_script is run.
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):
I uploaded a new example experiment here:
Good luck and don't hesitate to post any further questions!
Thank you so much for your help! I am still having trouble figuring out where I misspelled some things? (There is a quotation error..)
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.
Thank you for being patient. My error message is:
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.
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.
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!
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:
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:
After doing so, the variable will have the appropriate values in your logger item.
Please, also read:
Regarding your second question, are you perhaps using very large sound files?
Thank you so much for all of your help, Lotje and Sebastiaan!