Image size not setting every repeat

Hi all,

I am using PsychoPy verison 2022.2.4. I have a section of my study where participants can cycle through some images to study. I based the code for it off this post. The images cycle fine, but the image size won’t update even though I’ve made a variable for it and told it to set every repeat in the builder. I also have my code component above the image component in the routine. However, outside of this one section, during the trials, the changes in image size works fine. I will provide the code below and a link to my .psyexp file. Any help would be greatly appreciated.

—Begin experiment—

current_image = None
DoNotRep = False

—Begin Routine—

if BlockNum != 3 or DoNotRep == True:
    continueRoutine = False
    studyPhase.finished = True
    img_num = 0
    if studyPhase.thisN == 0:
        img_num = 0
    if current_image in wide_stims: ###not working
        stim_size = (.75,.50)
        stim_size = (.50,.75)
    current_image = stim_item[TRstims[img_num]]

—End Routine—

if BlockNum == 3:
    if TRkey.keys == 'left':
        img_num = max(0, img_num - 1)
        continueRoutine = False
    elif TRkey.keys == 'right':
        img_num = min(9, img_num + 1)
        continueRoutine = False
        studyPhase.finished = True
        DoNotRep = True

JR_Thesis.psyexp (79.6 KB)

  • current_image is initialised as None, so presumably this check will always fail on the first iteration.
  • we don’t know what current_image or wide_stims are so can’t tell why this comparison might be failing in general. But a common issue in this sort of situation is to conflate the name of an image file (i.e. a string of characters) with an ImageStim object (an instantiation of a PsychoPy-specific class).
  • img_num is updated at the end of the routine, but it is used to update current_image only after its membership of wide_stim is tested. This could be leading to off-by-one-trial comparisons, but we don’t know enough from this code to be sure.

A quick and dirty way to debug such code is to put in some (temporary) debugging code:


The output should help reveal why the test is failing. NB this code needs to be run near when the comparison is made, not after the value of current_image is updated.

Ah, this was my issue. Thank you.