Package: pycudadecon
pyCUDAdeconThis package provides a python wrapper and convenience functions forcudaDecon, which is a CUDA/C++
implementation of an accelerated Richardson Lucy Deconvolution
algorithm1.CUDA accelerated deconvolution with a handful of artifact-reducing features.radially averaged OTF generation with interpolation for voxel size
independence between PSF and data volumes3D deskew, rotation, general affine transformationsCUDA-based camera-correction forsCMOS artifact correctionInstallThe conda package includes the required pre-compiled libraries for Windows and Linux. See GPU driver requirementsbelowcondainstall-cconda-forgepycudadeconmacOS is not supported📖DocumentationGPU requirementsThis software requires a CUDA-compatible NVIDIA GPU. The underlying cudadecon
libraries have been compiled against different versions of the CUDA toolkit.
The required CUDA libraries are bundled in the conda distributions so you don't
need to install the CUDA toolkit separately.  If desired, you can pick which
version of CUDA you'd like based on your needs, but please note that different
versions of the CUDA toolkit have different GPU driver requirements:To specify a specific cudatoolkit version, install as follows (for instance, to
usecudatoolkit=10.2)condainstall-cconda-forgepycudadeconcudatoolkit=10.2CUDALinux driverWin driver10.2≥ 440.33≥ 441.2211.0≥ 450.36.06≥ 451.2211.1≥ 455.23≥ 456.3811.2≥ 460.27.03≥ 460.82If you run into trouble, feel free toopen an
issueand describe your
setup.UsageThepycudadecon.decon()function is designed be able to handle most basic applications:frompycudadeconimportdecon# pass filenames of an image and a PSFresult=decon('/path/to/3D_image.tif','/path/to/3D_psf.tif')# decon also accepts numpy arraysresult=decon(img_array,psf_array)# the image source can also be a sequence of arrays or pathsresult=decon([img_array,'/path/to/3D_image.tif'],psf_array)# see docstrings for additional parameter optionsFor finer-tuned control, you may wish to make an OTF file from your PSF usingpycudadecon.make_otf(), and then use thepycudadecon.RLContextcontext manager to setup the GPU for use with thepycudadecon.rl_decon()function.  (Note all images processed in the same context must have the same input shape).frompycudadeconimportRLContext,rl_deconfromglobimportglobimporttifffileimage_folder='/path/to/some_images/'imlist=glob(image_folder+'*488*.tif')otf_path='/path/to/pregenerated_otf.tif'withtifffile.TiffFile(imlist[0])astf:imshape=tf.series[0].shapewithRLContext(imshape,otf_path,dz)asctx:forimpathinimlist:image=tifffile.imread(impath)result=rl_decon(image,ctx.out_shape)# do something with result...If you have a 3D PSF volume, thepycudadecon.TemporaryOTFcontext manager facilitates temporary OTF generation...# continuing with the variables from the previous example...psf_path="/path/to/psf_3D.tif"withTemporaryOTF(psf)asotf:withRLContext(imshape,otf.path,dz)asctx:forimpathinimlist:image=tifffile.imread(impath)result=rl_decon(image,ctx.out_shape)# do something with result...... and that bit of code is essentially what thepycudadecon.decon()function is doing, with a little bit of additional conveniences added in.Each of these functions has many options and accepts multiple keyword arguments. See thedocumentationfor further information on the respective functions.For examples and information on affine transforms, volume rotations, and deskewing (typical of light sheet volumes acquired with stage-scanning), see thedocumentation on Affine Transformations1D.S.C. Biggs and M. Andrews, Acceleration of iterative image restoration algorithms, Applied Optics, Vol. 36, No. 8, 1997.https://doi.org/10.1364/AO.36.001766