Dear Chris,
Is there a way of drawing an arc in MWorks? something like the red object you can see in the attached image.
We would like for the arc to change color, luminance, position, and size like any other object.
thank you in advance
LG
a
Dear Chris,
Is there a way of drawing an arc in MWorks? something like the red object you can see in the attached image.
We would like for the arc to change color, luminance, position, and size like any other object.
thank you in advance
LG
a
Attachment: Screenshot_2020-11-15_at_16.50.01.png (142 KB)
Hi Antonino,
There’s no direct support for drawing arcs, but it should be possible to construct one via a combination of circular and rectangular masks. I can try to make an example of that for you, if it would be helpful.
I could also add built-in support for drawing arcs to MWorks, although that will take some time and will require you to upgrade to the latest nightly build to make use of it.
Cheers,
Chris
It would be helpful if you could make a little example if that does not require too much of your time.
Adding a built-in support for future experiments would also be useful. At the moment we are drawing an arc with a plugin that Ralf wrote, but utilising a plugin that is not native to mworks, makes it impractical and difficult to handle.
Thanks for the help
LG
a
Hi Antonino,
I’ve attached an example. The arc stimulus is implemented as an MWEL macro in a separate file (arc_stimulus.mwel
) included by the main experiment file (arc_demo.mwel
). This makes it easier to use in multiple experiments, should you wish to do so.
The only limitation with the stimulus as constructed is that theta_max-theta_min can be at most 180 degrees.
Adding a built-in support for future experiments would also be useful. At the moment we are drawing an arc with a plugin that Ralf wrote, but utilising a plugin that is not native to mworks, makes it impractical and difficult to handle.
If Ralf wants to give me the source code for his plugin, I’d be happy to add this to the standard MWorks distribution. Otherwise, I can write a new one.
Cheers,
Chris
Attachment: arc_demo.zip (1.16 KB)
Hey Chris,
the arc works perfectly and implementing it as a separate file is very
useful for us!
thanks again
Antonino
Also, I am very interested in how you actually implemented the arc itself.
Could you either explain or point me to somewhere in the documentation so
that I can understand better how you drew it?
thanks
lg
a
Hi Antonino,
The arc is implemented by combining a circle with three masks. The first is an inverted circular mask, which removes the center of the circle out to radius_inner, creating a ring. The other two are gratings configured as masks. The parameters of each grating are chosen so that half of the grating’s on-screen area is 100% visible, while the other half is 0% visible. Adjusting the direction parameter of each grating creates a 100% visible wedge that turns the ring into an arc.
To better see how the gratings work, you can remove mask = true
from both of the grating definitions and add alpha_multiplier = 0.5
to the second one. Then, when the stimulus is drawn, the 100% white region is the portion of the underlying ring that the combined grating masks let through. All other areas are masked out. This is also an easy way to see why you can’t use this technique to make an arc greater than 180 degrees.
Finally, in order for the masking to work, both the base circle and the three masks must be part of a layer. This is actually very convenient, as the layer serves as a single, top-level stimulus that can be queued and dequeued without worrying about managing its constituents individually.
I hope that makes sense. If you need more info, please let me know.
Cheers,
Chris
Hi Chris,
yes that makes a lot of sense, thanks for the detailed explanation.
I have another question for you (sorry to bother you so much).
We are planning to conduct an experiment online via a platform called
labvanced. It is a cognitive task so we need very simple stimuli which we
have generated with a plugin that Ralf wrote. Each stimulus has three
features, motion, color, shape. Usually with our monkeys we generate these
stimuli online with mworks and run the task like any other task, but in
labvanced we cannot generate such stimuli, mostly because there is no
motion engine on the platform.
So our current strategy is to have a little GIF or video clip for every
combination of these features and upload those clips on labvanced as
animated / moving stimuli.
My question for you would then be: is there a way of generating a video or
a series of images from MWorks that I can then quickly put together in
python or matlab to create a gif?
My plan would be to use mworks to generate the stimuli, show one stimulus
at a time on the screen, save each frame as an image into a specific
folder, cycle through the folders with python to generate one gif for each
stimulus.
I am not sure if it is possible in MWorks to export a frame into a picture
in an automatic way.
I hope this is clear, in case it is not I would also be available for a
skype call to explain better.
thanks in any case
best
Antonino