-
-
Notifications
You must be signed in to change notification settings - Fork 422
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Interactively rendering ~10 million points using datashader #6148
Comments
Hi @ahnsws, I am sorry that so far we didn't reply yet. Looks awesome, thank you! Would you be willing to join one of the community meetings some time to discuss? You can find the schedule here. Also, we have a zulip where I also post the agenda just a bit before the meeting to which people can freely add items. |
To echo what @melonora said: I'm one of the rocket emoji, but forgot to followup! |
Hi @melonora, I'd be happy to! Although the one tomorrow at 3am EST (my timezone) might be hard to join, so I will plan on joining the one next week (on 9/27). Hi @psobolewskiPhD, yes exactly, this layer is kind of in between an Image and a Points... because there are so many more points than pixels when zoomed out, datashader acts as a 2D histogram, and I believe this is actually the intended use case. But I think it would be very useful if it acted as a true Points layer when zoomed in enough to see individual points. I don't see why you couldn't use this to visualize other dynamically computed features based on the viewport dimensions and position; basically, anything that has the signature of the Here are some docs that inspired me: |
@ahnsws Awesome as I won't be able to join today either haha. I will add you to the agenda for next week. |
I am familiar with the datashader in interactive plotting libraries like bokeh. I noticed there the same thing that it can get laggy when going above 10 million pixels. I could be wrong here but I believe this is because for creating the pixel buffer rendering it still depends on the whole dataset. |
Hi @ahnsws, just as a reminder, tomorrow at 8:30 am PT. Hope to see you there! Agenda: https://hackmd.io/BXWDZ3i8Q6OAEASrkaSNIQ |
Hi @melonora, yes planning on it, thank you for the links! |
@melonora thanks for inviting me to the community meeting. Here is a gist for reproducing the polygons example, using the NYC buildings dataset (zip; download warning). Edit: the dataset has around 1 million polygons, and performance seems to depend on the datashader aggregation method. And to clarify in general, the code just asks napari for the canvas dimensions, then asks datashader to make a 2D histogram of the geometries, and then asks napari to render that histogram directly, without any transforms. |
Thanks @ahnsws for showing this off at the community meeting today and nice to meet you. I am curious where the bottleneck is in napari, so started looking into it (points layer specifically). I can't even create a points layer in reasonable time with 10M points 😅. However just playing around it seems that vispy can handle it. For example try this - first create a layer with only the first 10k points: import numpy as np
qt_viewer = viewer.window.qt_viewer
rng = np.random.default_rng(seed=0)
N = 10_000_000
points = rng.standard_normal(size=(N, 2)) * 1000
# only tell napari about the first 0.1% of points
layer = viewer.add_points(points[:int(0.001 * N)]) then in the napari console update the visual directly to show all the points: visual = qt_viewer.layer_to_visual[layer]
visual.node._subvisuals[0].set_data(points[:, ::-1]) This remains about as fast as the datashader example for me and suggests there may be a way to achieve this level of interactivity with fewer changes. I think some more tweaks (perhaps in vispy) could also improve the appearance. Anyway as mentioned above adding some type of support for the (very nice looking) datashader representations has other benefits/applications, but I found this interesting. |
I played around a bit with the image layer data protocol approach and got something kind of working. It's a little shorter than the approach above, but has some issues and also needs to access parts of the private API, so it's not really any better (maybe actually worse!). Agreed with @aganders3 that there's something suspicious about the surprisingly slow behavior in napari. I poked around a bit more and did some profiling and found the main offending line to be in the After changing that line, interacting with 10^6 points is pretty good on my machine (2020 Intel macbook pro). 10^7 kinda works, but it's a real struggle to do much. Whereas the example above works pretty well for me! |
🚀 Feature
Hello everyone, I'm not sure what work's been done on optimizing the Points layer, but I thought I'd try and give a go at using datashader to render into an image that napari can handle.
Motivation
We work with large segmented images that have millions of cells, and visualizing them somehow would be great.
Pitch
I threw together a script as a proof of concept, with the gif below:
Here's the script. I'm not really familiar with vispy or napari Layers, so please let me know if you see something that doesn't fit the intended API.
Edit: I moved the script to this gist
A few notes:
I'd love to hear your thoughts!
The text was updated successfully, but these errors were encountered: