Glew.h and other shaders

Hi Najib,

Another point that needs some clarification:

Our drifting grating plugin builds from the old plugin, it allows for multiple gratings that can be added or multiplied

I understand that you’re referring to the “overlay” gratings that your plugin supports. However, saying that these are “added or multiplied” to/with the grating they overlay doesn’t accurately describe what the code you gave me actually does.

In effect, your overlays are a second mask on the base grating. That is, they modify the alpha channel of the underlying grating+mask, but not the color (i.e. RGB values). The “shape” of the mask is itself a grating (sinusoid or square, which you’ve called “pulse”). While the net effect of this masking may look similar to multiplying two gratings, the operations aren’t identical.

I bring this up not to dispute what you’re doing, but just to confirm that this is, in fact, what you want. Personally, I think having the option to use a grating as a mask is pretty neat, particularly in concert with the layer and mask functionality I’m also working on. (For example, you could apply a grating mask to a static image or moving dot field.)

Alternatively, if you actually want to multiply two gratings, we can add support for that. In fact, we could support both techniques (grating-as-mask and grating multiplication), if that would be useful.

Please let me know how you’d like to proceed.

Thanks,
Chris

Hi Najib,

Regarding the “flattop” mask again:

If it’s OK with you, I think I’d prefer to add a raised cosine mask to MWorks. That will avoid the confusion of having two, sort-of-Gaussian mask types.

The raised cosine mask will be characterized by a single parameter, edge_width, which specifies the width of the sinusoidal edge as a fraction of the total width (i.e. diameter) of the mask. Hence, an edge width of 0.125 will produce a mask similar to your “flattop8”. (This will also be the default edge width.)

Does this sound OK to you?

Thanks,
Chris

Hi Chris,

Thanks again for staying on top of this. We are in the process of upgrading
one of our rigs and it will be great to have this plugin available, it will
make the transition so much easier.

I understand that you’re referring to the “overlay” gratings that your
plugin supports. However, saying that these are “added or multiplied”
to/with the grating they overlay doesn’t accurately describe what the code
you gave me actually do

You are absolutely right my description was brief and inaccurate.

In effect, your overlays are a second mask on the base grating. That is,
they modify the alpha channel of the underlying grating+mask, but not
the color (i.e. RGB values). The “shape” of the mask is itself a grating
(sinusoid or square, which you’ve called “pulse”). While the net effect of
this masking may look similar to multiplying two gratings, the operations
aren’t identical.

Correct. When I said multiply, I meant alpha multiply, but your reading of
the code is the correct thing.

I bring this up not to dispute what you’re doing, but just to confirm that
this is, in fact, what you want. Personally, I think having the option to
use a grating as a mask is pretty neat, particularly in concert with the layer
and mask http:///discussions/questions/790 functionality I’m also
working on. (For example, you could apply a grating mask to a static image
or moving dot field.)

Yes, this functionally basically allows you to do many thing including
combine two gratings in different ways, either to produce a plaid, or to
produce and inter-digitated pattern that alternates between a two grating
of different orientation.

Alternatively, if you actually want to multiply two gratings, we can add
support for that. In fact, we could support both techniques
(grating-as-mask and grating multiplication), if that would be useful.

Multiplying two grating might be useful, but can’t think of any direct
needs right now. I think that focusing on the above is what’s important. I
also am looking forward for the layer and mask functionality, your link
doesn’t work but I hope it will be coming soon.

Best
Najib

Hi Chris,

Regarding the “flattop” mask again:

If it’s OK with you, I think I’d prefer to add a raised cosine
https://en.wikipedia.org/wiki/Raised-cosine_filter mask to MWorks. That
will avoid the confusion of having two, sort-of-Gaussian mask types.

It is funny that you mention that, I was just chatting with our resident
programmer and he suggested a raised cosine since it is nice and defined
over particular ranges, unlike a guassian that extends to infinity and you
have to decide when to cut it off.

The raised cosine mask will be characterized by a single parameter,
edge_width, which specifies the width of the sinusoidal edge as a
fraction of the total width (i.e. diameter) of the mask. Hence, an edge
width of 0.125 will produce a mask similar to your “flattop8”. (This will
also be the default edge width.)

Does this sound OK to you?

This sounds great to me. Thanks.

Hi Najib,

Multiplying two grating might be useful, but can’t think of any direct needs right now. I think that focusing on the above is what’s important.

OK, we’ll stick with grating-as-mask for now.

I also am looking forward for the layer and mask functionality, your link doesn’t work but I hope it will be coming soon.

Sorry, I was just linking to the relevant discussion. (Hopefully that link works.)

The layer and mask stuff is mostly done. I’ll send you more info on it soon.

Cheers,
Chris

Hi Najib,

The current MWorks nightly build includes support for using gratings as masks. Also, as I noted elsewhere, raised cosine masks are now available. I’ve attached an example experiment (once again, written in MWEL) that demonstrates both features.

As you can see, the base grating, raised-cosine mask, and mask grating are all separate stimuli, brought together in a layer. This differs from your implementation, where they were all part of a single stimulus. However, the end result should be equivalent. Also, breaking the pieces out separately lets you use them in other contexts, too.

When you have a chance, please check this out, and let me know if it meets your needs.

Cheers,
Chris

Attachment: mask_grating.zip (629 Bytes)

Hi Chris,

Did I make a mistake with my download or the current (downloaded yesterday)
‘nightly built’ version of MWorks does not have the ‘raised-cosine mask’?

Thank you!
mariana

Hi Mariana,

It should be there. Does my example not work?

Chris

Hi Chris,

Your example works, but I was trying to edit an exiting script on XML
format (or via the MWorksEditor), and I could find the property:
‘edge_width’, and it was giving me an error message saying that
‘raised_cosine’ is not a valid type of mask. It seems a bit mysterious to
me; as your script works.

Thanks!

Hi Mariana,

The raised cosine mask is provided by the new Mask Stimulus. The drifting grating doesn’t support it. In fact, the grating’s integrated support for masks should be considered deprecated. The support that’s there will remain, but any new mask types and features will only go in the mask stimulus. (However, the grating’s support for being a mask is not deprecated, obviously.)

I’ve attached an XML version of the mask_demo experiment, in case that’s helpful.

Cheers,
Chris

Attachment: mask_demo.xml (3.02 KB)

Hi Chris,

Thank you! I couldn’t find a ‘mask’ on the MWEditor, and I was not sure how
to call it in XML. It’s working nicely.

Thank you!
mariana

Hi Chris,

One more question, did the gamma calibration got also included on the last
nightly built? The masking looks great, but it seems like it does not have
the gamma calibration working.

Thank you,
mariana

Hello again, Chris,

Apologies, it seems to be working.

I’ll do a small calibration test, but if I don’t bug you again, please
disregard the last email.

Thank you!