Images not loading and images not moving in new affective slider implementation

If this template helps then use it. If not then just delete and start from scratch.

OS (e.g. Win10):
PsychoPy version (e.g. 1.84.x): 2022.2.4
Standard Standalone? (y/n) y
What are you trying to achieve?:

I am adding this here to the builder tag as I have included this code has a code component in the builder, I have not coded the application from scratch.

I have been customizing a previous implementation of the affective slider made by a former member of my laboratory. The previous code had several flaws, the positioning of the images was not dynamically set with the monitor resolution, the movement of the slider was not smooth and not entirely accurate. So in my version I transformed the measures from cm to pix, made the positions dependent on the resolution and left the rest pretty much the same with a few exceptions. Two things aren’t working right, namely the happy, unhappy, sleepy and wideawake images are not being loaded, even thugh the path is correct and the rest of images, such as the AS_track (top_track and bottom_track), the AS_thumb and AS_intensitycue, are loading and being placed in the right position, so the problem is not my conversion of the base positions, or the dynamic positioning, I think there must be some other bug but I cannot figure it out.
As I mentioned another thing that is happening, which was working fine-ish on the original code is that the ball at the centre of the tracks (AS_thumb) was moving with the mouse, but now it isn’t moving at all.

What did you try to make it work?:

I have tried replacing the code segments where I load and place the images with the image component in the builder, but still it does not appear to place the images. One of the reasons why I changed from cm to pix was also because I imagined that the mouse position was being relayed in pixels and not centimetres, but it had no effect, or rather the ball went from moving very little to not moving at all.

What specifically went wrong when you tried that?:

Nothing else changed, the images still do not load and the ball does not move.

Bellow I am pasting my implementation of the code, I am also annexing the Slider folder that I am refering to in the path variables.

import psychopy
from psychopy import visual, core, event, data, gui, sound, parallel
# import pyautogui

def helpertransfer(x, y, SCw, SCh):
    x_new = ((x * SCw) / 800)
    y_new = ((y * SCh) / 800)

    return [x_new, y_new]
    
# helper funtions to draw and erase slider elements on screen
def draw_slider():
    happy.setAutoDraw(True)
    unhappy.setAutoDraw(True)
    sleepy.setAutoDraw(True)
    wideawake.setAutoDraw(True)

    top_track.setAutoDraw(True)
    top_mark.setPos([P1_new[0], P1_new[1]])
    top_mark.setAutoDraw(True)
    top_as_intensity_cue.setAutoDraw(True)

    bottom_track.setAutoDraw(True)
    bottom_mark.setPos([P2_new[0], P2_new[1]])
    bottom_mark.setAutoDraw(True)
    bottom_as_intensity_cue.setAutoDraw(True)


def erase_slider():
    happy.setAutoDraw(False)
    unhappy.setAutoDraw(False)
    sleepy.setAutoDraw(False)
    wideawake.setAutoDraw(False)

    top_track.setAutoDraw(False)
    top_mark.setAutoDraw(False)
    top_as_intensity_cue.setAutoDraw(False)

    bottom_track.setAutoDraw(False)
    bottom_mark.setAutoDraw(False)
    bottom_as_intensity_cue.setAutoDraw(False)


def set_marker_position(marker):
    mouse_position = my_mouse.getPos()
    if mouse_position[0] > MARKER_MAX_VALUE:
        mouse_position[0] = MARKER_MAX_VALUE
    elif mouse_position[0] < MARKER_MIN_VALUE:
        mouse_position[0] = MARKER_MIN_VALUE
    if marker == 'top':
        top_mark.setPos([mouse_position[0], P1_new[1]])
        win.flip()
    elif marker == 'bottom':
        bottom_mark.setPos([mouse_position[0], P2_new[1]])
        win.flip()
    else:
        raise RuntimeError("Marker can only be 'top' or 'bottom'.")
    return mouse_position[0]


# functions for responses
def clear_all_cue():
    while True:
        if event.getKeys():
            event.clearEvents('keyboard')
        else:
            break


def get_response():
    resp = event.getKeys()
    if resp:
        key_out = resp[0]
        return key_out


def initialize_slider():
    draw_slider()
    win.flip()
    my_mouse.clickReset()
    my_mouse.setVisible(True)
    clear_all_cue()


def calculate_slider_value(marker_value):
    final_value = (marker_value - MARKER_MIN_VALUE) / (MARKER_MAX_VALUE - MARKER_MIN_VALUE)
    final_value = MIN_SCALE_VALUE + final_value * (MAX_SCALE_VALUE - MIN_SCALE_VALUE)
    return final_value

