napari / napari-animation

A napari plugin for making animations
https://napari.github.io/napari-animation/
Other
74 stars 27 forks source link

Optional skip argument in capture_keyframe() #216

Closed aloboa closed 1 month ago

aloboa commented 1 month ago

Could you consider using an optional skip or jump argument? For me it is easier to think as “start at t=10, end at t=980, jump every 10 frames”, based on what I can currently display in the GUI.

brisvag commented 1 month ago

Hi @aloboa, could you provide a small piece of code or example situation to better explain what you want to achieve?

aloboa commented 1 month ago

In reference to https://forum.image.sc/t/select-range-of-frames/96764/3

In the GUI you would select frame t=10 and capture keyframe. Then select frame t=980 and capture keyframe. The steps is how many intermediate frames do you want.
So if you enter 60, you would go from 10 to 980 in 60 steps.

For me it would easier to define "save 1 each 15 frames" , thus skip=14 instead of step=60.

brisvag commented 1 month ago

I see, thanks for the link. as @psobolewskiPhD hinted at there, you're mixing up the concept of animation frames (= how many actual movie frames will there be between keyframe X and keyframe Y) and what you call "frames" which is just the position of the Dims slider along the 0th dimension. These are completely separate things, so there is no way to "jump" slider steps in a way that is directly tied to the amount of frames in your animation.

What you want to do is (as mentioned by @psobolewskiPhD):

If all you want is to show only specific steps along the dimension slider, you can re-slice the data with:

layer.data = layer.data[::10]

And then do an animation with as many frames as you want.