psf_generator.propagators.propagator#

The abstract propagator class.

Classes#

Propagator

Base class propagator.

Module Contents#

class psf_generator.propagators.propagator.Propagator(n_pix_pupil: int = 128, n_pix_psf: int = 128, device: str = 'cpu', zernike_coefficients=None, wavelength: float = 632, na: float = 1.3, pix_size: float = 20, defocus_step: float = 0.0, n_defocus: int = 1, apod_factor: bool = False, envelope=None, gibson_lanni: bool = False, z_p: float = 1000.0, n_s: float = 1.3, n_g: float = 1.5, n_g0: float = 1.5, t_g: float = 170000.0, t_g0: float = 170000.0, n_i: float = 1.5, n_i0: float = 1.5, t_i0: float = 100000.0)[source]#

Bases: abc.ABC

Base class propagator.

Parameters#

n_pix_pupilint, optional

Number of pixels (size) of the pupil (always a square image). Default value is 128.

n_pix_psfint, optional

Number of pixels (size) of the PSF (always a square image). Default value is 128.

devicestr, optional

Computational backend. Choose from ‘cpu’ and ‘gpu’. Default value is ‘cpu’.

zernike_coefficientsnp.ndarray or torch.tensor, optional

Zernike coefficients of length ‘K’ of the chosen first ‘K’ modes. Default is None.

wavelengthfloat, optional

Wavelength of light, in nanometer. Default value is 632.

nafloat, optional

Numerical aperture. Default value is 1.3.

pix_sizefloat, optional

Camera pixel size, in nanometer. Default value is 20.

defocus_stepfloat, optional

Step size of the defocus along the optical (z) axis on one side of the focal plane in nanometer. Default value is 0.0.

n_defocusint, optional

Number of z-stack. Default value is 1.

apod_factorbool, optional

Apply apodization factor or not. Default value is False.

envelopefloat, optional

Size \(k_{\mathrm{env}}\) of the Gaussian envelope \(A(\mathbf{s}) = \mathrm{e}^{-(k^2_x+k^2_y)/k_\mathrm{env}^2}\). Default is None.

gibson_lannibool, optional

Apply Gibson-Lanni aberration correction or not. Default value is False.

z_pfloat, optional

Depth of the focal plane in the sample. It is usually obtained experimentally by focusing on a point source at this depth. Default value is 1e3.

n_sfloat, optional

Refractive index of the sample. Default value is 1.3.

n_gfloat, optional

Refractive index of the (glass) cover slip. Default value is 1.5.

n_g0float, optional

Design condition of the refractive index of the cover slip. Default value is 1.5.

t_gfloat, optional

Thickness of the sample. Default value is 170e3.

t_g0float, optional

Design condition of the thickness of the sample. Default value is 170e3.

n_ifloat, optional

Refractive index of the immersion medium. Default value is 1.5.

n_i0float, optional

Design condition of the refractive index of the immersion medium. Default value is 1.5.

t_i0float, optional

Design condition of the thickness of the immersion medium. Default value is 100e3.

Notes#

Internal parameters:

1. t_i : float, thickness of the immersion medium. It is computed from \(t_i = z_p - z + n_i \left( -\frac{z_p}{n_s} - \frac{t_g}{n_g} + \frac{t_g^0}{n_g^0} + \frac{t_i^0}{n_i^0} \right)\).

2. refractive_index : float, refractive index of the propagation medium. It is equal to \(n_s\) if gibson_lanni=True, \(n_i\), otherwise.

3. (z_p, n_s, n_g, n_g0, t_g, t_g0, n_i, t_i0, t_i) are coefficients related to the aberrations due to refractive index mismatch between stratified layers of the microscope. This aberration is computed by method self.compute_optical_path.

n_pix_pupil[source]#
n_pix_psf[source]#
device[source]#
zernike_coefficients[source]#
wavelength[source]#
na[source]#
pix_size[source]#
fov[source]#
defocus_step[source]#
n_defocus[source]#
defocus_min[source]#
defocus_max[source]#
apod_factor[source]#
envelope[source]#
gibson_lanni[source]#
z_p[source]#
n_s[source]#
n_g[source]#
n_g0[source]#
t_g[source]#
t_g0[source]#
n_i[source]#
n_i0[source]#
t_i0[source]#
t_i[source]#
classmethod get_name() str[source]#
Abstractmethod:

Get name of the propagator in a certain format, e.g. ‘scalar_cartesian’.

abstract initialize_input_field() torch.Tensor[source]#

Initialize the input field of propagator.

abstract get_pupil() torch.Tensor[source]#

Get the pupil function with all corrections applied.

abstract compute_focus_field() torch.Tensor[source]#

Compute the output field of the propagator at focal plane.

update_zernike_coefficients(zernike_coefficients)[source]#

Update Zernike coefficients without reinitializing propagator.

compute_optical_path(sin_t: torch.Tensor) torch.Tensor[source]#

Compute the optical path following Eq. (3.45) in [1].

\[\begin{split}W(\mathbf{s}) &= k \left( t_s \sqrt{n_s^2 - n_i^2 \sin^2 \theta} + t_i \sqrt{n_i^2 - n_i^2 \sin^2 \theta} -t_i^* \sqrt{\left.n_i^*\right.^2 - n_i^2 \sin^2 \theta} \right. \\ & \quad \left. + t_g \sqrt{n_g^2 - n_i^2 \sin^2 \theta} - t_g^* \sqrt{\left.n_g^*\right.^2 - n_i^2 \sin^2 \theta}\right).\end{split}\]

References#

_get_args() dict[source]#

Get the parameters of the propagator.

save_parameters(json_filepath: str)[source]#

Save the parameters of the propagator in a JSON file.

Notes#

  • Zernike coefficients are converted to a list

  • complex numbers, e.g. e0x or e0y, are converted to a string

Parameters#

json_filepathstr, optional

Path to save the attributes in a JSON file.