Skip to content

Commit

Permalink
Fix interpolation and spline issues (#161)
Browse files Browse the repository at this point in the history
  • Loading branch information
brisvag authored Jan 24, 2024
1 parent 34db573 commit 0649ea6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,16 @@ dependencies = [
# https://peps.python.org/pep-0621/#dependencies-optional-dependencies
[project.optional-dependencies]
all = [
"napari[all]>=0.4.19rc2",
"napari[all]>=0.4.19rc4",
"napari-properties-plotter",
"napari-properties-viewer",
"napari-label-interpolator",
"napari-label-interpolator>=0.1.1",
]
test = [
"pytest>=6.0",
"pytest-cov",
"pytest-qt",
"napari[all]>=0.4.19rc2",
"napari[all]>=0.4.19rc4",
]
dev = [
"blik[test]",
Expand Down
8 changes: 7 additions & 1 deletion src/blik/widgets/picking.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ def _generate_surface_grids_from_shapes_layer(
for line in sorted(lines, key=lambda x: x[0, 0])
]

# drop duplicate points (messes up scipy's fitpack for splines)
lines = [pd.DataFrame(line).drop_duplicates().to_numpy() for line in lines]

try:
surface_grids.append(
GriddedSplineSurface(
Expand Down Expand Up @@ -82,7 +85,10 @@ def _resample_surfaces(image_layer, surface_grids, spacing, thickness, masked):
def _generate_filaments_from_points_layer(filament_picks):
"""create a new filament representation from picked points."""
# invert xyz to go back to xyz world
return HelicalFilament(points=invert_xyz(filament_picks.data.astype(float)))
points = invert_xyz(filament_picks.data.astype(float))
# drop duplicate points (messes up scipy's fitpack for splines)
points = pd.DataFrame(points).drop_duplicates().to_numpy()
return HelicalFilament(points=points)


def _resample_filament(image_layer, filament, spacing, thickness):
Expand Down

0 comments on commit 0649ea6

Please sign in to comment.