haesleinhuepf / napari-process-points-and-surfaces

Process and analyze surfaces using vedo in napari.
BSD 3-Clause "New" or "Revised" License
22 stars 4 forks source link

Open3d vedo conversion #23

Closed haesleinhuepf closed 1 year ago

haesleinhuepf commented 2 years ago

closes #14 closes #22 closes #34 closes #38 closes #39 closes #45 closes #48 closes #49

haesleinhuepf commented 2 years ago

I'm stuck here because the mesh smoothing in vedo delivers weird results:

This is how it looks at the moment (example notebook):

image

Compared to the open3d-version:

image

haesleinhuepf commented 1 year ago

Tests pass locally:

(bio39) C:\structure\code\napari-process-points-and-surfaces>pytest
================================================= test session starts =================================================
platform win32 -- Python 3.9.15, pytest-7.2.0, pluggy-1.0.0
PyQt5 5.15.7 -- Qt runtime 5.15.6 -- Qt compiled 5.15.6
rootdir: C:\structure\code\napari-process-points-and-surfaces
plugins: anyio-3.6.2, dash-2.7.1, napari-0.4.17, napari-plugin-engine-0.2.0, npe2-0.6.1, qt-4.2.0
collected 5 items

napari_process_points_and_surfaces\_tests\test_function.py .....                                                 [100%]

================================================== warnings summary ===================================================
..\..\..\Users\haase\mambaforge\envs\bio39\lib\site-packages\vispy\app\backends\_qt.py:93
  C:\Users\haase\mambaforge\envs\bio39\lib\site-packages\vispy\app\backends\_qt.py:93: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
    if LooseVersion(QT_VERSION_STR) >= '5.4.0':

..\..\..\Users\haase\AppData\Roaming\Python\Python39\site-packages\setuptools\_distutils\version.py:346
  C:\Users\haase\AppData\Roaming\Python\Python39\site-packages\setuptools\_distutils\version.py:346: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
    other = LooseVersion(other)

napari_process_points_and_surfaces/_tests/test_function.py::test_something
  C:\structure\code\napari-process-points-and-surfaces\napari_process_points_and_surfaces\__init__.py:341: DeprecationWarning: nppas.convex_hull() is deprecated. Use nppas.convex_hull_from_surface() instead.
    warnings.warn("nppas.convex_hull() is deprecated. Use nppas.convex_hull_from_surface() instead.", DeprecationWarning)

napari_process_points_and_surfaces/_tests/test_function.py::test_something
napari_process_points_and_surfaces/_tests/test_function.py::test_something
napari_process_points_and_surfaces/_tests/test_function.py::test_something
napari_process_points_and_surfaces/_tests/test_function.py::test_something
napari_process_points_and_surfaces/_tests/test_function.py::test_something
napari_process_points_and_surfaces/_tests/test_function.py::test_something
napari_process_points_and_surfaces/_tests/test_function.py::test_something
napari_process_points_and_surfaces/_tests/test_function.py::test_something
napari_process_points_and_surfaces/_tests/test_function.py::test_something
  C:\structure\code\napari-process-points-and-surfaces\napari_process_points_and_surfaces\__init__.py:312: DeprecationWarning: nppas.to_mesh() is deprecated. Use nppas.to_vedo_mesh() instead.
    warnings.warn("nppas.to_mesh() is deprecated. Use nppas.to_vedo_mesh() instead.", DeprecationWarning)

napari_process_points_and_surfaces/_tests/test_function.py: 13 warnings
  C:\structure\code\napari-process-points-and-surfaces\napari_process_points_and_surfaces\__init__.py:289: DeprecationWarning: nppas.to_vector_d() is deprecated.
    warnings.warn("nppas.to_vector_d() is deprecated.", DeprecationWarning)

napari_process_points_and_surfaces/_tests/test_function.py::test_something
napari_process_points_and_surfaces/_tests/test_function.py::test_something
napari_process_points_and_surfaces/_tests/test_function.py::test_something
napari_process_points_and_surfaces/_tests/test_function.py::test_something
napari_process_points_and_surfaces/_tests/test_function.py::test_something
napari_process_points_and_surfaces/_tests/test_function.py::test_something
napari_process_points_and_surfaces/_tests/test_function.py::test_something
napari_process_points_and_surfaces/_tests/test_function.py::test_something
napari_process_points_and_surfaces/_tests/test_function.py::test_something
  C:\structure\code\napari-process-points-and-surfaces\napari_process_points_and_surfaces\__init__.py:295: DeprecationWarning: nppas.to_vector_i() is deprecated.
    warnings.warn("nppas.to_vector_i() is deprecated.", DeprecationWarning)

