tlambert03 / pycudadecon

Python wrapper for cudaDecon - GPU accelerated 3D deconvolution for microscopy
http://www.talleylambert.com/pycudadecon/
MIT License
59 stars 12 forks source link

Output images contain 0 pixels only #34

Open haesleinhuepf opened 2 years ago

haesleinhuepf commented 2 years ago

Hi Talley @tlambert03 ,

I'm just exploring pycudadecon and running into some issues. After applying it to some images, I retrieve output images with all pixels zero. Sometimes, I see errors like this one (I need to restart the juypter kernel then and afterwards, the same code works):

---------------------------------------------------------------------------
OSError                                   Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_1376/3905717240.py in <module>
----> 1 deconvolved = decon(image, psf)
      2 
      3 imshow(deconvolved)

~\miniconda3\envs\bio_39\lib\site-packages\pycudadecon\deconvolution.py in decon(images, psf, fpattern, **kwargs)
    375             while True:
    376                 out.append(
--> 377                     rl_decon(next_im, output_shape=ctx.out_shape, **decon_kwargs)
    378                 )
    379                 try:

~\miniconda3\envs\bio_39\lib\site-packages\pycudadecon\deconvolution.py in rl_decon(im, background, n_iters, shift, save_deskewed, output_shape, napodize, nz_blend, pad_val, dup_rev_z)
    165     if not im.flags["C_CONTIGUOUS"]:
    166         im = np.ascontiguousarray(im)
--> 167     RL_interface(
    168         im,
    169         nx,

~\miniconda3\envs\bio_39\lib\site-packages\pycudadecon\_ctyped.py in __call__(self, *args, **kw)
     71 
     72             def __call__(self, *args, **kw):
---> 73                 return self._func(*args, **kw)
     74 
     75             def __repr__(_self):

OSError: [WinError -529697949] Windows Error 0xe06d7363

I'm running on Windows 10 using an NVidia RTX 3050 Ti, using CUDA 10.2, GPU Driver version 30.0.14.9649.

You can reproduce my experiment using this notebook: https://github.com/haesleinhuepf/BioImageAnalysisNotebooks/blob/main/docs/18a_deconvolution/deconvolution_pycudadecon.ipynb

It's not urgent btw. Any hint is appreciated though!

Thanks! Robert

tlambert03 commented 2 years ago

the most common bug issue in the upstream library is PSF/OTF shape. when you get this error, can you try padding/cropping the PSF? can't remember if it applies to Z as well, but maybe try something like 64 x 128 x128?

If that solves it, then perhaps we can figure out the failure patterns and pad/trim stuff on the python side before passing to C... (or, we can try to fix at https://github.com/scopetools/cudaDecon). If you want to figure out which library the error is in, you could also try using the CLI for cudadecon

haesleinhuepf commented 2 years ago

I see, we had similar padding issues in clij-fft. Anyway, I just tried image and psf with shape 64x64x64, and the issue remains...

tlambert03 commented 2 years ago

can you try the demo data and tell me if that works? https://github.com/tlambert03/pycudadecon/tree/master/test/test_data

and if not, could you send me your data?

haesleinhuepf commented 2 years ago

I've just tested with your data and the images are still black: https://github.com/haesleinhuepf/BioImageAnalysisNotebooks/blob/main/docs/18a_deconvolution/deconvolution_pycudadecon_test.ipynb

You find my example data in the same repository:

https://github.com/haesleinhuepf/BioImageAnalysisNotebooks/blob/main/data/DeconvolutionSampleVerticalGrid1AU-crop.tif

https://github.com/haesleinhuepf/BioImageAnalysisNotebooks/blob/main/data/psf.tif

Thanks for digging into this!