psychopy.org | Reference | Downloads | Github

Move Forward & Backward through a Slideshow

I use PyschoPy 3 on Windows 10 and Mac OS, to run a simple “Dwell Time Paradigm.” We create slideshows of still images which participants advance at their own pace with a button or mouse press, and we measure the looking time for each image. I would like to allow participants to move forward and backward along the stream of still images. Normally our button press only advances to the next slide, but I want them to be able to go back to the previous slide. I imagine using some sort of loop and two different button presses, right arrow to advance forward, and left arrow to move back to the previous slide. The participant should be able to go forward and/or back as many times as they would like, and we still hope to measure the looking time at every new slide.

Thank you for any help or suggestions!

Scott

Hi Scott,

You are right: nest a second loop inside your main trial loop, only surrounding the routine(s) you want to keep repeating. Don’t connect this inner loop to a conditions file. Instead just give it some unfeasibly large nReps value (like 100), so that the trial can be repeated up to that many times.

Insert a code component from the “custom” component panel. In the “End routine” tab of that component, put something like the code below. The idea is to terminate the inner loop if you simply want to progress to the next trial (i.e. the next iteration of the main, outer loop). Otherwise, the inner loop will iterate again, running the routine once more:

if your_keyboard_component_name.keys == 'right':
    your_inner_loop_name.finished = True

i.e. in this case, if the right arrow key was pushed, then the routine will not repeat, and instead the next trial will proceed. You don’t need any code to handle the other keypress option: the inner loop will just keep running automatically until you tell it to stop (or it reaches the nReps value).

Michael, thank you so much for the quick and concise response. A friend of mine referred me to the Discourse page because he was raving about the quick and helpful responses. I really appreciate the help. I hope a few follow up questions are ok before I try to implement your solutions.

  • The critical measure of this paradigm is collecting the looking time at each slide after the button press. Since this has only been done in one direction, forward, a single time is collected for each slide. If participants are allowed to move forward and back, will a time be collected in the same way?

i.e. if a participant moves through the slides; 1, 2, 3, 4, 3, 2, 3, 4, 5; will we get a looking time for each of those 9 instances separately? (I’m hoping so.)

  • I should also point out that our slideshows can contain 100 images or more. Is this an issue?

-Last, I have an interesting idea which no one has implemented yet in these types of studies. Perhaps you can give me an idea of whether or not this is feasible to implement in PsychoPy. Instead of using a button press to advance (or revisit) each slide discretely. I would like to allow participants to “throttle” through the slideshow in a more continuous way. I imagine a simple knob, joystick, or less exciting a button press which allows participants to roll through the slides in succession (maybe even forward & backward) and instead of collecting a looking time for each slide, we capture the speed at which the participant advances the slides across time.

Thank you again for your support, it is sincerely appreciated!

P.S. if you happened to be curious, I am a PhD student at the University of Oregon in Cognitive Neuroscience and Developmental Psychology. I study the visual and sensorimotor systems in the Perception & Action Lab with an interest in how contextual information guides our actions, and also design research experiments probing the developmental process of statistical learning of action streams in the Acquiring Minds Lab. My work is directed toward practical applications for those with Traumatic Brain Injury, Autism Spectrum Disorders, and Sensory Sensitivity challenges.

Hi!

I had a go with this. You can download the bare bones project I put together with three stock images here: https://github.com/AnonZebra/psychopy_sgwallner
(if you’re not used to github, just use the green ‘clone or download’ button->‘download zip’, and then unpack the project wherever you want)

I’ve added a couple of code snippets. I tried adding comments to make them fairly self-explanatory. I don’t think I came up with an elegant solution, but maybe it can help you towards figuring out what the best way would be? I just remembered I never put in any instruction about using the ‘left’/‘right’ arrow keys, but that is how you navigate the slide show. Edit: Oh, and the time spent looking at each image is represented by the “rt” (reaction time) column, don’t think I explained that in the comments either.

If I understood you correctly, participants should be able to go back and forth between images however they want, for a set time period. So they could go to image 1-2-3-2-1-100-99-98-99-100-1-2-3-4-3-… and so on? I assumed in the simple example that you would want the image slide to loop around to the beginning when the participant reaches the highest image number, and vice versa. Also, if people are free to roam about the images you need some custom (since I think PsychoPy Builder mostly assumes a more linear experiment setup?) clock for knowing when to end the experiment, after say 10 minutes. But once those 10 minutes pass, should the experiment end abruptly right away, or only once the participant gives their next response? The example assumes the latter.

I don’t know about the “throttle” functionality you describe, I guess you would need to write a code snippet that ensures that the experiment proceeds to another routine if it registers that the mouse is pressed (even when it’s not a new ‘click’).

I hope this is of some use.

1 Like