Sequence of routines based on slider response

I’m sorry if someone already asked something like this anywhere. I couldn’t find an answer to my question if it is possible to determine the sequence of multiple routines based on a response that people gave on a slider component.
For example, if they choose option 1 I first want to present them Routine 1 and then Routine 2. If they choose option 2 on the slider I want to do it the other way round. Is this possible somehow?

I think it depends on how different your routines are. For example, if it is just a case of differing stimuli between routines, you can add a code component at the end of your routine where the slider is to determine which conditions file is used.

See here for info on blocking and counterbalancing (https://www.psychopy.org/builder/blocksCounterbalance.html)

Hey, I tried to follow the instructions but I am unable to click ok here.

Also, I think my experiment doesn’t quiet match the instruction for blocks and counterbalancing cause I don’t know from the beginning in which group/condition participants are. Is there another possibility with code components that are like
if sliderRating == 1, then present routine 1 and afterwards routine 2. else sliderRating ==2 present routine 2 first und then routine 1?

Hi There,

Apologies for my delayed response. This demo should do what you need :slight_smile: please note the ‘selectBranch’ code component in the ‘trial’ routine. Essentially we use the slider response to determine the conditions files used, and the conditions files determine the which routine will be presented on each iteration of the loop using nReps (0 will mean that routine is never presented)

sliderBranchedExp.psyexp (14.1 KB) conditionsA.xlsx (8.5 KB) conditionsB.xlsx (8.5 KB)

Hope this helps,
Becca

Hey Becca,
thank you so much. Unfortunately I can’t run the study.

Running: /Users/b/Desktop/sliderBranchedExp_lastrun.py

/Applications/PsychoPy3.app/Contents/MacOS/python: can’t open file ‘/Users/b/Desktop/sliderBranchedExp_lastrun.py’: [Errno 2] No such file or directory

also I can’t klick the code component to see what is written in there.

Weird - shouldn’t need a last run file. make sure all of the files are in a specific folder (rather than just on a desktop) - here is the latrun file from my directory nonetheless
sliderBranchedExp_lastrun.py (18.7 KB)

In terms of clicking the code component - that is strange - please can you make sure you are running a recent version of psychopy (preferably 2020.2.6 as that is what I made this in Releases · psychopy/psychopy · GitHub)

Becca

Hi There,

To clarify - the branching works (and my demo illustrated how to do this ok for you?) but this is possibly a separate issue specifically relating to image presentation in your task and only when online?

Since this is a separate issue. Please can I request that you mark my answer above as the solution for this query, and start a separate thread for a new issue. But first, some debugging things to try

  1. does this run locally but not online? if so this is a JS error, so try opening the developer tools as outlined in the psychopy to JS crib sheet to see if you get an error message.
  2. if this doesn’t work locally, look in the ‘alerts’ box, this can have useful information that might help you figure out why the picture is not presenting (e.g. a small typo can mean the image is presented off the screen! but the alerts box will warn you of that).

once you’ve had a play with these do feel free to start a new thread, sharing error messages with us can also help us figure things out more quickly :slight_smile:

Becca

oops I see you marked the corresponding solution whilst I was responding! thanks!

I already asked that one in the “original” thread. Is that ok like this?

And yes, you got it right. It does work in the Builder but not online. But I don’t get any error message.

deleting and reuploading the project on pavlovia solved the problem.

Hi @bubu,

Pleased to see that you found the solution to your problem :slight_smile:

Becca

I am experiencing a similar question. I have a branching logic that depends on the slider.marker location. Currently, I am using the code shown in the image which shows a correct routine if the markerPos is equal to the correct location (loaded from an excel sheet using a text component). Each time I run the routine, the incorrect routine is shown even when the slidermarker is moverd to the right location. This makes me wonder if I need to change slider.markerPos to another variable or if the answers in from the excel file need to be written in a different format. Right now the correct answer is loaded as (x,y) which is how I believe the slider.markerPos is read as.

Hi @eakwayena, I think you should open a new thread for this issue, as this one is marked as resolved. Before you do, you can add

print(slider_12in.markerPos)
print(text_Feedback_Check.text)

before your if statements to get an insight, into which values both of these variables actually have when they are compared (printed to the console).