Napari time lapse surface rendering (surface changes across time)

Hi All:
First of all, thanks the amazing Napari visualization platform and its developers. Now it becomes an essential part of my everyday image processing pipelines.

My question is on surface layer for 3D time-lapse data. I look at the example of Surface time series from Napari website: https://github.com/napari/napari/blob/e43f730170aab1e011c42060c65ba44133f6f18f/examples/surface_timeseries.py. This is targeted for static surface with changing values across time. But my data is the opposite. The meshes (both vertices and faces) change across time but surface value stays constant.

I am not sure whether Napari supports this kind of time lapse surface rendering . Thanks a lot and sorry for the wordiness of this question.

Thanks! That’s so nice of you to share!!

napari should, but the API might not be so pleasant (in which case we can try and improve it) and performance will not be as great as the constant vertices changing values (which we could look into too). Surface takes a data 3-tuple as follows

    data : 3-tuple of array
        The first element of the tuple is an (N, D) array of vertices of
        mesh triangles. The second is an (M, 3) array of int of indices
        of the mesh triangles. The third element is the (K0, ..., KL, N)
        array of values used to color vertices where the additional L
        dimensions are used to color the same mesh with different values.

so it sounds like you have a list of meshes [vertices], [faces], and then constant values (I assume that means you always have the same number of N vertices of each time point), then you’ll want to append append the time index to each vertex array as a new dimension and then concatenate them, concatenate all the faces, and repeat all the values. It is similar to the discussion here about constant surface changing values, but swapped Slider widget to control surface values.

The performance might not be so great though because every time you move the slider we now have redraw the whole surface instead of just change colormap values, but we can try looking into that too.

If you have some example data you want to try get working, or want to describe exactly what form you have your data in (list of numpy array of what shapes/ sizes etc) then I can help you more to get this working, but I’m confident that we can get a minimal example working with the performance caveat I noted above.

I am deeply appreciated for all your help!

Unfortunately, my data has changing N vertices each time point. Here is a snap shot of number of vertices in each time point:

I modify my data shapes according to the “Slider widget to control surface values” post. Here is a review of data shapes I am working with:

Total_N = N0 + N1 + N2 + .... + Nt
Total_M = M0 + M1 + M2  + .... + Mt


Vertice_t.shape = (Total_N, 4)
Face_t.shape = (Total_M,3)
Value_t.shape = (Total_N)

Note: Vertice_t has the structure of [[0,(N0, 3),], [1,(N1, 3)], ...., [t,(Nt, 3)]]

And here is the snapshot of my numpy arrays:

The surface layer works perfect if I only slice and display one single time point:

Red is segmentation result and green is constructed surface from segmentation.

But it leads to unpredictable behaviors when I try displaying multiple time points.

Thanks for all your help!