psychopy.org | Reference | Downloads | Github

Online experiment issue: Fade in of image flickers

#1

Hi all,

URL of experiment: https://pavlovia.org/run/orig_amir/gradcpt/html/

Description of the problem: I’m trying to get an image to smoothly fade in. It works in python, but the online JS version flickers. before fading in from 0 opacity it flashes a 100% opacity version of the image for a few ms. How can I get rid of this?



gradCPT_demo.psyexp (6.5 KB)

#2

Hi @orig_amir, I think that the final opacity is being carried over into the next trial. A quick way to fix this is to set the opacity to zero before and after each routine using a code component. Select a code type of “Both” in a code component, and in the right panel for JS:

// Begin Routine
next_image.setOpacity(0)

// End Routine
next_image.setOpacity(0)

This should get rid of your flicker.

#3

Thanks for the quick response!
That fixes the issue!

#4

Hi @dvbridges,

Another question if I may, how do I determine the refresh rate of the computer the task runs on?

The fading relies on the code ‘frameN/120’, this gives me a fade of 2s assuming the refresh rate is 60hz. But I imagine this might vary from computer to computer? Shouldn’t the ‘120’ be dynamically set at the beginning of the experiment?

Many thanks!

#5

@orig_amir, you could use win.getActualFrameRate(), where win is the name of your window object. This returns actual FPS for your screen - see docs.

#6

Ok, I found a way to do easily get the measurement in the builder:
Math.round(expInfo[‘frameRate’])

#7

Great, it is the same thing. I mean, expInfo['frameRate'] is assigned the value returned from win.getActualFrameRate().

#8

I suspected that, but since I don’t know the name of my window I went with this solution :sweat_smile:

#9

Good thinking. In future, if you want to see the Python code, you can compile the script from Builder and have a look at the output in the Coder window, or any other text editor.