napari-phasors / napari-hsi-phasor

A plugin to performe hyperspectral imaging and phasor analysis
BSD 3-Clause "New" or "Revised" License
4 stars 1 forks source link

Compatibility with napari-cluster-plotter #1

Closed schutyb closed 1 year ago

schutyb commented 1 year ago

Hi @zoccoler I was getting an error when manualy segment the cluster using napari-cluster-plotter. I created the layer to fill the plotter in the _widget.py file (as in napari-flim-phasor-plotter). Its seems that the data is numpy.float64 and I found that manual_clustering_method(self.ind_mask) from napari-cluster-plotter takes int type. If you can see it let me know if there is a way to change the layer format or if I'm missing something.

zoccoler commented 1 year ago

Hi @schutyb ,

I could not reproduce this behavior, for me this seems to work fine. Below is the Minimal Working Example (MWE) I did to try to reproduce it.

I cloned this repo and created a new environment with:

mamba create -n napari-hsi-env python=3.9
mamba activate napari-hsi-env
mamba install napari pyqt
mamba install napari-clusters-plotter

And then installed the local version of napari-hsi-phasor. This yielded an environment with these packages:

Packages versions ``` # packages in environment at C:\Users\mazo260d\mambaforge\envs\napari-hsi-dev: # # Name Version Build Channel alabaster 0.7.13 pyhd8ed1ab_0 conda-forge aom 3.6.1 h63175ca_0 conda-forge app-model 0.2.2 pyhd8ed1ab_0 conda-forge appdirs 1.4.4 pyh9f0ad1d_0 conda-forge asciitree 0.3.3 py_2 conda-forge asttokens 2.4.0 pyhd8ed1ab_0 conda-forge attrs 23.1.0 pyh71513ae_1 conda-forge autopep8 2.0.4 pyhd8ed1ab_0 conda-forge babel 2.13.1 pyhd8ed1ab_0 conda-forge backcall 0.2.0 pyh9f0ad1d_0 conda-forge backports 1.0 pyhd8ed1ab_3 conda-forge backports.functools_lru_cache 1.6.5 pyhd8ed1ab_0 conda-forge blosc 1.21.5 hdccc3a2_0 conda-forge brotli 1.1.0 hcfcfb64_1 conda-forge brotli-bin 1.1.0 hcfcfb64_1 conda-forge brotli-python 1.1.0 py39h99910a6_1 conda-forge bzip2 1.0.8 h8ffe710_4 conda-forge c-blosc2 2.10.5 h183a6f4_0 conda-forge ca-certificates 2023.7.22 h56e8100_0 conda-forge cachey 0.2.1 pyh9f0ad1d_0 conda-forge certifi 2023.7.22 pyhd8ed1ab_0 conda-forge charls 2.4.2 h1537add_0 conda-forge charset-normalizer 3.3.1 pyhd8ed1ab_0 conda-forge click 8.1.7 win_pyh7428d3b_0 conda-forge cloudpickle 3.0.0 pyhd8ed1ab_0 conda-forge colorama 0.4.6 pyhd8ed1ab_0 conda-forge comm 0.1.4 pyhd8ed1ab_0 conda-forge contourpy 1.1.1 py39h1f6ef14_1 conda-forge cycler 0.12.1 pyhd8ed1ab_0 conda-forge cython 0.29.36 py39h99910a6_1 conda-forge cytoolz 0.12.2 py39ha55989b_1 conda-forge dask-core 2023.10.0 pyhd8ed1ab_0 conda-forge dav1d 1.2.1 hcfcfb64_0 conda-forge debugpy 1.8.0 py39h99910a6_1 conda-forge decorator 5.1.1 pyhd8ed1ab_0 conda-forge deprecated 1.2.14 pyh1a96a4e_0 conda-forge docstring_parser 0.15 pyhd8ed1ab_0 conda-forge docutils 0.17.1 py39hcbf5309_4 conda-forge exceptiongroup 1.1.3 pyhd8ed1ab_0 conda-forge executing 1.2.0 pyhd8ed1ab_0 conda-forge fasteners 0.17.3 pyhd8ed1ab_0 conda-forge fonttools 4.43.1 py39ha55989b_0 conda-forge freetype 2.12.1 hdaf720e_2 conda-forge freetype-py 2.4.0 pyhd8ed1ab_0 conda-forge fsspec 2023.10.0 pyhca7485f_0 conda-forge gettext 0.21.1 h5728263_0 conda-forge giflib 5.2.1 h64bf75a_3 conda-forge glib 2.78.0 h12be248_0 conda-forge glib-tools 2.78.0 h12be248_0 conda-forge gst-plugins-base 1.22.6 h001b923_2 conda-forge gstreamer 1.22.6 hb4038d2_2 conda-forge hdbscan 0.8.33 py39hd88c2e4_4 conda-forge heapdict 1.0.1 py_0 conda-forge hsluv 5.0.4 pyhd8ed1ab_0 conda-forge icu 73.2 h63175ca_0 conda-forge idna 3.4 pyhd8ed1ab_0 conda-forge imagecodecs 2023.9.18 py39h445c58b_2 conda-forge imageio 2.31.5 pyh8c1a49c_0 conda-forge imagesize 1.4.1 pyhd8ed1ab_0 conda-forge importlib-metadata 6.8.0 pyha770c72_0 conda-forge importlib-resources 6.1.0 pyhd8ed1ab_0 conda-forge importlib_metadata 6.8.0 hd8ed1ab_0 conda-forge importlib_resources 6.1.0 pyhd8ed1ab_0 conda-forge in-n-out 0.1.9 pyhd8ed1ab_0 conda-forge intel-openmp 2023.2.0 h57928b3_50496 conda-forge ipykernel 6.26.0 pyha63f2e9_0 conda-forge ipython 8.16.1 pyh5737063_0 conda-forge ipython_genutils 0.2.0 py_1 conda-forge jedi 0.19.1 pyhd8ed1ab_0 conda-forge jinja2 3.1.2 pyhd8ed1ab_1 conda-forge joblib 1.3.2 pyhd8ed1ab_0 conda-forge jsonschema 4.19.1 pyhd8ed1ab_0 conda-forge jsonschema-specifications 2023.7.1 pyhd8ed1ab_0 conda-forge jupyter_client 8.5.0 pyhd8ed1ab_0 conda-forge jupyter_core 5.4.0 py39hcbf5309_0 conda-forge jxrlib 1.1 h8ffe710_2 conda-forge kiwisolver 1.4.5 py39h1f6ef14_1 conda-forge krb5 1.21.2 heb0366b_0 conda-forge lazy_loader 0.3 pyhd8ed1ab_0 conda-forge lcms2 2.15 h67d730c_3 conda-forge lerc 4.0.0 h63175ca_0 conda-forge libaec 1.1.2 h63175ca_1 conda-forge libavif 1.0.1 hea6d26e_2 conda-forge libblas 3.9.0 19_win64_mkl conda-forge libbrotlicommon 1.1.0 hcfcfb64_1 conda-forge libbrotlidec 1.1.0 hcfcfb64_1 conda-forge libbrotlienc 1.1.0 hcfcfb64_1 conda-forge libcblas 3.9.0 19_win64_mkl conda-forge libclang 15.0.7 default_h77d9078_3 conda-forge libclang13 15.0.7 default_h77d9078_3 conda-forge libdeflate 1.19 hcfcfb64_0 conda-forge libffi 3.4.2 h8ffe710_5 conda-forge libglib 2.78.0 he8f3873_0 conda-forge libhwloc 2.9.3 default_haede6df_1009 conda-forge libiconv 1.17 h8ffe710_0 conda-forge libjpeg-turbo 3.0.0 hcfcfb64_1 conda-forge liblapack 3.9.0 19_win64_mkl conda-forge libogg 1.3.4 h8ffe710_1 conda-forge libpng 1.6.39 h19919ed_0 conda-forge libsodium 1.0.18 h8d14728_1 conda-forge libsqlite 3.43.2 hcfcfb64_0 conda-forge libtiff 4.6.0 h6e2ebb7_2 conda-forge libvorbis 1.3.7 h0e60522_0 conda-forge libwebp-base 1.3.2 hcfcfb64_0 conda-forge libxcb 1.15 hcd874cb_0 conda-forge libxml2 2.11.5 hc3477c8_1 conda-forge libzlib 1.2.13 hcfcfb64_5 conda-forge libzopfli 1.0.3 h0e60522_0 conda-forge llvmlite 0.40.1 py39hd28a505_0 conda-forge locket 1.0.0 pyhd8ed1ab_0 conda-forge lz4-c 1.9.4 hcfcfb64_0 conda-forge m2w64-gcc-libgfortran 5.3.0 6 conda-forge m2w64-gcc-libs 5.3.0 7 conda-forge m2w64-gcc-libs-core 5.3.0 7 conda-forge m2w64-gmp 6.1.0 2 conda-forge m2w64-libwinpthread-git 5.0.0.4634.697f757 2 conda-forge magicgui 0.8.0 pyhd8ed1ab_0 conda-forge markdown-it-py 3.0.0 pyhd8ed1ab_0 conda-forge markupsafe 2.1.3 py39ha55989b_1 conda-forge matplotlib-base 3.8.0 py39hf19769e_2 conda-forge matplotlib-inline 0.1.6 pyhd8ed1ab_0 conda-forge mdurl 0.1.0 pyhd8ed1ab_0 conda-forge mkl 2023.2.0 h6a75c08_50496 conda-forge msgpack-python 1.0.6 py39h1f6ef14_0 conda-forge msys2-conda-epoch 20160418 1 conda-forge munkres 1.1.4 pyh9f0ad1d_0 conda-forge mypy_extensions 1.0.0 pyha770c72_0 conda-forge napari 0.4.18 pyh9208f05_3 conda-forge napari-clusters-plotter 0.7.3 pyhd8ed1ab_0 conda-forge napari-console 0.0.8 pyhd8ed1ab_0 conda-forge napari-hsi-phasor 0.0.5 pypi_0 pypi napari-plugin-engine 0.2.0 pyhd8ed1ab_2 conda-forge napari-skimage-regionprops 0.10.1 pyhd8ed1ab_0 conda-forge napari-svg 0.1.10 pyhd8ed1ab_0 conda-forge napari-tools-menu 0.1.19 pyhd8ed1ab_0 conda-forge napari-workflows 0.2.9 pyhd8ed1ab_0 conda-forge nest-asyncio 1.5.8 pyhd8ed1ab_0 conda-forge networkx 3.2 pyhd8ed1ab_1 conda-forge npe2 0.7.2 pyhd8ed1ab_0 conda-forge numba 0.57.1 py39hadaa1c4_0 conda-forge numcodecs 0.12.1 py39h99910a6_0 conda-forge numpy 1.23.5 py39hbccbffa_0 conda-forge numpydoc 1.5.0 pyhd8ed1ab_0 conda-forge openjpeg 2.5.0 h3d672ee_3 conda-forge openssl 3.1.4 hcfcfb64_0 conda-forge packaging 23.2 pyhd8ed1ab_0 conda-forge pandas 2.1.1 py39h32e6231_1 conda-forge parso 0.8.3 pyhd8ed1ab_0 conda-forge partd 1.4.1 pyhd8ed1ab_0 conda-forge pcre2 10.40 h17e33f8_0 conda-forge pickleshare 0.7.5 py_1003 conda-forge pillow 10.1.0 py39h368b509_0 conda-forge pint 0.22 pyhd8ed1ab_1 conda-forge pip 23.3.1 pyhd8ed1ab_0 conda-forge pkgutil-resolve-name 1.3.10 pyhd8ed1ab_1 conda-forge platformdirs 3.11.0 pyhd8ed1ab_0 conda-forge ply 3.11 py_1 conda-forge pooch 1.8.0 pyhd8ed1ab_0 conda-forge prompt-toolkit 3.0.39 pyha770c72_0 conda-forge prompt_toolkit 3.0.39 hd8ed1ab_0 conda-forge psutil 5.9.5 py39ha55989b_1 conda-forge psygnal 0.9.4 pyhd8ed1ab_0 conda-forge pthread-stubs 0.4 hcd874cb_1001 conda-forge pthreads-win32 2.9.1 hfa6e2cd_3 conda-forge pure_eval 0.2.2 pyhd8ed1ab_0 conda-forge pycodestyle 2.11.1 pyhd8ed1ab_0 conda-forge pyconify 0.1.6 pyhd8ed1ab_0 conda-forge pydantic 1.10.13 py39ha55989b_1 conda-forge pygments 2.16.1 pyhd8ed1ab_0 conda-forge pynndescent 0.5.10 pyh1a96a4e_0 conda-forge pyopengl 3.1.6 pyhd8ed1ab_1 conda-forge pyparsing 3.1.1 pyhd8ed1ab_0 conda-forge pyproject_hooks 1.0.0 pyhd8ed1ab_0 conda-forge pyqt 5.15.9 py39hb77abff_5 conda-forge pyqt5-sip 12.12.2 py39h99910a6_5 conda-forge pysocks 1.7.1 pyh0701188_6 conda-forge python 3.9.18 h4de0772_0_cpython conda-forge python-build 1.0.3 pyhd8ed1ab_0 conda-forge python-dateutil 2.8.2 pyhd8ed1ab_0 conda-forge python-tzdata 2023.3 pyhd8ed1ab_0 conda-forge python_abi 3.9 4_cp39 conda-forge pytz 2023.3.post1 pyhd8ed1ab_0 conda-forge pywavelets 1.4.1 py39hd88c2e4_1 conda-forge pywin32 306 py39h99910a6_2 conda-forge pyyaml 6.0.1 py39ha55989b_1 conda-forge pyzmq 25.1.1 py39h7eaf5a6_2 conda-forge qt-main 5.15.8 h9e85ed6_17 conda-forge qtconsole-base 5.4.4 pyha770c72_0 conda-forge qtpy 2.4.1 pyhd8ed1ab_0 conda-forge rav1e 0.6.6 h975169c_2 conda-forge referencing 0.30.2 pyhd8ed1ab_0 conda-forge requests 2.31.0 pyhd8ed1ab_0 conda-forge rich 13.6.0 pyhd8ed1ab_0 conda-forge rpds-py 0.10.6 py39hf21820d_0 conda-forge scikit-image 0.22.0 py39h32e6231_2 conda-forge scikit-learn 1.3.2 py39h7c199eb_1 conda-forge scipy 1.11.3 py39hddb5d58_1 conda-forge setuptools 68.2.2 pyhd8ed1ab_0 conda-forge shellingham 1.5.4 pyhd8ed1ab_0 conda-forge sip 6.7.12 py39h99910a6_0 conda-forge six 1.16.0 pyh6c4a22f_0 conda-forge snappy 1.1.10 hfb803bf_0 conda-forge snowballstemmer 2.2.0 pyhd8ed1ab_0 conda-forge sphinx 4.5.0 pyh6c4a22f_0 conda-forge sphinxcontrib-applehelp 1.0.4 pyhd8ed1ab_0 conda-forge sphinxcontrib-devhelp 1.0.2 py_0 conda-forge sphinxcontrib-htmlhelp 2.0.1 pyhd8ed1ab_0 conda-forge sphinxcontrib-jsmath 1.0.1 pyhd8ed1ab_0 conda-forge sphinxcontrib-qthelp 1.0.3 py_0 conda-forge sphinxcontrib-serializinghtml 1.1.5 pyhd8ed1ab_2 conda-forge stack_data 0.6.2 pyhd8ed1ab_0 conda-forge superqt 0.6.1 pyh9208f05_0 conda-forge svt-av1 1.7.0 h63175ca_0 conda-forge tbb 2021.10.0 h91493d7_2 conda-forge threadpoolctl 3.2.0 pyha21a80b_0 conda-forge tifffile 2023.9.26 pyhd8ed1ab_0 conda-forge tiffile 2018.10.18 pypi_0 pypi tk 8.6.13 hcfcfb64_0 conda-forge toml 0.10.2 pyhd8ed1ab_0 conda-forge tomli 2.0.1 pyhd8ed1ab_0 conda-forge tomli-w 1.0.0 pyhd8ed1ab_0 conda-forge toolz 0.12.0 pyhd8ed1ab_0 conda-forge tornado 6.3.3 py39ha55989b_1 conda-forge tqdm 4.66.1 pyhd8ed1ab_0 conda-forge traitlets 5.12.0 pyhd8ed1ab_0 conda-forge typer 0.9.0 pyhd8ed1ab_0 conda-forge typing-extensions 4.8.0 hd8ed1ab_0 conda-forge typing_extensions 4.8.0 pyha770c72_0 conda-forge tzdata 2023c h71feb2d_0 conda-forge ucrt 10.0.22621.0 h57928b3_0 conda-forge umap-learn 0.5.4 py39hcbf5309_0 conda-forge unicodedata2 15.1.0 py39ha55989b_0 conda-forge urllib3 2.0.7 pyhd8ed1ab_0 conda-forge vc 14.3 h64f974e_17 conda-forge vc14_runtime 14.36.32532 hdcecf7f_17 conda-forge vispy 0.12.2 py39hc266a54_0 conda-forge vs2015_runtime 14.36.32532 h05e6639_17 conda-forge wcwidth 0.2.8 pyhd8ed1ab_0 conda-forge wheel 0.41.2 pyhd8ed1ab_0 conda-forge win_inet_pton 1.1.0 pyhd8ed1ab_6 conda-forge wrapt 1.15.0 py39ha55989b_1 conda-forge xorg-libxau 1.0.11 hcd874cb_0 conda-forge xorg-libxdmcp 1.1.3 hcd874cb_0 conda-forge xz 5.2.6 h8d14728_0 conda-forge yaml 0.2.5 h8ffe710_2 conda-forge zarr 2.16.1 pyhd8ed1ab_0 conda-forge zeromq 4.3.5 h63175ca_0 conda-forge zfp 1.0.0 h63175ca_4 conda-forge zipp 3.17.0 pyhd8ed1ab_0 conda-forge zlib-ng 2.0.7 hcfcfb64_0 conda-forge zstd 1.5.5 h12be248_0 conda-forge ```

After that, from this environment, I ran this code:

import napari
from napari_hsi_phasor._widget import phasor_plot

data_path = r"D:\Datasets\Bruno Schuty\SP_paramesium_561_y_633_R2.lsm"

viewer = napari.Viewer()
viewer.open(data_path, plugin='napari')

widget = phasor_plot()
viewer.window.add_dock_widget(widget, area='right')

napari.run()

After clicking on the 'Run' button, the phasor showed up and I could manually select clusters without errors. The only detail is that I had to slide the slider to the left in order to see the label results. This is because the input data is not in the standardized shape as I did for the napari-flim-phasor-plotter. It may also be related to different napari versions, as there were some changes after 0.4.18. Here is how it looked to me:

phasor-hsi

Could you check if this example works for you? Or in which context the error shows up.

schutyb commented 1 year ago

Thanks @zoccoler for the detailed answer and the MWE, it's working perfectly now. I wan't using a mamba venv and I had some diferent dependencies, maybe that generate the error.