Can you move backward through routines?

Hi all!

What are you trying to achieve?:
I have created a task where the first six routines are instructions explaining the task. I am wondering if there is any way to allow participants to use the arrow keys to move forward and backwards through the instructions in case they miss something.

What did you try to make it work?:
I tried making loops that send the participant back to the previous instruction routine if they press the backwards arrow, and move them on to the next instruction routine if they press the forwards arrow. However, it seems you cannot put Routine 2 in a loop with Routine 1 AND in a separate loop with Routine 3. This means that I can scroll back from Routine 2 to Routine 1, but not from Routine 3 to Routine 2.

Is there any way around this, besides putting a loop at the final instruction that allows them to repeat all instructions from the start?

Thanks in advance!

1 Like

Hi,

Iā€™ve adapted this recent example for you. Please find the modified version attached.

The basic idea is similar:

  • Use one routine for all instructions
  • Update the text displayed depending on which key was pressed using a dictionary

Hope this helps.

Jan

instructions.psyexp (9.9 KB)

1 Like

Hi Jan,

Thanks for that info! Unfortunately, it wont work with my instructions as they are quite detailed and have images in them, so I have created them as PDFs and include them in separate routines.

Is there any way I can scroll back and forward through the various instruction PDFs?

Thanks,

Paige

I think Janā€™s instinct to use just one routine is correct. I didnā€™t even know that PsychoPy could display PDFs but Iā€™m going to assume it is no different than displaying a full page .png file or similar, and that you have those six image files available and numbered meaningfully.

So surround that routine with a loop, set to have some unfeasibly large nReps value, like 100.

Insert a Code component from the Custom Components tab, and put something like this in its ā€œbegin Experimentā€ tab:

current_instruction = 1

Then in the image field on your instruction routine, put something like this, set to update every repeat:

$'instruction_' + str(current_instruction) + '.png'

modified as required to fit the naming scheme of your files. i.e. the displayed image will update, deepening on the value of the current_instruction variable.

Insert a keyboard component set to end the trial on a keypress and to store only the last key, with allowed values of 'left', 'right' or whatever responses you want. Then in the ā€œEnd routineā€ tab of the Code component, put something like this:

response = your_keyboard_component_name.keys

if response == 'left' and current_instruction > 1:
    current_instruction = current_instruction - 1
elif response == 'right':
    current_instruction = current_instruction + 1

if current_instruction == 7: # pressed 'right' on the last instructions
    your_loop_name.finished = True
2 Likes

Hi Michael and Jan,

Ahh yes Iā€™m using .jpg not .pdf!

I tried Michaelā€™s recommendation and it appears the program isnā€™t accepting that command as a formulation to create a file name, but rather is looking for a file that is named that.

This was the error message:
17.2779 ERROR Couldnā€™t find image ā€˜Emotion_Instructionā€™ + str(current_instruction) + ā€˜.jpgā€™; check path? (tried: /Applications/PsychoPy2/Experiments/SCZ_E1/ā€˜Emotion_Instructionā€™ + str(current_instruction) + ā€˜.jpgā€™)

Hi Paige,

You probably forgot to add the $-sign in the field Image:

$'instruction_' + str(current_instruction) + '.png'

Jan

1 Like

That works perfectly now.
Thanks guys!