Help with transparency and alpha_blending

hi chris,

i am trying to generate the movie enclosed on the fly in mworks and was wondering if you have any advice. this probably relates to a question that i once asked about multiplying images in mworks.

the concept of the movie is that you have two image on top of each other. a moving transparent window allows you to see a portion of the background images through the foreground image.

i realize that i can generate as movies, but the path of the movies is meant to be random on every trial.

any advice would be much appreciated.

best
najib

Hi Najib,

Good to hear from you! At present, there’s no way to do what you want in MWorks. However, I can think of a couple ways we could make it possible.

What you need is more or less a generalization of the masks that get applied to drifting gratings (except that the alpha would be zero in the center and “decay” to one at the edges). It’d be great if we could make masks a standard feature of all stimulus types. Unfortunately, I don’t see a way to do this in a generic fashion, meaning that we would need to add mask support to each stimulus type individually. While this would work, it’s far from ideal.

A more appealing alternative would be to make the mask a separate stimulus type that could have an arbitrary size and position. To make this work with the way MWorks draws stimuli, we’d need to add something akin to Photoshop layers. Specifically, the stimuli in a “layer” (in your case, the top image and the mask) would first be rendered separately, against a transparent background, and then the entire layer would be drawn into the framebuffer.

I’m pretty fond of the second option, as I think it would open up a lot of interesting possibilities for stimulus construction. I also think it would be pretty straightforward (although still a fair amount of work) to implement.

What do you think?

Cheers,
Chris

Hi Chris,

Sorry for the delay in responding.
The second options is exactly what we want, and it is a feature that will
open a lot of things in mworks.
How can I help?

Best
Najib

Hi Najib,

The second options is exactly what we want, and it is a feature that will open a lot of things in mworks.

OK, I’ll add this to my to-do list. When do you want/need to start using it?

How can I help?

Once the feature is in the nightly build, I’ll certainly appreciate your help in testing it. Also, are there mask types you’d want beyond what the drifting grating already has (rectangle, ellipse, and gaussian)?

Cheers,
Chris

Hi Chris,

Of course the sooner the better, but I understand that you have a long to
do list.
Would early february be doable.
Happy to test whatever you need tested.

Best
Najib

Oops, forgot to answer the question about the windows.
The options you list are a bit limited, would be awesome if we could do a
raised cosine, or a flattop 8.
They are like gaussians but with steeper tapers.

Best
Najib

Hi Najib,

Layers and masks are now available in the MWorks nightly build.

I’ve attached an experiment that demonstrates how you can use them to generate something like your example movie. The experiment is written in MWEL, so don’t try to open it in MWEditor. Instead, view/edit it using the text editor of your choice (TextEdit, Sublime Text, emacs, vi, etc.).

My example creates two layers, one on top of the other. Each layer contains a square image, overlaid by an elliptical mask that crops the image into a circle. The top layer contains an additional, smaller, inverted raised-cosine mask that creates a window into the bottom layer. The window steps randomly over the top image, exposing different portions of the bottom image as it moves.

When you have a chance, please check out the linked docs and the example, and let me know if this meets your needs.

Cheers,
Chris

Attachment: mask_demo.zip (895 KB)