napari_process_points_and_surfaces/_tests/test_function.py: 10 warnings
  C:\structure\code\napari-process-points-and-surfaces\napari_process_points_and_surfaces\__init__.py:329: DeprecationWarning: nppas.to_surface() is deprecated. Use nppas.to_napari_surface_data() instead.
    warnings.warn("nppas.to_surface() is deprecated. Use nppas.to_napari_surface_data() instead.", DeprecationWarning)

napari_process_points_and_surfaces/_tests/test_function.py: 23 warnings
  C:\structure\code\napari-process-points-and-surfaces\napari_process_points_and_surfaces\__init__.py:307: DeprecationWarning: nppas.to_numpy() is deprecated. Use np.asarray() instead.
    warnings.warn("nppas.to_numpy() is deprecated. Use np.asarray() instead.", DeprecationWarning)

napari_process_points_and_surfaces/_tests/test_function.py::test_something
  C:\structure\code\napari-process-points-and-surfaces\napari_process_points_and_surfaces\__init__.py:361: DeprecationWarning: nppas.filter_smooth_simple() is deprecated. Use nppas.smooth_surface() instead.
    warnings.warn("nppas.filter_smooth_simple() is deprecated. Use nppas.smooth_surface() instead.", DeprecationWarning)

napari_process_points_and_surfaces/_tests/test_function.py::test_something
  C:\structure\code\napari-process-points-and-surfaces\napari_process_points_and_surfaces\__init__.py:402: DeprecationWarning: nppas.filter_smooth_taubin() is deprecated. Use nppas.smooth_surface() instead.
    warnings.warn("nppas.filter_smooth_taubin() is deprecated. Use nppas.smooth_surface() instead.", DeprecationWarning)

napari_process_points_and_surfaces/_tests/test_function.py::test_something
  C:\structure\code\napari-process-points-and-surfaces\napari_process_points_and_surfaces\__init__.py:381: DeprecationWarning: nppas.filter_smooth_laplacian() is deprecated. Use nppas.smooth_surface() instead.
    warnings.warn("nppas.filter_smooth_laplacian() is deprecated. Use nppas.smooth_surface() instead.", DeprecationWarning)

napari_process_points_and_surfaces/_tests/test_function.py::test_something
  C:\structure\code\napari-process-points-and-surfaces\napari_process_points_and_surfaces\__init__.py:446: DeprecationWarning: nppas.simplify_quadric_decimation() is deprecated. Open an issue if you are using this function and/or if you know a good replacement https://github.com/haesleinhuepf/napari-process-points-and-surfaces/issues.
    warnings.warn("nppas.simplify_quadric_decimation() is deprecated. Open an issue if you are using this function and/or if you know a good replacement https://github.com/haesleinhuepf/napari-process-points-and-surfaces/issues.", DeprecationWarning)

napari_process_points_and_surfaces/_tests/test_function.py::test_something
  C:\structure\code\napari-process-points-and-surfaces\napari_process_points_and_surfaces\__init__.py:422: DeprecationWarning: nppas.simplify_vertex_clustering() is deprecated. Open an issue if you are using this function and/or if you know a good replacement https://github.com/haesleinhuepf/napari-process-points-and-surfaces/issues.
    warnings.warn("nppas.simplify_vertex_clustering() is deprecated. Open an issue if you are using this function and/or if you know a good replacement https://github.com/haesleinhuepf/napari-process-points-and-surfaces/issues.", DeprecationWarning)

napari_process_points_and_surfaces/_tests/test_function.py::test_something
  C:\structure\code\napari-process-points-and-surfaces\napari_process_points_and_surfaces\__init__.py:467: DeprecationWarning: nppas.subdivide_loop() is deprecated. Use nppas.subdivide_loop_vedo() instead.
    warnings.warn("nppas.subdivide_loop() is deprecated. Use nppas.subdivide_loop_vedo() instead.", DeprecationWarning)

napari_process_points_and_surfaces/_tests/test_function.py::test_something
  C:\structure\code\napari-process-points-and-surfaces\napari_process_points_and_surfaces\__init__.py:487: DeprecationWarning: nppas.sample_points_uniformly() is deprecated. Use nppas.sample_points_from_surface() instead.
    warnings.warn("nppas.sample_points_uniformly() is deprecated. Use nppas.sample_points_from_surface() instead.", DeprecationWarning)

