PYME.Analysis.points.astigmatism.astigTools module

PYME.Analysis.points.astigmatism.astigTools.find_and_add_zRange(astig_library, rough_knot_spacing=50.0)

Find range about highest intensity point over which sigmax - sigmay is monotonic. Note that astig_library[psfIndex][‘zCenter’] should contain the offset in nm to the brightest z-slice

Parameters
astig_libraryList

Elements are dictionaries containing PSF fit information

rough_knot_spacingFloat

Smoothing is applied to (sigmax-sigmay) before finding the region over which it is monotonic. A cubic spline is fit to (sigmax-sigmay) using knots spaced roughly be rough_knot_spacing (units of nanometers, i.e. that of astig_library[ind][‘z’]). To make deciding the knots convenient, they are spaced an integer number of z-steps, so the actual knot spacing is rounded to this.

Returns
astig_libraryList

The astigmatism calibration list which is taken as an input is modified in place and returned.

PYME.Analysis.points.astigmatism.astigTools.lookup_astig_z(fres, astig_calibrations, rough_knot_spacing=75.0, plot=False)

Generates a look-up table of sorts for z based on sigma x/y fit results and calibration information. If a molecule appears on multiple planes, sigma values from both planes will be used in the look up.

Parameters
fresdict-like

Contains fit results (localizations) to be mapped in z

astig_calibrationslist

Each element is a dictionary corresponding to a multiview channel, which contains the x and y PSF widths at various z-positions

rough_knot_spacingFloat

Smoothing is applied to the sigmax/y look-up curves by fitting a cubic spline with knots spaced roughly at intervals of rough_knot_spacing (in nanometers). There is potentially rounding within the step-size of the astigmatism calibration to make knot placing more convenient.

plotbool

Flag to toggle plotting

Returns
zndarray

astigmatic Z-position of each localization in fres

zerrndarray

discrepancies between sigma values and the PSF calibration curves

PYME.Analysis.points.astigmatism.astigTools.lookup_astig_z_dsigma(fres, astig_calibrations, rough_knot_spacing=75.0, plot=False)

Looks up the z position based on the difference between sigmax and sigmay. When compared to lookup_astig_z, which attempts to match sigmax and sigmay, can work across multiple channels, and will take advantage of biplane information this method will only work for a single channel (or focal plane) and is likely less accurate. It should, however, be somewhat more robust to errors in the calibration measurment and/or sample-induced changes in the PSF.

Parameters
fresdict-like

Contains fit results (localizations) to be mapped in z

astig_calibrationslist

Each element is a dictionary corresponding to a multiview channel, which contains the x and y PSF widths at various z-positions

rough_knot_spacingFloat

Smoothing is applied to the sigmax/y look-up curves by fitting a cubic spline with knots spaced roughly at intervals of rough_knot_spacing (in nanometers). There is potentially rounding within the step-size of the astigmatism calibration to make knot placing more convenient.

plotbool

Flag to toggle plotting

Returns
zndarray

astigmatic Z-position of each localization in fres

zerrndarray

discrepancies between sigma values and the PSF calibration curves