Movies with napari

Hi everyone,

I recently worked on projects involving multi-dimensional images and have completely and happily adopted a Jupyter-napari combination in such cases. The only thing that is still missing is the possibility to make movies out of napari visualisations, and so I put together a small solution for myself. As I though it might be of interest to others I tried to clean-it up and package it in a useful way, and you can find the result on the naparimovie repository with some instructions on how to install and use. I also want to be very clear here that this is not an official part of napari.

The package allows you to do two things. First, if you have a napari window, you can select a series of views (key-frames) and create a movie based on those. To capture and modify the key-frames I used the really nice possibility to create key- and mouse-bindings. To see how that works, see this example:

Second, I added the possibility to use minimalistic 3Dscript-style scripts to create animations. You can find another example of how that works here:

I hope others will find this useful. Let me also know if you have suggestions. Parts of the code are probably quite “hacky” because I’m not very familiar e.g. with vispy, so let me know how to improve it!

Cheers,
Guillaume

17 Likes

@guiwitz this is incredible! I just gave it a go and it worked right out of the box, see my gif at the bottom of this post. We love to see people build on top of napari in this way and are so happy to see this sort of work.

I’m not sure if you’d seen our issue on supporting animations https://github.com/napari/napari/issues/448, but it was tagged as help-wanted and your solution seems like a great one!

We can either move the convo onto that issue or keep it here but I’m curious from you if there’s more stuff we need to expose better to make this easier for you, if you have feedback on our apis or napari in general, or if you’re interested in contributing any of this into the main napari repo. I think we see support for high quality animations as something pretty fundamental and something we want to provide to all users.

Truly very impressive and exciting stuff!

3 Likes

Thanks @sofroniewn, great to see that everything works smoothly for others too!

When I was checking whether it was possible to record movies in napari, I indeed stumbled across that github issue. As I’m not yet familiar enough with the inner workings of napari and quickly needed something usable, I just took a few days to write something minimalistic where I would not have to care about an elegant integration in napari (also I have to admit that not being a software engineer, it’s always a bit intimidating to try contributing to this type of professional projects). After deciding to release the tool, making sure everything was running smoothly made it grow to a somewhat larger scale than I had originally planned. I would be absolutely thrilled to contribute to napari by trying to integrate this in it, but this will need some more technical discussions that I’ll move to Github https://github.com/napari/napari/issues/448.

2 Likes

That’s great that you’re excited about integrating this with napari. I’ll follow-up on the GitHub issue about how we can make that happen!! Great work again.