| Reference | Downloads | Github

Online experiment issue: Fade in of image flickers

Hi all,

URL of experiment:

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)

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

// End Routine

This should get rid of your flicker.

Thanks for the quick response!
That fixes the issue!

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!

@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.

Ok, I found a way to do easily get the measurement in the builder:

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

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

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.