Stimulus advice and some drifting grating questions

swegger's Avatar

swegger

27 Jun, 2016 01:59 PM

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

  1. Support Staff 1 Posted by Christopher Sta... on 29 Jun, 2016 02:25 PM

    Christopher Stawarz's Avatar

    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

  2. 2 Posted by swegger on 29 Jun, 2016 03:41 PM

    swegger's Avatar

    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

  3. Support Staff 3 Posted by Christopher Sta... on 05 Jul, 2016 01:48 PM

    Christopher Stawarz's Avatar

    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

  4. Support Staff 4 Posted by Christopher Sta... on 07 Aug, 2017 03:07 PM

    Christopher Stawarz's Avatar

    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

  5. Christopher Stawarz closed this discussion on 06 Sep, 2017 02:40 PM.

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