AllenCellModeling / napari-aicsimageio

Multiple file format reading directly into napari using pure Python
GNU General Public License v3.0
33 stars 9 forks source link

Getting image scale from napari viewer #65

Closed christinab12 closed 1 year ago

christinab12 commented 1 year ago

Hi,

I'm using your plugin to load images for my own plugin. For this, I get the image and scale, once loaded directly from the viewer:

img_data = self.viewer.layers[self.image_layer_name].data
img_scale = self.viewer.layers[self.image_layer_name].scale

For czi data the scale is correctly taken as the physical distance of X, Y (visible in the side panel under images->pixels). For tif data (previously created with _aicsimageio.writers.ome_tiffwriter.OmeTiffWriter) the scale is always 1.0 even though the correct resolution is visible also for this image type in the side panel.

How can I get the correct resolution also for tiff images?

Thanks!

psobolewskiPhD commented 1 year ago

Eep, this got overlooked. @christinab12 I think your issue isn't related to this plugin, per se, but upstream to the aicsimageio library that does the actual reading. It looks like the tiff reader doesn't provide the physical_pixel_sizes attribute, so the scale isn't set. There's a PR which I think should fix this https://github.com/AllenCellModeling/aicsimageio/pull/456

christinab12 commented 1 year ago

Thanks @psobolewskiPhD, makes sense! So I will wait for newer version :)

psobolewskiPhD commented 1 year ago

That PR has been merged: https://github.com/AllenCellModeling/aicsimageio/pull/456 So you can either install aicsimageio from git or wait for a release!

christinab12 commented 1 year ago

great thank you!