ConfocalBlurGenerator3D#
- class deepinv.physics.generator.ConfocalBlurGenerator3D(psf_size, num_channels=1, zernike_index=tuple(range(4, 12)), NI=1.51, NA=1.37, lambda_ill=489e-9, lambda_coll=395e-9, pixelsize_XY=50e-9, pixelsize_Z=100e-9, pinhole_radius=1, max_zernike_amplitude=0.1, pupil_size=(512, 512), index_convention='noll', device='cpu', dtype=torch.float32, rng=None, **kwargs)[source]#
Bases:
PSFGeneratorGenerates the 3D point spread function (PSF) of a confocal laser scanning microsope.
- Parameters:
psf_size (tuple) – give in the order
(depth, height, width)num_channels (int) – number of channels. Default to
1.zernike_index (tuple[int, ...], tuple[tuple[int, int], ...]) –
activated Zernike coefficients in the following
index_conventionconvention. It can be either:a tuple of
intcorresponding to the Noll or ANSI indices, in which case theindex_conventionparameter is required to interpret them correctly.a tuple of
tuple[int, int]corresponding to the standard radial-angular indexing \((n,m)\). In this case, theindex_conventionparameter is ignored.
Defaults to
(4, 5, 6, 7, 8, 9, 10, 11), correspond to radial ordernfrom 2 to 3 (included) and the spherical aberration. These correspond to the following aberrations: defocus, astigmatism, coma, trefoil and spherical aberration.NI (float) – Refractive index of the immersion medium. Defaults to
1.51(oil),NA (float) – Numerical aperture. Should be less than NI. Defaults to
1.37.lambda_ill (float) – Wavelength of the illumination light (fluorescence excitation). Defaults to
489e-9.lambda_coll (float) – Wavelength of the collection light (fluorescence emission). Defaults to
395e-9.pixelsize_XY (float) – Physical pixel size in the lateral direction (height, width). Defaults to
50e-9.pixelsize_Z (float) – Physical pixel size in the axial direction (depth). Defaults to
100e-9.pinhole_radius (float) – Radius of pinhole in Airy units. Defaults to
1.max_zernike_amplitude (float) – maximum amplitude of Zernike coefficients. Defaults to
0.1.pupil_size (tuple[int]) – pixel size to synthesize the super-resolved pupil. The higher the more precise, defaults to
(512, 512). If anintis given, a square pupil is considered.index_convention (str) – convention for the Zernike indices, either
'noll'(default) or'ansi'.rng (torch.Generator) – random number generator (default to
None).device (str) – device (default to
cpu).dtype (type) – data type (default to
torch.float32).
- Examples:
>>> import torch >>> from deepinv.physics.generator import ConfocalBlurGenerator3D >>> generator = ConfocalBlurGenerator3D((21, 51, 51), zernike_index=(3,)) >>> print(generator.zernike_polynomials) ['Zernike(n = 1, m = -1) -- Vertical Tilt'] >>> dict = generator.step() >>> filter = dict['filter'] >>> print(filter.shape) torch.Size([1, 1, 21, 51, 51]) >>> batch_size = 2 >>> n_zernike = len(generator.generator_ill.generator2d.zernike_index) >>> dict = generator.step(batch_size=batch_size, ... coeff_ill = 0.1 * torch.rand(batch_size, n_zernike), ... coeff_coll = 0.1 * torch.rand(batch_size, n_zernike)) >>> dict.keys() dict_keys(['filter', 'coeff_ill', 'coeff_coll'])
- step(batch_size=1, coeff_ill=None, coeff_coll=None, **kwargs)[source]#
Generate a batch of 3D confocal PSF with a batch of Zernike coefficients for illumination and collection
- Parameters:
batch_size (int) – number of PSFs to generate.
coeff_ill (torch.Tensor) – tensor of size
batch_size x len(zernike_index)containing the Zernike coefficients for illumination. IfNone, random coefficients are generated.coeff_coll (torch.Tensor) – tensor of size
batch_size x len(zernike_index)containing the Zernike coefficients for collection. IfNone, random coefficients are generated.
- Returns:
dictionary with keys
filter: tensor of sizebatch_size x num_channels x psf_size[0] x psf_size[1]batch of PSFs,coeff_ill: list of sampled Zernike coefficients in this realization of illumination,coeff_coll: list of sampled Zernike coefficients in this realization of collection,
- Return type: