sylvainprigent / napari-sdeconv

Napari plugin for 2D and 3D image deconvolution
BSD 3-Clause "New" or "Revised" License
4 stars 1 forks source link

Issue with pixel type UINT16 #4

Open rohud91 opened 11 months ago

rohud91 commented 11 months ago

Hello, I would like to report an issue with your plugin in Napari. I installed everything and followed your guide on the GitHub page. When I want to run the spitfire deconvolution in Napari, I get an error (see below). I tried to avoid the pixel type uint16 but unfortunately, the .tif format is always in this pixel type. Can you please help me? Many thanks in advance for any type of help or suggestions.

Error from CMD: "" File ~\miniconda3\envs\napari-env\lib\site-packages\sdeconv\deconv\spitfire.py:335, in spitfire(image=<class 'pims.frame.Frame'> (22, 166, 662, 659) uint16, psf=<class 'numpy.ndarray'> (65, 256, 256) float32, weight=0.6, delta=1.0, reg=0.995, gradient_step=0.01, precision=1e-07, pad=13, observers=[]) 333 filter_.addobserver(observer) 334 if isinstance(image, np.ndarray): --> 335 return filter(torch.tensor(image).to(SSettings.instance().device)) filter = <sdeconv.deconv.spitfire.Spitfire object at 0x0000014DD3CE8580> image = <class 'pims.frame.Frame'> (22, 166, 662, 659) uint16 336 return filter(image)

TypeError: can't convert np.ndarray of type numpy.uint16. The only supported types are: float64, float32, float16, complex64, complex128, int64, int32, int16, int8, uint8, and bool. ""

My napari version info:

napari: 0.4.18 Platform: Windows-10-10.0.19045-SP0 Python: 3.9.18 | packaged by conda-forge | (main, Aug 30 2023, 03:40:31) [MSC v.1929 64 bit (AMD64)] Qt: 5.15.2 PyQt5: 5.15.10 NumPy: 1.26.2 SciPy: 1.11.4 Dask: 2023.11.0 VisPy: 0.12.2 magicgui: 0.8.0 superqt: 0.6.1 in-n-out: 0.1.9 app-model: 0.2.2 npe2: 0.7.3

OpenGL:

Thank you Roman

onghuiting commented 11 months ago

hi, you can convert your data to 32 bit in Fiji.

rohud91 commented 11 months ago

Oh thank you. It worked although that was the first I tried yesterday without success but today is a new day. I have a question regarding a user guide and GPU acceleration. Is it possible in Napari, python or FIJI to run Spitfire decon on GPU? Also, is there a user guide for dummies to handle the algorithm, change iterations and explain other functions of the spitfire ? Thank you for all your help and tips or directions. Roman

sylvainmprigent commented 11 months ago

Hello, yes Spitfire napari plugin is implemented using sdeconv library that is based on pytorch. So it automatically runs on GPU when pytorch finds the GPU. If it does not run on the GPU, it might be because pytorch GPU dependencies are missing.

The two main parameters of the Spitfire methods are the weight and the regularisation:

The "weight" controls the sparsity of the image. This means that if you have fiew signal (example vesicules) you need a small value like 0.1. If you have a non-sparse signal, you can put it at 0.9.

You can see the "regularisation" as the amount of noise filtering. In a perfect image without noise, the regularisation parameter should be 1 in the sdeconv code. Decreading the regularization increase the noise filtering. In general values around 0.995 is a good choice to start finding the best regularisation.