Re: [Fwd: psychopy: quick and dirty way to draw a square checkerboard]

398 views
Skip to first unread message

Jon Peirce

unread,
Feb 10, 2010, 7:21:36 AM2/10/10
to Andre Gouws, PsychoPy-users
Hi andre,

Yes I've forwarded this to the list so that the answer is more generally
seen. The following works on my machine. If you want exactly alternating
pixels over a 128 pixel stimulus then set the cycles to 64 (sf=0.5; half
a cycle of the texture per pixel).

Jon


from psychopy import visual, core
import numpy as np

tex = np.array([[1,-1],[-1,1]])
cycles=4

win = visual.Window([400,400])
stim = visual.PatchStim(win, tex=tex, size=128, units='pix',
sf=cycles/128.0, interpolate=False)

stim.draw()
win.flip()
core.wait(1)

Andre Gouws wrote:
>
> I've tried a few ways of generating a square ware 'square'
> checkerboard (i.e. not radial) patch with fine resolution (i.e.
> alternating pixels
> are black and white) .. can't seem to get the texture perfect though ..
> have tried generating a numpy array and passing it to patchstim as a
> exture .. perhaps I am getting the SF and texRes wrong?
>
> Help appreciated.
>
> A
>
> p.s. would you prefer me to start posting to the psychopy mailing list?

This message has been checked for viruses but the contents of an attachment
may still contain software viruses which could damage your computer system:
you are advised to perform your own checks. Email communications with the
University of Nottingham may be monitored as permitted by UK legislation.

Reply all
Reply to author
Forward
0 new messages