napari_process_points_and_surfaces/_tests/test_function.py::test_something
  C:\structure\code\napari-process-points-and-surfaces\napari_process_points_and_surfaces\__init__.py:510: DeprecationWarning: nppas.sample_points_poisson_disk() is deprecated. Use nppas.sample_points_from_surface() instead.
    warnings.warn("nppas.sample_points_poisson_disk() is deprecated. Use nppas.sample_points_from_surface() instead.",

napari_process_points_and_surfaces/_tests/test_function.py::test_something
  C:\structure\code\napari-process-points-and-surfaces\napari_process_points_and_surfaces\__init__.py:527: DeprecationWarning: nppas.voxel_down_sample() is deprecated. Use nppas.subsample_points() instead.
    warnings.warn(

napari_process_points_and_surfaces/_tests/test_function.py::test_something
napari_process_points_and_surfaces/_tests/test_function.py::test_something
napari_process_points_and_surfaces/_tests/test_function.py::test_something
napari_process_points_and_surfaces/_tests/test_function.py::test_something
  C:\structure\code\napari-process-points-and-surfaces\napari_process_points_and_surfaces\__init__.py:321: DeprecationWarning: nppas.to_point_cloud() is deprecated. Use nppas.to_napari_points_data() instead.
    warnings.warn("nppas.to_point_cloud() is deprecated. Use nppas.to_napari_points_data() instead.", DeprecationWarning)

napari_process_points_and_surfaces/_tests/test_function.py::test_something
  C:\structure\code\napari-process-points-and-surfaces\napari_process_points_and_surfaces\__init__.py:550: DeprecationWarning: nppas.points_to_convex_hull_surface() is deprecated. Use nppas.create_convex_hull_from_points() instead.
    warnings.warn("nppas.points_to_convex_hull_surface() is deprecated. Use nppas.create_convex_hull_from_points() instead.", DeprecationWarning)

napari_process_points_and_surfaces/_tests/test_function.py::test_something
  C:\structure\code\napari-process-points-and-surfaces\napari_process_points_and_surfaces\__init__.py:628: DeprecationWarning: nppas.fill_holes() is deprecated. Use nppas.fill_holes_in_surface() instead.
    warnings.warn(

napari_process_points_and_surfaces/_tests/test_function.py::test_something
  C:\structure\code\napari-process-points-and-surfaces\napari_process_points_and_surfaces\__init__.py:597: DeprecationWarning: nppas.surface_from_point_cloud_ball_pivoting() is deprecated. Use nppas.create_convex_hull_from_points() instead.
    warnings.warn("nppas.surface_from_point_cloud_ball_pivoting() is deprecated. Use nppas.create_convex_hull_from_points() instead.", DeprecationWarning)

napari_process_points_and_surfaces/_tests/test_function.py::test_something
  C:\structure\code\napari-process-points-and-surfaces\napari_process_points_and_surfaces\__init__.py:301: DeprecationWarning: nppas.to_vector_double() is deprecated.
    warnings.warn("nppas.to_vector_double() is deprecated.", DeprecationWarning)

napari_process_points_and_surfaces/_tests/test_function.py::test_something
  C:\structure\code\napari-process-points-and-surfaces\napari_process_points_and_surfaces\__init__.py:571: DeprecationWarning: nppas.surface_from_point_cloud_alpha_shape() is deprecated. Use nppas.create_convex_hull_from_points() instead.
    warnings.warn("nppas.surface_from_point_cloud_alpha_shape() is deprecated. Use nppas.create_convex_hull_from_points() instead.", DeprecationWarning)

napari_process_points_and_surfaces/_tests/test_function.py::test_curvature
  C:\Users\haase\mambaforge\envs\bio39\lib\site-packages\vedo\pointcloud.py:463: FutureWarning: `rcond` parameter will change to the default of machine precision times ``max(M, N)`` where M and N are the input matrix dimensions.
  To use the future default and silence this warning we advise to pass `rcond=None`, to keep using the old, explicitly pass `rcond=-1`.
    C, residue, rank, _ = np.linalg.lstsq(A, f)  # solve AC=f

napari_process_points_and_surfaces/_tests/test_function.py: 64 warnings
  C:\Users\haase\mambaforge\envs\bio39\lib\site-packages\vedo\colors.py:779: PendingDeprecationWarning: The get_cmap function will be deprecated in a future version. Use ``matplotlib.colormaps[name]`` or ``matplotlib.colormaps.get_cmap(obj)`` instead.
    mp = _cm_mpl.get_cmap(name=name)

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
========================================== 5 passed, 150 warnings in 17.35s ===========================================
haesleinhuepf commented 1 year ago

Hi @jo-mueller ,

can you do me a favor and try out this branch? Especially in the context of napari-stress it might be important to check if common workflows still work. All menus with open3d in the name were removed and thus, I presume we need to update documentation in napari-stress if those used open3d-nppas-menus.

Thanks!

Best, Robert

jo-mueller commented 1 year ago

can you do me a favor and try out this branch?

Can do. I'll probably do a napari-stress release next week and make sure that it's not broken by this.

haesleinhuepf commented 1 year ago

I'll probably do a napari-stress release next week

Please let me know in advance @jo-mueller . I can release nppas then as well and you could link the right version here: https://github.com/campaslab/napari-stress/blob/97f0e1c3153b5d1ec0997b69d4ec936735783512/setup.cfg#L52

jo-mueller commented 1 year ago

Hi @haesleinhuepf Looks alright to me. I found a small bug in the remove_duplicate_vertices function (it was missing the return type annotation, PR coming). Once that is merged it should be fine on the napari-stress end.

codecov-commenter commented 1 year ago

Codecov Report

Base: 53.55% // Head: 68.89% // Increases project coverage by +15.34% :tada:

Coverage data is based on head (72d9c95) compared to base (b1eee05). Patch coverage: 76.61% of modified lines in pull request are covered.

:mega: This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #23 +/- ## =========================================== + Coverage 53.55% 68.89% +15.34% =========================================== Files 3 8 +5 Lines 338 929 +591 =========================================== + Hits 181 640 +459 - Misses 157 289 +132 ``` | [Impacted Files](https://codecov.io/gh/haesleinhuepf/napari-process-points-and-surfaces/pull/23?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Robert+Haase) | Coverage Δ | | |---|---|---| | [...\_points\_and\_surfaces/\_surface\_annotation\_widget.py](https://codecov.io/gh/haesleinhuepf/napari-process-points-and-surfaces/pull/23?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Robert+Haase#diff-bmFwYXJpX3Byb2Nlc3NfcG9pbnRzX2FuZF9zdXJmYWNlcy9fc3VyZmFjZV9hbm5vdGF0aW9uX3dpZGdldC5weQ==) | `14.54% <0.00%> (-2.88%)` | :arrow_down: | | [...ari\_process\_points\_and\_surfaces/\_quantification.py](https://codecov.io/gh/haesleinhuepf/napari-process-points-and-surfaces/pull/23?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Robert+Haase#diff-bmFwYXJpX3Byb2Nlc3NfcG9pbnRzX2FuZF9zdXJmYWNlcy9fcXVhbnRpZmljYXRpb24ucHk=) | `70.00% <65.47%> (-7.35%)` | :arrow_down: | | [napari\_process\_points\_and\_surfaces/\_vedo.py](https://codecov.io/gh/haesleinhuepf/napari-process-points-and-surfaces/pull/23?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Robert+Haase#diff-bmFwYXJpX3Byb2Nlc3NfcG9pbnRzX2FuZF9zdXJmYWNlcy9fdmVkby5weQ==) | `68.75% <68.75%> (ø)` | | | [napari\_process\_points\_and\_surfaces/\_\_init\_\_.py](https://codecov.io/gh/haesleinhuepf/napari-process-points-and-surfaces/pull/23?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Robert+Haase#diff-bmFwYXJpX3Byb2Nlc3NfcG9pbnRzX2FuZF9zdXJmYWNlcy9fX2luaXRfXy5weQ==) | `82.05% <79.65%> (ø)` | | | [...rocess\_points\_and\_surfaces/\_tests/test\_function.py](https://codecov.io/gh/haesleinhuepf/napari-process-points-and-surfaces/pull/23?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Robert+Haase#diff-bmFwYXJpX3Byb2Nlc3NfcG9pbnRzX2FuZF9zdXJmYWNlcy9fdGVzdHMvdGVzdF9mdW5jdGlvbi5weQ==) | `100.00% <100.00%> (ø)` | | | [...\_process\_points\_and\_surfaces/\_tests/test\_open3d.py](https://codecov.io/gh/haesleinhuepf/napari-process-points-and-surfaces/pull/23?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Robert+Haase#diff-bmFwYXJpX3Byb2Nlc3NfcG9pbnRzX2FuZF9zdXJmYWNlcy9fdGVzdHMvdGVzdF9vcGVuM2QucHk=) | `100.00% <100.00%> (ø)` | | | [...\_points\_and\_surfaces/\_tests/test\_vedo\_functions.py](https://codecov.io/gh/haesleinhuepf/napari-process-points-and-surfaces/pull/23?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Robert+Haase#diff-bmFwYXJpX3Byb2Nlc3NfcG9pbnRzX2FuZF9zdXJmYWNlcy9fdGVzdHMvdGVzdF92ZWRvX2Z1bmN0aW9ucy5weQ==) | `100.00% <100.00%> (ø)` | | | [napari\_process\_points\_and\_surfaces/\_utils.py](https://codecov.io/gh/haesleinhuepf/napari-process-points-and-surfaces/pull/23?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Robert+Haase#diff-bmFwYXJpX3Byb2Nlc3NfcG9pbnRzX2FuZF9zdXJmYWNlcy9fdXRpbHMucHk=) | `100.00% <100.00%> (ø)` | | Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Robert+Haase). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Robert+Haase)

:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.

jo-mueller commented 1 year ago

Awesome!