Shrinking Kernel Deconvolution (DeconvSK, non-peer reviewed)

This module carries out shrinking kernel deconvolution on SOFI reconstructed images. The DeconvSK method is non-peer reviewed.

With the help of high-order SOFI analysis, the point spread function (PSF) of the optical system can be estimated. Since the acquired fluorescence image is a convolution between the system PSF and emitters’ locations, the true locations of emitters can be determined using deconvolution. In SOFI 2.0, a consecutive Richard-Lucy deconvolution with a series of different 2D Gaussian kernels (shrinking kernels) is applied on each frame of the noise filtered moment-reconstructions. This method is called the shrinking kernel deconvolution (deconvSK).

functions

pysofi.deconvsk.corelucy(image, h)

Make core for the LR estimation. Calculates f to produce the next iteration array that maximizes the likelihood that the entire suite satisfies the Poisson statistics. This is a simplified version of MATLAB corelucy function without damping, weights and externally defined functions.

Parameters
  • image (ndarray) – Input image.

  • h (ndarray) – Zero-padded OTF. h should have the same dimensions as image.

Returns

f – LR extimation core.

Return type

ndarray

References

1

Acceleration of iterative image restoration algorithms, by D.S.C. Biggs

and M. Andrews, Applied Optics, Vol. 36, No. 8, 1997. .. [2] Deconvolutions of Hubble Space Telescope Images and Spectra, R.J. Hanisch, R.L. White, and R.L. Gilliland. in “Deconvolution of Images and Spectra”, Ed. P.A. Jansson, 2nd ed., Academic Press, CA, 1997.

pysofi.deconvsk.deconvsk(est_psf, input_im, deconv_lambda, deconv_iter)

Perform serial Richardson-Lucy deconvolution with shrinking PSFs. U = (U**(l/(l-1))) * (U**(l**2/(l-1))) * … * (U**(l**n/(l-1))). The PSF of the imaging system U can be decomposed into a series a smaller (shrinking) PSF U**r where r > 1, and the image can be deconvolved by these PSFs in sequence. In this way, the result is more similar to the input image, so each individual deconvolution step is a lighter deconcolution task.

Parameters
  • est_psf (ndarray) – Estimated PSF.

  • input_im (ndarray) – Input image that need deconvolution.

  • deconv_lambda (float) – Lambda for the exponent between. It is an empirical parameter within the range of (1,2).

  • deconv_iter (int) – Number of iterations for each deconvolution.

Returns

deconv_im – Deconvoluted image.

Return type

ndarray

Notes

The quality of the deconvolution result is greatly dependent on the initial PSF size instead of the value. We recommend to calibrate PSF of the imaging system and use that as the initial PSF guess. Otherwise, generating a PSF according to the magnification of the imaging system is an option. For more details on the shrinking kernel deconvolution method, please refer to [1].

References

1

Xiyu Yi, Sungho Son, Ryoko Ando, Atsushi Miyawaki, and Shimon Weiss,

“Moments reconstruction and local dynamic range compression of high order superresolution optical fluctuation imaging,” Biomed. Opt. Express 10, 2430-2445 (2019).

pysofi.deconvsk.otf2psf(otf, shape)

Convert optical transfer function (OTF) to point-spread function (PSF). Compute the Inverse Fast Fourier Transform (ifft) of the OTF array and creates the PSF array that is not influenced by the OTF off-centering. By default, the PSF array is the same size as the OTF array. Adapted from MATLAB otf2psf function.

Parameters
  • otf (ndarray) – OTF array.

  • shape (list (int)) – Output shape of the OTF array.

Returns

psf – PSF array.

Return type

ndarray

pysofi.deconvsk.psf2otf(psf, shape)

From https: // github.com/aboucaud/pypher/blob/master/pypher/pypher.py. Convert point-spread function to optical transfer function. Compute the Fast Fourier Transform(FFT) of the point-spread function(PSF) array and creates the optical transfer function(OTF) array that is not influenced by the PSF off-centering. By default, the OTF array is the same size as the PSF array. To ensure that the OTF is not altered due to PSF off-centering, PSF2OTF post-pads the PSF array(down or to the right) with zeros to match dimensions specified in OUTSIZE, then circularly shifts the values of the PSF array up ( or to the left) until the central pixel reaches (1, 1) position. Adapted from MATLAB psf2otf function.

Parameters
  • psf (ndarray) – PSF array.

  • shape (list(int)) – Output shape of the OTF array.

Returns

otf – OTF array.

Return type

ndarray

pysofi.deconvsk.richardson_lucy(image, psf, iterations=10, **kwargs)

Richardson-Lucy deconvolution. It deconvolves image using maximum likelihood algorithm, returning both deblurred image J and a restored point-spread function PSF. This is a simplified version of MATLAB deconvblind function without damping, weights and externally defined functions.

Parameters
  • image (ndarray) – Input degraded image.

  • psf (ndarray) – The point spread function.

  • iterations (int) – Number of iterations.

Returns

  • P (ndarray) – Restored point-spread function PSF.

  • J (ndarray) – Deblurred image.

Examples

>>> import numpy as np
>>> from scipy.ndimage.gaussian_filter
>>> image = np.zeros((8,8),dtype=int)
>>> image[1::2,::2] = 1
>>> image[::2,1::2] = 1
>>> psf = np.zeros((7, 7))
>>> psf[3, 3] = 1
>>> psf = gaussian_filter(psf, sigma=[7,7])
>>> new_psf, deconv_im = richardson_lucy(image, psf, 15)

Notes

The quality of the deconvolution result is greatly dependent on the initial PSF size instead of the value. We recommend to calibrate PSF of the imaging system and use that as the initial PSF guess. Otherwise, generating a PSF according to the magnification of the imaging system is an option.

References

1

http: // en.wikipedia.org/wiki/Richardson % E2 % 80 % 93Lucy_deconvolution

2

Biggs, D. S. C.; Andrews, M. Acceleration of Iterative Image

Restoration Algorithms. Applied Optics 1997, 36 (8), 1766.

pysofi.deconvsk.zero_pad(image, shape, position='center')

From https: // github.com/aboucaud/pypher/blob/master/pypher/pypher.py. Extends image to a certain size with zeros.

Parameters
  • image (real 2d ndarray) – Input image.

  • shape (tuple of list(int)) – Desired output shape of the image.

  • position (str, optional) –

    The position of the input image in the output one:
    • ’corner’

      top-left corner(default)

    • ’center’

      centered

Returns

padded_img – The zero-padded image.

Return type

real ndarray

Example

Set the initial guess of the PSF (deconv_psf) as a normalized 2D Gaussian, and conduct deconvSK iteratively on the average image 20 times:

deconv_psf = masks.gauss2d_mask((51, 51), 2)
deconv_psf = deconv_psf / np.max(deconv_psf)
deconv_im = deconvsk.deconvsk(est_psf=deconv_psf, input_im=d.average_image(), deconv_lambda=1.5, deconv_iter=20)