SyMBac.PSF

class SyMBac.PSF.Camera(baseline, sensitivity, dark_noise)[source]

Class for instantiating Camera objects.

Example:

>>> my_camera = Camera(baseline=100, sensitivity=2.9, dark_noise=8)
>>> my_camera.render_dark_image()
__init__(baseline, sensitivity, dark_noise)[source]
Parameters
  • baseline (int) – The baseline intensity of the camera.

  • sensitivity (float) – The camera sensitivity.

  • dark_noise – The camera dark noise

render_dark_image(size, plot=True)[source]

Render a sample synthetic dark image from the camera

Parameters
  • size (tuple(int, int)) – Size of the dark image.

  • plot (bool) – Whether or not to plot the image.

Returns

Dark image sample.

Return type

np.ndarray

class SyMBac.PSF.PSF_generator(radius, wavelength, NA, n, apo_sigma, mode, condenser=None, z_height=None, resize_amount=None, pix_mic_conv=None, scale=None, offset=0, pz=0, working_distance=None)[source]

Instantiate a PSF generator, allows you to create phase contrast or fluorescence PSFs.

Example:

>>> #Creating a phase contrast PSF
>>> my_kernel = PSF_generator(
        radius = 50,
        wavelength = 0.75,
        NA = 1.2,
        n = 1.3,
        resize_amount = 3,
        pix_mic_conv = 0.065,
        apo_sigma = 10,
        mode="phase contrast",
        condenser = "Ph3"
    )
>>> my_kernel.calculate_PSF()
>>> my_kernel.plot_PSF()
__init__(radius, wavelength, NA, n, apo_sigma, mode, condenser=None, z_height=None, resize_amount=None, pix_mic_conv=None, scale=None, offset=0, pz=0, working_distance=None)[source]
Parameters
  • radius (int) – Radius of the PSF.

  • wavelength (float) – Wavelength of imaging light in micron.

  • NA (float) – Numerical aperture of the objective lens.

  • n (float) – Refractive index of the imaging medium.

  • apo_sigma (float) – Gaussian apodisation sigma for phase contrast PSF (will be ignored for fluorescence PSFs).

  • mode (str) – Either phase contrast, simple fluo, or 3d fluo`.

  • condenser (str) – Either Ph1, Ph2, Ph3, Ph4, or PhF (will be ignored for fluorescence PSFs).

  • z_height (int) – The Z-size of a 3D fluorescence PSF. Will be ignored for mode=phase contrast or simple fluo.

  • resize_amount (int) – Upscaling factor, typically chosen to be 3.

  • pix_mic_conv (float) – Micron per pixel conversion factor. E.g approx 0.1 for 60x on some cameras.

  • scale (float) – If not provided will be calculated as self.pix_mic_conv / self.resize_amount.

  • offset (float) – A constant offset to add to the PSF, increases accuracy of long range effects, especially useful for colony simulations.``.

static gaussian_2D(size, σ)[source]

Returns a 2D gaussian (numpy array) of size (pixels x pixels) and gaussian radius (σ)

static get_condensers()[source]

Returns a dictionary of common phase contrast condenser dimensions, where the numbers are W, R, diameter (in mm)

static get_fluorescence_kernel(wavelength, NA, n, radius, scale, offset=0)[source]

Returns a 2D numpy array which is an airy-disk approximation of the fluorescence point spread function

Parameters
  • Lambda (float) – Wavelength of imaging light (micron)

  • NA (float) – Numerical aperture of the objective lens

  • n (float) – Refractive index of the imaging medium (~1 for air, ~1.4-1.5 for oil)

  • radius (int) – The radius of the PSF to be rendered in pixels

  • scale (float) – The pixel size of the image to be rendered (micron/pix)

  • offset (float) – A constant offset to add to the PSF, increases accuracy of long range effects, especially useful for colony simulations.

Return type

2-D numpy array representing the fluorescence contrast PSF

static get_phase_contrast_kernel(R, W, radius, scale, NA, n, sigma, wavelength, offset=0)[source]

Returns a 2D numpy array which is the phase contrast kernel based on microscope parameters

Parameters
  • R (float) – The radius of the phase contrast condenser (in mm)

  • W (float) – The width of the phase contrast condenser opening (in mm)

  • radius (int) – The radius of the PSF to be rendered in pixels

  • scale (float) – The pixel size of the image to be rendered (micron/pix)

  • NA (float) – Numerical aperture of the objective lens

  • n (float) – Refractive index of the imaging medium (~1 for air, ~1.4-1.5 for oil)

  • sigma (float) – radius of a 2D gaussian of the same size as the PSF (in pixels) which is multiplied by the PSF to simulate apodisation of the PSF

  • λ (float) – The mean wavelength of the imaging light (in micron)

  • offset (float) – A constant offset to add to the PSF, increases accuracy of long range effects, especially useful for colony simulations.

Return type

2-D numpy array representing the phase contrast PSF

static somb(x)[source]

Returns the sombrero function of a 2D numpy array, defined as

\[somb(x)= \frac{2 J_1 (\pi x)}{\pi x}\]