Stimulus advice and some drifting grating questions

Hi Chris,

I’m hoping you could give me some advice on the best way to generate a particular stimulus in MWorks. Basically, what I want is a stimulus with a Gaussian luminance profile whose peak luminance is modulated over time according to a sinusoid. How would you try to generate this stimulus?

The approach I’ve used thus far is to attempt to generate a “counterphase” grating (that is a grating that does not drift, but the brightness at a given point is modulated according to a given temporal frequency). This can, theoretically, be achieved by the sum of two identical gratings that drift in opposite directions. However, in practice, I’m having some difficulty achieving the desired effect. I queue two gratings that drift in opposite directions, but there seems to be a small offset between the actual start time of the drifting of each grating, with the grating that is cued first also starting first. Is there a way to start both simultaneously? I’ve tried a frame-list but that creates an undesirable flicker…

In addition, I have some basic questions about how to specify the drifting grating stimuli:
spatial frequency - units? cyc/deg?
speed - units? deg/s?
Mask - I have Gaussian, but it doesn’t look like there is a Gaussian mask; instead I see a square.
std_dev - Based on the name, I would think it controls the size of the mask; instead it looks like it controls the contrast. Is that true?

Thanks!
Seth

Hi Seth,

Sorry for the delay in replying.

This can, theoretically, be achieved by the sum of two identical gratings that drift in opposite directions. However, in practice, I’m having some difficulty achieving the desired effect.

I’m having trouble getting this to work, too, but I’m not sure we’re seeing the same issue. Can you send me an example experiment that demonstrates your problem?

I have some basic questions about how to specify the drifting grating stimuli

You’re correct on the units: spatial_frequency is cycles/degree, and speed is degrees/second.

Mask - I have Gaussian, but it doesn’t look like there is a Gaussian mask; instead I see a square.

std_dev - Based on the name, I would think it controls the size of the mask; instead it looks like it controls the contrast. Is that true?

The Gaussian mask is computed using the Gaussian function (eq. 1), where mean is 휇, std_dev is 휎, and the distance from the center of the grating is 푥. As std_dev gets larger, the maximum amplitude decreases, and the decay becomes less steep.

Irrespective of the mask, the extent of the grating is limited to the rectangle defined by x_size and y_size. So, if std_dev is large, then the grating will look like a low-contrast rectangle, as the edges of the Gaussian are cut off. If you use a smaller value (say, 0.3), then you should get something that actually looks Gaussian.

Cheers,
Chris

Hi Chris,

No worries! Attached is a simple experiment that will produce the near
counter-phase grating. If you want to confirm it is the timing of the start
of each stimulus, just switch which grating is cued first and you should
see stuff move in the opposite direction. Let me know if it doesn’t work
for you.

Thanks for clarifying some of the options on the Gabor stimuli. I’m
surprised the amplitude of the Gaussian is specified as part of the spatial
mask; imagine you’d like to create two Gabors with identical contrast,
spatial and temporal frequencies but with differing visual extents. Its
unclear how one could accomplish this with the current version of the
stimuli. If, instead, the amplitude and width of the Gaussian were
independently controlled, this type of stimulus would be easy to implement.

Cheers,
Seth

Attachment: MWGratingTest.xml (2.87 KB)

Hi Seth,

Thanks for the example. I think we are seeing the same issue, although I don’t yet know what the cause is. I’ll continue to investigate.

I’m surprised the amplitude of the Gaussian is specified as part of the spatial mask

Yeah, there are many aspects of MWorks’ drifting grating stimulus that are surprising and/or just plain dumb. I’ve wanted to replace it for a while now, but it hasn’t been a high-priority item.

Returning to your original question:

Basically, what I want is a stimulus with a Gaussian luminance profile whose peak luminance is modulated over time according to a sinusoid. How would you try to generate this stimulus?

At the moment, finagling the grating is probably the only way to do this. In the future, I could see adding general support for stimulus masks, so that you could take a simple circle stimulus and apply a generic Gaussian mask (with the amplitude specified as a time-varying expression) to get your desired stimulus. It seems like that could be a useful feature.

Cheers,
Chris

Hi Seth,

Basically, what I want is a stimulus with a Gaussian luminance profile whose peak luminance is modulated over time according to a sinusoid.

In case it’s still relevant, the current MWorks nightly build has some new features that let you create this type of stimulus.

First, the drifting grating stimulus has a new parameter: normalized. If set to NO, the normalization term (1/(std_dev*sqrt(2*pi))) is omitted from the Gaussian mask, thereby decoupling the spatial extent of the mask from its peak luminance.

Second, the grating now has a color parameter, each component of which can be an arbitrary expression. If you make those expressions time dependent and live queue the stimulus, then the luminance (and also the hue, if you want) will vary in time.

I’ve attached an example experiment, which I believe demonstrates the type of stimulus you wanted. You’ll need the current nightly build to run it. (Also, the experiment is written in MWEL, which is a new, non-XML format for writing MWorks experiments. To view/modify it, open it in any text editor.)

If you have any questions, please let me know.

Cheers,
Chris

Attachment: time_varying_gaussian.mwel.txt (773 Bytes)