Hi Sarah,
This is an interesting little riddle, and I'm not honestly sure why the
'obvious' solution didnt work.
The best way to fix it will be to implement some new methods of
combining pixels from textures to the frame buffer (including the option
to 'add' rather than 'average'). But that will take some hardish coding
at my end.
In the meantime, the ugly hack is this: draw the two gratings as you are
doing but with no masks, and then afterwards draw a stimulus with no
texture but an inverse of a gaussian mask (ie, transparent centre and
opaque at sides).
Hope that works! Apols for the ugliness of the hack. ;-)
Jon
#INITIALISE SOME STIMULI
grating1 = visual.GratingStim(myWin,mask=None,
color=[1.0,1.0,1.0],opacity=0.3,
size=(1.0,1.0), sf=(4,0), ori = 45,
autoLog=False)#this stim changes too much for autologging to be useful
grating2 = visual.GratingStim(myWin,mask=None,
color=[1.0,1.0,1.0],opacity=0.3,
size=(1.0,1.0), sf=(4,0), ori = 135,
autoLog=False)#this stim changes too much for autologging to be useful
#overlay an inverse gaussian mask (grey outside, transparent inside)
gaussTexture = filters.makeMask(128, shape='gauss') #has -1 for transp,
+1 for opaque
invGaussTexture = -gaussTexture #make opaq->transp and vice versa
gaussMask = visual.GratingStim(myWin,mask=invGaussTexture,tex=None,
contrast=0, ori = grating2.ori, size=(1,1))
trialClock = core.Clock()
t = 0
while t<20:#quits after 20 secs
t=trialClock.getTime()
grating1.setPhase(1*t) #drift at 1Hz
grating1.draw() #redraw it
grating2.setPhase(2*t) #drift at 2Hz
grating2.draw() #redraw it
gaussMask.draw()
myWin.flip() #update the screen
On 12/04/2013 15:58, Sarah Harrison wrote:
> Hi all,
>
> The problem is as in the title, and has come to light because I want
> the two plaid components to be of different contrast.
>
> The intuitive solution is to create two gratings windowed by
> gaussians, then draw them both with their new phase (one after the
> other, with the second having reduced opacity), on each frame.
> However, drawing the gratings like this, when they have each already
> been masked by a gaussian, doesn't 'add' them correctly - this problem
> can be seen because the result depends on which grating is drawn
> first, which it shouldn't.
>
> I can create the correct stationary plaids by adding two arrays (for
> instance using visual.filters.makeGrating), making a mask (using
> visual.filters.makeMask), and then multiplying the two arrays. The
> problem here is that the array then has to be used as a 'image' in
> visual.ImageStim or a 'tex' in visual.GratingStim to make an object
> that has the attribute 'draw'. Once the object has been created in
> this way, I can't access the phase of the (two) gratings to make them
> appear to drift, without creating a new object on each frame.
>
> In fact, even once the two grating arrays are combined to make a plaid
> array, I can't see a simple way to alter the plaid component phases...
> but even if I could, this wouldn't solve the problem.
>
> Any new ideas welcome!
>
> Thanks.
>
> Sarah
> --
> You received this message because you are subscribed to the Google
> Groups "psychopy-users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to
psychopy-user...@googlegroups.com.
> To post to this group, send email to
psychop...@googlegroups.com.
> To view this discussion on the web visit
>
https://groups.google.com/d/msg/psychopy-users/-/62vZvkwWrpsJ.
> For more options, visit
https://groups.google.com/groups/opt_out.
>
>
--
Jonathan Peirce
Nottingham Visual Neuroscience
http://www.peirce.org.uk/