# base coordinates
X = [-453.54, 170.07]
Y = [453.54, 170.07]
Z = [-453.54, 0]
W = [453.54, 0]
V1 = [0, 170.07]
U1 = [0, 113.38]
V2 = [0, 0]
U2 = [0, -56.69]
P1 = [0, 170.07]
P2 = [0, 0]

# prepare window
FULLSCR = True
MAX_SCALE_VALUE = 10
MIN_SCALE_VALUE = 0
MARKER_MAX_VALUE = (9.14 * 1080) / 800
MARKER_MIN_VALUE = (-9.14 * 1080) / 800
SCw, SCh = [1920, 1080]
win = visual.Window((SCw, SCh), monitor='testMonitor', fullscr=FULLSCR, color='white', units='pix')


# dynamic coordinates
X_new = helpertransfer(X[0], X[1], SCw, SCh)
Y_new = helpertransfer(Y[0], Y[1], SCw, SCh)
Z_new = helpertransfer(Z[0], Z[1], SCw, SCh)
W_new = helpertransfer(W[0], W[1], SCw, SCh)
V1_new = helpertransfer(V1[0], V1[1], SCw, SCh)
V2_new = helpertransfer(V2[0], V2[1], SCw, SCh)
U1_new = helpertransfer(U1[0], U1[1], SCw, SCh)
U2_new = helpertransfer(U2[0], U2[1], SCw, SCh)
P1_new = helpertransfer(P1[0], P1[1], SCw, SCh)
P2_new = helpertransfer(P2[0], P2[1], SCw, SCh)

# load images
AS_happy = './Slider/AS_happy.png'
AS_sleepy = './Slider/AS_sleepy.png'
AS_unhappy = './Slider/AS_unhappy.png'
AS_wideawake = './Slider/AS_wideawake.png'
AS_intensitycue = './Slider/AS_intensity_cue.png'
AS_track = './Slider/AS_track.png'
AS_thumb = './Slider/AS_thumb.png'

# happy, unhappy, sleepy and wideawake images loading
happy = visual.ImageStim(win, image=AS_happy, pos=(W_new[0], W_new[1]), units='pix')
unhappy = visual.ImageStim(win, image=AS_unhappy, pos=(Z_new[0], Z_new[1]), units='pix')
sleepy = visual.ImageStim(win, image=AS_sleepy, pos=(X_new[0], X_new[1]), units='pix')
wideawake = visual.ImageStim(win, image=AS_wideawake, pos=(Y_new[0], Y_new[1]), units='pix')

# top slider
top_track = visual.ImageStim(win, image=AS_track, pos=(V1_new[0], V1_new[1]), units='pix')
top_mark = visual.ImageStim(win, image=AS_thumb, pos=(P1_new[0], P1_new[1]), units='pix')
top_as_intensity_cue = visual.ImageStim(win, image=AS_intensitycue, pos=(U1_new[0], U1_new[1]), units='pix')

# bottom slider
bottom_track = visual.ImageStim(win, image=AS_track, pos=(V2_new[0], V2_new[1]), units='pix')
bottom_mark = visual.ImageStim(win, image=AS_thumb, pos=(P2_new[0], P2_new[1]), units='pix')
bottom_as_intensity_cue = visual.ImageStim(win, image=AS_intensitycue, pos=(U2_new[0], U2_new[1]), units='pix')

# prepare mouse
my_mouse = event.Mouse()
event.Mouse(visible=False)

# slider
initialize_slider()
top_slider_value = 0
bottom_slider_value = 0

while True:
    key = get_response()
    if key:
        # when pressing spacebar
        if key == "space":
            break
        # when pressing ESC
        elif key == "escape":
            win.close()
            core.quit()

    # checking if top_mark is clicked on
    if my_mouse.isPressedIn(top_mark):
        while my_mouse.getPressed()[0]:
            top_slider_value = set_marker_position('top')

    # checking if top_mark is clicked on
    if my_mouse.isPressedIn(bottom_mark):
        while my_mouse.getPressed()[0]:
            bottom_slider_value = set_marker_position('bottom')
    win.flip()

erase_slider()
my_mouse.setVisible(False)
win.flip()

# final slider value calculation
top_slider_value = calculate_slider_value(top_slider_value)
bottom_slider_value = calculate_slider_value(bottom_slider_value)

Slider.zip (63.9 KB)

I’d really appreciate some help! Thank you in advance!

I will add to this that everything before ‘’‘#base coordinates’‘’ is in before experiment, from ‘’‘#base coordinates’‘’ to ‘’‘#slider’‘’ is in the begin experiment segment, from ‘’‘#slider’‘’ to ‘’‘#final slider value calculation’‘’ is in the begin routine segment, and the rest is in the end routine segment. I figured I’d give this information as it could be at the root o whatever error I am making.
Thank you again, in advance for any help.