-
Notifications
You must be signed in to change notification settings - Fork 10
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
Support other layer types #229
Conversation
for more information, see https://pre-commit.ci
…PoL/napari-clusters-plotter into suppor-other-layer-types-new
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #229 +/- ##
==========================================
+ Coverage 75.88% 76.52% +0.63%
==========================================
Files 14 16 +2
Lines 1667 1853 +186
==========================================
+ Hits 1265 1418 +153
- Misses 402 435 +33 ☔ View full report in Codecov by Sentry. |
Hi Robert @haesleinhuepf, I will hand over this PR to you now. This is our hackathon's branch with all merge conflicts fixed, and up to date with the main branch (it is not up to date only with histogram1d branch, which has an open PR now). I have also added a couple of tests for surfaces. Now support for the points layer could be added or just documentation regarding surfaces, as you see fit :) The name of this branch is suppor-other-layer-types-new (excuse the typo) |
Hi @zoccoler @thawn @Cryaaa @haesleinhuepf @stefanhahmann @marabuuu , sorry for spaming - would any of you have some time to give this not a deeper look, but at least try whether it works on your end/for your usecase? I am afraid that the clusters plotter is falling into a bit of disrepair at the moment. With more features coming in (e.g. PR #257 ) and this one having rather extensive changes, I think it would be helpful for other contributors to move their contributions forward to see this through so that others can adapt. Thanks! |
Hey @jo-mueller, |
@Cryaaa
|
@jo-mueller |
Test procedure:
Test cases:
|
Code snippets for test dataFor points import numpy as np
n_points = 100
points = np.random.rand(n_points, 2)
feature1 = np.random.normal(size=n_points)
feature2 = np.random.normal(size=n_points, loc=1)
annotations = 1 * (np.random.uniform(size=100) > 0.5)
viewer.add_points(points, properties={"feature1": feature1, "feature2": feature2}) For points timelapse: import numpy as np
import pandas as pd
n_points = 100
points = np.random.rand(n_points, 4)
time_frame = np.array([0,1]).repeat(50)
points[:, 0] = time_frame
feature1 = np.random.normal(size=n_points)
feature2 = np.random.normal(size=n_points, loc=1)
df = pd.DataFrame({'frame': time_frame, 'feature1': feature1, 'feature2': feature2})
viewer.add_points(points, features=df, size=0.1) For surfaces import numpy as np
import pandas as pd
# Create a random mesh
vertices = np.random.rand(100, 3)
faces = np.random.randint(0, 100, (100, 3))
feature1 = np.random.normal(size=100)
feature2 = np.random.normal(size=100, loc=1)
layer = viewer.add_surface((vertices, faces))
layer.features = pd.DataFrame({"feature1": feature1, "feature2": feature2}) For 4D surfaces import numpy as np
import pandas as pd
vertices = np.random.rand(100, 4)
time_frame = np.array([0, 1]).repeat(50)
vertices[:, 0] = time_frame
faces1 = np.random.randint(0, 50, (50, 3))
faces2 = np.random.randint(0, 50, (50, 3)) + 50
faces = np.concatenate([faces1, faces2])
feature1 = np.random.normal(size=100)
feature2 = np.random.normal(size=100, loc=1)
layer = viewer.add_surface((vertices, faces))
layer.features = pd.DataFrame({"feature1": feature1, "feature2": feature2, 'frame': time_frame}) |
Needed a few changes to make it work again
for more information, see https://pre-commit.ci
A few notes on some of my tests:
Otherwise everything I tested seemed to work (although I still need to test 3D images and time lapses) |
And 8d47668 does the same for 4D surface data: |
for more information, see https://pre-commit.ci
Maybe one side note: The peculiar thing here is that the features to color the mesh are stored per vertex, but the color is shown for a triangle. So it can happen that a face of the mesh is neighbor to three vertices with a different value to visualize on each, which creates the odd color gradient on the surface above. |
Hey @jo-mueller
Yep that looks good now!
Perfect!
Its not exactly that. As you select more and more clusters with the shift button, even the clusters which you did not change (basically the orange ones) change colors in the cluster image (see video for demonstration). No idea what might be going on there though and didn't have enough brain power to investigate today :D demonstraction.surface.bug.mp4 |
Ouf ok that looks really weird 😅 it's probably something in the function that creates the colormap for surfaces, will investigate. |
@jo-mueller, @zoccoler, @stefanhahmann |
Great to see this merged everyone. Fantastic work! 😍 |
Todo list: