OS (e.g. Win10): macOS 13.5.1
PsychoPy version (e.g. 2024.2.4 Py 3.8): PsychoPy v2024.1.5
Hi there! I am trying to randomise the duration that a stimuli is presented. For a little context, I’m trying to set my experiment up in a way that makes participants decide quickly between imageA and imageB. If they do not make the decision in 28 frames, they will be prompted to make their decision faster in a different routine. If they do make the decision on time, the experiment will skip the next routine and move to the next trial (repeat the routine). My current flow in my single routine is:
polygonFixation (60 frames) → imageAScrambled (2 frames) → imageA (x frames) → imageBScrambled (2 frames) → imageB (x frames) → imageBScrambled2 (2 frames)
x should be assigned 2/6/12 frames.
I set each component to begin when the previous component ends. For example, when imageAScrambled is supposed to begin, the start is specificed as “$polygonFixation.status==FINISHED”. Additionally, after imageBScrambled ends, a text and a key will also start for 28 frames (to prompt the decision making). That means that it should continue displaying even if x < 28 frames.
When x is preassigned to the image pairs, the experiment works perfect. However, we preferred to randomise them fully.
I first randomised the presentation times through Excel with column “frame” and value “$[2,6,12][randint(3)]”. However, I think PsychoPy is processing the input as a string and thus the experiment keeps crashing.
I then tried to use code to randomise it (I’m still new to Python, sorry for any mistakes!).
Begin experiment:
import random
allFrames = [random.choice([2, 6, 12]) for _ in range(15)] # 15 trials
random.shuffle(allFrames)
Begin routine:
currentFrame = allFrames.pop(0) #take and remove the FIRST item from the list
Currently, the randomisation works well, but the text and key disappears. The data output also recorded the start and stop time of these two components as exactly the same (i.e., as when imageBScrambled ends).
I appreciate all the help I can get (preferably with as little code), and happy to provide more context if necessary. Been working on this problem for a few weeks now