[solved] Navigating Back and Forward in an Exeperiment + some more Questions
Hello,
Im at the moment creating an experiment with OS where i want to observe the choices people make.
It should look like this:
[Instruction]
[Instruction]
[Loop]
[Sequence]
[Choice1]
"Here i want to display 4 different Options wish lead to different consequences based on the option choosen" (Can i make a new variable "Choice" and set the LoopChoice1-4 to "Run if [Choice]=1 etc.?)
[DisplayConsequences1-4]
"Here i want to show them the Consequence of their choice and give them the option to go backwards to "Choice1" ([No idea how to do it)
"Does it make more sense to put the [DisplayConsequences1-4] in the Loops of the choice?"
[LoopChoice1]
"After they press "accept" the next Loop shall get started where they are presented the consequences of their Choice"
[LoopChoice2]
[LoopChoice3]
[LoopChoice4]
I Will have around 20-30 Trials running this experiment to see if people favor one of the choices over the other.
Next Question is, i want them to have an overall Ressource wish they spend based on the choices they make. For example, if they choose Choice1 they spend 2 Tokens, if they choose Choice3 they spend 5 Tokens and so on, how to operate such a ressource?
Thank you very much for your superior support!
Best regards,
Henrik
Comments
Hi Henrik,
Yes.
Going back in a sequence is not possible, but you can implement this behavior using a simple inline script. Basically, you want to repeat the part of the experiment from
Choice1
onwards until the participant has accepted their choice, right?So what you can do is put all items that should be repeated into a separate sequence, let's call it
repeatable_sequence
. Then, immediately afterrepeatable_sequence
, you add an inline script that keeps runningrepeatable_sequence
, unless they have accepted their choice.Does that make sense?
That depends on what exactly you want to do, I cannot say.
Again, you would need to do this with inline scripts. At the beginning of the experiment, you set an initial variable
credits
(resource
has a special meaning for OpenSesame, so you can't use that as a variable name) to some value, such as 10:Then, when you want to deduct something from the credits, you do
Hope this helps!
Cheers,
Sebastiaan
Check out SigmundAI.eu for our OpenSesame AI assistant!
Hey,
Thanks alot for the tipps, the credits-part works very well!
But I failed to explain what I really mean to say with the choices.
The participant has the choice to select one of the options. If, for example, the participant decides to take Choice1 he presses “1” and then he gets the loop he choose for himself.
So I need an option to make a variable that is equal to the keypress on one of the sketchpads.
So if the participant presses “1” he gets loop1, if he presses “2” he gets into loop2, “3” for loop3 and “4” into loop4 and that for every trial.
Same for the you-have-choosen sketchpad.
l.uzI want to display on that sketchpad which option has been choosen:
“1” is ship, so I want to display there:
You have chosen ship and for that distance you will need [shiptime].
If they press “2”:
You have chosen bus and for that distance you will need [bustime].
Then they should have the option to go back to the “Choose your vehicle” and decide if they want to switch the vehicle or continue with their choice.
If they continue with their choice they get into the ship/bus/train/motorbike loop, pay a price for their vehicle and wait for a bit while they travel. Then they get back to choose their vehicle again.
Another Question, the participant has to wait depending on the trial he is in, is there any chance to display on a sketchpad a countdown for how long the sketchpad will be presented? So if the sketchpad is presented for 50000 there is a timer counting down till they sketchpad fades away?
My last Question:
Is there a chance to put a sketchpad in a trial that only appears every third trial? Problem is I can´t apply weights over the variables since I don’t know which vehicle will be chosen and those events only appear every third time they go by ship.
Again thank you very much for your awesome support!
Best regards,
Henrik
Hi Henrik,
This sounds like quite a complicated structure! I'm not sure I fully understand, but I think that with some tinkering my explanation should go quite a long way towards achieving what you're describing. To reiterate, in general the trick is to use 'Run if' statements to select which item should be executed based on some response variable. I.e.: run-if statements like
[response] == 1
for loop 1,[response] == 2
for loop 2, etc.To go back to a previous item, run-if statements are obviously of little use, in which case you can the while-loop structure from my previous post.
A sketchpad is only a single display, so it cannot, on its own, display something dynamic such as a countdown. However, what you could do is create a feedback item with a variable text on it, such as
[countdown]
. An inline script like this would then construct and show the feedback item over and over again, each time with a different value forcountdown
:One thing is that you need to set the run-if statement for the feedback item to never, so that it's not automatically executed, only when explicitly called by the inline script.
You can use a Python-style run-if statement by prepending an
=
sign, as described here:Then, using the modulo operator and the
count_trial_sequence
variable, you can construct the following run-if statement:Hope this helps!
Cheers,
Sebastiaan
Check out SigmundAI.eu for our OpenSesame AI assistant!
Hey,
Sorry that i took so long. I tried to make it work the way i wanted but i got some bugs (probably because of my mistakes).
I start with an Inline script:" exp.set('credits', 1000)"
As next there is a sketchpad with Instructions saying:" You have [credits]"
When i try to Run the experiment it says:
Error: Runtime error
Description: Variable 'credits' is not set in item 'Instruktion1'.
You are trying to use a variable that does not exist. Make sure that you have spelled and capitalized the variable name correctly. You may wish to use the variable inspector (Control + I) to find the intended variable."
Second:
the keypress leads to a loop.
The loop consists of 3 sketchpads and 2 inline scripts. One of the "Carcost" which shall appear only all 3 trials.
Problem is, once i go to the "car" trial it says:
Error: Runtime error
Description: Variable 'carcost' is not set in item 'Car'.
You are trying to use a variable that does not exist. Make sure that you have spelled and capitalized the variable name correctly. You may wish to use the variable inspector (Control + I) to find the intended variable."
I checked my spelling several times and it is correct. Any idea why that is so?
The Rest works perfectly.
Thanks again for you great support!
Hi Henrik,
If you are sure that you have spelled the names correctly (and I'm sure you are), then the problem might be that the variables are not available yet when OpenSesame tries to use them. For example, if you add the text
[response]
to a sketchpad before any response has been collected, you will get this error, even though the variable inspector will tell you thatresponse
is a variable (and it will be, at some point in the experiment).I cannot really be more specific, because this depends on the structure of your experiment, but this page might help you trace the issue down, because it explains when things are prepared and executed:
Cheers,
Sebastiaan
Check out SigmundAI.eu for our OpenSesame AI assistant!
Hi again,
how do i use:
I want the Participant to pay every third trial for using the car. The inlinescript is called "Carcost".
So i put this line into the sequence where "Carcost" shall appear:
Right?
Problem is, if i do that i get the bug: Variable "Carcost" is not set.
So structure looks like this:
I hope i didn´t do any stupid mistakes and could explain what my problem is right now, thanks again for your support, the program is really awesome!
Hi Henrik,
Counter variables always start with 'count_', followed by the name of the to-be-counted variable. So in your case, the Run-if statement should be:
Also, depending on where in your experiment you first use this Run-if statement, the 'count_Carcost' variable may not be defined yet (simply because the 'Carcost' inline_script item has never been run yet. Therefore, you should give the counter variable a starting value at the very beginning of your experiment, for example by typing
in the prepare phase of an inline_script item appended to your experiment sequence.
Do those suggestions solve your problem?
Best wishes,
Lotje
Did you like my answer? Feel free to
Hello,
That helped, now im trying to get it to run and im experiencing some issues. I have set the variable "credits" in a loadsequence. However if i try to run the experiment i get the following error:
Error: Runtime error
Description: Variable 'credits' is not set in item 'Instruktion1'.
You are trying to use a variable that does not exist. Make sure that you have spelled and capitalized the variable name correctly. You may wish to use the variable inspector (Control + I) to find the intended variable.
How can i still get a error message even though i allready set the variables?
Best regards,
Henrik
Hi Henrik,
Could it be that you declared your variables in the Run phase tab of your inline_script item? Due to OpenSesame's prepare-run strategy, in-an-inline_script-defined variables are only available in the prepare phase of other items when they are delared in the Prepare phase tab.
For more information, please see:
If putting the code in the Prepare phase tab of your inline_script item doesn't solve the problem, please let us know!
Best,
Lotje
Did you like my answer? Feel free to
Hello,
Me again, i keep having some issues. Im using the variable [credits] now to let the participant pay at a fixed number of intervals.
I use several different loops:
At the beginning i set the variables as following:
In the specific loop i use a load_sequence.
Loop
load-sequence
Inline_reduce
sketchpad_Pay (Informing the participant that a specific amount of credits have been removed)
To reduce it only at the specific number of trials im using in the run-if-line of the loop the following sequence:
Or
=self.get('count_Exp_Choice_Bike) % 10 == 0
Or
=self.get('count_Exp_Choice_Bike) % 20 == 0
On the load_sequence and on the sketchpad.
The problem now is, it reduces the credits every cycle, whats my mistake?
And sidequestion, if i want to give the participant a trial sequence, how can i reset the [credits]? I tried it by using an inline-script: exp.set('credits', 60) but it seems to have logged that credits have been spent before.
Best regards and once more THANKS alot for the amazing support!
Henrik
Hi Henrik,
One thing that comes to mind is that the code is placed in the prepare phase of the inline_reduce script. With a Run-if statement you only prevent the the run phase from being executed, but not the prepare phase. Could that be it?
I'm afraid I don't understand this question. Could you perhaps rephrase or provide some more details?
Cheers!
Sebastiaan
Check out SigmundAI.eu for our OpenSesame AI assistant!
Hi again,
Yeah i had it in the prepare-phase, thats why it didnt work! Thanks.
To the sidequestion, I had a trialphase where the participant could how the experiment works, so he started with 60 credits and could spend some of them to pay for example for the bus.
After the trialphase i wanted to run the real experiment and in order to do so i wanted to let them start with 60 credits.
So i actually wanted to refill the credits back to 60.
But i somehow screwed up and the experiment would save that they spended some credits before.
Trial 60 credits
52 credits
=> Refresh on 60 for the real experiment (That doesn´t work)
So they start with 52 credits instead of 60...
Thanks again,
Henrik
Hi Henrik,
I imagine that this too is a result from putting the reset command in the prepare phase of a script. Could that be it? If you insert an
inline_script
item after the practice phase and before the experimental phase, withexp.set('credits', 60)
in the run phase, then the variablecredits
will be reset to 60. Does that answer your question?Cheers,
Sebastiaan
Check out SigmundAI.eu for our OpenSesame AI assistant!
Hey,
Yeah that solved the problem. I experience two other issues right now. I tried to solve them by myself but im somewhat unable to do so.
First again with the counters:
I got the 3 conditions bus, bike and car.
The bus condition has to be paid every time its used, for 2 credits. Im using a loop around an inlinescript:
The inlinescript has in the run_phase:
The sketchpad is supposed to show that 2 credits have been removed:
"You pay 2 credits, you have [credits] remaining"
In some cases it doesn´t show that 2 credits are missing so it says for example in the first run:
"You pay 2 credits, you have 60 credits remaining"
One phase after it has it removed the 2 credits so it actually removes them, but doesnt show it, what can i do to solve that?
Its a bit tricky in the car condition, the participant has to pay every 8th usage of the car for fuel.
So in the car sequence im using the following command in the run-if statement:
For the car_loadsequence and the sketchpad that shows that credits have been removed.
It looks like this:
By using this i thought it would only run both (inlinescript and sketchpad) every 8th trial where condition car has been selected. But it shows both each trial, removing the participants 20 credits.
What can i do to fix that?
Same problem in the bike condition, there it is each 10th trial and each 20th trial where the participant has to spend credits in order to use the bike.
And the last problem is in the loop sequences im using around 20 different variables, like weather, time and the distance the participant has to go.
It keeps shuffeling it. I want the order in which the entire loop is presented to be randomed, but i want weather, time and distance to be presented together. so i want weather 1 with distance 1 and time 1. But i don´t want them to be presented as first.
Just randomed wether its starting with 1 or 2 or 3 and so on.
I hope i could explain my problem, thx alot for the support.
Best regards,
Henrik
This (again!) appears due to a mix-up between the prepare and run phase. The script updates the credits during the run phase, but the
sketchpad
is created during the prepare phase. Therefore, the contents of the sketchpad will 'lag behind', reflecting the credits as they were during the prepare phase. The solution would be to use afeedback
item instead of asketchpad
, becausefeedback
items are prepared during the run phase:I cannot tell based on your description, but my guess is that the variable
count_Exp_Choice_Car
is somehow not updated properly. I would print it to the debug window at various points during the trial to see how and whether it is updated, with commands like this:This will help you to track down the problem further.
I don't quite understand this question. The order of the rows in the loop table is shuffled, but columns are not shuffled independently of each other. So if you have a table like this:
You will have one trial where
var1
is 'a' andvar2
is '1', and one trial wherevar1
is 'b' andvar2
is 'a'. But 'a' will never be paired with '2'. Does that answer your question?Cheers!
Check out SigmundAI.eu for our OpenSesame AI assistant!
Hey,
Just wanted to let you know i got it working now, thanks alot for the support again. I got one last Question, im using the Counter variables to make the participant pay credits all 8 Trials. Open Sesame makes him pay in the first trial, and then in the eight trial. Is there any chance that he doesn´t have to pay in the first trial?
At the moment he pays in Trial 1 and in Trial 9, so every eights trial.
I want him to pay in Trial 9 first. Without paying in Trial 1, to simulate some sort of hidden costs.
I Tried to set the counter variables to "1" to begin with and hoped OpenSesame would skip the first time payment then, but that didn´t work.
Thanks alot for your support once more.
Changing your run-if statement to something like this should probably do the trick:
You're welcome and good luck with the experiment!
Check out SigmundAI.eu for our OpenSesame AI assistant!
Hey,
Its all running now, thank you very much.
Hey everyone,
I'm trying to implement a countdown in my experiment as well by using your code
the countdown appears on my feedback item, so far so good.
Here is basically what's happening in this part of my experiment: On the feedback item a target and a couple of distractors are presented of which the participants need to find the target and mouseclick on it. (Without the countdown collecting the click works fine.)
But now while the countdown is running I can not collect a mouse response, only after the countdown counted down to 1 (which is logical, because the feedback Item is repeated without running the mouse_response). How can I fix this? Any ideas?
Thank you!
Charlotte
Hi Charlotte,
You have two options:
1) Make the countdown work in the loop structure of your experiment
This would be rather complicated I am afraid.
2) Make your experiment fit in the countdown loop
That would be my approach. Basically, in the code snippet of yours you would have to add mouse collection and logging. This shouldn't be very tricky though. The simplest solution would be this:
Of course there are additions to this code to improve it (some more necessary than others). For example, you probably have set the duration of the feedback item to 1000 ms, right? In this case, you will be able to poll mouse responses only once every second. If you need more frequent sampling, you have to set the timeout to 0, and instead make sure in the loop that the feedback item is updated every second. The code below could be a starting point to implement this:
I hope this is useful.
Eduard
Hi Eduard,
Thank you for your detailed response, it is very useful! I am trying your second approach, it seems perfect for me.
Now, when I try running it it returns this error:
Could you help me with this as well?
Thank you!
Charlotte
I guess that should be
exp.set('countdown', countdown)
. But I haven't tested it, so there might be more issues. Probably it is best if you try to build up the 2 functionalities (updating the sketchpad, and making the countdown) first separately with the same principle (while loop), and once both work, combine them. Like that debugging is easier and you won't have the hardest time finding out why your code is not doing what you want it to do.Good luck,
Eduard
Hi Eduard,
I managed to start the countdown now, there seem to be only two problems left now, with which you could probably help, das would super :)
First the cursor flickers the whole time. I put Mouse().show_cursor(True) at the end of the while loop, which makes it a little better. Maybe there is a way to stop making it flicker all together?
Next and more important: I get the following Error message:
I implemented ms.flush() which seems not to be the way to go.
Do you have an idea how to solve this?
Thanks in advance!
Charlotte
This is my script so far:
Why do you have ms.flush in there? If it causes the error message, how do you still get the flicker (The error message breaks the experiment, right?). So intuitively, I would say that removing the ms.flush() would also solve the flickering.
Does it do that?
Eduard