haesleinhuepf / napari-plot-profile

BSD 3-Clause "New" or "Revised" License
17 stars 5 forks source link

User-interface unresponsive when loading images via aicsimageio #1

Open haesleinhuepf opened 3 years ago

haesleinhuepf commented 3 years ago

When napari-acisimageio is installed, TIF image are loaded in a different way. The live-update doesn't work with those images efficiently. Napari freezed then. It appears the images are then no numpy-arrays (but dask arrays?) and thus, pixel-wise access is slower.

Workaround: Convert the images to numpy arrays first, for example using Plugins > clEsperanto > Convert to numpy. You may have to install napari-pyclesperanto-assistant to get access to this menu.

Long-term solution: Make a numpy array internally and cache it. This may cause isssues with large image data.

CC @JacksonMaxfield: Do you have a better idea how to deal with this? Thanks!

haesleinhuepf commented 3 years ago

The issue might be located here: https://github.com/haesleinhuepf/napari-plot-profile/blob/7151f4c54f87f3dd57df97e586f9aa18f6685692/napari_plot_profile/_dock_widget.py#L232

evamaxfield commented 3 years ago

Can you try turning aicsimageio-out-of-memory off? napari-aicsimageio installs two versions of the plugin, one that reads to dask and one that reads to numpy. aicsimageio-in-memory should be what you want.

haesleinhuepf commented 3 years ago

Thanks @JacksonMaxfield, that helps indeed! Really good to know :-)

Note to self: Replacing

intensities = [layer.data[tuple(position)] for position in positions]

with

intensities = layer.data[tuple(np.asarray(positions).T)]

might be faster, but isn't supported by dask yet (fancy indexing not supported).