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

dup_rev_z of wrong type in method rl_decon #9

Closed irahorecka closed 3 years ago

irahorecka commented 4 years ago

Hello @tlambert03, I am using your pycudadecon library and so far I have found success in deconvoluting a single image. However, when I attempt to process a batch of tif images using RLContext, I receive ArgumentError: argument 7: <class 'TypeError'>: wrong type.

It seems like the dup_rev_z kwarg in rl_decon is defaulted to False. On another note, it also appears that the dz kwarg in RLContext is defaulted to float 0.1. Below is the code I am executing:

from pycudadecon import RLContext, rl_decon
from glob import glob
import tifffile

IMG_PATH = f"{image_path}\\raw_tiff"
PSF_PATH = f"{image_path}\\PSF\\488nm.tif"
OTF_PATH = f"{image_path}\\PSF\\OTF488nm.tif"

imlist = glob(IMG_PATH + '\\*488*.tif')
with tifffile.TiffFile(imlist[0]) as tf:
    imshape = tf.series[0].shape
with RLContext(imshape, OTF_PATH, dz=0.1) as ctx:
    for impath in imlist:
        image = tifffile.imread(impath)
        result = rl_decon(image, ctx.out_shape)

I am also new to the field of LLS, so please let me know if I am making a mistake! Thank you.

tlambert03 commented 4 years ago

hi @irahorecka, thanks for the heads up. i will try to take a look this week.

tlambert03 commented 4 years ago

Hi @irahorecka, Sorry I think that was just my bad in the docs. Try adding specifying the output_shape argument for the rl_decon function like this:

# also don't forget that you might need to provide additional keywords to RLcontext,
# like a deskew angle (or anything that you can pass to rl_init)
with RLContext(imshape, OTF_PATH, dz=0.5) as ctx:
    for impath in imlist:
        image = tifffile.imread(impath)
        result = rl_decon(image, output_shape=ctx.out_shape)

I'll update the documentation in the meantime, let me know if that solves it for you.