Skip to content

Commit dc1f27b

Browse files
elevanshinerm
authored andcommitted
Add Deconvolution example
1 parent 862f848 commit dc1f27b

File tree

2 files changed

+141
-0
lines changed

2 files changed

+141
-0
lines changed
Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
=============
2+
Deconvolution
3+
=============
4+
5+
In this example we will use SciJava Ops to perform Richardson-Lucy (RL) deconvolution on a 3D dataset (X, Y, Z) of
6+
a HeLa cell nucleus stained with DAPI (4′,6-diamidino-2-phenylindole) and imaged on an epifluorescent microscope at 100x.
7+
The SciJava Ops framework currently supports the standard RL algorithm as well as the Richardson-Lucy Total Variation (RLTV)
8+
algorithm, which utilizes a regularization factor to limit the noise amplified by the RL algorithm :sup:`1`.
9+
10+
You can download the 3D HeLa cell nuclus data `here`_.
11+
12+
The table below contains the necessary parameter values needed for the ``kernelDiffraction`` Op to create the synthetic
13+
point spread function (PSF) using the Gibson-Lanni model :sup:`2`.
14+
15+
+--------------------------------------+-------+
16+
| Parameter | Value |
17+
+======================================+=======+
18+
| Iterations | 15 |
19+
+--------------------------------------+-------+
20+
| Numerical aperature | 1.45 |
21+
+--------------------------------------+-------+
22+
| Emission wavelength (nm) | 457 |
23+
+--------------------------------------+-------+
24+
| Refractive index (Immersion) | 1.5 |
25+
+--------------------------------------+-------+
26+
| Refractive index (Sample) | 1.4 |
27+
+--------------------------------------+-------+
28+
| Lateral resolution (μm/pixel) | 0.065 |
29+
+--------------------------------------+-------+
30+
| Axial resolution (μm/pixel) | 0.1 |
31+
+--------------------------------------+-------+
32+
| Particle/sample position (μm/pixel) | 0.0 |
33+
+--------------------------------------+-------+
34+
| Regularization factor | 0.002 |
35+
+--------------------------------------+-------+
36+
37+
38+
.. tabs::
39+
40+
.. code-tab:: scijava-groovy
41+
42+
#@ OpEnvironment ops
43+
#@ ImgPlus img
44+
#@ Integer iterations(label="Iterations", value=30)
45+
#@ Float numericalAperture(label="Numerical Aperture", style="format:0.00", min=0.00, value=1.45)
46+
#@ Integer wavelength(label="Emission Wavelength (nm)", value=550)
47+
#@ Float riImmersion(label="Refractive Index (immersion)", style="format:0.00", min=0.00, value=1.5)
48+
#@ Float riSample(label="Refractive Index (sample)", style="format:0.00", min=0.00, value=1.4)
49+
#@ Float lateral_res(label="Lateral resolution (μm/pixel)", style="format:0.0000", min=0.0000, value=0.065)
50+
#@ Float axial_res(label="Axial resolution (μm/pixel)", style="format:0.0000", min=0.0000, value=0.1)
51+
#@ Float pZ(label="Particle/sample Position (μm)", style="format:0.0000", min=0.0000, value=0)
52+
#@ Float regularizationFactor(label="Regularization factor", style="format:0.00000", min=0.00000, value=0.002)
53+
#@output ImgPlus psf
54+
#@output ImgPlus result
55+
56+
import net.imglib2.FinalDimensions
57+
import net.imglib2.type.numeric.real.FloatType
58+
import net.imglib2.type.numeric.complex.ComplexFloatType
59+
60+
// convert input image to float
61+
img_float = ops.op("create.img").arity2().input(img, new FloatType()).apply()
62+
ops.op("convert.float32").arity1().input(img).output(img_float).compute()
63+
64+
// use image dimensions for PSF size
65+
psf_size = new FinalDimensions(img.dimensionsAsLongArray())
66+
67+
// convert the input parameters to meters (m)
68+
wavelength = wavelength.toFloat() * 1E-9
69+
lateral_res = lateral_res * 1E-6
70+
axial_res = axial_res * 1E-6
71+
pZ = pZ * 1E-6
72+
73+
// create the synthetic PSF
74+
psf = ops.op("create.kernelDiffraction").arity9().input(psf_size,
75+
numericalAperture,
76+
wavelength,
77+
riSample,
78+
riImmersion,
79+
lateral_res,
80+
axial_res,
81+
pZ,
82+
new FloatType()).apply()
83+
84+
// deconvole image
85+
result = ops.op("deconvolve.richardsonLucyTV").arity8().input(img_float, psf, new FloatType(), new ComplexFloatType(), iterations, false, false, regularizationFactor).apply()
86+
87+
88+
.. code-tab:: python
89+
90+
#@ OpEnvironment ops
91+
#@ ImgPlus img
92+
#@ Integer iterations(label="Iterations", value=30)
93+
#@ Float numericalAperture(label="Numerical Aperture", style="format:0.00", min=0.00, value=1.45)
94+
#@ Integer wavelength(label="Emission Wavelength (nm)", value=550)
95+
#@ Float riImmersion(label="Refractive Index (immersion)", style="format:0.00", min=0.00, value=1.5)
96+
#@ Float riSample(label="Refractive Index (sample)", style="format:0.00", min=0.00, value=1.4)
97+
#@ Float lateral_res(label="Lateral resolution (μm/pixel)", style="format:0.0000", min=0.0000, value=0.065)
98+
#@ Float axial_res(label="Axial resolution (μm/pixel)", style="format:0.0000", min=0.0000, value=0.1)
99+
#@ Float pZ(label="Particle/sample Position (μm)", style="format:0.0000", min=0.0000, value=0)
100+
#@ Float regularizationFactor(label="Regularization factor", style="format:0.00000", min=0.00000, value=0.002)
101+
#@output ImgPlus psf
102+
#@output ImgPlus result
103+
104+
from net.imglib2 import FinalDimensions
105+
from net.imglib2.type.numeric.real import FloatType
106+
from net.imglib2.type.numeric.complex import ComplexFloatType
107+
108+
# convert input image to float
109+
img_float = ops.op("create.img").arity2().input(img, FloatType()).apply()
110+
ops.op("convert.float32").arity1().input(img).output(img_float).compute()
111+
112+
# use image dimensions for PSF size
113+
psf_size = FinalDimensions(img.dimensionsAsLongArray())
114+
115+
# convert the input parameters to meters (m)
116+
wavelength = float(wavelength) * 1E-9
117+
lateral_res = lateral_res * 1E-6
118+
axial_res = axial_res * 1E-6
119+
pZ = pZ * 1E-6
120+
121+
# create the synthetic PSF
122+
psf = ops.op("create.kernelDiffraction").arity9().input(psf_size,
123+
numericalAperture,
124+
wavelength,
125+
riSample,
126+
riImmersion,
127+
lateral_res,
128+
axial_res,
129+
pZ,
130+
FloatType()).apply()
131+
132+
# deconvole image
133+
result = ops.op("deconvolve.richardsonLucyTV").arity8().input(img_float, psf, FloatType(), ComplexFloatType(), iterations, False, False, regularizationFactor).apply()
134+
135+
| :sup:`1`: `Dey et. al, Micros Res Tech 2006`_
136+
| :sup:`2`: `Gibson & Lanni, JOSA 1992`_
137+
138+
.. _`Dey et. al, Micros Res Tech 2006`: https://pubmed.ncbi.nlm.nih.gov/16586486/
139+
.. _`Gibson & Lanni, JOSA 1992`: https://pubmed.ncbi.nlm.nih.gov/1738047/
140+
.. _`here`: https://media.imagej.net/sample_data/3d/hela_nucleus.tif

docs/ops/doc/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ The combination of these libraries allows declarative image analysis workflows,
2929
:maxdepth: 2
3030
:caption: ⚙️ Examples
3131

32+
examples/deconvolution
3233
examples/example_gaussian_subtraction
3334
examples/opencv_denoise
3435

0 commit comments

Comments
 (0)