Hi,

I’m working in neuroscience, on 3d calcium recordings, and I’m trying to use napari to visualize the analysis process. I want to show 2 layers, with my stack in one, and each neuron activity after segmentation in the other. This means plotting points in 3D (x,y,z), and changing their colors with time.

I’m able to use napari to show my 4D (x,y,z,t) stacks, but I haven’t found a good way to show neuron activity.

Right now I’m doing the following (I have simplified for clarity) :

```
nb_points = < the number of neurons >
nb_t_steps = < the number of time steps >
points_coords = < an array with the (x,y,z) coordinates of my neurons
shape = [nb_points,3] >
viewer = napari.Viewer()
t = np.arange(nb_t_steps)
t = np.broadcast_to(t, (nb_points, nb_t_steps))
t = t.flatten(order="F")
Points = np.broadcast_to(
points_coords, (nb_t_steps, nb_points, 3)
)
Points = np.reshape(
Points, (nb_t_steps * nb_points, 3), order="C"
)
Points = np.c_[Points * 100, t]
act = points_activity.flatten()
color = np.c_[0.5 * (1 - act), 0.5 * (1 + act), 0.5 * (1 - act)]
viewer.add_points(Points, face_color=color, opacity=0.7)
```

This does exactly what I want, but it requires way to much memory because of all the broadcasting. So for a large number of neurons like 50k or more, it’s not a good solution.

Reading the napari documentation and forums, I haven’t found a satisfactory solution.

Does anyone have an idea of how to do this cleanly ?

Thanks a lot !

EmeEmu