Skip to main content

Python wrapper for CUDA-accelerated 3D deconvolution

Project description

pyCUDAdecon

This package provides a python wrapper and convenience functions for cudaDecon, 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 volumes
  • 3D deskew, rotation, general affine transformations
  • CUDA-based camera-correction for sCMOS artifact correction

Install

The conda package includes the required pre-compiled libraries for Windows and Linux. See GPU driver requirements below

conda install -c conda-forge pycudadecon

macOS is not supported

📖   Documentation

GPU requirements

This 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 use cudatoolkit=10.2)

conda install -c conda-forge pycudadecon cudatoolkit=10.2
CUDA Linux driver Win driver
10.2 ≥ 440.33 ≥ 441.22
11.0 ≥ 450.36.06 ≥ 451.22
11.1 ≥ 455.23 ≥ 456.38
11.2 ≥ 460.27.03 ≥ 460.82

If you run into trouble, feel free to open an issue and describe your setup.

Usage

The pycudadecon.decon() function is designed be able to handle most basic applications:

from pycudadecon import decon

# pass filenames of an image and a PSF
result = decon('/path/to/3D_image.tif', '/path/to/3D_psf.tif')

# decon also accepts numpy arrays
result = decon(img_array, psf_array)

# the image source can also be a sequence of arrays or paths
result = decon([img_array, '/path/to/3D_image.tif'], psf_array)

# see docstrings for additional parameter options

For finer-tuned control, you may wish to make an OTF file from your PSF using pycudadecon.make_otf(), and then use the pycudadecon.RLContext context manager to setup the GPU for use with the pycudadecon.rl_decon() function. (Note all images processed in the same context must have the same input shape).

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

image_folder = '/path/to/some_images/'
imlist = glob(image_folder + '*488*.tif')
otf_path = '/path/to/pregenerated_otf.tif'

with tifffile.TiffFile(imlist[0]) as tf:
    imshape = tf.series[0].shape

with RLContext(imshape, otf_path, dz) as ctx:
    for impath in imlist:
        image = tifffile.imread(impath)
        result = rl_decon(image, ctx.out_shape)
        # do something with result...

If you have a 3D PSF volume, the pycudadecon.TemporaryOTF context manager facilitates temporary OTF generation...

 # continuing with the variables from the previous example...
 psf_path = "/path/to/psf_3D.tif"
 with TemporaryOTF(psf) as otf:
     with RLContext(imshape, otf.path, dz) as ctx:
         for impath in imlist:
             image = tifffile.imread(impath)
             result = rl_decon(image, ctx.out_shape)
             # do something with result...

... and that bit of code is essentially what the pycudadecon.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 the documentation for 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 the documentation on Affine Transformations


1 D.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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pycudadecon-0.5.1.tar.gz (52.4 MB view details)

Uploaded Source

Built Distribution

pycudadecon-0.5.1-py3-none-any.whl (22.9 kB view details)

Uploaded Python 3

File details

Details for the file pycudadecon-0.5.1.tar.gz.

File metadata

  • Download URL: pycudadecon-0.5.1.tar.gz
  • Upload date:
  • Size: 52.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for pycudadecon-0.5.1.tar.gz
Algorithm Hash digest
SHA256 244a2d0fe3d663aca4c9ded6e51eb39dc9610b9f3a0546fafb9eb9c9595da048
MD5 5271cd1bb6aec4ce3b6628bc5547079d
BLAKE2b-256 95058c57d87c4c15dc87aa34b4eea13f11f4bfa854eef4d5035f3baff157a0a3

See more details on using hashes here.

Provenance

File details

Details for the file pycudadecon-0.5.1-py3-none-any.whl.

File metadata

  • Download URL: pycudadecon-0.5.1-py3-none-any.whl
  • Upload date:
  • Size: 22.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for pycudadecon-0.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 19269e37f6a1e0e86b76a97948fbc10a052984557b73d86709969f9e7bb59c0b
MD5 f49a47a6dbd5f0e5be4aaf6e5aa8e451
BLAKE2b-256 9dd67496e62d9d46fe8763200008e3b3c5db07820602dd7e33d1cdede70f5716

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page