Help on drifting grating and masks

Hi Chris,

I am interested in finding the FWHM of the MWorks gaussian mask that is created with stddev 0.3 and mean 0.1, normalized=true.

For those parameters, if I follow the calculations in the code on github

I find that the region where mask == 1 is about 0.5size. But when I actually measure the stimulus onscreen, I get a region where mask == 1 that is about 0.3size or even a bit smaller.

Can you calculate/measure the length of the region where mask==1 with these parameters, and the FWHM?

Another note from testing today:

  • Could it be that the drifting_grating starting_phase parameter is not phase in degrees, as stated in the docs? If I set the stimulus spatial frequency to 0.05, I need to set starting phase to a value greater than 40 to even shift a half-phase.

Thanks,
Mark

plot of stimulus profile:

code I used, following MWorks code as closely as possible, to create mask

from numpy import pi, sqrt, exp
def simMWorksMask(stdDev=0.3, mean=0.0, doNorm=True):
nPts = 128
maskCenter = 0.5
xv = np.linspace(0.0, 1.0, nPts)
yv = np.linspace(0.0, 1.0, nPts)

def distance(x0,x1):
    return (np.sqrt((x0[0]-x1[0])**2 + (x0[1]-x1[1])**2))

stdDev=stdDev#/2
mean=mean#/2
maskImage = np.zeros((nPts,nPts))
if doNorm:
    mult = (1.0 / (stdDev * sqrt(2.0 * pi)))
else:
    mult = 1.0
for (iX,tX) in enumerate(xv):
    for (iY,tY) in enumerate(yv):
        dist = distance(((tX,tY)), (maskCenter,maskCenter))
        maskImage[iY,iX] = ( mult *
                              exp(-1.0 * (dist - mean) * (dist - mean) / (2.0 * stdDev * stdDev)));
return (maskImage,xv,yv)

maskImage = simMWorksMask()

Hi Mark,

Your code is calculating dist differently than MWorks. Your code:

dist = distance(((tX,tY)), (maskCenter,maskCenter))

MWorks:

dist = distance(maskVaryingCoords, maskCenter) / maskRadius;

You’re not dividing by maskRadius (0.5). I think that’s the source of the discrepancy.

Could it be that the drifting_grating starting_phase parameter is not phase in degrees, as stated in the docs? If I set the stimulus spatial frequency to 0.05, I need to set starting phase to a value greater than 40 to even shift a half-phase.

It’s in degrees of phase, not degrees of visual angle. Changing starting_phase from zero to 180 inverts the grating (highs become lows, lows become highs). Or am I misunderstanding the question?

Chris

Thanks for this.

  1. You found the bug in my code, appreciated.
  2. Of course, degrees of phase. Whoops. You’re right. Thanks.

Mark