Skip to content

Commit

Permalink
Merge pull request #66 from haesleinhuepf/code_quality
Browse files Browse the repository at this point in the history
Code quality
  • Loading branch information
haesleinhuepf authored Mar 4, 2023
2 parents f033e4d + 908be5b commit 7c86cce
Show file tree
Hide file tree
Showing 6 changed files with 135 additions and 205 deletions.
208 changes: 69 additions & 139 deletions docs/demo.ipynb

Large diffs are not rendered by default.

72 changes: 36 additions & 36 deletions docs/quality_measurements.ipynb

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions napari_process_points_and_surfaces/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

__version__ = "0.4.0"
__version__ = "0.4.1"
__common_alias__ = "nppas"

import warnings
Expand Down Expand Up @@ -37,10 +37,10 @@
decimate_pro,
show,
SurfaceTuple,
smooth_surface_moving_least_squares_2D,
smooth_surface_moving_least_squares_2D_radius,
smooth_pointcloud_moving_least_squares_2D_radius,
smooth_pointcloud_moving_least_squares_2D
smooth_surface_moving_least_squares_2d,
smooth_surface_moving_least_squares_2d_radius,
smooth_pointcloud_moving_least_squares_2d_radius,
smooth_pointcloud_moving_least_squares_2d
)

from ._utils import isotropic_scale_surface
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,12 @@ def test_smooth_surface():
assert len(gastruloid[0]) == len(smoothed_gastruloid[0])
assert len(gastruloid[1]) == len(smoothed_gastruloid[1])

smoothed_gastruloid2 = nppas.smooth_surface_moving_least_squares_2D(gastruloid, smoothing_factor=0.2)
smoothed_gastruloid2 = nppas.smooth_surface_moving_least_squares_2d(gastruloid, smoothing_factor=0.2)
# check if vertices/faces are still the same count
assert len(gastruloid[0]) == len(smoothed_gastruloid2[0])
assert len(gastruloid[1]) == len(smoothed_gastruloid2[1])

