DiffractionBlurGenerator3D#
- class deepinv.physics.generator.DiffractionBlurGenerator3D(psf_size: tuple, num_channels: int = 1, device: str = 'cpu', dtype: type = torch.float32, list_param: List[str] = ['Z4', 'Z5', 'Z6', 'Z7', 'Z8', 'Z9', 'Z10', 'Z11'], fc: float = 0.2, kb: float = 0.25, max_zernike_amplitude: float = 0.15, pupil_size: Tuple[int] = (512, 512), stepz_pixel: float = 1.0)[source]#
Bases:
PSFGenerator
3D diffraction limited kernels using Zernike decomposition of the phase mask.
Fresnel/Fraunhoffer diffraction theory, see
deepinv.physics.generator.DiffractionBlurGenerator()
for more details.- Parameters:
psf_size (tuple) – give in the order (depth, height, width)
num_channels (int) – number of channels. Default to 1.
list_param (list[str]) – list of activated Zernike coefficients, defaults to
["Z4", "Z5", "Z6","Z7", "Z8", "Z9", "Z10", "Z11"]
fc (float) – cutoff frequency (NA/emission_wavelength) * pixel_size. Should be in [0, 1/4] to respect Shannon, defaults to 0.2
kb (float) – wave number (NI/emission_wavelength) * pixel_size or (NA/NI) * fc. Must be greater than fc. Defaults to 0.3.
max_zernike_amplitude (float) – maximum amplitude of Zernike coefficients. Defaults to 0.15.
pupil_size (tuple[int]) – this is used to synthesize the super-resolved pupil. The higher the more precise, defaults to (512, 512). If an int is given, a square pupil is considered.
stepz_pixel (float) – Ratio between the physical size of the z direction to that in the x/y direction of the voxels in the 3D image.
- Returns:
a DiffractionBlurGenerator object
Note
NA: numerical aperture, NI: refraction index of the immersion medium, emission_wavelength: wavelength of the light, pixel_size: physical size of the pixels in the xy plane in the same unit as emission_wavelength
- Examples:
>>> import torch >>> from deepinv.physics.generator import DiffractionBlurGenerator3D >>> generator = DiffractionBlurGenerator3D((21, 51, 51), stepz_pixel = 2, list_param=['Z0']) >>> dict = generator.step() >>> filter = dict['filter'] >>> print(filter.shape) torch.Size([1, 1, 21, 51, 51]) >>> batch_size = 2 >>> n_zernike = len(generator.generator2d.list_param) >>> dict = generator.step(batch_size=batch_size, coeff=0.1 * torch.rand(batch_size, n_zernike, **generator.factory_kwargs)) >>> dict.keys() dict_keys(['filter', 'pupil', 'coeff'])
- step(batch_size: int = 1, coeff: Tensor | None = None)[source]#
Generate a batch of PSF with a batch of Zernike coefficients
- Returns:
dictionary with keys ‘filter’: tensor of size (batch_size x num_channels x psf_size[0] x psf_size[1]) batch of psfs, ‘pupil’: the pupil function, ‘coeff’: list of sampled Zernike coefficients in this realization,
- Return type: