layering stimuli

Lindsey Glickfeld's Avatar

Lindsey Glickfeld

03 Feb, 2020 03:18 PM

Hi Chris,

I've been using MWorks 0.8 (I think it's from a nightly around Nov 2017) to present plaid stimuli by sequentially queuing two orthogonal gratings ("stimOne" and "maskOne") and then updating the stimulus display:

<action tag="Queue Stimulus" type="live_queue_stimulus" stimulus="stimOne"></action>
<action type="play_dynamic_stimulus" stimulus="stimOne" tag="StimOn"></action>
<action type="if" condition="doMask">
<action tag="Queue Stimulus" type="live_queue_stimulus" stimulus="maskOne"></action>
<action type="play_dynamic_stimulus" stimulus="maskOne" tag="StimOn"></action>
</action>
<action type="update_stimulus_display"></action>

The stimuli look fine to me but I've noticed some asymmetries in the data. At first I thought they were biological, but now I'm starting to wonder if they're due to the stimuli. Is it possible that the final contrast of each stimulus depends on the order that the stimuli are queued? If so, do more recent versions of MWorks handle this more symmetrically?

Here is the code defining the stimulus properties if that's useful (the one for the "mask" is comparable):
<stimulus type="drifting_grating" tag="stimOne" direction="0" starting_phase="tStimOneGratingPhaseDeg"
spatial_frequency="tStimOneGratingSpatialFreqCPD"
speed="tStimOneGratingTemporalFreqCPS/tStimOneGratingSpatialFreqCPD"
grating_type="sinusoid" mask="gaussian" std_dev="0.3" mean="0.1"
x_size="tStimOneGratingDiameterDeg" y_size="tStimOneGratingDiameterDeg"
x_position="tStimOneGratingAzimuthDeg" y_position="tStimOneGratingElevationDeg"
rotation="tStimOneGratingDirectionDeg"
alpha_multiplier="tStimOneGratingContrast"></stimulus>

Thanks,
Lindsey.

Showing page 2 out of 2. View the first page

  1. Support Staff 31 Posted by Christopher Sta... on 07 Aug, 2020 08:45 PM

    Christopher Stawarz's Avatar

    Hi Lindsey,

    I was wrong. It is totally possible and not very difficult. See the attached example, which I believe implements what you're after.

    Note that this is a distinct construction from the plaid you wanted previously. There's not a way to define a single pair of gratings that can sometimes combine, sometimes not. If you want both types of stimuli in the same experiment, you'll need to define two separate pairs of gratings.

    Cheers,
    Chris

  2. 32 Posted by Lindsey Glickfe... on 07 Aug, 2020 09:21 PM

    Lindsey Glickfeld's Avatar

    Thanks! I'll try it out.
    Best,
    Lindsey.

  3. 33 Posted by Lindsey Glickfe... on 15 Sep, 2020 04:23 PM

    Lindsey Glickfeld's Avatar

    Hi Chris,
    This seems to work well.
    However, I'm having a strange problem where the phase of the two gratings
    is not matched.
    I set them both to have a starting phase of 0 (and confirmed in the output
    that both were 0), but for some reason, they're out of phase. I even tried
    setting them to have the same variable controlling the phase (see below for
    stimulus definition), but they were still out of phase. This suggests that
    there must be some deeper issue. Can you look into it?
    Thanks,
    Lindsey

    %define opaque_grating (direction_deg, phase_deg, diameter_deg, contrast,
    spatial_freq_cpd, temporal_freq_cps, azimuth_deg, elevation_deg)

        layer {
            // Grating
            drifting_grating (
                direction = direction_deg
                starting_phase = phase_deg
                spatial_frequency = spatial_freq_cpd
                speed = temporal_freq_cps/spatial_freq_cpd
                grating_type = gratingType
                x_size = diameter_deg
                x_position = azimuth_deg
                y_position = elevation_deg
                alpha_multiplier = contrast
                dest_blend_factor = zero
                autoplay = true
                )

            // Contrast rectangle
            rectangle (
                color = 0.5, 0.5, 0.5
                x_size = diameter_deg
                x_position = azimuth_deg
                y_position = elevation_deg
                alpha_multiplier = contrast
                source_blend_factor = one_minus_source_alpha
                dest_blend_factor = one
                )

            // Opacity rectangle
            rectangle (
                x_size = diameter_deg
                x_position = azimuth_deg
                y_position = elevation_deg
                source_blend_factor = zero
                dest_blend_factor = one
                source_alpha_blend_factor = one
                dest_alpha_blend_factor = zero
                )

            // Mask
            mask (
                mask = maskType
                std_dev = gratingStd
                mean = gratingMean
                edge_width = gratingEdge
                x_size = diameter_deg
                x_position = azimuth_deg
                y_position = elevation_deg
                )
        }
    %end

    opaque_grating stimOne (
        direction_deg = tStimOneGratingDirectionDeg
        phase_deg = tStimOneGratingPhaseDeg
        diameter_deg = tStimOneGratingDiameterDeg
        contrast = tStimOneGratingContrast
        spatial_freq_cpd = tStimOneGratingSpatialFreqCPD
        temporal_freq_cps = tStimOneGratingTemporalFreqCPS
        azimuth_deg = tStimOneGratingAzimuthDeg
        elevation_deg = tStimOneGratingElevationDeg
        )

    opaque_grating maskOne (
        direction_deg = tMaskOneGratingDirectionDeg
        phase_deg = tStimOneGratingPhaseDeg
        diameter_deg = tMaskOneGratingDiameterDeg
        contrast = tMaskOneGratingContrast
        spatial_freq_cpd = tStimOneGratingSpatialFreqCPD
        temporal_freq_cps = tStimOneGratingTemporalFreqCPS
        azimuth_deg = tStimOneGratingAzimuthDeg
        elevation_deg = tStimOneGratingElevationDeg
        )

  4. Support Staff 34 Posted by Christopher Sta... on 17 Sep, 2020 03:07 PM

    Christopher Stawarz's Avatar

    Hi Lindsey,

    Sorry for the delayed reply. I'm on vacation this week and will take a look at this next week.

    Cheers,
    Chris

  5. Support Staff 35 Posted by Christopher Sta... on 21 Sep, 2020 09:16 PM

    Christopher Stawarz's Avatar

    Hi Lindsey,

    The gratings are out of phase because the starting_phase parameter specifies the phase at the "starting" edge of the grating (e.g. the left edge when the direction is 0), rather than at the center of the grating. John Maunsell noted ages ago that this doesn't make much sense, but I didn't feel comfortable changing such a basic behavior after the stimulus had already been in use.

    Fortunately, I think you can get the behavior you expect by adding a computed offset to the starting phase. To do this, change the definition of opaque_grating by replacing

    starting_phase = phase_deg
    

    with

    starting_phase = phase_deg + 360 * spatial_freq_cpd * (diameter_deg / 2)
    

    I believe this will resolve the issue. If not, please let me know!

    Cheers,
    Chris

  6. 36 Posted by Lindsey Glickfe... on 21 Sep, 2020 09:17 PM

    Lindsey Glickfeld's Avatar

    Got it- thanks!
    Lindsey.

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

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