smoothed_gastruloid3 = nppas.smooth_surface_moving_least_squares_2D_radius(gastruloid,
smoothed_gastruloid3 = nppas.smooth_surface_moving_least_squares_2d_radius(gastruloid,
smoothing_factor=0.2,
radius=3)
# check if vertices/faces are still the same count
Expand Down Expand Up @@ -157,11 +157,11 @@ def test_smooth_pointclouds():

points = nppas.sample_points_from_surface(gastruloid)

smoothed_points = nppas.smooth_pointcloud_moving_least_squares_2D(points,
smoothed_points = nppas.smooth_pointcloud_moving_least_squares_2d(points,
smoothing_factor=0.2)
assert len(points) == len(smoothed_points)

smoothed_points = nppas.smooth_pointcloud_moving_least_squares_2D_radius(points,
smoothed_points = nppas.smooth_pointcloud_moving_least_squares_2d_radius(points,
smoothing_factor=0.2,
radius=3)
assert len(points) == len(smoothed_points)
Expand Down
40 changes: 20 additions & 20 deletions napari_process_points_and_surfaces/_vedo.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def remove_duplicate_vertices(surface: "napari.types.SurfaceData") -> "napari.ty
See Also
--------
..[0] https://vedo.embl.es/autodocs/content/vedo/pointcloud.html#vedo.pointcloud.Points.clean
..[0] https://vedo.embl.es/docs/vedo/pointcloud.html#Points.clean
"""
mesh = to_vedo_mesh(surface)
Expand All @@ -174,8 +174,8 @@ def remove_duplicate_vertices(surface: "napari.types.SurfaceData") -> "napari.ty
return to_napari_surface_data(clean_mesh)


@register_function(menu="Surfaces > Smooth moving least squares (vedo, nppas)")
def smooth_surface_moving_least_squares_2D(surface: "napari.types.SurfaceData",
@register_function(menu="Surfaces > Smooth (moving least squares, vedo, nppas)")
def smooth_surface_moving_least_squares_2d(surface: "napari.types.SurfaceData",
smoothing_factor: float = 0.2) -> "napari.types.SurfaceData":
"""Apply a moving least squares approach to smooth a surface
Expand All @@ -191,8 +191,8 @@ def smooth_surface_moving_least_squares_2D(surface: "napari.types.SurfaceData",
return to_napari_surface_data(smooth_mesh)


@register_function(menu="Surfaces > Smooth moving least squares with radius (vedo, nppas)")
def smooth_surface_moving_least_squares_2D_radius(surface: "napari.types.SurfaceData",
@register_function(menu="Surfaces > Smooth (moving least squares with radius, vedo, nppas)")
def smooth_surface_moving_least_squares_2d_radius(surface: "napari.types.SurfaceData",
smoothing_factor: float = 0.2,
radius: float = 0.2) -> "napari.types.SurfaceData":
"""Apply a moving least squares approach to smooth a surface.
Expand All @@ -211,8 +211,8 @@ def smooth_surface_moving_least_squares_2D_radius(surface: "napari.types.Surface
return to_napari_surface_data(smooth_mesh)


@register_function(menu="Points > Smooth moving least squares (vedo, nppas)")
def smooth_pointcloud_moving_least_squares_2D(pointcloud: "napari.types.PointsData",
@register_function(menu="Points > Smooth (moving least squares, vedo, nppas)")
def smooth_pointcloud_moving_least_squares_2d(pointcloud: "napari.types.PointsData",
smoothing_factor: float = 0.2) -> "napari.types.PointsData":
"""Apply a moving least squares approach to smooth a point cloud.
Expand All @@ -228,8 +228,8 @@ def smooth_pointcloud_moving_least_squares_2D(pointcloud: "napari.types.PointsDa
return to_napari_points_data(smooth_points)


@register_function(menu="Points > Smooth moving least squares radius (vedo, nppas)")
def smooth_pointcloud_moving_least_squares_2D_radius(pointcloud: "napari.types.PointsData",
@register_function(menu="Points > Smooth (moving least squares radius, vedo, nppas)")
def smooth_pointcloud_moving_least_squares_2d_radius(pointcloud: "napari.types.PointsData",
smoothing_factor: float = 0.2,
radius=2) -> "napari.types.PointsData":
"""Apply a moving least squares approach to smooth a point cloud.
Expand All @@ -248,19 +248,19 @@ def smooth_pointcloud_moving_least_squares_2D_radius(pointcloud: "napari.types.P
return to_napari_points_data(smooth_points)


@register_function(menu="Surfaces > Smooth (vedo, nppas)")
@register_function(menu="Surfaces > Smooth (Windowed Sinc, vedo, nppas)")
def smooth_surface(surface: "napari.types.SurfaceData",
number_of_iterations: int = 15,
pass_band: float = 0.1,
edge_angle: float = 15,
feature_angle: float = 60,
boundary: bool = False
) -> "napari.types.SurfaceData":
"""Smooth a surface
"""Smooth a surface using a Windowed Sinc kernel.
See Also
--------
..[0] https://vedo.embl.es/autodocs/content/vedo/mesh.html#vedo.mesh.Mesh.smooth
..[0] https://vedo.embl.es/docs/vedo/mesh.html#Mesh.smooth
"""

mesh = to_vedo_mesh(surface)
Expand Down Expand Up @@ -291,7 +291,7 @@ def _subdivide_loop_vedo(surface: "napari.types.SurfaceData",
See Also
--------
..[0] https://vedo.embl.es/autodocs/content/vedo/mesh.html#vedo.mesh.Mesh.subdivide
..[0] https://vedo.embl.es/docs/vedo/mesh.html#Mesh.subdivide
..[1] https://vtk.org/doc/nightly/html/classvtkLoopSubdivisionFilter.html
"""
mesh_in = to_vedo_mesh(surface)
Expand All @@ -317,7 +317,7 @@ def _subdivide_linear(surface: "napari.types.SurfaceData",
See Also
--------
..[0] https://vedo.embl.es/autodocs/content/vedo/mesh.html#vedo.mesh.Mesh.subdivide
..[0] https://vedo.embl.es/docs/vedo/mesh.html#Mesh.subdivide
..[1] https://vtk.org/doc/nightly/html/classvtkLinearSubdivisionFilter.html
"""
mesh_in = to_vedo_mesh(surface)
Expand Down Expand Up @@ -345,7 +345,7 @@ def subdivide_adaptive(surface: "napari.types.SurfaceData",
See Also
--------
..[0] https://vedo.embl.es/autodocs/content/vedo/mesh.html#vedo.mesh.Mesh.subdivide
..[0] https://vedo.embl.es/docs/vedo/mesh.html#Mesh.subdivide
..[1] https://vtk.org/doc/nightly/html/classvtkAdaptiveSubdivisionFilter.html
"""
mesh_in = to_vedo_mesh(surface)
Expand Down Expand Up @@ -376,7 +376,7 @@ def _subdivide_butterfly(surface: "napari.types.SurfaceData",
See Also
--------
..[0] https://vedo.embl.es/autodocs/content/vedo/mesh.html#vedo.mesh.Mesh.subdivide
..[0] https://vedo.embl.es/docs/vedo/mesh.html#Mesh.subdivide
..[1] https://vtk.org/doc/nightly/html/classvtkButterflySubdivisionFilter.html
..[2] Zorin et al. "Interpolating Subdivisions for Meshes with Arbitrary Topology," Computer Graphics Proceedings, Annual Conference Series, 1996, ACM SIGGRAPH, pp.189-192
"""
Expand All @@ -399,7 +399,7 @@ def subdivide_centroid(surface: "napari.types.SurfaceData",
See Also
--------
..[0] https://vedo.embl.es/autodocs/content/vedo/mesh.html#vedo.mesh.Mesh.subdivide
..[0] https://vedo.embl.es/docs/vedo/mesh.html#Mesh.subdivide
"""
mesh_in = to_vedo_mesh(surface)
mesh_out = mesh_in.subdivide(number_of_iterations, method=4)
Expand Down Expand Up @@ -476,7 +476,7 @@ def sample_points_from_surface(surface: "napari.types.SurfaceData", distance_fra
See Also
--------
..[0] https://vedo.embl.es/autodocs/content/vedo/pointcloud.html#vedo.pointcloud.Points.subsample
..[0] https://vedo.embl.es/docs/vedo/pointcloud.html#Points.subsample
"""

mesh_in = to_vedo_mesh(surface)
Expand All @@ -499,7 +499,7 @@ def subsample_points(points_data: "napari.types.PointsData", distance_fraction:
See Also
--------
..[0] https://vedo.embl.es/autodocs/content/vedo/pointcloud.html#vedo.pointcloud.Points.subsample
..[0] https://vedo.embl.es/docs/vedo/pointcloud.html#Points.subsample
"""

mesh_in = to_vedo_points(points_data)
Expand Down Expand Up @@ -543,7 +543,7 @@ def fill_holes_in_surface(surface: "napari.types.SurfaceData", size_limit: float
See also
--------
..[0] https://vedo.embl.es/autodocs/content/vedo/mesh.html#vedo.mesh.Mesh.fillHoles
..[0] https://vedo.embl.es/docs/vedo/mesh.html#Mesh.fillHoles
"""
mesh = to_vedo_mesh((surface[0], surface[1]))
mesh.fill_holes(size=size_limit)
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = napari-process-points-and-surfaces
version = 0.4.0
version = 0.4.1
author = Robert Haase, Johannes Soltwedel
author_email = [email protected]
url = https://github.com/haesleinhuepf/napari-process-points-and-surfaces
Expand Down

0 comments on commit 7c86cce

Please sign in to comment.