napari / napari-animation

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

Retain 'color by' from tracks layer #137

Closed schienstockd closed 1 year ago

schienstockd commented 1 year ago

Hello,

I am trying to record live cell imaging movies. I am using a tracks layer which has different color by values:

I choose speed, then capture the frames and then create a movie. While creating the movie, it always switches back to track_id but I would like to record speed or any of the other measurements.

Screenshot 2022-10-31 at 14 55 26
napari: 0.4.16
Platform: macOS-10.15.5-x86_64-i386-64bit
System: MacOS 10.15.5
Python: 3.9.13 | packaged by conda-forge | (main, May 27 2022, 17:00:52)  [Clang 13.0.1 ]
Qt: 5.15.4
PyQt5: 5.15.7
NumPy: 1.23.2
SciPy: 1.9.0
Dask: 2022.8.0
VisPy: 0.10.0

OpenGL:
  - GL version:  2.1 INTEL-14.6.18
  - MAX_TEXTURE_SIZE: 16384

Screens:
  - screen 1: resolution 1680x1050, scale 2.0

Plugins:
  - btrack: 0.4.5
  - console: 0.0.4
  - napari-animation: 0.0.3
  - napari-svg: 0.1.6
  - ome-types: 0.3.0
  - scikit-image: 0.4.16
alisterburt commented 1 year ago

Hi @schienstockd ! That's no good, thanks for the report.

I'm travelling at the moment, will get to this soon but as a short term fix could you try commenting out line 34 here?

https://github.com/napari/napari-animation/blob/main/napari_animation/viewer_state.py

schienstockd commented 1 year ago

Thanks! - I tried that, did not change anything.

alisterburt commented 1 year ago

Huh, interesting! Could you provide a small example of some tracks data? I think napari is just not serialising this information and it would be good to fix upstream :)

schienstockd commented 1 year ago

That is just from the napari documentation: https://napari.org/stable/howtos/layers/tracks.html

It always reverts back to time.

import napari
from skimage import data
import numpy as np

hubble_image = data.hubble_deep_field()

tracks_data = np.asarray([
    [1, 0, 236, 0],
    [1, 1, 236, 100],
    [1, 2, 236, 200],
    [1, 3, 236, 500],
    [1, 4, 236, 1000],
    [2, 0, 436, 0],
    [2, 1, 436, 100],
    [2, 2, 436, 200],
    [2, 3, 436, 500],
    [2, 4, 436, 1000],
    [3, 0, 636, 0],
    [3, 1, 636, 100],
    [3, 2, 636, 200],
    [3, 3, 636, 500],
    [3, 4, 636, 1000]
])
track_confidence = np.array(5*[0.9] + 5*[0.3] + 5 * [0.1])
properties = {
    'time': tracks_data[:, 1],
    'confidence': track_confidence
}

viewer = napari.view_image(hubble_image)
viewer.add_tracks(tracks_data, properties=properties)
napari.run()
alisterburt commented 1 year ago

sorry for the delay here - I've found the issue, basically...

I can temporarily fix in napari-animation by not tracking properties which may be sane anyway, that can be a lot of data to drag around. Will also try to fix upstream in napari

alisterburt commented 1 year ago

@schienstockd fixed in #141 Thanks for the report and providing a runnable example, made things much easier to debug!

https://user-images.githubusercontent.com/7307488/201485516-1189b167-736b-42c7-b510-45784bf12e6f.mp4

alisterburt commented 1 year ago

should be available in v0.0.5 on PyPI soon

https://github.com/napari/napari-animation/actions/runs/3451750009

schienstockd commented 1 year ago

Thanks!