Skip to content

Commit

Permalink
Dynamically rescale raw input image according to pixel sizes
Browse files Browse the repository at this point in the history
  • Loading branch information
multimeric committed Dec 19, 2023
1 parent 884b6b7 commit ef448fc
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions plugin/napari_lattice/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,23 @@ def _img_changed(self) -> None:
# Recalculate the dimension options whenever the image changes
self.dimension_order.reset_choices()

@pixel_sizes_source.connect
@pixel_sizes.connect
def _rescale_image(self):
# Whenever the pixel sizes are changed, this should be reflected in the viewer
image: Image
try:
pixels = self._get_kwargs()["physical_pixel_sizes"]
for image in self.img_layer.value:
image.scale = (
*image.scale[0:-3],
pixels.Z,
pixels.Y,
pixels.X,
)
except:
pass

@pixel_sizes_source.connect
@enable_if([pixel_sizes])
def _hide_pixel_sizes(self, pixel_sizes_source: str):
Expand Down

0 comments on commit ef448fc

Please sign in to comment.