RatInABox-Lab / RatInABox

A python package for modelling locomotion in complex environments and spatially/velocity selective cell activity.
MIT License
175 stars 31 forks source link

Slow animations #54

Closed TomGeorge1234 closed 1 year ago

TomGeorge1234 commented 1 year ago

Animations are slow. Long run the fix for this is to have plotting done in a more structured way so the whole frame doesn't need to be updated on each frame, just the changing comments then we can put blitting=True

Another good solution could be to multithread this. Split time span into segments and do each one on another thread.

mehulrastogi commented 1 year ago

I did look into this. It seems like the multi threading may not be an option as it seems like matplotlib does not allow one to pre-render and store plots.

My idea was to pre-render the plots in a list(a dict rather) using multiple threads and then use these pre-rendered plots to make the animation.

Another ad-hoc idea maybe to render parts of the video and then stitch them together. This will require saving the gifs on the disk.

Maybe someone has a better idea?

TomGeorge1234 commented 1 year ago

Thanks for looking into it!

Hmm ok, so multithreading is out. I think, long run, I want to revamp how RiaB does plotting. Like you said, we shouldn't be replotting the environment each time we make a new frame. @SynapticSage has mentioned this as well and it could be worth our/my time particular in light of the Env.render() necessity from RL environments. I'm quite busy rn but I'll have a think and leave this issue open.

TomGeorge1234 commented 1 year ago

As mentioned in #60 this is feature (hopefully) coming in 2.0