Duplicating an image in multiple locations

Hey Chris,

Is there a way to take a single image file loaded into mworks and draw it at multiple locations on screen? I have a stimulus group named Noise, containing multiple images. In a given trial I want to select a single image from that group and draw it at three separate locations simultaneously. I would think this is straightforward but for some reason, even though I change the position of the x,y position properties of the selected image and queue it three times, when I update stimulus display I only get one image displayed at one location.

Manu

Hi Manu,

Is there a way to take a single image file loaded into mworks and draw it at multiple locations on screen?

No. An image stimulus has a single position, and that’s where it’s drawn on screen. Queuing an already-queued stimulus just moves it to the front (a la Bring Stimulus to Front). If you want to display the same image at multiple locations simultaneously, you’ll need a separate image stimulus for each location.

Cheers,
Chris

Okay, so as an interim solution, I can create duplicates of the same image so that the filenames are slightly different, but the pixel values are the same. I can then draw them at different locations. However, this does strike me as redundant. While it does not matter in terms of the GPU memory, it does mean that when you do not defer the loading of the stimuli, you essentially are loading the same image file multiple times onto the server’s tmp memory. Is that correct? And how difficult would it be to change that in the future?

Hi Manu,

I can create duplicates of the same image so that the filenames are slightly different, but the pixel values are the same.

As far as MWorks is concerned, there’s no reason to create duplicates of the image files. You can use the same path with multiple image stimuli.

While it does not matter in terms of the GPU memory, it does mean that when you do not defer the loading of the stimuli, you essentially are loading the same image file multiple times onto the server’s tmp memory. Is that correct?

Not entirely. If, as you proposed, you create duplicate copies of each image file, then yes, you will be storing all those duplicates on the server. But as I said above, there’s no need for you to create duplicates.

However, regardless of whether you create duplicate image files or not, you will be using more GPU memory. Each image stimulus creates a texture from the image file data, and the texture resides in GPU memory. You can limit the total amount of GPU memory MWServer uses at a given time by setting deferred to explicit and manually loading and unloading images as needed. But the fact remains that three image stimuli will use more GPU memory than a single image, even if they’re all loading the same image file.

And how difficult would it be to change that in the future?

Allowing a stimulus to be drawn at multiple locations in a single display update would be a major change. It’s probably possible, but I’d have to think through the details before I could say for sure.

If you’re mainly concerned about the extra GPU memory usage, I could imagine adding a way for image stimuli to share the same texture. That would be a simpler solution, but it also strikes me as unnecessary, given what I said above about dynamically loading/unloading images.

Cheers,
Chris