Point spread functions (optix.psf)
Estimators
Point spread functions: measured from beads, or modelled.
BeadPSF/bead_psf: empirical PSF averaged over images of isolated beads.lightsheet_psf: effective PSF of light-sheet imaging, a detection PSF times the sheet profile (gaussian_sheet).richards_wolf: vectorial PSF of an aplanatic system of high aperture (Richards & Wolf, 1959).PhaseRetrieval/phase_retrieval: pupil function retrieved from a bead z-stack, with its Zernike expansion (Hanser et al. 2004);pupil_psfandzernike_psfrender PSFs from it, andindex_mismatch_aberrationmodifies it for a refractive-index mismatch.gibson_lanni: scalar PSF model of an objective used outside its design conditions (refractive-index and thickness mismatch of the specimen, coverslip and immersion layers).
Building blocks (smoothing, peak detection, sub-voxel centres and
shifts, FWHM, Gaussian-beam optics) are in optix.psf.utils.
BeadPSF
BeadPSF(*, radius=None, sigma=None, threshold=None, min_distance=None, saturation=None, background=None, center=None, shift=None, weights=None, symmetrize=None, taper=None, max_beads=None, block=None, faithful=True, dtype=None, device=None, layout=None)
Bases: Estimator
Point spread function averaged over images of isolated beads.
Sub-resolution fluorescent beads image the PSF directly. Each isolated bead is cropped, its background is removed, it is shifted so that its centre falls on the central voxel, and the crops are averaged:
h = N(∑ₙ wₙ · Tₙ(yₙ − bₙ)),
with yₙ the crop of bead n, bₙ its background, Tₙ the sub-voxel
shift that moves its centre cₙ to index K // 2, wₙ its weight and
N the final post-processing and normalisation to unit sum.
There is no single published method for this procedure; every step
below is a standard choice, and each is an option. faithful has no
effect: both presets are the defaults listed here.
Detection. The data are smoothed with a Gaussian of standard
deviation sigma voxels. A first pass estimates the noise level of
the smoothed data from a uniform random sample of 100 000 of its
values (per group): the median μ and σ = 1.4826 · MAD. Candidates
are the voxels that are the maximum of their window of half-width
min_distance and exceed μ + threshold · σ.
Rejection. A candidate is discarded when its crop of half-size
radius does not fit inside the data, when another candidate lies
inside that crop (overlapping beads), when the crop reaches the
saturation level, when its fitted centre lies more than 2 voxels
from the detected peak, or when its background-subtracted sum is not
positive.
Background. "border": the median of the voxels on the faces of
the crop, per bead; a number: a constant.
Centre. "gaussian": least-squares fit of an axis-aligned
Gaussian plus a constant (see
fit_gaussian); "centroid":
centroid of the part of the crop above a quarter of its peak (see
threshold_centroid).
Alignment. "fourier": multiplication of the spectrum by a phase
ramp (exact for band-limited data, circular on the crop); "linear":
separable linear interpolation (smooths slightly).
Averaging. "equal": each aligned crop is normalised to unit sum
first, so all beads weigh the same; "brightness": crops are summed
as they are, so brighter beads weigh more.
Post-processing. Optional mirror symmetrisation along chosen
axes (symmetrize), an optional separable Tukey taper (taper),
clipping of negative values to zero, and normalisation to unit sum.
The full width at half maximum along each axis is reported as a
quality check.
The data are read block by block, twice (noise level, then beads), with a halo wide enough to see every crop and its neighbours; a bead belongs to the block whose core holds its peak. Group axes give one PSF each; sample axes (e.g. several bead acquisitions) are pooled.
apply is not defined: the result is
estimates["psf"], a PSFEstimate,
whose psf can be given to the deconvolution estimators.
Set the detection, alignment and averaging options.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
radius
|
int or sequence of int
|
Half-size of the crop along each spatial axis (layout
order); the PSF has shape |
None
|
sigma
|
float or sequence of float
|
Standard deviation, in voxels, of the Gaussian smoothing used for detection. Default 1. |
None
|
threshold
|
float
|
Detection threshold, in noise standard deviations of the smoothed data above its median. Default 5. |
None
|
min_distance
|
int
|
Half-width of the window in which a candidate must be the maximum. Default 2. |
None
|
saturation
|
float
|
Beads whose crop reaches this value are rejected. Default: the largest value of the data type for integer data, no test for floating-point data. |
None
|
background
|
border
|
Background estimate (default |
"border"
|
center
|
(gaussian, centroid)
|
Sub-voxel centre estimate (default |
"gaussian"
|
shift
|
(fourier, linear)
|
Sub-voxel alignment (default |
"fourier"
|
weights
|
(equal, brightness)
|
Bead weights in the average (default |
"equal"
|
symmetrize
|
sequence of int
|
Spatial axes (layout order) along which the PSF is averaged with its mirror image. Default: none. |
None
|
taper
|
float
|
Fraction of each axis inside the cosine tapers of a Tukey window applied to the result; 0 (default) for none. |
None
|
max_beads
|
int
|
Stop collecting beads (per group) once this many are kept. |
None
|
block
|
sequence of int or None
|
Core block size along the spatial axes (default: from the memory budget). Does not change the result. |
None
|
faithful
|
bool
|
No effect (the procedure has no reference publication). |
True
|
dtype
|
optional
|
See |
None
|
device
|
optional
|
See |
None
|
layout
|
optional
|
See |
None
|
PhaseRetrieval
PhaseRetrieval(*, spacing=None, wavelength=None, numerical_aperture=None, refractive_index=None, offsets=None, focus=None, iterations=None, smoothing=None, zernike_terms=None, unwrap=None, faithful=True, dtype=None, device=None, layout=None)
Bases: Estimator
Pupil function retrieved from a bead z-stack, and its Zernike fit.
The pupil function P(k_x, k_y) of a wide-field microscope is
estimated from a few defocused sections of a measured intensity PSF
by the Gerchberg–Saxton-type iteration of Hanser et al. (2004),
built on the imaging model of
pupil_psf (Eq. 2):
- Start from P = 1 inside the pupil |k| ≤ NA/λ, 0 outside.
- For each selected section j at defocus z_j, multiply P by the defocus phase function e^{2πi k_z z_j} and Fourier transform it to the amplitude PSF section g_j.
- Replace the magnitude of g_j by the square root of the measured intensity, keeping its phase.
- Transform back and refocus by e^{−2πi k_z z_j}.
- Average the refocused pupils over the sections.
- Set P = 0 outside the pupil (NA constraint), and smooth it (see the warning below).
- Repeat from 2 for a fixed number of iterations (25 in the paper).
The magnitude and the phase of the final pupil are then expanded in Zernike polynomials by linear least squares (79 terms: all radial orders up to 11, plus the radial polynomial of order 12), after the phase is unwrapped.
Sections. The paper uses about four sections offset by −3, −1,
+1 and +3 µm from the peak-intensity section; offsets selects the
sections nearest to these offsets (in the units of spacing) from
the focus section (default: the one holding the brightest voxel),
and z_j = (i_j − focus) Δz.
Corrections. The paper corrects calculated PSFs after retrieval
for the bead size, the vectorial nature of light and an empirical
OTF rescaling; these are options of
pupil_psf /
zernike_psf, with
fit_otf_rescaling for the
rescaling.
Quality. The intensity mean-square error (iMSE) and the
correlation coefficient between the measured sections and those of
the current pupil are recorded at each iteration in history
(extras["imse"], extras["correlation"], plus the amplitude error
∑(|g_j| − √I_j)² / ∑ I_j, which the iteration never increases without
smoothing); history.objective is −iMSE. The final values over the
whole stack are in meta["imse"] / meta["correlation"].
Memory. The stack is read in z-slabs, one group at a time: a pass
for the per-section maxima (only when focus is None), the selected
sections, and a pass for the whole-stack iMSE and correlation, which
are accumulated from mergeable sums. Only the selected sections and
the pupils of all groups are held in memory during the iteration.
Choices not specified in the paper
- iMSE = ∑(I_calc − I_meas)² / ∑ I_meas² over the voxels compared.
- The data are scaled so that the mean energy of the selected sections equals that of the starting pupil (its number of pixels); the retrieved magnitude is then close to 1.
- Negative intensities (after background subtraction) are set to 0 before the square root.
- The paper's optional stopping criterion is not implemented (fixed number of iterations).
- The arbitrary global phase of the result is set so that ∑P is real and positive.
- Zernike indexing and normalisation are Noll's (1976), whom the paper cites; the 79 terms are Noll indices 1 … 79.
- The phase is unwrapped by
unwrap_phase(path not specified in the paper); the fits are unweighted over the pupil pixels.
Departure from the paper: smoothing
Hanser et al. (2004) applied a smoothing filter to the pupil at
every iteration (step 6) to suppress noise, noting that less
frequent or no smoothing may suit low-noise data. The paper does
not specify the filter, so it cannot be reproduced: the default
(smoothing=None, also in faithful mode) runs without smoothing.
smoothing=σ applies a Gaussian of standard deviation σ pupil
pixels to the real and imaginary parts of the pupil at each
iteration; it is an extension (is_faithful is then False).
Sampling
The pupil grid is the Fourier grid of the lateral field of view:
the pupil radius is NA · X · Δx / λ pixels, and the most
defocused sections must fit in the field of view. Pad the data
laterally (after background subtraction) for a finer pupil.
Preprocessing (bad pixels, background, lamp flicker) is left to
the caller, e.g. BeadPSF.
References
- Hanser BM, Gustafsson MGL, Agard DA, Sedat JW. Phase-retrieved pupil functions in wide-field fluorescence microscopy. J Microsc 216(1):32–48, 2004. doi:10.1111/j.0022-2720.2004.01393.x
BibTeX
@article{hanser2004phase,
author = {Hanser, B. M. and Gustafsson, M. G. L. and
Agard, D. A. and Sedat, J. W.},
title = {Phase-retrieved pupil functions in wide-field
fluorescence microscopy},
journal = {Journal of Microscopy},
volume = {216}, number = {1}, pages = {32--48},
year = {2004}, doi = {10.1111/j.0022-2720.2004.01393.x}
}
Set the optics and the retrieval options.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
spacing
|
(float, float, float)
|
Voxel size |
None
|
wavelength
|
float
|
Vacuum wavelength λ of the detected light. Required. |
None
|
numerical_aperture
|
float
|
Numerical aperture. Required. |
None
|
refractive_index
|
float
|
Refractive index of the immersion medium. Required. |
None
|
offsets
|
sequence of float or "all"
|
Defocus of the sections used, relative to |
None
|
focus
|
int
|
Index of the in-focus section. Default (paper): the section holding the brightest voxel. |
None
|
iterations
|
int
|
Number of iterations. Paper: 25. |
None
|
smoothing
|
float
|
Standard deviation, in pupil pixels, of a Gaussian smoothing of the pupil at each iteration. Default: none. The paper smooths at each iteration with a filter it does not specify, so faithful mode leaves smoothing off (see the warning above); any value is an extension. |
None
|
zernike_terms
|
int
|
Number of Noll-ordered Zernike terms fitted. Paper: 79. |
None
|
unwrap
|
bool
|
Unwrap the phase before its Zernike fit. Paper: True. |
None
|
faithful
|
bool
|
Both presets are the paper's settings. |
True
|
dtype
|
optional
|
See |
None
|
device
|
optional
|
See |
None
|
layout
|
Layout
|
Axis roles: three spatial axes |
None
|
Transforms
Point spread functions: measured from beads, or modelled.
BeadPSF/bead_psf: empirical PSF averaged over images of isolated beads.lightsheet_psf: effective PSF of light-sheet imaging, a detection PSF times the sheet profile (gaussian_sheet).richards_wolf: vectorial PSF of an aplanatic system of high aperture (Richards & Wolf, 1959).PhaseRetrieval/phase_retrieval: pupil function retrieved from a bead z-stack, with its Zernike expansion (Hanser et al. 2004);pupil_psfandzernike_psfrender PSFs from it, andindex_mismatch_aberrationmodifies it for a refractive-index mismatch.gibson_lanni: scalar PSF model of an objective used outside its design conditions (refractive-index and thickness mismatch of the specimen, coverslip and immersion layers).
Building blocks (smoothing, peak detection, sub-voxel centres and
shifts, FWHM, Gaussian-beam optics) are in optix.psf.utils.
bead_psf
bead_psf(data, *, layout=None, **options)
Point spread function averaged over images of isolated beads.
Shortcut for BeadPSF(**options).fit(data, layout=layout); see
BeadPSF for the procedure and the options.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
array - like or Labeled
|
Bead images; without a layout, the trailing |
required |
layout
|
Layout
|
Axis roles. |
None
|
**options
|
object
|
Options of |
{}
|
Returns:
| Type | Description |
|---|---|
(*group, *K) Tensor
|
PSF centred at |
lightsheet_psf
lightsheet_psf(psf, *, detection, waist=None, wavelength=None, refractive_index=1.0, spacing=1.0, position=0.0, offset=0.0, sheet=None, rotation=None, propagation=None, axes=None, normalize=False)
Effective PSF of light-sheet imaging: detection PSF times the sheet.
h_eff(r) = h_det(r) · I(r_det − `offset`, `position`),
with I the Gaussian sheet_intensity
and r the offset from the point source, with 0 at index K // 2.
A point source at distance z from the waist along the propagation
axis is excited by I(t, z), with t its distance from the sheet's
central plane: as the sheet (or the sample) is stepped along the
detection axis, the image of the point is the detection PSF weighted
by the excitation at each step. The sheet thickness is therefore
taken at the point's own position z = position (not specified in
any reference), and the factor varies only along the detection
axis; for a field of view, evaluate the PSF at several positions.
Rotated sheet (multiview). When psf is sampled on a grid that
is rotated relative to the view (as the PSFs of
MultiviewRL, given in the
orientation of the common grid), the sheet factor varies along the
view's detection direction n = R e_det:
h_eff(r) = h_det(r) · I(n · r − `offset`, `position`).
It is evaluated on the grid of psf only, so its cost is that of
one PSF-sized tensor. For a rotated view, the distance p · r from
the waist varies across the support of the PSF, but the thickness
is still taken at position: the approximation needs the PSF to be
small compared to the Rayleigh range z_R. With a Gaussian detection
PSF of covariance Σ and a Gaussian sheet, h_eff is Gaussian with
covariance (Σ⁻¹ + (4 / W²) n nᵀ)⁻¹, W = W(position); with
offset ≠ 0 the covariance is the same, but the mean moves along n
and the amplitude changes.
Rotation conventions (not specified in any reference)
As in gaussian_sheet: R maps
sheet-frame (view) coordinates to the coordinates of the psf
grid (for MultiviewRL, the common
grid), r = R s, on physical coordinates in array-axis
order; an angle turns the (detection, propagation) plane
from the detection axis towards the propagation axis. A
registration transform in the other direction (common grid to
view) must be inverted (transposed); one written in xyz order
must have its axes reversed for a zyx array; with anisotropic
voxels the rotation must be between physical coordinates, not
voxel indices. Improper matrices (det R = −1) are accepted and
give the same sheet as the proper rotation with the unused axis
negated, since only n = R e_det is used.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
psf
|
Tensor
|
Detection PSF h_det, centred at index |
required |
detection
|
int or str
|
Axis of the detection objective (an index, or a label of
|
required |
waist
|
float | None
|
Gaussian sheet (see
|
None
|
wavelength
|
float | None
|
Gaussian sheet (see
|
None
|
refractive_index
|
float | None
|
Gaussian sheet (see
|
None
|
spacing
|
float or sequence of float
|
Voxel size, per axis (only the |
1.0
|
position
|
float
|
Distance z of the point source from the waist, along the propagation axis. |
0.0
|
offset
|
float
|
Position of the sheet's central plane along |
0.0
|
sheet
|
Tensor
|
Measured sheet profile, used instead of the Gaussian sheet.
Without |
None
|
rotation
|
float, Tensor or sequence of sequence of float
|
Orientation of the sheet frame relative to the axes of |
None
|
propagation
|
int or str
|
Propagation axis, needed only for a rotation angle. |
None
|
axes
|
str or sequence of str
|
Axis labels of |
None
|
normalize
|
bool
|
Rescale the result to unit sum. |
False
|
Returns:
| Type | Description |
|---|---|
Tensor
|
h_eff, same shape, dtype and device as |
!!! references "References"
|
BibTeX |
gaussian_sheet
gaussian_sheet(shape, *, detection, propagation, waist, wavelength, refractive_index=1.0, spacing=1.0, offset=0.0, focus=0.0, rotation=None, axes=None, dtype=None, device=None)
Gaussian light-sheet intensity sampled on a grid.
I(r) = (W₀ / W(z)) · exp(−2 t² / W(z)²),
t = r_det − `offset`, z = r_prop − `focus`,
the sheet_intensity across the
detection axis, with a thickness that varies along the
propagation axis; it is uniform along the other axes. Coordinates
r are physical (index times spacing), with 0 at index n // 2.
With a rotation R, the sheet frame is rotated relative to the
grid (e.g. a view of a multiview acquisition sampled on the common
grid): its normal is n = R e_det and its propagation direction
p = R e_prop, and
t = n · r − `offset`, z = p · r − `focus`.
R = 1 (or an angle 0) gives the sheet as without rotation; an angle of 90°
turns the sheet normal onto the propagation axis of the grid and
the propagation direction onto −e_det.
Rotation conventions (not specified in any reference)
R maps sheet-frame (view) coordinates s to grid coordinates
r = R s. It acts on physical coordinates (index times
spacing), in the array-axis order of the grid. An angle θ
turns the (detection, propagation) plane from the detection
axis towards the propagation axis. offset and focus are
measured along n and p from the grid origin (index n // 2 of
each axis).
Relation to registration transforms: a transform that maps grid coordinates to view coordinates is the inverse, so pass its transpose. A transform written in xyz order must have its rows and columns reversed to match an array in zyx order. With anisotropic voxels, use the rotation between physical coordinates, not between voxel indices.
Any orthogonal matrix is accepted, including improper ones (det R = −1, a mirror). Only the columns n = R e_det and p = R e_prop are used, and any orthonormal pair is a valid sheet frame, so a matrix with an axis flip (for example from a registration with a mirrored camera) describes the same sheet as the proper rotation with that axis negated.
Memory
Without rotation, the intensity is computed from two 1-D coordinates and broadcast. With a rotation, t, z, W(z) and the exponential are full-grid tensors, so the peak memory is about four to five times the size of the output.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
shape
|
sequence of int
|
Grid shape. |
required |
detection
|
int or str
|
Axis of the detection objective, across the sheet (an index, or
a label of |
required |
propagation
|
int or str
|
Axis along which the illumination propagates. |
required |
waist
|
float
|
See |
required |
wavelength
|
float
|
See |
required |
refractive_index
|
float
|
See |
required |
spacing
|
float or sequence of float
|
Voxel size, per axis. |
1.0
|
offset
|
float
|
Position of the sheet's central plane along |
0.0
|
focus
|
float
|
Position of the waist along |
0.0
|
rotation
|
float, Tensor or sequence of sequence of float
|
Orientation of the sheet frame on the grid: an angle θ (radians)
in the ( |
None
|
axes
|
str or sequence of str
|
Axis labels (e.g. |
None
|
dtype
|
optional
|
Default: configuration. |
None
|
device
|
optional
|
Default: configuration. |
None
|
Returns:
| Type | Description |
|---|---|
Tensor
|
Intensity of shape |
!!! references "References"
|
BibTeX |
richards_wolf
richards_wolf(shape, *, wavelength, numerical_aperture, refractive_index=1.0, spacing=1.0, polarization='x', emitter=None, pupil_phase=None, normalize=None, nodes=None, dtype=None, device=None)
Vectorial PSF of an aplanatic system of high aperture.
Model (faithful). A linearly polarised monochromatic wave focused by an aplanatic system (axially stigmatic, obeying the sine condition) of angular semi-aperture α on the image side. The time-averaged electric energy density near the focus is
⟨w_e⟩ = (A² / 16π) {|I₀|² + 4 |I₁|² cos²φ + |I₂|²
+ 2 cos 2φ · ℜ(I₀ I₂*)}
(Richards & Wolf 1959, Eq. 3.14), with φ the azimuth of the point
measured from the electric vector of the incident wave, and I₀, I₁,
I₂ the integrals of Eq. (2.32) (see
richards_wolf_integrals),
which carry the √cos θ apodisation of an aplanatic system
(Eqs. 2.12–2.13). It is ⟨E²⟩ / 8π, i.e. |e|² / 16π, with e the
field of richards_wolf_field
(Eq. 2.30). The output is ⟨w_e⟩ with A = 1 (A = π f l₀ / λ,
Eq. 2.28, depends on the focal length f and the incident amplitude
l₀). At the focus ⟨w_e⟩ = (A² / 16π) I₀(0, 0)², with
I₀(0, 0) = (16/15){1 − (5/8) cos^{3/2}α (1 + (3/5) cos α)}
(Eqs. 3.18–3.19).
The distribution is symmetric about the focal plane (Eq. 3.15) but, for α > 0, not about the axis: in the focal plane it is elongated along the polarisation direction (Figs. 3–4). As α → 0 it tends to the Airy pattern ∝ (2 J₁(v) / v)² in the focal plane (Eq. 4.12) and to the Lommel–Struve distribution near the focus (Eq. 4.8).
polarization selects the incident wave, all within the paper:
"x"(default) or"y": linear polarisation along x or y;- an angle φ₀ in radians: linear polarisation at azimuth φ₀ from the x axis, i.e. φ replaced by φ − φ₀ above (Eq. 5.1);
"unpolarized": the average of Eq. (5.1) over φ₀ (Section 5, Eq. 5.2), (A² / 16π) {|I₀|² + 2 |I₁|² + |I₂|²}, radially symmetric.
Extension: fluorescence emitters (emitter, not in the paper).
The detection PSF of a dipole emitter imaged by the same system,
obtained by reciprocity: the signal at an image point from a dipole
p at a point r of the object space, as a function of r, is
∑_j |p · e⁽ʲ⁾(r)|², where e⁽ʲ⁾ is the focal field of Eq. (2.30)
produced in the object space by a point source at the image point
(a wave of uniform amplitude on the pupil when the other side of the
system has a low aperture) and j runs over the two orthogonal
polarisations x and y, since a camera records both. Derivation:
- e⁽ˣ⁾ = −iA (I₀ + I₂ cos 2φ, I₂ sin 2φ, −2i I₁ cos φ) (Eq. 2.30), and e⁽ʸ⁾, its rotation by 90° about the axis, e⁽ʸ⁾ = −iA (I₂ sin 2φ, I₀ − I₂ cos 2φ, −2i I₁ sin φ);
emitter=(p_x, p_y, p_z)(a fixed dipole, normalised to unit length): (1/16π) {|p · e⁽ˣ⁾|² + |p · e⁽ʸ⁾|²};emitter="isotropic"(a freely rotating dipole, or an unpolarised emitter): the average over orientations p uniform on the sphere, using ⟨|p · e|²⟩ = |e|² / 3 and |e⁽ˣ⁾|² + |e⁽ʸ⁾|² = 2A² {|I₀|² + 2 |I₁|² + |I₂|²}: (1/16π) · (2/3) {|I₀|² + 2 |I₁|² + |I₂|²}, proportional to Eq. (5.2).
The √cos θ apodisation is kept: a dipole radiates an intensity per unit solid angle that the sine condition (h = f sin θ, Eq. 2.8) spreads over a pupil area f² cos θ dΩ, so the pupil amplitude is ∝ 1/√cos θ, and the pupil area element contributes cos θ, leaving √cos θ, as in Eq. (2.32). The model also assumes that:
- the emitter is in a homogeneous medium of index
refractive_index(no interface); - a fixed dipole is excited independently of its orientation (no excitation selection by a polarised illumination);
- the result is the detection PSF only: a confocal or light-sheet system multiplies it by an illumination PSF.
The prefactor 1/16π is kept from Eq. (3.14) for continuity with the focal energy density; it has no physical meaning for an emitter (the 2/3 of the isotropic case is not a collection efficiency).
Extension: pupil phase (pupil_phase, not in the paper): an
aberration phase e^{iψ(θ)} multiplied into the integrands. It is a
phase only (no s- and p-dependent amplitudes, such as Fresnel
coefficients), and ψ should be a smooth function of sin²θ; see
richards_wolf_integrals.
Evaluation. The integrals are computed by Gauss-Legendre
quadrature in s = √cos θ, for each axial position and each distinct
distance from the axis on the grid (as matrix products), with Bessel
functions accurate to ~10⁻¹⁵ (bessel_j012).
The default number of nodes, which accounts for the grid extent and
for the total variation of ψ, keeps the error near 10⁻¹² of the
peak in float64. The Bessel work arrays are chunked within the
memory budget of optix.config; I₀, I₁, I₂ are then gathered onto
every voxel, so the peak memory is about ten times the size of the
output. It runs on any torch device.
References
- Richards B, Wolf E. Electromagnetic diffraction in optical systems II. Structure of the image field in an aplanatic system. Proc R Soc Lond A 253(1274):358–379, 1959. doi:10.1098/rspa.1959.0200
BibTeX
@article{richards1959electromagnetic,
author = {Richards, B. and Wolf, E.},
title = {Electromagnetic diffraction in optical systems
{II}. {Structure} of the image field in an
aplanatic system},
journal = {Proceedings of the Royal Society of London.
Series A, Mathematical and Physical Sciences},
volume = {253},
number = {1274},
pages = {358--379},
year = {1959},
doi = {10.1098/rspa.1959.0200}
}
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
shape
|
sequence of int
|
|
required |
wavelength
|
float
|
Vacuum wavelength λ₀, in the units of |
required |
numerical_aperture
|
float
|
NA = n sin α, at most |
required |
refractive_index
|
float
|
Refractive index n of the image space (immersion medium); the wave number is k = n k₀, with k₀ = 2π / λ₀. The paper takes n = 1. |
1.0
|
spacing
|
float or sequence of float
|
Voxel size, per axis. |
1.0
|
polarization
|
(x, y, unpolarized)
|
Incident wave (see above; |
"x"
|
emitter
|
isotropic
|
Extension: return the detection PSF of a fluorescent emitter (see above) instead of the focal energy density. |
"isotropic"
|
pupil_phase
|
callable
|
Extension: aberration phase ψ(θ), in radians (real, smooth in sin²θ; see above). |
None
|
normalize
|
(None, focus, sum)
|
None (default): ⟨w_e⟩ with A = 1, the paper's quantity;
|
None
|
nodes
|
int
|
Number of quadrature nodes (default: automatic, see
|
None
|
dtype
|
optional
|
Default: configuration. |
None
|
device
|
optional
|
Default: configuration. |
None
|
Returns:
| Type | Description |
|---|---|
Tensor
|
Real tensor of shape |
phase_retrieval
phase_retrieval(data, **options)
Pupil function of a microscope from a bead z-stack.
Shortcut for PhaseRetrieval(**options).fit(data); see
PhaseRetrieval for the algorithm and
the options.
References
- Hanser BM, Gustafsson MGL, Agard DA, Sedat JW. Phase-retrieved pupil functions in wide-field fluorescence microscopy. J Microsc 216(1):32–48, 2004. doi:10.1111/j.0022-2720.2004.01393.x
BibTeX
@article{hanser2004phase,
author = {Hanser, B. M. and Gustafsson, M. G. L. and
Agard, D. A. and Sedat, J. W.},
title = {Phase-retrieved pupil functions in wide-field
fluorescence microscopy},
journal = {Journal of Microscopy},
volume = {216}, number = {1}, pages = {32--48},
year = {2004}, doi = {10.1111/j.0022-2720.2004.01393.x}
}
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
(array - like, Labeled, PSFEstimate or BeadPSF)
|
|
required |
**options
|
object
|
Options of |
{}
|
Returns:
| Type | Description |
|---|---|
PupilEstimate
|
The pupil and its Zernike coefficients. |
pupil_psf
pupil_psf(pupil, z, *, spacing, wavelength, numerical_aperture, refractive_index, vectorial=False, bead_diameter=None, otf_sigma=None, normalize=True)
Intensity PSF sections computed from a pupil function.
The amplitude PSF at defocus z is the 2D Fourier transform of the pupil P(k_x, k_y) times the defocus phase function (Hanser et al. 2004, Eq. 2):
PSF_A(x, y, z) = ∬ P(k) e^{2πi(k_x x + k_y y)} e^{2πi k_z z} dk,
k_z = √((n/λ)² − k_x² − k_y²), |k| ≤ NA/λ,
evaluated by a discrete Fourier transform (unitary), and the intensity PSF is |PSF_A|². The piston n z/λ of k_z only adds a global phase per section and is dropped.
Optional corrections, which the paper applies to PSFs calculated after phase retrieval:
vectorial: six component PSFs, the pupil times each factor ofvectorial_factors(Eq. 3), added incoherently;bead_diameter: the 3D OTF is multiplied bybead_otf(a convolution with the bead);otf_sigma: the 3D OTF is multiplied by the empirical Gaussian rescaling exp(−|k|²/(2σ²)) (seefit_otf_rescaling).
The OTF corrections are circular on the computed grid and need
uniformly spaced z.
Orientation
z increases with the section index. Flipping the axis (z → −z)
changes the pupil into its complex conjugate rotated by 180°
about index K // 2, i.e. P(k) → P*(−k). For even K the row and
column at index 0 have no partner: the rotation is
torch.roll(P.flip(-2, -1), (1, 1), (-2, -1)), not a plain flip.
References
- Hanser BM, Gustafsson MGL, Agard DA, Sedat JW. Phase-retrieved pupil functions in wide-field fluorescence microscopy. J Microsc 216(1):32–48, 2004. doi:10.1111/j.0022-2720.2004.01393.x
BibTeX
@article{hanser2004phase,
author = {Hanser, B. M. and Gustafsson, M. G. L. and
Agard, D. A. and Sedat, J. W.},
title = {Phase-retrieved pupil functions in wide-field
fluorescence microscopy},
journal = {Journal of Microscopy},
volume = {216}, number = {1}, pages = {32--48},
year = {2004}, doi = {10.1111/j.0022-2720.2004.01393.x}
}
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pupil
|
Tensor
|
|
required |
z
|
float or sequence of float or Tensor
|
Defocus of each section, in the units of |
required |
spacing
|
(float, float)
|
Lateral pixel size |
required |
wavelength
|
float
|
Vacuum wavelength λ, numerical aperture and immersion refractive index. |
required |
numerical_aperture
|
float
|
Vacuum wavelength λ, numerical aperture and immersion refractive index. |
required |
refractive_index
|
float
|
Vacuum wavelength λ, numerical aperture and immersion refractive index. |
required |
vectorial
|
bool
|
Use the vectorial model of Eq. 3. Default False (scalar). |
False
|
bead_diameter
|
float
|
Convolve with a bead of this diameter. |
None
|
otf_sigma
|
float
|
Width σ of the Gaussian OTF rescaling (cycles per unit length). |
None
|
normalize
|
bool
|
Divide the result by its sum (unit-sum PSF). Default True. |
True
|
Returns:
| Type | Description |
|---|---|
Tensor
|
|
zernike_psf
zernike_psf(magnitude, phase, *, shape, spacing, wavelength, numerical_aperture, refractive_index, vectorial=False, bead_diameter=None, otf_sigma=None, normalize=True)
Intensity PSF on any grid from Zernike coefficients of a pupil.
The pupil of zernike_pupil is
built on the pupil grid of the lateral image grid and propagated by
pupil_psf to the planes
z = (i − Z // 2) Δz, so that the PSF is centred at index K // 2
along every axis. Typical input: the coefficients of a
PupilEstimate.
References
- Hanser BM, Gustafsson MGL, Agard DA, Sedat JW. Phase-retrieved pupil functions in wide-field fluorescence microscopy. J Microsc 216(1):32–48, 2004. doi:10.1111/j.0022-2720.2004.01393.x
BibTeX
@article{hanser2004phase,
author = {Hanser, B. M. and Gustafsson, M. G. L. and
Agard, D. A. and Sedat, J. W.},
title = {Phase-retrieved pupil functions in wide-field
fluorescence microscopy},
journal = {Journal of Microscopy},
volume = {216}, number = {1}, pages = {32--48},
year = {2004}, doi = {10.1111/j.0022-2720.2004.01393.x}
}
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
magnitude
|
Tensor or sequence of float
|
Noll-ordered Zernike coefficients of the pupil magnitude and
phase (see |
required |
phase
|
Tensor or sequence of float
|
Noll-ordered Zernike coefficients of the pupil magnitude and
phase (see |
required |
shape
|
(int, int, int)
|
Output shape |
required |
spacing
|
(float, float, float)
|
Voxel size |
required |
wavelength
|
float
|
Vacuum wavelength, numerical aperture and immersion refractive index. |
required |
numerical_aperture
|
float
|
Vacuum wavelength, numerical aperture and immersion refractive index. |
required |
refractive_index
|
float
|
Vacuum wavelength, numerical aperture and immersion refractive index. |
required |
vectorial
|
bool
|
See |
False
|
bead_diameter
|
bool
|
See |
False
|
otf_sigma
|
bool
|
See |
False
|
normalize
|
bool
|
See |
False
|
Returns:
| Type | Description |
|---|---|
Tensor
|
|
index_mismatch_aberration
index_mismatch_aberration(shape, spacing, *, depth, wavelength, numerical_aperture, immersion_index, specimen_index, dtype=None, device=None)
Pupil aberration function of a refractive-index mismatch.
A point source at depth d in a medium of index n₂, imaged by an objective designed for an immersion medium of index n₁ (Hanser et al. 2004, Eqs. 4–8):
OP = d (n₂ cos θ₂ − n₁ cos θ₁),
A_t = [sin θ₁ cos θ₂ / sin(θ₁ + θ₂)] [1 + 1/cos(θ₂ − θ₁)],
A_w = n₁ tan θ₂ / (n₂ tan θ₁),
sin θ₁ = (λ/n₁) |k|, n₁ sin θ₁ = n₂ sin θ₂,
ψ = A_t A_w e^{2πi OP/λ}.
A_t is the mean of the s and p Fresnel transmittances, A_w the wavefront compression. Multiplying an unaberrated pupil by ψ gives the pupil of the microscope under the mismatched conditions (Eq. 9). They are evaluated in the equivalent forms A_t = cos θ₂ [1 + 1/cos(θ₂ − θ₁)] / (cos θ₂ + (n₁/n₂) cos θ₁) and A_w = (n₁/n₂)² cos θ₁ / cos θ₂, which are finite on axis.
Note
Rays beyond the critical angle (n₁ sin θ₁ > n₂) do not reach the pupil and get ψ = 0; this case is not specified in the paper. Eq. 9 of the paper also carries a constant factor 1/λ, which only scales the PSF and is omitted here.
References
- Hanser BM, Gustafsson MGL, Agard DA, Sedat JW. Phase-retrieved pupil functions in wide-field fluorescence microscopy. J Microsc 216(1):32–48, 2004. doi:10.1111/j.0022-2720.2004.01393.x
BibTeX
@article{hanser2004phase,
author = {Hanser, B. M. and Gustafsson, M. G. L. and
Agard, D. A. and Sedat, J. W.},
title = {Phase-retrieved pupil functions in wide-field
fluorescence microscopy},
journal = {Journal of Microscopy},
volume = {216}, number = {1}, pages = {32--48},
year = {2004}, doi = {10.1111/j.0022-2720.2004.01393.x}
}
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
shape
|
((int, int), (float, float))
|
Lateral image grid (see
|
required |
spacing
|
((int, int), (float, float))
|
Lateral image grid (see
|
required |
depth
|
float
|
Depth d of the source below the cover glass, in the units of
|
required |
wavelength
|
float
|
Vacuum wavelength and numerical aperture. |
required |
numerical_aperture
|
float
|
Vacuum wavelength and numerical aperture. |
required |
immersion_index
|
float
|
Refractive index n₁ of the immersion medium the objective is designed for. |
required |
specimen_index
|
float
|
Refractive index n₂ of the specimen (mounting medium). |
required |
dtype
|
optional
|
|
None
|
device
|
optional
|
|
None
|
Returns:
| Type | Description |
|---|---|
Tensor
|
|
gibson_lanni
gibson_lanni(shape, *, spacing, wavelength, numerical_aperture, depth=0.0, specimen_index=1.33, coverslip_index=None, coverslip_thickness=None, immersion_index=None, design_coverslip_index=1.522, design_coverslip_thickness=170.0, design_immersion_index=1.515, design_immersion_thickness=150.0, defocus=0.0, method='quadrature', nodes=None, rtol=1e-06, basis=100, samples=1000, oversample=1, return_estimate=False, dtype=None, device=None)
Gibson–Lanni scalar PSF of a widefield microscope, on a voxel grid.
The PSF of an objective used outside its design conditions: the source lies at a depth t_s in a specimen of index n_s, below a coverslip and an immersion layer whose indices and thicknesses may differ from the design ones (Gibson & Lanni 1991, Fig. 1). The intensity at lateral distance r from the source and defocus Δz is the Kirchhoff integral (Eq. 5),
I(r, Δz) ∝ | ∫₀^a J₀(k₀ NA r ρ) exp(i k₀ OPD(ρ; Δz)) ρ dρ |²,
with k₀ = 2π/λ₀ the wave number in vacuum and OPD the optical path
difference between the actual and the design rays (Eq. 4, see
gibson_lanni_opd):
OPD(ρ; Δz) = n_oil Δz C_oil(ρ)
+ ∑ₗ ± nₗ tₗ [Cₗ(ρ) − (n_oil/nₗ)² C_oil(ρ)],
C_n(ρ) = [1 − (NA ρ / n)²]^½,
summed over the specimen (t_s, n_s), the actual coverslip (+) and the design coverslip and immersion layer (−). Δz is the defocus of Eq. (3), measured in object space as the stage movement from the paraxial focus of the source (Δz = 0, where the ρ² term of the OPD vanishes). Δz > 0 is a thicker immersion layer (objective moved away from the coverslip): the focal plane then lies between the source and the objective.
The detector is at its design distance (z_d = z_d), so the tube-length terms of Eq. (4) vanish. (As printed, the separate detector term of Eq. (4) has n_oil in its denominator, which would leave a ρ² term at Δz = 0, against the text of the paper; the term that cancels it is a²ρ²(z_d − z_d)/(2 z_d* z_d). With z_d = z_d* both vanish, so the PSF computed here does not depend on this.) The lateral coordinate is in object space: Gibson & Lanni's J₀(k₀ a ρ r_d / z_d) on the detector equals J₀(k₀ NA ρ r) with r = r_d / M up to a factor [1 − (NA/M)²]^−½, taken as 1 (as in Li et al.). Since a/z_d is tan θ′ in image space and the sine condition gives sin θ′ = NA/M, the factor 1 is the exact sine-condition form, not a further approximation. The constant amplitude C / z_d is dropped: the PSF is normalised to unit sum.
Aperture. The upper limit is a = 1, or a = n_min / NA when the
numerical aperture exceeds n_min, the smallest refractive index of
the layers of non-zero thickness: the actual immersion layer, and
the specimen, the actual and design coverslips and the design
immersion layer when their thickness is > 0. Beyond ρ = n_min/NA the
ray is evanescent in that layer and the model's square roots stop
being real; Gibson & Lanni do not specify the truncation (their
design system has no specimen layer, and its PSF integrates over the
whole aperture). Li et al. truncate at the smallest index of all
layers, the specimen included at any depth; here a layer of zero
thickness, which has no term in the OPD, does not truncate, so that
with depth=0 an NA 1.4 oil objective has its full aperture,
whatever specimen_index. For t_s > 0 the super-critical rays are
dropped (they would be attenuated as
exp(−k₀ t_s √((NA ρ)² − n_s²))), the large-depth limit; the
aperture therefore jumps from 1 to n_s/NA as the depth leaves 0. The
value of a is meta["aperture"] of the returned estimate.
Evaluation. With method="quadrature" (default) the 1-D pupil
integral is computed for each (r, Δz) by Gauss–Legendre quadrature
(as in Gibson & Lanni) over the ray angle θ in the layer of lowest
index, ρ = (n_min/NA) sin θ, which keeps the integrand smooth up to
the edge of the aperture. Without nodes, the number of nodes is
doubled from 32 until the amplitude, evaluated with n and 2n nodes on
a probe set, changes by at most rtol relative to its peak. The
probe set is 17 radii evenly spaced from 0 to the largest radius of
the grid, and the defocus values of the grid, or 257 of them evenly
spaced in index (both ends included) when there are more.
Oscillations at large r (Bessel function) or large defocus or depth
(phase) need more nodes. The phase is computed in float64 and each
square root as √(n² − s²) − n = −s² / (√(n² − s²) + n), so large
constant optical paths never cancel. The integral is one matrix
product per chunk of radii, [cos(k₀ OPD), sin(k₀ OPD)] · J₀ᵀ, on the
working device.
With method="li2017" the phase factor is expanded on M rescaled
Bessel functions (Li et al. Eq. 4),
exp(i k₀ OPD(ρ)) ≈ ∑ₘ cₘ J₀(σₘ ρ), σₘ = NA (3m − 2) λ_ref/λ₀ with
the reference wavelength λ_ref = 0.436 µm of Li et al. (their λ₀),
fitted by least squares on K samples ρ_k uniform in [0, a], so that
the integral is the closed form
∫₀^a ρ J₀(σρ) J₀(βρ) dρ
= a [σ J₁(σa) J₀(βa) − β J₀(σa) J₁(βa)] / (σ² − β²),
β = k₀ NA r (Eqs. 3 and 5), and (a²/2)[J₀(σa)² + J₁(σa)²] for σ = β (printed as (a²/2) J₁(σa)² under Eq. 3 of Li et al., which lacks the J₀² term). The coefficients are found once for all Δz with an SVD least-squares solver, equal to (JᵀJ)⁻¹JᵀF in exact arithmetic. Li et al. report a relative squared error RSE ≈ (M/45)^−6.5 (K/80)^−1.5 % against the exact model for 30 ≤ M ≤ 100, 50 ≤ K ≤ 1000. Both methods evaluate each voxel at its exact radius (Li et al. interpolate a 2× oversampled radial profile).
Depth error of li2017
When NA ≥ n_s and the source is below the surface, the aperture
ends at ρ = a = n_s/NA, where the specimen term of the phase
varies as k₀ t_s n_s √(1 − (ρ/a)²): its slope is infinite at the
edge, and the uniform samples of Li et al. cannot follow it. The
fit is aliased there, whatever M, and the error grows with the
depth. It is inherent to the published method (MicroscPSF has
the same), and it is reduced by samples (K), not by basis
(M). For NA 1.4, λ₀ = 0.61 µm, a source in water at t_s = 10 µm
(r ≤ 3.2 µm, |Δz| ≤ 4 µm, M = 100), the largest error is about
7·10⁻³ of the peak with K = 1000, 10⁻³ with K = 3000 and 2·10⁻⁴
with K = 10000, and about 4·10⁻² at 50 µm with K = 1000; with
NA 1.2 it is 10⁻¹³ at 10 µm. Raise samples with the depth, or
use the quadrature.
Sampling. Voxel (k, j, i) is at Δz = defocus + (k − K_z//2) d_z
and lateral offset ((j − K_y//2) d_y, (i − K_x//2) d_x) from the
source: the PSF is centred at index K // 2, the convention of
optix.deconv. Slices are in order of increasing Δz along axis 0,
i.e. of the objective moving away from the specimen; flip axis 0 for
a stack acquired with the focus moving deeper. Point sampling is the
model; oversample > 1 instead averages s points per axis inside
each voxel (integration over the voxel; an extension, not in Gibson
& Lanni).
Relation to the z of Li et al. Li et al., MicroscPSF and PSF Generator scan the actual immersion thickness t_oil = t_oil* + z, so their z is the stage position from the design one (focus at the coverslip), not the defocus from the paraxial focus of the source. By Eq. (3),
Δz = z + t_oil* + n_oil (t_s/n_s + t_g/n_g − t_g*/n_g*
− t_oil*/n_oil*),
which is Δz = z + n_oil t_s/n_s when the coverslip and the immersion medium match the design.
References
- Gibson SF, Lanni F. Experimental test of an analytical model of aberration in an oil-immersion objective lens used in three-dimensional light microscopy. J Opt Soc Am A 8(10):1601–1613, 1991. doi:10.1364/JOSAA.8.001601
- Li J, Xue F, Blu T. Fast and accurate three-dimensional point spread function computation for fluorescence microscopy. J Opt Soc Am A 34(6):1029–1034, 2017. doi:10.1364/JOSAA.34.001029
BibTeX
@article{gibson1991experimental,
author = {Gibson, Sarah Frisken and Lanni, Frederick},
title = {Experimental test of an analytical model of
aberration in an oil-immersion objective lens
used in three-dimensional light microscopy},
journal = {Journal of the Optical Society of America A},
volume = {8},
number = {10},
pages = {1601--1613},
year = {1991},
doi = {10.1364/JOSAA.8.001601}
}
@article{li2017fast,
author = {Li, Jizhou and Xue, Feng and Blu, Thierry},
title = {Fast and accurate three-dimensional point spread
function computation for fluorescence microscopy},
journal = {Journal of the Optical Society of America A},
volume = {34},
number = {6},
pages = {1029--1034},
year = {2017},
doi = {10.1364/JOSAA.34.001029}
}
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
shape
|
sequence of int
|
(K_z, K_y, K_x) grid shape. |
required |
spacing
|
float or sequence of float
|
Voxel size (d_z, d_y, d_x) in object space, in µm; two values mean (d_z, d_xy). |
required |
wavelength
|
float
|
Emission wavelength λ₀ in vacuum, in µm. |
required |
numerical_aperture
|
float
|
NA of the objective. |
required |
depth
|
float
|
t_s, depth of the source below the coverslip, in µm. |
0.0
|
specimen_index
|
float
|
n_s, refractive index of the specimen. |
1.33
|
coverslip_index
|
float
|
Actual n_g and t_g (µm). Default: the design values. |
None
|
coverslip_thickness
|
float
|
Actual n_g and t_g (µm). Default: the design values. |
None
|
immersion_index
|
float
|
Actual n_oil. Default: the design value. The actual immersion thickness t_oil is set by the defocus (Eq. 3). |
None
|
design_coverslip_index
|
float
|
n_g* and t_g* (µm), defaults from the experiments of Gibson & Lanni (1.522, 170 µm). |
1.522
|
design_coverslip_thickness
|
float
|
n_g* and t_g* (µm), defaults from the experiments of Gibson & Lanni (1.522, 170 µm). |
1.522
|
design_immersion_index
|
float
|
n_oil*, default from Gibson & Lanni (1.515). |
1.515
|
design_immersion_thickness
|
float
|
t_oil* (µm), the working distance. It only matters when
|
150.0
|
defocus
|
float
|
Δz of the central slice |
0.0
|
method
|
(quadrature, li2017)
|
Evaluation of the pupil integral (see above). |
"quadrature"
|
nodes
|
int
|
Number of Gauss–Legendre nodes. Default: chosen to meet |
None
|
rtol
|
float
|
Accuracy target of the automatic node count, relative to the peak amplitude (author choice; not specified in Gibson & Lanni). |
1e-06
|
basis
|
int
|
M and K of |
100
|
samples
|
int
|
M and K of |
100
|
oversample
|
int or sequence of int
|
Samples per voxel along (z, y, x); 1 = point sampling. |
1
|
return_estimate
|
bool
|
Return a |
False
|
dtype
|
optional
|
Working dtype and device. Default: configuration. |
None
|
device
|
optional
|
Working dtype and device. Default: configuration. |
None
|
Returns:
| Type | Description |
|---|---|
(K_z, K_y, K_x) Tensor or PSFEstimate
|
PSF normalised to unit sum, centred at |
Utilities
No stability promise
optix.psf.utils holds building blocks of the functions above; they may change without notice.
Building blocks of optix.psf.
Semi-public: these may change without notice.
gaussian_filter
gaussian_filter(x, sigma, *, truncate=3.0)
Separable Gaussian smoothing of every dim of x.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Tensor
|
Array to smooth (all dims are filtered). |
required |
sigma
|
float or sequence of float
|
Standard deviation in voxels, per dim; 0 leaves a dim unfiltered. |
required |
truncate
|
float
|
The kernel is cut at ⌈truncate · σ⌉ voxels from its centre. |
3.0
|
Returns:
| Type | Description |
|---|---|
Tensor
|
Smoothed array, same shape; values past the edges are taken equal to the edge value (replicate boundary). |
local_maxima
local_maxima(x, half_width, threshold)
Voxels that are the maximum of their window and above a threshold.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Tensor
|
1-D, 2-D or 3-D array. |
required |
half_width
|
int
|
The window spans |
required |
threshold
|
float
|
Maxima must be strictly above it. |
required |
Returns:
| Type | Description |
|---|---|
(M, ndim) Tensor
|
Integer positions of the maxima. |
fit_gaussian
fit_gaussian(x, *, n_iter=50)
Least-squares fit of an axis-aligned Gaussian plus a constant.
m(r) = A · exp(−∑ᵢ (rᵢ − cᵢ)² / (2 sᵢ²)) + B,
fitted to each crop by Levenberg–Marquardt, with the damping adapted per crop (multiplied by 3 on a rejected step, divided by 3 on an accepted one). Each crop is scaled to unit peak before the fit.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
(M, *K) Tensor
|
Crops (one bead each), background-subtracted or not. |
required |
n_iter
|
int
|
Number of iterations. |
50
|
Returns:
| Name | Type | Description |
|---|---|---|
center |
(M, D) Tensor
|
Centres c in voxel coordinates of the crop. |
sigma |
(M, D) Tensor
|
Standard deviations s, in voxels. |
amplitude |
(M,) Tensor
|
A, in the units of |
offset |
(M,) Tensor
|
B, in the units of |
threshold_centroid
threshold_centroid(x, *, level=0.25)
Centroid of the part of each crop above a fraction of its peak.
c = ∑ᵣ r · w(r) / ∑ᵣ w(r), w = max(x − level · max x, 0).
For a PSF symmetric about its centre, the clipped weights are too, so the centroid is not pulled towards the crop centre.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
(M, *K) Tensor
|
Background-subtracted crops. |
required |
level
|
float
|
Fraction of the peak subtracted before taking the centroid. |
0.25
|
Returns:
| Type | Description |
|---|---|
(M, D) Tensor
|
Centres in voxel coordinates of the crop. |
fourier_shift
fourier_shift(x, shift)
Shift a batch of arrays by sub-voxel amounts, with the DFT.
out(r) = in(r − d), F[out](k) = F[in](k) · exp(−2πi ∑ᵢ kᵢ dᵢ / Kᵢ),
with F the discrete Fourier transform.
The shift is circular: content leaving one side re-enters on the other, so the arrays should fall to zero at their edges.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
(M, *K) Tensor
|
Arrays to shift. |
required |
shift
|
(M, D) Tensor
|
Shift d of each array, in voxels, along its D trailing dims. |
required |
Returns:
| Type | Description |
|---|---|
(M, *K) Tensor
|
Real part of the shifted arrays. |
linear_shift
linear_shift(x, shift)
Shift a batch of arrays by sub-voxel amounts, by linear interpolation.
out(r) = in(r − d),
interpolated separably along each dim; values from outside the array are zero.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
(M, *K) Tensor
|
Arrays to shift. |
required |
shift
|
(M, D) Tensor
|
Shift d of each array, in voxels, along its D trailing dims. |
required |
Returns:
| Type | Description |
|---|---|
(M, *K) Tensor
|
|
tukey_window
tukey_window(n, fraction, **backend)
Tukey (tapered cosine) window of length n.
w(k) = ½ (1 + cos(π (k / a − 1))) for k < a,
w(k) = 1 for a ≤ k ≤ n − 1 − a,
mirrored at the other end, with a = fraction · (n − 1) / 2.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n
|
int
|
Length. |
required |
fraction
|
float
|
Fraction of the window inside the two cosine tapers, in [0, 1] (0: rectangular, 1: Hann). |
required |
Returns:
| Type | Description |
|---|---|
(n,) Tensor
|
|
fwhm
fwhm(psf, center=None)
Full width at half maximum along each axis.
The width is measured on the line through center, parallel to the
axis, between the first half-maximum crossings on either side of the
centre, located by linear interpolation between voxels.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
psf
|
Tensor
|
Point spread function (any number of dims). |
required |
center
|
sequence of int
|
Voxel through which the profiles pass (default: the maximum). |
None
|
Returns:
| Type | Description |
|---|---|
(ndim,) Tensor
|
Width in voxels along each dim; NaN where the profile does not fall below half its central value on both sides. |
rayleigh_range
rayleigh_range(waist, wavelength, refractive_index=1.0)
Rayleigh range of a Gaussian beam.
z_R = π W₀² / λ, λ = λ₀ / n,
with W₀ the waist radius, λ₀ the vacuum wavelength and n the refractive index of the medium (Saleh & Teich). The beam radius grows to √2 W₀ at z = ± z_R.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
waist
|
float or Tensor
|
Waist radius W₀ (1/e² intensity half-width at the focus). |
required |
wavelength
|
float
|
Vacuum wavelength λ₀, in the units of |
required |
refractive_index
|
float
|
Refractive index n of the immersion medium. |
1.0
|
Returns:
| Type | Description |
|---|---|
float or Tensor
|
z_R, in the units of |
!!! references "References"
|
BibTeX |
beam_radius
beam_radius(z, *, waist, wavelength, refractive_index=1.0)
Radius of a Gaussian beam along its propagation axis.
W(z) = W₀ √(1 + (z / z_R)²)
(Saleh & Teich), with z measured from the waist and z_R
the rayleigh_range.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
z
|
float or Tensor
|
Distance from the waist along the propagation axis. |
required |
waist
|
float
|
See |
required |
wavelength
|
float
|
See |
required |
refractive_index
|
float
|
See |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
W(z), the 1/e² intensity half-width. |
!!! references "References"
|
BibTeX |
sheet_intensity
sheet_intensity(transverse, propagation, *, waist, wavelength, refractive_index=1.0)
Intensity of a Gaussian light sheet.
I(t, z) = (W₀ / W(z)) · exp(−2 t² / W(z)²),
with t the distance from the sheet's central plane (along the
detection axis), z the distance from the waist along the propagation
axis and W(z) the beam_radius. The
transverse profile is that of a Gaussian beam (Saleh & Teich)
focused along t only, as by a cylindrical lens; the factor
W₀ / W(z) conserves the power per unit length of the sheet,
∫ I dt = W₀ √(π / 2) for every z. A circular Gaussian beam scanned
along the sheet plane has the same time-averaged profile. I = 1 at
the centre of the waist.
The full width at half maximum of the sheet is W(z) √(2 ln 2).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
transverse
|
float or Tensor
|
t, distance from the central plane. |
required |
propagation
|
float or Tensor
|
z, distance from the waist along the propagation axis. |
required |
waist
|
float
|
See |
required |
wavelength
|
float
|
See |
required |
refractive_index
|
float
|
See |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
I(t, z), broadcast over |
!!! references "References"
|
BibTeX |
richards_wolf_field
richards_wolf_field(shape, *, wavelength, numerical_aperture, refractive_index=1.0, spacing=1.0, nodes=None, pupil_phase=None, dtype=None, device=None)
Electric field near the focus of an aplanatic system, on a grid.
e_x = −iA (I₀ + I₂ cos 2φ),
e_y = −iA I₂ sin 2φ,
e_z = −2A I₁ cos φ,
(Richards & Wolf 1959, Eq. 2.30), for a linearly polarised incident
wave with its electric vector along x, with A = 1 (A = π f l₀ / λ,
Eq. 2.28, scales the whole field), φ the azimuth of the point from
the x axis and I₀, I₁, I₂ the
richards_wolf_integrals.
The time dependence is e^{−iωt} and z increases away from the
lens.
References
- Richards B, Wolf E. Electromagnetic diffraction in optical systems II. Structure of the image field in an aplanatic system. Proc R Soc Lond A 253(1274):358–379, 1959. doi:10.1098/rspa.1959.0200
BibTeX
@article{richards1959electromagnetic,
author = {Richards, B. and Wolf, E.},
title = {Electromagnetic diffraction in optical systems
{II}. {Structure} of the image field in an
aplanatic system},
journal = {Proceedings of the Royal Society of London.
Series A, Mathematical and Physical Sciences},
volume = {253},
number = {1274},
pages = {358--379},
year = {1959},
doi = {10.1098/rspa.1959.0200}
}
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
shape
|
Sequence[int]
|
See |
required |
wavelength
|
Sequence[int]
|
See |
required |
numerical_aperture
|
Sequence[int]
|
See |
required |
refractive_index
|
Sequence[int]
|
See |
required |
spacing
|
Sequence[int]
|
See |
required |
nodes
|
int | None
|
None
|
|
pupil_phase
|
int | None
|
None
|
|
dtype
|
optional
|
Real working dtype and device. Default: configuration. |
None
|
device
|
optional
|
Real working dtype and device. Default: configuration. |
None
|
Returns:
| Type | Description |
|---|---|
Tensor
|
Complex field, |
richards_wolf_integrals
richards_wolf_integrals(radial, axial, aperture, *, nodes=None, pupil_phase=None)
The integrals I₀, I₁, I₂ of Richards & Wolf (1959), Eq. (2.32).
I₀ = ∫₀^α √cos θ sin θ (1 + cos θ) J₀(k r sin θ) e^{ikz cos θ} dθ,
I₁ = ∫₀^α √cos θ sin²θ J₁(k r sin θ) e^{ikz cos θ} dθ,
I₂ = ∫₀^α √cos θ sin θ (1 − cos θ) J₂(k r sin θ) e^{ikz cos θ} dθ,
with α the angular semi-aperture on the image side, k = n k₀ the wave number in the image space (k₀ = 2π / λ₀, λ₀ the vacuum wavelength, n the refractive index), r = √(x² + y²) the distance from the axis and z the distance from the Gaussian focus along the axis, positive away from the exit pupil (k r = k r_P sin θ_P and kz = k r_P cos θ_P in the paper). In the optical coordinates of Eq. (3.1a), u = kz sin²α and v = k r sin α, these are the integrals of Eq. (3.2).
The integrals are computed by Gauss-Legendre quadrature in the
variable s = √cos θ, in which the three integrands are analytic on
[√cos α, 1] (the √cos θ factor, singular at θ = 90°, is absorbed by
the change of variable), so that the quadrature converges
exponentially once the nodes resolve the oscillations of the
integrand. Bessel functions are from
bessel_j012.
References
- Richards B, Wolf E. Electromagnetic diffraction in optical systems II. Structure of the image field in an aplanatic system. Proc R Soc Lond A 253(1274):358–379, 1959. doi:10.1098/rspa.1959.0200
BibTeX
@article{richards1959electromagnetic,
author = {Richards, B. and Wolf, E.},
title = {Electromagnetic diffraction in optical systems
{II}. {Structure} of the image field in an
aplanatic system},
journal = {Proceedings of the Royal Society of London.
Series A, Mathematical and Physical Sciences},
volume = {253},
number = {1274},
pages = {358--379},
year = {1959},
doi = {10.1098/rspa.1959.0200}
}
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
radial
|
Tensor or float
|
k r, the radial optical distance (≥ 0). |
required |
axial
|
Tensor or float
|
kz, the axial optical distance. Broadcast with |
required |
aperture
|
float
|
Angular semi-aperture α, in radians, in (0, π/2]. |
required |
nodes
|
int
|
Number of quadrature nodes. Default:
24 + ⌈½ Φ + 4 (max k r · sin α)^⅓⌉, with
Φ = max k r · sin α + max |kz| · (1 − cos α) + TV(ψ) the largest
phase excursion of the integrand and TV(ψ) the total variation
of |
None
|
pupil_phase
|
callable
|
Extension (not in the aplanatic model of the paper): a phase
ψ(θ) = kΦ(θ), in radians, multiplied into the integrands as
e^{iψ(θ)}. Φ is the aberration function of Eq. (2.2), which the
paper sets to zero for an aplanatic system (Eq. 2.7); ψ must
depend on θ only (not on the azimuth), so that the azimuthal
integration (2.29) still applies. Called with a tensor of polar
angles θ, it returns a real tensor broadcastable to the shape of
θ (a |
None
|
Returns:
| Type | Description |
|---|---|
I0, I1, I2 : Tensor
|
Complex tensors of the broadcast shape of |
zernike
zernike(j, rho, theta)
Zernike circle polynomials with Noll's indexing and normalisation.
Z_j(ρ, θ) = √(n + 1) R_n^0(ρ) (m = 0),
Z_j(ρ, θ) = √(2(n + 1)) R_n^|m|(ρ) cos(m θ) (m > 0, j even),
Z_j(ρ, θ) = √(2(n + 1)) R_n^|m|(ρ) sin(|m| θ) (m < 0, j odd),
with (n, m) = noll_index(j). They are
orthonormal on the unit disk: (1/π) ∫∫ Z_i Z_j ρ dρ dθ = δ_ij, so a
coefficient is the root-mean-square contribution of its term. The
radial polynomials are computed by a three-term recurrence, stable in
single precision.
References
- Noll RJ. Zernike polynomials and atmospheric turbulence. J Opt Soc Am 66(3):207–211, 1976. doi:10.1364/JOSA.66.000207
BibTeX
@article{noll1976zernike,
author = {Noll, R. J.},
title = {Zernike polynomials and atmospheric turbulence},
journal = {Journal of the Optical Society of America},
volume = {66}, number = {3}, pages = {207--211},
year = {1976}, doi = {10.1364/JOSA.66.000207}
}
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
j
|
int or sequence of int
|
Noll index or indices (≥ 1). |
required |
rho
|
Tensor
|
Normalised radius (1 on the pupil edge) and azimuth, broadcast together. Values at ρ > 1 are the polynomials' continuation. |
required |
theta
|
Tensor
|
Normalised radius (1 on the pupil edge) and azimuth, broadcast together. Values at ρ > 1 are the polynomials' continuation. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
|
noll_index
noll_index(j)
Radial order and azimuthal frequency of the Noll index j.
Noll (1976) numbers the Zernike polynomials row by row (radial order n = 0, 1, 2, ...), by increasing |m| within a row; for m ≠ 0, the even index of each pair is the cosine term (m > 0) and the odd index the sine term (m < 0).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
j
|
int
|
Noll index, j ≥ 1. |
required |
Returns:
| Type | Description |
|---|---|
n, m : int
|
Radial order and signed azimuthal frequency (|m| ≤ n, n − |m| even). |
Examples:
>>> [noll_index(j) for j in (1, 2, 3, 4, 11)]
[(0, 0), (1, 1), (1, -1), (2, 0), (4, 0)]
zernike_fit
zernike_fit(values, rho, theta, *, terms=79, support=None)
Linear least-squares Zernike coefficients of maps on the unit disk.
c = argmin ∑_{ρ ≤ 1} (v(ρ, θ) − ∑_{j=1}^{J} c_j Z_j(ρ, θ))²,
unweighted over the pixels of the disk (Hanser et al. 2004 fit the magnitude and the phase of pupil functions this way, with J = 79: all polynomials up to radial order 11 plus the radial one of order 12, i.e. Noll indices 1 … 79).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
values
|
Tensor
|
|
required |
rho
|
Tensor
|
|
required |
theta
|
Tensor
|
|
required |
terms
|
int
|
Number J of polynomials, Noll indices 1 … J. Default 79. |
79
|
support
|
Tensor
|
|
None
|
Returns:
| Type | Description |
|---|---|
Tensor
|
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If the support has fewer pixels than |
unwrap_phase
unwrap_phase(phase, support)
Unwrap a phase map on a disk by linear extrapolation along paths.
Each pixel is moved by a multiple of 2π to the value closest to the
linear extrapolation 2φ₁ − φ₂ of the two previous pixels of its
path (the previous pixel alone for the first step). The paths start
at the centre pixel (H // 2, W // 2), run along the centre column,
then along each row outwards from that column. The phase is set to
0 outside the support.
Interpretation
Hanser et al. (2004) unwrap the phase "using a simple linear extrapolation method" before the Zernike fit; the path is not specified in the paper.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
phase
|
Tensor
|
|
required |
support
|
Tensor
|
|
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
Unwrapped phase, same shape. |
pupil_coordinates
pupil_coordinates(shape, spacing, *, wavelength, numerical_aperture, dtype=None, device=None)
Normalised polar coordinates of the pupil grid of an image grid.
The pupil grid is the discrete Fourier grid of the lateral image
grid: k = (i − K // 2) / (K · Δ) along each axis, so that k = 0 is at
index K // 2. The normalised radius is ρ = |k| / (NA/λ), 1 on the
pupil edge, and θ = atan2(k_y, k_x).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
shape
|
(int, int)
|
Lateral image shape |
required |
spacing
|
(float, float)
|
Lateral pixel size |
required |
wavelength
|
float
|
Vacuum wavelength λ of the detected light. |
required |
numerical_aperture
|
float
|
Numerical aperture. |
required |
dtype
|
optional
|
Floating dtype and device (default: torch's default dtype, CPU). |
None
|
device
|
optional
|
Floating dtype and device (default: torch's default dtype, CPU). |
None
|
Returns:
| Type | Description |
|---|---|
rho, theta : Tensor
|
|
zernike_pupil
zernike_pupil(magnitude, phase, *, shape, spacing, wavelength, numerical_aperture, dtype=None, device=None)
Pupil function from Zernike expansions of its magnitude and phase.
P(ρ, θ) = (∑_j a_j Z_j(ρ, θ)) · exp(i ∑_j b_j Z_j(ρ, θ)), ρ ≤ 1,
with Noll-indexed zernike polynomials
(j = 1, 2, ...) on the pupil grid of a lateral image grid, and P = 0
outside the pupil. Truncate the coefficient vectors to truncate the
expansion.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
magnitude
|
Tensor or sequence of float
|
|
required |
phase
|
Tensor or sequence of float
|
|
required |
shape
|
((int, int), (float, float))
|
Lateral image grid |
required |
spacing
|
((int, int), (float, float))
|
Lateral image grid |
required |
wavelength
|
float
|
Vacuum wavelength and numerical aperture. |
required |
numerical_aperture
|
float
|
Vacuum wavelength and numerical aperture. |
required |
dtype
|
optional
|
Floating dtype (default: that of the coefficients, else torch's default) and device. |
None
|
device
|
optional
|
Floating dtype (default: that of the coefficients, else torch's default) and device. |
None
|
Returns:
| Type | Description |
|---|---|
Tensor
|
|
vectorial_factors
vectorial_factors(shape, spacing, *, wavelength, numerical_aperture, refractive_index, dtype=None, device=None)
Pupil factors of the six dipole-to-polarisation components.
With sin θ = λ|k|/n (sine condition) and φ the azimuth of k (Hanser et al. 2004, Eq. 3):
Pₓ → Eₓ: cos θ cos² φ + sin² φ
Pₓ → E_y: (cos θ − 1) sin φ cos φ
P_y → Eₓ: (cos θ − 1) sin φ cos φ
P_y → E_y: cos θ sin² φ + cos² φ
P_z → Eₓ: sin θ cos φ
P_z → E_y: sin θ sin φ
The sum of their squares is 2 everywhere.
References
- Hanser BM, Gustafsson MGL, Agard DA, Sedat JW. Phase-retrieved pupil functions in wide-field fluorescence microscopy. J Microsc 216(1):32–48, 2004. doi:10.1111/j.0022-2720.2004.01393.x
BibTeX
@article{hanser2004phase,
author = {Hanser, B. M. and Gustafsson, M. G. L. and
Agard, D. A. and Sedat, J. W.},
title = {Phase-retrieved pupil functions in wide-field
fluorescence microscopy},
journal = {Journal of Microscopy},
volume = {216}, number = {1}, pages = {32--48},
year = {2004}, doi = {10.1111/j.0022-2720.2004.01393.x}
}
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
shape
|
((int, int), (float, float))
|
Lateral image grid (see
|
required |
spacing
|
((int, int), (float, float))
|
Lateral image grid (see
|
required |
wavelength
|
float
|
Vacuum wavelength, numerical aperture and immersion refractive index. |
required |
numerical_aperture
|
float
|
Vacuum wavelength, numerical aperture and immersion refractive index. |
required |
refractive_index
|
float
|
Vacuum wavelength, numerical aperture and immersion refractive index. |
required |
dtype
|
optional
|
|
None
|
device
|
optional
|
|
None
|
Returns:
| Type | Description |
|---|---|
Tensor
|
|
bead_otf
bead_otf(k, diameter)
Fourier transform of a uniformly fluorescent spherical bead.
b(k) = 3 h(π k d), h(x) = sin(x)/x³ − cos(x)/x²,
with k the magnitude of the 3D spatial frequency (cycles per unit length) and d the bead diameter (Hanser et al. 2004); b(0) = 1. For x < 1 the power series 3h(x) = ∑ₖ 3(−1)ᵏ(2k + 2) x²ᵏ / (2k + 3)! is used instead of the closed form, which cancels catastrophically near 0.
References
- Hanser BM, Gustafsson MGL, Agard DA, Sedat JW. Phase-retrieved pupil functions in wide-field fluorescence microscopy. J Microsc 216(1):32–48, 2004. doi:10.1111/j.0022-2720.2004.01393.x
BibTeX
@article{hanser2004phase,
author = {Hanser, B. M. and Gustafsson, M. G. L. and
Agard, D. A. and Sedat, J. W.},
title = {Phase-retrieved pupil functions in wide-field
fluorescence microscopy},
journal = {Journal of Microscopy},
volume = {216}, number = {1}, pages = {32--48},
year = {2004}, doi = {10.1111/j.0022-2720.2004.01393.x}
}
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
k
|
Tensor
|
Spatial frequency magnitudes, ≥ 0. |
required |
diameter
|
float
|
Bead diameter d, in the inverse units of |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
b(k), same shape. |
fit_otf_rescaling
fit_otf_rescaling(measured, calculated, *, spacing, wavelength, numerical_aperture, refractive_index)
Width of the empirical Gaussian OTF rescaling.
The point-wise ratio of the magnitudes of the measured and the calculated 3D OTFs, each normalised to 1 at k = 0, is fitted by least squares with
g(k) = exp(−|k|² / (2σ²))
over the OTF support of a wide-field microscope of numerical
aperture numerical_aperture, i.e. |k_r| ≤ 2 NA/λ and
|k_z| ≤ √((n/λ)² − (|k_r| − NA/λ)²) − √((n/λ)² − (NA/λ)²).
Hanser et al. (2004) fit on the support of a smaller aperture than
the objective's (NA 1.15 for an NA 1.3 objective), where the
measured OTF is above the noise, and multiply the magnitude of
calculated OTFs by g (pupil_psf with
otf_sigma=σ).
Interpretation
The paper fits "a Gaussian" "as a function of spatial frequency"; its exact form is not specified. Here g is isotropic in the 3D frequency |k|, with unit value at k = 0 (so the PSF sum is kept), and σ is found by a golden-section search of the least-squares criterion. Frequencies where the calculated OTF is below 10⁻³ of its value at k = 0 are left out of the fit, since the ratio is dominated by noise there (not specified in the paper, which restricts the fit to the support of a smaller aperture for the same reason).
References
- Hanser BM, Gustafsson MGL, Agard DA, Sedat JW. Phase-retrieved pupil functions in wide-field fluorescence microscopy. J Microsc 216(1):32–48, 2004. doi:10.1111/j.0022-2720.2004.01393.x
BibTeX
@article{hanser2004phase,
author = {Hanser, B. M. and Gustafsson, M. G. L. and
Agard, D. A. and Sedat, J. W.},
title = {Phase-retrieved pupil functions in wide-field
fluorescence microscopy},
journal = {Journal of Microscopy},
volume = {216}, number = {1}, pages = {32--48},
year = {2004}, doi = {10.1111/j.0022-2720.2004.01393.x}
}
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
measured
|
Tensor
|
|
required |
calculated
|
Tensor
|
|
required |
spacing
|
(float, float, float)
|
Voxel size |
required |
wavelength
|
float
|
Vacuum wavelength, numerical aperture of the fit support, and immersion refractive index. |
required |
numerical_aperture
|
float
|
Vacuum wavelength, numerical aperture of the fit support, and immersion refractive index. |
required |
refractive_index
|
float
|
Vacuum wavelength, numerical aperture of the fit support, and immersion refractive index. |
required |
Returns:
| Type | Description |
|---|---|
float
|
σ in cycles per unit length ( |
gibson_lanni_opd
gibson_lanni_opd(rho, defocus=0.0, **optics)
Optical path difference of the Gibson–Lanni model.
OPD(ρ; Δz) = n_oil Δz C_oil(ρ)
+ n_s t_s [C_s(ρ) − (n_oil/n_s)² C_oil(ρ)]
+ n_g t_g [C_g(ρ) − (n_oil/n_g)² C_oil(ρ)]
− n_g* t_g* [C_g*(ρ) − (n_oil/n_g*)² C_oil(ρ)]
− n_oil* t_oil* [C_oil*(ρ) − (n_oil/n_oil*)² C_oil(ρ)],
C_n(ρ) = [1 − (NA ρ / n)²]^½,
Gibson & Lanni Eq. (4) with the detector at its design distance (z_d = z_d*), minus its value at ρ = 0 (a constant phase, which does not change the intensity). Starred quantities are the design values; t_s is the depth of the source below the coverslip and Δz the defocus of Eq. (3),
Δz/n_oil = t_s/n_s + t_g/n_g + t_oil/n_oil − t_g*/n_g* − t_oil*/n_oil*,
which eliminates the actual immersion thickness t_oil from Eq. (2): Δz = 0 is the paraxial (geometric) focus, where the ρ² term of the OPD vanishes. Each square root is evaluated as √(n² − s²) − n = −s² / (√(n² − s²) + n), s = NA ρ, so that no large terms cancel.
The OPD is defined for |ρ| ≤ n_min/NA, with n_min the smallest
refractive index of the layers of non-zero thickness (see
gibson_lanni); beyond, a square root is
imaginary (the ray is evanescent in that layer) and NaN is returned.
The pupil itself is ρ ≤ a = min(1, n_min/NA).
References
- Gibson SF, Lanni F. Experimental test of an analytical model of aberration in an oil-immersion objective lens used in three-dimensional light microscopy. J Opt Soc Am A 8(10):1601–1613, 1991. doi:10.1364/JOSAA.8.001601
BibTeX
@article{gibson1991experimental,
author = {Gibson, Sarah Frisken and Lanni, Frederick},
title = {Experimental test of an analytical model of
aberration in an oil-immersion objective lens
used in three-dimensional light microscopy},
journal = {Journal of the Optical Society of America A},
volume = {8},
number = {10},
pages = {1601--1613},
year = {1991},
doi = {10.1364/JOSAA.8.001601}
}
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rho
|
float or Tensor
|
Normalised pupil radius ρ = n sin θ / NA (1 at the edge of the aperture of the objective), |ρ| ≤ n_min/NA. |
required |
defocus
|
float or Tensor
|
Δz; broadcast against |
0.0
|
**optics
|
float | None
|
|
{}
|
Returns:
| Type | Description |
|---|---|
Tensor
|
OPD, in the units of the lengths (µm), in float64 (float32 on MPS); NaN where |ρ| > n_min/NA. |
gibson_lanni_profile
gibson_lanni_profile(radius, defocus=0.0, *, wavelength, method='quadrature', nodes=None, rtol=1e-06, basis=100, samples=1000, dtype=None, device=None, **optics)
Gibson–Lanni intensity at radii r and defocus values Δz.
I(r, Δz) = | 2 ∫₀^a J₀(k₀ NA r ρ) exp(i k₀ OPD(ρ; Δz)) ρ dρ |²,
the Kirchhoff integral of Gibson & Lanni Eq. (5) with the
gibson_lanni_opd, in object
space, k₀ = 2π/λ₀. I = 1 at the focus of an aberration-free system
with a = 1.
See gibson_lanni for the methods and
the parameters.
References
- Gibson SF, Lanni F. Experimental test of an analytical model of aberration in an oil-immersion objective lens used in three-dimensional light microscopy. J Opt Soc Am A 8(10):1601–1613, 1991. doi:10.1364/JOSAA.8.001601
- Li J, Xue F, Blu T. Fast and accurate three-dimensional point spread function computation for fluorescence microscopy. J Opt Soc Am A 34(6):1029–1034, 2017. doi:10.1364/JOSAA.34.001029
BibTeX
@article{gibson1991experimental,
author = {Gibson, Sarah Frisken and Lanni, Frederick},
title = {Experimental test of an analytical model of
aberration in an oil-immersion objective lens
used in three-dimensional light microscopy},
journal = {Journal of the Optical Society of America A},
volume = {8},
number = {10},
pages = {1601--1613},
year = {1991},
doi = {10.1364/JOSAA.8.001601}
}
@article{li2017fast,
author = {Li, Jizhou and Xue, Feng and Blu, Thierry},
title = {Fast and accurate three-dimensional point spread
function computation for fluorescence microscopy},
journal = {Journal of the Optical Society of America A},
volume = {34},
number = {6},
pages = {1029--1034},
year = {2017},
doi = {10.1364/JOSAA.34.001029}
}
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
radius
|
float or Tensor
|
(R,) lateral distances r from the source, in µm. |
required |
defocus
|
float or Tensor
|
(Z,) defocus values Δz, in µm. |
0.0
|
wavelength
|
float
|
Emission wavelength λ₀ in vacuum, in µm. |
required |
method
|
str
|
See |
'quadrature'
|
nodes
|
str
|
See |
'quadrature'
|
rtol
|
str
|
See |
'quadrature'
|
basis
|
str
|
See |
'quadrature'
|
samples
|
str
|
See |
'quadrature'
|
dtype
|
optional
|
Working dtype and device. Default: configuration. |
None
|
device
|
optional
|
Working dtype and device. Default: configuration. |
None
|
**optics
|
float | None
|
|
{}
|
Returns:
| Type | Description |
|---|---|
(Z, R) Tensor
|
Intensity. |