psychopy.org | Reference | Downloads | Github

How to use cylindrical warping?

Hi there! I’m trying to utilize psychopy for projecting visual stimuli onto a cylindrical screen, so I’m very interested in the Warper function. However, utilizing the Warper doesn’t seem to change the projected image at all.

For example, I’ve been running the following code to try it out:

from psychopy.visual.windowwarp import Warper
from psychopy.visual import Window, GratingStim

win = Window(monitor='testMonitor', screen=1, fullscr=True, useFBO = True) 
warper = Warper(win, warp='cylindrical', warpfile = "", warpGridsize = 64, eyepoint = [0.5, 0.5], flipHorizontal = False, flipVertical = False)

grating = GratingStim(win=win, mask='circle', size=50, pos=[0,0], sf=1000)

while True:
    grating.setPhase(0.05, '+')
    grating.draw()
    win.flip()

The projected image is no different if I leave or comment out the warper line. I’ve also played with the parameters and warper.dist_cm parameter. Can anyone let me know if this is the proper way to utilize the warper, or if I need to call another function when I’m drawing/flipping to warp the image?

Thanks so much :slightly_smiling_face:

Wow, I didn’t even know this was a thing. According to the source code (https://github.com/psychopy/versions/blob/master/psychopy/visual/windowwarp.py), initialising a warper monkey patches the window’s render method, so you shouldn’t have to do anything special to see a result, just a win.flip() should suffice.

So I don’t have much useful to suggest. Have you tried just setting the flipHorizontal or flipVertical parameters to True. That might show if anything is being applied at all.

Odd that the eye point definition is at odds with the normal PsychoPy normalised convention.

If you add something like this below the warper = ... line, you should see a warping effect (more extreme if warper.dist_cm is lower):

warper.dist_cm = 20.0
warper.changeProjection("cylindrical")
1 Like

Many thanks! This did the trick.

Beautiful cylindrical projections! :slight_smile: