# 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

https://github.com/mworks/mworks/blob/master/plugins/core/DriftingGratingStimulus/DriftingGratingStimulus.cpp

I find that the region where mask == 1 is about 0.5*size. But when I actually measure the stimulus onscreen, I get a region where mask == 1 that is about 0.3*size 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:

[X]

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()

Comments are currently closed for this discussion. You can start a new one.

# Keyboard shortcuts

### Generic

? | Show this help |
---|---|

ESC | Blurs the current field |

### Comment Form

r | Focus the comment reply box |
---|---|

^ + ↩ | Submit the comment |

You can use `Command ⌘`

instead of `Control ^`

on Mac

Support Staff 1 Posted by

Christopher Sta...on 07 May, 2019 03:29 PMHi Mark,

Your code is calculating

`dist`

differently than MWorks. Your code:MWorks:

You're not dividing by

`maskRadius`

(0.5). I think that's the source of the discrepancy.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

2 Posted by

mhistedon 13 May, 2019 06:29 PMThanks for this.

1. You found the bug in my code, appreciated.

2. Of course, degrees of phase. Whoops. You're right. Thanks.

Mark

Christopher Stawarz

closedthis discussion on 13 May, 2019 06:59 PM.