help with transparency and alpha_blending

Najib Majaj's Avatar

Najib Majaj

16 Nov, 2017 07:02 PM

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

  1. Support Staff 1 Posted by Christopher Sta... on 17 Nov, 2017 04:00 PM

    Christopher Stawarz's Avatar

    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

  2. 2 Posted by Najib Majaj on 12 Dec, 2017 05:09 PM

    Najib Majaj's Avatar

    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

  3. Support Staff 3 Posted by Christopher Sta... on 19 Dec, 2017 02:51 PM

    Christopher Stawarz's Avatar

    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

  4. 4 Posted by Najib Majaj on 19 Dec, 2017 07:10 PM

    Najib Majaj's Avatar

    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

  5. 5 Posted by Najib Majaj on 19 Dec, 2017 07:12 PM

    Najib Majaj's Avatar

    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

  6. Support Staff 6 Posted by Christopher Sta... on 01 Aug, 2018 06:10 PM

    Christopher Stawarz's Avatar

    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

  7. Christopher Stawarz closed this discussion on 28 Nov, 2018 04:00 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

Recent Discussions

07 Feb, 2019 02:24 PM
02 Feb, 2019 01:58 PM
01 Feb, 2019 06:25 PM
26 Jan, 2019 12:15 AM
18 Jan, 2019 05:44 PM