[solved] Self paced breaks as an inline script?
Greetings,
First off, I would like to say I’m really happy with Opensesame. I have been using it for a couple of months and I really like it! So, thank you. I’m also working on learning python code to further improve on what I can do in Opensesame (I’m still very much a beginner, though). Now my question:
I’m designing a variation on a ‘delayed match to sample task’ and I need a lot of trials:
My design looks something like this at the moment:
>Instructions >Practice loop Practice sequence Block loop (1 x 24 trials) Trial Sequence Feedback >End of Practice >Experimental loop Exp sequence Exp loop (50 x 24 trials) Trial Sequence >End
Of course, 50 times 24 trials is a lot of trials, taking a lot of time. I would like participants to have a self paced break after 72 trials, also providing feedback (average RT and ACC). Can I add an Inline script somewhere to achieve this? (If I add this inline script in the Trial sequence it will also be in the practice loop.)
I could probably make the ‘Exp loop’ (3 x 24 trials) and then repeat the ‘Experimental loop’ 17 times, but I want the 1200 trials to be completely random.
Your help with the best way to achieve this and the formulation of possible inline scripts is much appreciated!
Thank you very much in advance!
Michel
Comments
Hi Michel,
Glad you like OpenSesame!
Indeed, 1200 trials is a bit much. The easiest way to show feedback after 72 trials without subdividing your trials into multiple blocks is probably as follows:
At the end of the trial_sequence, add a feedback item and (in the trial_sequence) set its Run if condition to:
Just before the new feedback item, add an inline_script with the following code:
This script determines based on the count_trial_sequence variable, which contains the number of times that the trial_sequence has been called, whether the show_feedback variable should be set to 0 or to 1.
Another discussion that might come in handy is this one:
More info about variables and conditional statements:
Good luck and don't hesitate to ask questions!
Sebastiaan
Check out SigmundAI.eu for our OpenSesame AI assistant!
Hi Sebastiaan,
Thank you very much! It works like a charm. If I have any other questions in the future I'll be sure to ask!
Greetings,
Michel
Great!
For future reference, in 0.27 (currently as pre-release) you can implement this using only a Run if statement. The functionality that has been added is that you can now use Python statements directly in a Run if statement, by prepending an '=' sign:
Run if:
So in your case this would be something like:
Run if:
There's no real advantage of this method over the one using an inline_script, btw. It's just shorter.
Check out SigmundAI.eu for our OpenSesame AI assistant!
Hi,
unfortunately I'm a very beginner at Open Sesame and I have a similar problem to MichelQ above:
When I set the Run if: statement of the feedback to
=(self.get('count_trial_sequence')+1)%32 == 0 (I would like to have a break after 32 Items), opensesame counts the items of the trial sequence plus the items of the practice sequence, because the two are attached. But I just want opensesame to count the items of the trial sequence without the items of the practice sequence. How does this work? Could you help me?
Greetings
Karin
Hi Karin,
If you're using OpenSesame 3.1 or later, you can make use of the fact that each
loop
maintains a variable that indicates the row that is currently active. This variable is calledlive_row_[loop name]
.So say that you want exit block_loop after 3 trials, and resume where you left of the next time that block_loop is called, then you can do this as follows:
[live_row_block_loop] % 3 = 0
So this allows you to cut up your blocks when they have very long tables.
Does that clear things up?
Cheers,
Sebastiaan
Check out SigmundAI.eu for our OpenSesame AI assistant!
Hi,
I have the same problem but my program says that the variable live_row_[loop name] doesn´t exist. I want my loop to stop every 6 items, so I can change subjects quickly - I'm going to be in an a exhibition, so I can't take much time and the ideia is that each subject can see 6 pictures, there's a break and the next subject can come and continue!
Greetings,
Rita Almeida
Hi Rita,
The
live_row
variable was introduced in OpenSesame 3.1, so I would first make sure that you're not simply using an older version of OpenSesame. If that's not the issue, could you then post the full error message here, including the item stack etc.?Cheers,
Sebastiaan
Check out SigmundAI.eu for our OpenSesame AI assistant!
Hi,
I'm using Open Sesame 3.2.4 and have implemented this as per Sebastian's suggestion:
Break if: [live_row_block_loop] % 3 = 0
Evaluate on first cycle: no
Resume after break: yes
However after the first break, the experiment ends instead of resuming where it left off. Do I need to set something in the sketchpad where I have my break message?
Thanks,
Kate
Hi stoney,
YOu still have to make sure that the block loop is called again after the break. If you don't enter this loop again, then the experiment will just end. So eventually, you should have something like a nested loop structure.
Eduard
Thanks Eduard.
A colleague also suggested another option (maybe simpler?): The break sketchpad should be inserted at the end of the trial sequence. Then, if you click on the trial node, you can edit the 'Run if' statement next to the break sketchpad to be [live_row_block_loop] % 3 = 0.
Best,
Kate
Hi Sebastian,
I have a similar problem as Michael. Would this also work if I just want to initiate a break without feedback?
At the moment I have 120 trials and want to initiate a break every 60 trials (without feedback and just a sketchpad that says "Block 2 : Press any key to continue"
Also, in your tutorial, what is the reason for setting up experiment as Experimental Loop - Exp Sequence - Block Loop when it works the same when I set it up as Experiment Loop - Exp Sequence?
Thank you so much in advance!
Hi,
Would this also work if I just want to initiate a break without feedback
Yes, the same procedure applies. Just choose which item you want to show and what you want it to include. Just make a sketchpad that includes only the text "Block 2. Press a key to continue" and set its run_if field to [count_block] or whatever your variable is called.
Also, in your tutorial, what is the reason for setting up experiment as Experimental Loop - Exp Sequence - Block Loop when it works the same when I set it up as Experiment Loop - Exp Sequence?
The explanation is here: https://osdoc.cogsci.nl/3.2/manual/prepare-run/
Essentially, the reason is improved timing.
Eduard
Hi again,
I tried to introduce the code Sebastian proposed on October 2012 edited 2:02PM in order to seperate my 135 trials in 3 blocks but it does not seem to be working. Do you think that the problem might lies in the
co-routine
?This is my trial sequence before the co-routine. I added the [show_feedback]=1 variable in the Run if here, as it would not let me to add it directly on
trial_sequence
.This is my inline script as proposed above (October 2012 edited 2:02PM)
So, when the inline_script and feedback are added here, the trial (loop) does not run at all and goes directly to feedback, which then, in order to finish the experiment I have to press esc and Q.
When I add the inline scrip right after the new_logger it does not recognize the show_feedback variable.
Could you please support?
Best,
Nomi.
Hi again.
Just an update. As mentioned in the previous message, I am not able to fix my problem with the above inline_script. I wish to find the correct code and solution to the above if you could provide one, or if you could spot my mistake :-)
Nevertheless, I managed to provide "rest breaks" after 45 trials each time along with feedback with the following code =(self.get('count_trial_sequence')+1)%45 == 0 added in the Run if of the
feedback
item which is found inside thecoroutine
See below:
Thanks,
Nomi
Hi Nomi,
I tried to introduce the code Sebastian proposed on October 2012
Yeah, that is too long ago. That code won't work anymore, it might give you inspiration though how to solve the problem.
Just to answer some of your questions:
Do you think that the problem might lies in the
co-routine
?No, that should be unrelated.
I added the [show_feedback]=1 variable in the Run if here
Where does that variable come from? If the co-routine is always skipped this variable is not ever 1. The questions is then why this is the case. (Sharing your experiments helps me to help you find out). If you define that variable in the inline_script that follows the co-routine, that yeah, the co-routine will be skipped (as the variable is only properly set afterwards).
When I add the inline scrip right after the new_logger it does not recognize the show_feedback variable.
Exactly. So you need to define the variable before the loop, and set it to your needs within the loop (once you hit a specific trial).
Apart of that, I'm sorry, but I lost track a bit, which part have you made work already, and what is still not working? Is there still stuff you need help with?
Eduard
Hi again,
Apologies for the mess. I was also lost with the previous code as a nuby!
I managed to provide "rest breaks" after 45 trials each time along with
feedback
with the following code"=(self.get('count_trial_sequence')+1)%45 == 0" added in the Run if of the
feedback
item which is foundinside the
coroutine
Cool, so all good now? Great :)
I guess!
I am currently trying
a) to pseudorandomize my trials and
b) use inline code to give a warning when accuracy drops below 70%
but no luck yet.
I will get back with new posts if I will not make it.
Thanks
Nomi
Sounds good.
a )
If the loop table randomization is no option for you, the approach is usually to create a list of stimuli before you enter the trial loop, shuffle it, and then pick one item at a time from that list and use it as stimulus on a specific trial.
b)
The variable var.acc that opensesame creates per default could be useful. It requires though that var.correct_response is defined
Good luck!
Eduard
@eduard Thanks Eduard!
a) true, an excel file for example because it feels im incompetent with coding!
b) i have managed to do it with the Run if command, simple as that. The code also worked (after I defined the var.correct_response) but I couldn't managed it to run the time I wanted it, the message would only appear at the end of the cycle. But i think I am OK since it runs through the Run If without coding.
Best,
Nomi