We will now apply pycudadecon for 3D image deconvolution.
from skimage.io import imread
from pyclesperanto_prototype import imshow
import matplotlib.pyplot as plt
import numpy as np
from pycudadecon import decon
We will load an image showing fluorescent intensity along lines. This 3D image was taken with a confocal microscope.
image = imread('C:/structure/code/pycudadecon/test/test_data/im_raw.tif').astype(float)
image.shape
(88, 320, 256)
imshow(image, colorbar=True)
The following PSF image was extracted from images taken with the same microscope using the procedure explained before.
psf = imread('C:/structure/code/pycudadecon/test/test_data/psf.tif').astype(float)
print(psf.shape)
imshow(psf, colorbar=True)
(61, 128, 128)
We can now deconvolve the image using pycudadecon's decon()
function. It accepts file names as well as images as input.
deconvolved = decon(image, psf)
imshow(deconvolved)
deconvolved.min()
0.0
deconvolved.max()
0.0
decon?
Signature: decon( images: Union[str, numpy.ndarray, Sequence[Union[str, numpy.ndarray]]], psf: Union[str, numpy.ndarray], fpattern: str = '*.tif', **kwargs, ) -> Union[numpy.ndarray, List[numpy.ndarray]] Docstring: Deconvolve an image or images with a PSF or OTF file If `images` is a directory, use the `fpattern` argument to select files by filename pattern. Parameters ---------- images : str, np.ndarray, or sequence of either The array, filepath, directory, or list/tuple thereof to deconvolve psf : str or np.ndarray a filepath of a PSF or OTF file, or a 3D numpy PSF array. Function will auto-detect whether the file is a 3D PSF or a filepath representing a 2D complex OTF. fpattern : str, optional Filepattern to use when a directory is provided in the `images` argument, by default "*.tif" **kwargs All other kwargs must be valid for either :func:`rl_init` or :func:`rl_decon`. Returns ------- np.ndarray or list of array The deconvolved image(s) Raises ------ ValueError If save_deskewed is True and deskew is unset or 0 IOError If a directory is provided as input and ``fpattern`` yields no files NotImplementedError If ``psf`` is provided as a complex, 2D numpy array (OTFs can only be provided as filenames created with :func:`pycudadecon.make_otf`) Examples -------- deconvolve a 3D TIF volume with a 3D PSF volume (e.g. a single bead stack) >>> result = decon('/path/to/image.tif', '/path/to/psf.tif') deconvolve all TIF files in a specific directory that match a certain `filename pattern <https://docs.python.org/3.6/library/fnmatch.html>`_, (in this example, all TIFs with the string '560nm' in their name) >>> result = decon( ... '/directory/with/images', '/path/to/psf.tif', fpattern='*560nm*.tif' ... ) deconvolve a list of images, provided either as np.ndarrays, filepaths, or directories >>> imarray = tifffile.imread('some_other_image.tif') >>> inputs = ['/directory/with/images', '/path/to/image.tif', imarray] >>> result = decon(inputs, '/path/to/psf.tif', fpattern='*560nm*.tif') File: c:\users\rober\miniconda3\envs\bio_39\lib\site-packages\pycudadecon\deconvolution.py Type: function