Loading new images into mworks without restarting experiment

Alina Peter's Avatar

Alina Peter

08 Apr, 2022 01:08 PM

Hi Chris,

We’re trying to move forward with neural control projects and want to achieve something like closed-loop control. This means that we will try to generate images based on neural data and stream them into mworks as fast as possible, within the same recording session. Rob will be implementing this.

My current understanding is that even with the load setting in mworks set to explicit and we unload and load every trial, there’s some read-in of everything at the beginning?

Ideally we would set something up where say 100 images exist at the beginning (x reps), image 101-200 are generated using these. Then these are added to the experiment so that when the monkey reaches the end of the initial images, indexing continues into 101 that we have pushed onto the mworks PC into the right folder at that point. Perhaps with an additional catch that if it finds 101 not to be existing yet (compute delays or so), it gets more trials from 101-200 until 101 is found to exist…

Is this currently within the capabilities of mworks?

I think the catch isn’t the hard part, I am just not sure if we can add fresh images in any way. Could we perhaps cheat with placeholder images of the same name?

Thanks!

Alina

  1. Support Staff 1 Posted by Christopher Sta... on 11 Apr, 2022 01:54 PM

    Christopher Stawarz's Avatar

    Hi Alina & Rob,

    It is possible to generate images dynamically and load them in to MWorks on the fly.

    I'm attaching an example experiment that demonstrates this. I wrote it for a user who wanted to generate and present white noise images on demand, but the method should work for you, too. The key points are the macro update_dynamic_white_noise in experiment.mwel and the Python script create_whitenoise_images.py, which is loaded as a Python file resource by the experiment. You can ignore all the stuff involving MATLAB, which is there only because the user in question wanted to use MATLAB to create the images.

    Hopefully the example will make sense, but please let me know if you have questions.

    Cheers,
    Chris

  2. 2 Posted by Alina Peter on 11 Apr, 2022 03:23 PM

    Alina Peter's Avatar

    Hi Chris,

    This looks promising at first glance, thanks for that!

    I assume we can make a python file that then looks for new images written and outputs these to be loaded or unloaded.

  3. Support Staff 3 Posted by Christopher Sta... on 12 Apr, 2022 01:20 PM

    Christopher Stawarz's Avatar

    I assume we can make a python file that then looks for new images written and outputs these to be loaded or unloaded.

    Sure, that's one option. The Python script could also control the generation of the new images, based on the state of the experiment.

    The key takeaway from the example I sent is how to load a completely dynamic set of images. How you generate and manage the images is up to you.

    Chris

  4. Christopher Stawarz closed this discussion on 17 May, 2022 02:34 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

17 May, 2022 02:12 PM
16 May, 2022 03:12 PM
04 May, 2022 06:02 PM
03 May, 2022 01:30 PM
02 May, 2022 10:47 PM