linumpy.intensity.psf_model#

Confocal PSF model fitting and volume-based PSF estimation.

Functions#

get_average_volume(data, z[, mask, s])

Compute an average volume for a specific slice.

find_focal_depth(vol)

Detect the focal plane depth in a volume.

i_profile_piece_wise_model(z, I0, Imax, z0, zf, s, mu, k)

Evaluate the piece-wise OCT intensity profile model.

glm_volume_normalization(vol, average_vol)

Volume intensity normalization using GLM fit.

volume_normalization(vol, average_vol[, epsilon])

Volume intensity normalization.

T_r(p, x, y)

Radiometric transformation function.

f_r(x, data, z, pos, i_mean)

Global radiometric objective function.

confocal_psf(z, zf, zR[, A])

Confocal PSF model using a gaussian beam.

get_slice_resolutions_from_psf(zf, zr[, nz, spacing, ...])

Compute the lateral resolution at each depth using the confocal PSF model.

estimate_psf(agarose[, interface, dz, ...])

Estimates the confocal PSF assuming a gaussian beam.

get_3d_psf(vol, interface[, res, ...])

Compute a 3D PSF from a given uniform volume (e.g. agarose).

fit_tissue_confocal_model(iprofile, z0[, zr_0, res, ...])

Fit a confocal tissue intensity profile model to depth data.

Module Contents#

linumpy.intensity.psf_model.get_average_volume(data, z, mask=None, s=0)[source]#

Compute an average volume for a specific slice.

Parameters:
  • data (Any) – The dataset for which the average volume is computed.

  • z (int) – Slice number.

  • mask (ndarray, optional) – Mask specifying which volume contributes to the computation.

  • s (int, optional) – Smoothing kernel size in pixel, by default 0 (no smoothing).

Returns:

Average volume.

Return type:

ndarray

linumpy.intensity.psf_model.find_focal_depth(vol)[source]#

Detect the focal plane depth in a volume.

Parameters:

vol (ndarray) – Volume in which the focal plane is detected

Returns:

The focal plane depth

Return type:

int

linumpy.intensity.psf_model.i_profile_piece_wise_model(z, I0, Imax, z0, zf, s, mu, k)[source]#

Evaluate the piece-wise OCT intensity profile model.

Parameters:
Return type:

numpy.ndarray

linumpy.intensity.psf_model.glm_volume_normalization(vol, average_vol)[source]#

Volume intensity normalization using GLM fit.

Parameters:
  • vol (ndarray) – Volume to normalize

  • average_vol (ndarray) – Average volume representing the background or objective profile without tissue

Returns:

Normalized volume

Return type:

ndarray

linumpy.intensity.psf_model.volume_normalization(vol, average_vol, epsilon=0.05)[source]#

Volume intensity normalization.

Parameters:
  • vol (ndarray) – Volume to normalize

  • average_vol (ndarray) – Average volume representing the background or objective profile without tissue

  • epsilon (float (optional, 0 < epsilon < 1)) – Small constant to prevent zero-division

Returns:

Normalized volume.

Return type:

ndarray

linumpy.intensity.psf_model.T_r(p, x, y)[source]#

Radiometric transformation function.

Parameters:
  • p (tuple) – Radiometic function parameters to evaluate. (Should be a (6,) tuple)

  • x (int or ndarray) – X position where the function is evaluated (int or result of meshgrid)

  • y (int or ndarray) – Y position where the function is evaluated (int or result of meshgrid)

Returns:

Function evaluated at given positoin

Return type:

int or ndarray

linumpy.intensity.psf_model.f_r(x, data, z, pos, i_mean)[source]#

Global radiometric objective function.

Parameters:
  • x (tuple) – Radiometic function parameters to evaluate. (Should be a (6,) tuple)

  • data ((slicecode.utils.FileUtils.data object)) – Data object used to iterate over volumes or images.

  • z (int) – Slice number over which the function is evaluated.

  • pos (ndarray) – Volume absolute positions computed with the shift_oct module

  • i_mean (float) – Average volume / image intensity across all tiles.

Returns:

Objective function evaluation for parameters x.

Return type:

float

Notes

This method is an implementation of [Sun2006](http://onlinelibrary.wiley.com/doi/10.1111/j.1365-2818.2006.01687.x/full)

linumpy.intensity.psf_model.confocal_psf(z, zf, zR, A=None)[source]#

Confocal PSF model using a gaussian beam.

Parameters:
  • z (ndarray) – Depths at which the psf is evaluated

  • zf (float) – Focal plane depth

  • zR (float) – Rayleigh Length

  • A (float) – Normalization constant

Returns:

PSF evaluated at each z locations

Return type:

ndarray

linumpy.intensity.psf_model.get_slice_resolutions_from_psf(zf, zr, nz=120, spacing=(6.5, 6.5, 6.5), N=512, lam=1.03)[source]#

Compute the lateral resolution at each depth using the confocal PSF model.

Parameters:
Return type:

numpy.ndarray

linumpy.intensity.psf_model.estimate_psf(agarose, interface=None, dz=6.5, remove_saturation=False, mask_interface=False, zf=None, fit_attn=False)[source]#

Estimates the confocal PSF assuming a gaussian beam.

Parameters:
  • agarose (ndarray) – Agarose volume

  • interface (ndarray) – Water-Tissue interface map

  • dz (float) – Z spacing in micron

  • remove_saturation (bool) – If True, remove saturated pixels before fitting.

  • mask_interface (bool) – If True, mask the tissue interface region before fitting.

  • zf (float, optional) – Fixed focal plane depth. If None, it is estimated.

  • fit_attn (bool) – If True, also fit the attenuation parameter.

Returns:

  • float – Focal plane depth

  • float – Rayleigh length

  • float – Normalization constant

Return type:

tuple[float, Ellipsis]

Notes

  • If no interface is given, the whole volume is used for the psf regression

linumpy.intensity.psf_model.get_3d_psf(vol, interface, res=6.5, use_average_rayleigh=False, remove_interface=True, zf=None)[source]#

Compute a 3D PSF from a given uniform volume (e.g. agarose).

Parameters:
  • vol (ndarray) – Agarose / Background volume to use for the PSF computation

  • interface (ndarray) – Water/Tissue interface depth map (in pixel)

  • res (float) – Z axis resolution (in micron / pixel)

  • use_average_rayleigh (bool) – Use average Rayleigh length instead of the Rayleigh map.

  • remove_interface (bool) – If True, mask the tissue interface before computing the PSF.

  • zf (ndarray, optional) – Fixed focal depth map. If None, it is estimated from data.

Returns:

  • ndarray – PSF

  • ndarray – Focal depth map

  • ndarray – Rayleigh length map

Return type:

tuple[numpy.ndarray, numpy.ndarray, numpy.ndarray]

linumpy.intensity.psf_model.fit_tissue_confocal_model(iprofile, z0, zr_0=400.0, res=6.5, use_bump_model=False, return_parameters=False, return_full_model=False, plot_profiles=False, fix_zr=False)[source]#

Fit a confocal tissue intensity profile model to depth data.

Parameters:
Return type:

dict