# How to use cylindrical warping?

**URL:** <https://discourse.psychopy.org/t/how-to-use-cylindrical-warping/7183>\
**Category:** Coding\
**Created:** [March 27, 2019, 8:32pm UTC](https://discourse.psychopy.org/t/how-to-use-cylindrical-warping/7183 "2019-03-27T20:32:42Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jmmanley](https://avatars.discourse-cdn.com/v4/letter/j/db5fbb/32.png) [@jmmanley](https://discourse.psychopy.org/u/jmmanley)\
**Post date:** [March 27, 2019, 8:32pm UTC](https://discourse.psychopy.org/t/how-to-use-cylindrical-warping/7183/1 "2019-03-27T20:32:42Z")

</div>

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:

```auto
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 🙂

---

<div class="post-metadata">

**Author:** ![Michael](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/michael/32/16_2.png) [@Michael](https://discourse.psychopy.org/u/Michael)\
**Post date:** [March 27, 2019, 8:50pm UTC](https://discourse.psychopy.org/t/how-to-use-cylindrical-warping/7183/2 "2019-03-27T20:50:27Z")

</div>

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](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.

---

<div class="post-metadata">

**Author:** ![djmannion](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/djmannion/32/37535_2.png) [@djmannion](https://discourse.psychopy.org/u/djmannion)\
**Post date:** [March 28, 2019, 4:28am UTC](https://discourse.psychopy.org/t/how-to-use-cylindrical-warping/7183/3 "2019-03-28T04:28:35Z")

</div>

> [@jmmanley](#):
>
> I’ve also played with the parameters and warper.dist\_cm parameter.

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

```python
warper.dist_cm = 20.0
warper.changeProjection("cylindrical")

```

---

<div class="post-metadata">

**Author:** ![jmmanley](https://avatars.discourse-cdn.com/v4/letter/j/db5fbb/32.png) [@jmmanley](https://discourse.psychopy.org/u/jmmanley)\
**Post date:** [March 29, 2019, 6:39pm UTC](https://discourse.psychopy.org/t/how-to-use-cylindrical-warping/7183/4 "2019-03-29T18:39:52Z")

</div>

Many thanks! This did the trick.

Beautiful cylindrical projections! 🙂
