PSF calibration

Localize · version 3

make the PSF calibration Spline 3D and Spline 3D 2C read: from bead z-stacks, the bead average or a physical model of the pupil and its aberrations learnt with uiPSF v2; or that model learnt in situ from the blinking molecules of a measurement; opens its own window

What it does

A 3D fit needs to know what one molecule looks like at every height: the point spread function (PSF). The PSF calibration makes it from bead z-stacks by the bead average (its page), or a model of the microscope's optics learnt from the same stacks: the objective's pupil, with its aberrations written as Zernike modes, from which the PSF at any height follows. This is uiPSF (Liu et al. 2024, doi:10.1038/s41592-024-02282-x), re-implemented in PyTorch as uiPSF v2 and run inside SMAPpy.

The same model can also be learnt in situ, from the blinking molecules of a measurement itself, with no beads: it then includes what the sample adds, the spherical aberration that grows with depth above all.

A model is smooth without smoothing, says which aberrations the microscope has and how sure it is of each, and shows where it does not fit the data. Saved, it is turned into the same kind of spline calibration the bead average writes, so Spline 3D and Spline 3D 2C read either alike, and the model is kept inside the same file.

By hand, this section only opens the PSF calibration window, with the Open button in its title bar; the window's page explains the methods, their settings and what they show. It replaces the Bead calibration plugin and window, retired in 2026-11. The pupil model, from beads or in situ, needs PyTorch, an optional part of SMAPpy; without it the window says what to type to install it.

Without the window

The settings below are for a calibration made without the window: by the AI assistant (run_plugin), in a chain, or from a script. The section in the tab never shows them: the window has its own. They are the window's, by the same names. Each part is one of the window's sections, and it is read only where the chosen method reads it, as the window shows only those sections.

Such a run does what the window's Detect beads and Calibrate do with no bead marked by hand. The beads the detection marks as doubles are left out. The method's finish follows: for a pupil model, the fit quality and the model against the data. With save model on, the calibration is saved beside the stacks, as the window saves it, unless save as names another file. Either way it is listed for the fitters' auto, as the window lists it. The figures are the window's pages, with no bead selected, and a page that is a table (the Zernikes) goes into the result's data.

The method is named by its key, because two methods share a label. pupil, average and elliptical read bead z-stacks. molecules and molecules elliptical read molecules on the coverslip in z sweeps. insitu reads a blinking measurement. A pupil model needs the microscope's NA and emission wavelength. If the database does not give them for the stacks, type them under microscope; the run refuses before any work and says which are missing.

A run without the window does not put the calibration into the fitter. Set the fitter's calibration to the file it reports, or leave it on auto.

Parameters

settingdefaultwhat it does
stacks
stacks
–A bead z-stack, z sweep or movie, or a folder of them: every acquisition found in it is used.

A file is one acquisition. A folder is searched as the window's Add... searches it, so a folder of bead stacks calibrates from all of them.

search subdirectories
subdirectories
onA folder's subfolders searched too.
method
method
pupilPupil: uiPSF's model from beads; average: the bead average; elliptical: astigmatic widths; molecules: from molecules on the coverslip; insitu: from a blinking measurement. Choices: pupil; average; elliptical; molecules; molecules elliptical; insitu
mode
mode
Single channelOne channel, a split camera's two (dual colour), or 4Pi's four.

Dual colour and 4Pi are offered only by the methods that have them, as in the window. Another mode is refused, with the modes the method has.

Choices: Single channel; Dual colour; 4Pi
save as
save_as
–Where the calibration is written; empty: beside the stacks, as the window saves it, if save model is on.
run – What a run starts from and leaves behind.
   start from
   run.start_from
–A previous model of this microscope (its calibration, or an older .uipsf.h5): the start, and the reference the Zernikes are drawn against.
   save model
   run.save_model
onSave the calibration and its model beside the stacks; off: figures only.
microscope – The microscope. Each field on auto takes the microscope database's value for the file's microscope (microscope_db, carried in CameraMetadata.microscope): its NA, its immersion, the emission of each arm from the filter it was set to. A value typed beats it. There is no default for the NA and the emission: without a microscope that gives them, a run refuses to start.
   microscope
   microscope.microscope
autoAuto: recognised from the stacks' metadata, else the last one used.
   camera
   microscope.camera
autoAuto: identified from the stacks' metadata, else the microscope's.
   NA
   microscope.NA
autoThe objective's numerical aperture; auto: the microscope's (required without one). 0.1 to 1.7
   emission
   microscope.wavelength_nm
autoThe beads' emission wavelength; auto: from the microscope's filter (required without one). 300 to 1200 nm
   emission, 2nd
   microscope.wavelength2_nm
autoDual colour: the secondary channel's; auto: the microscope's other arm, or the same without one. 300 to 1200 nm
   immersion index
   microscope.n_immersion
autoThe immersion medium's refractive index; auto: the microscope's, else oil's 1.518. 1 to 2
   sample index
   microscope.medium
autoWhat the sample is in: water 1.33 (beads, live cells), blinking buffer 1.345 (fixed cells in a dSTORM buffer), index matched (the immersion's), or typed; auto: water's 1.33, the immersion's for 4Pi. Choices: auto; water; blinking buffer; index matched; typed
   n
   microscope.n_medium
autoThe sample's refractive index the choice stands for; type over it for another. 1 to 2
   coverslip index (more)
   microscope.n_coverslip
autoAuto: the microscope's for its objective, else the immersion's. 1 to 2
   coverslip thickness (more)
   microscope.coverslip_um
autoThe coverslip's thickness; auto: the objective's design thickness. Only with a coverslip of another index. 0 to 1000 µm
   pixel x
   microscope.pixel_x_nm
autoOn the sample; auto: the microscope's for its 3D lens, or the camera's. at least 1 nm
   pixel y
   microscope.pixel_y_nm
autoAuto: as x, or the microscope's. at least 1 nm
   conversion
   microscope.conversion
autoPhotoelectrons per count; auto: the camera database's.
   offset
   microscope.offset
autoThe count of a pixel that saw no light.
   EM gain
   microscope.emgain
autoAuto: from the stacks.
model – The choices a bead calibration exposes, one channel or two; the instrument comes as Optics.
PSF model – The PSF model's choices, one section wherever a model is learnt – beads in one or two channels, in situ, 4Pi – and what uipsf's builder reads (uipsf.model.build): the pupil's order and magnitude, the blur. Each workflow keeps its own fields beside it (BeadSettings, InSituModelSettings), and the form hides what one does not read (model_shown).
      Zernike order
      model.psf.zernike_order
autoThe highest radial order of the pupil's modes; auto: 6. 2 to 12
      pupil magnitude
      model.psf.magnitude
minimal (cos θ^γ)Minimal: cos θ^γ, the ring beyond the critical angle and the NA, a few physical numbers; Zernike: every mode up to the order; symmetric: the rotationally symmetric ones; fixed: uniform, the apodisation only. Choices: minimal (cos θ^γ); Zernike; symmetric Zernike; fixed (apodisation)
      blur (more)
      model.psf.blur
roundA Gaussian blur of the image beyond the pixel's own, learnt (round: one σ for x and y) or held at its value. Choices: free; round; fixed
      blur σ (more)
      model.psf.blur_nm
20 nmThe blur beyond the pixel's: its start when learnt, its value when fixed.
      SAF damping (more)
      model.psf.saf_damping
onMinimal magnitude: learn a damping of the supercritical-angle ring, the light beyond the critical angle; off: the ring of a point on the coverslip.
      learn NA (more)
      model.psf.learn_na
offMinimal magnitude: learn the aperture's NA, an effective one at most 5 % above the objective's; off: the objective's NA as typed.
      learn sample index (more)
      model.psf.learn_n_med
offLearn the sample's refractive index from the microscope's sample index, a diagnostic; off: as typed.
   bead diameter
   model.bead_diameter_nm
0 nmThe beads' size, taken out of the model; 0: point-like.
   field dependence
   model.field_dependence
offLearn astigmatism and coma that vary over the field of view; the spline is then one per point of a grid over the chip, blended per spot.
   drift (more)
   model.drift
linear per stackA lateral drift of the stage through each stack, learnt: linear per stack, or free per slice. Choices: none; linear per stack; free per slice
   learn coverslip tilt (more)
   model.fit_tilt
offLearn the coverslip's tilt against the optical axis, mostly a coma: in situ, or beads seen through a coverslip of another index than the immersion's.
   rejection (k) (more)
   model.rejection_k
3Robust standard deviations above the median at which a bead is rejected. at least 1
   held out (more)
   model.heldout
0The fraction of beads kept out of learning and localised for the held-out report. 0 to 0.5
   largest z step (more)
   model.max_dz_nm
50 nmLearn from every n-th slice, n the most whose step stays within this. at least 1 nm
   learn z range (more)
   model.z_range_nm
1500 nm± about focus learnt from, a shorter stack whole; auto: the whole stack. at least 100 nm
spline – How the learnt model is sampled into the spline the fitter reads.
   spline z step
   spline.dz_nm
autoAuto: the stacks' step. at least 1 nm
   spline z range
   spline.z_range_nm
auto± about focus; auto: the range every used bead covers. at least 50 nm
beads – A single-channel calibration's settings, where the two channels lie (channels, the microscope's or chosen, never detected) and how the beads are paired and their map fitted (registration: the same RegisterSettings a movie registration reads, with a bead slide's defaults). The map is always measured from these beads: no source has asked for another yet.
   bead box
   beads.roi_size
27 pxThe square cut around each bead; the model's size. at least 7 px
   padding (more)
   beads.padding
autoAuto: max xy shift + 2, rounded down. at least 1 px
   z step
   beads.dz_nm
autoAuto: from the acquisition.
   detection sigma (more)
   beads.detection_sigma_px
2 pxThe smoothing before beads are found.
   threshold
   beads.detection_threshold_sigma
6 sigmaHow far above the background noise a bead must stand.
   min distance
   beads.min_distance_px
25 pxBeads closer than this to a neighbour are dropped.
   doubles (k) (more)
   beads.double_k
5Robust standard deviations above the median shape difference at which a bead is marked a double; auto: none marked. at least 1
   max xy shift (more)
   beads.max_xy_shift_px
3 pxThe largest lateral shift the alignment allows a bead.
   max z shift (more)
   beads.max_z_shift_nm
250 nmThe largest shift in height the alignment allows a bead.
   alignment range (more)
   beads.alignment_range_nm
500 nmThe z range around the focus the alignment correlates over.
   iterations (more)
   beads.registration_iterations
2Alignment passes. at least 1
   rejection (MAD) (more)
   beads.rejection_mad
1.5The shape cut, in robust standard deviations.
   smoothing z
   beads.smooth_z_nm
20 nmThe spline's smoothing along z, a Gaussian's sigma.
   smoothing xy (more)
   beads.smooth_xy_px
0 pxThe spline's smoothing across.
   min beads (more)
   beads.min_beads
1The fewest accepted beads to build from. at least 1
   brightness range (more)
   beads.brightness_range
6Largest accepted max/min; auto disables it.
   saturation (more)
   beads.saturation_adu
autoAuto: the integer type's maximum.
channels – Where a split chip's two channels lie: the microscope's entry, or chosen by hand.
      layout
      beads.channels.layout
the microscope'sHow the chip is split: the microscope's entry, or chosen by hand with the main channel and the split. Choices: the microscope's; right-left; right-left mirrored; up-down; up-down mirrored
      main channel
      beads.channels.main_channel
the microscope'sThe channel the other is registered onto: the microscope's (its transmitted arm), or either half, to swap them. Choices: the microscope's; left; right; upper; lower
      split position (more)
      beads.channels.split_position
autoThe first pixel of the second channel, on the chip, for a layout chosen by hand; empty: the middle of the frame. at least 1 px
registration – How a registration between two channels is measured: the vote, the pairing and the fit.
      coarse matching
      beads.registration.coarse_tolerance_px
12 pxHow far a bead may lie from where the offset the beads voted for puts its partner. at least 0.1 px
      minimum pairs (more)
      beads.registration.min_pairs
8Fewer pairs than this and the registration refuses. at least 4
      outlier threshold (more)
      beads.registration.reprojection_threshold_px
2 pxThe first round's robust (RANSAC) inlier radius. at least 0.01 px
      dx/dy limit (more)
      beads.registration.transform_axis_limit_px
0.15 pxThe largest |dx| or |dy| a pair may keep after the first round. at least 0.01 px
in situ – What in situ learning needs beyond the microscope and the model's choices.
   focus
   in_situ.focus_nm
autoThe focal plane's height above the coverslip, as the objective was moved from it; auto: estimated from the molecules on the coverslip.
   astigmatism (more)
   in_situ.astigmatism_nm
autoThe start's vertical astigmatism (Noll 6), with the microscope's sign; auto: the microscope's, for its 3D lens; not used with start from.
   hold
   in_situ.hold
the start'sThe start's: γ (a Zernike model's symmetric magnitude) and the phase above the order held from start from or the microscope's pupil, else the microscope's γ; every aberration: the start model's whole pupil, only the focus and the blur learnt; nothing: γ learnt, the focus then pinned. Choices: the start's; every aberration; nothing
   focus fit
   in_situ.focus_fit
learntLearnt with the pupil; from the coverslip: set by the lowest molecules' edge each round, not fitted; typed: held at focus. Choices: learnt; from the coverslip; typed
   on the coverslip
   in_situ.coverslip
onThe sample touches the coverslip: its lowest molecules pin the focus.
   rounds
   in_situ.max_rounds
4At most this many rounds of localising every molecule, choosing and learning. 1 to 8
   spline z
   in_situ.spline_z
above the plane in focusWhat the spline's z is: the height above the plane in focus, or above the coverslip. Choices: above the plane in focus; above the coverslip
in situ detection – How molecules are found and chosen. One number to set, molecules; under more the few that depend on the data; the rest hidden, the defaults decided in M5 (a script or a chain still sets them).
   molecules
   in_situ_detection.molecules
2000How many spots to learn from, each frame of a blink one: the movies are read until this many pass the selection. at least 21
   significance (more)
   in_situ_detection.significance
6Photons above the background in a disc, in standard deviations of its noise, for a detection. at least 1
   region (more)
   in_situ_detection.roi_px
autoThe square region each molecule is fitted in (odd); auto: 3 µm on the sample. at least 7 px
   z proxy (more)
   in_situ_detection.proxy
astigmatism: σx² − σy²How the first round sorts by height: an astigmatic PSF's elongation, or a 2D PSF's size. Choices: astigmatism: σx² − σy²; size: σx² + σy²
molecules – How molecules are found and chosen in z sweeps. One number to set, molecules; under more what depends on the data, and the molecules' height (held at 5 nm, learnt on auto); the rest hidden, the prototype's on M5's AF647 (November 2026).
   molecules
   molecules.molecules
4000How many spots to learn from at most, drawn evenly over the defocus. at least 50
   height (more)
   molecules.height_nm
5 nmThe molecules' height above the glass, held; auto: learnt. 0 to 200 nm
   PSF (more)
   molecules.psf_shape
autoHow each file's focus is found: where σx = σy (astigmatic) or the spot is smallest (round); auto: from the widths. Choices: auto; astigmatic; round (2D)
   illumination radius (more)
   molecules.illumination_px
autoMolecules only inside this circle about the image's centre; auto: the circle inscribed in the image. at least 5 px
   significance (more)
   molecules.significance
3.5A detection's peak in the matched filter, in robust standard deviations of the filtered frame. at least 1
   region (more)
   molecules.roi_px
autoThe square region each molecule is fitted in (odd); auto: 2.6 µm on the sample. at least 7 px
   z step (more)
   molecules.z_step_nm
autoFor files that do not record the stage's z: its step; auto: from the metadata. at least 1 nm
   frames per sweep (more)
   molecules.sweep_frames
autoWith a typed z step: the frames of one sweep, all upwards. at least 2
channels – Where a split chip's two channels lie: the microscope's entry, or chosen by hand.
      layout
      molecules.channels.layout
the microscope'sHow the chip is split: the microscope's entry, or chosen by hand with the main channel and the split. Choices: the microscope's; right-left; right-left mirrored; up-down; up-down mirrored
      main channel
      molecules.channels.main_channel
the microscope'sThe channel the other is registered onto: the microscope's (its transmitted arm), or either half, to swap them. Choices: the microscope's; left; right; upper; lower
      split position (more)
      molecules.channels.split_position
autoThe first pixel of the second channel, on the chip, for a layout chosen by hand; empty: the middle of the frame. at least 1 px
   registration
   molecules.registration
–Dual colour: the halves' map, a dual bead calibration or a registration file; empty: measured from the molecules.
elliptical Gaussian
   fit box
   elliptical.fit_box_px
13 pxThe box the data will be fitted in: a Gaussian's widths depend on it. at least 5 px
   higher orders
   elliptical.higher_orders
onFit Huang's A and B as well; off: the plain defocus curve.
   start sigma (more)
   elliptical.start_sigma_px
1.2 pxThe width the fits start from. at least 0.1 px
4Pi – The 4Pi beads section of the PSF calibration window: the PSF model a section of its own (PSFModelSettings), as in every other workflow, and 4Pi's own fields.
channels – Where a 4Pi's phase channels are on the chip: the channels part of Spline 4Pi and of the PSF calibration window's 4Pi beads, one part so that the two read a chip alike (fourpi_layout). The maps between the channels are not here: they are the model's, learnt with the PSF.
      layout
      fourpi.channels.layout
the file's, else the microscope'sWhere the phase channels are: the file's own layout, the microscope's (the database), typed, or the 4Pi-SMS design. Choices: the file's, else the microscope's; the microscope's; as the file lays them out; typed corners; 4Pi-SMS (Bewersdorf lab)
      x corners
      fourpi.channels.x_corners
0, 200, 400, 600Each channel's left edge on the chip, comma-separated.
      y corners
      fourpi.channels.y_corners
0, 0, 0, 0Each channel's top edge on the chip.
      width
      fourpi.channels.width
200 pxOne channel's width. at least 8 px
      height
      fourpi.channels.height
200 pxOne channel's height. at least 8 px
      mirrored in x
      fourpi.channels.mirrored
–The channels mirrored left-right, by number from 1, comma-separated; empty: none.
   z step
   fourpi.z_step_nm
0 nmThe stage's step between slices; 0: from the scan's own record.
   mirror steps
   fourpi.mirror_steps
2, 0, -2A scan's phase steps per slice, as set; a scan of one phase per slice has none.
   box
   fourpi.roi_size
21 pxThe box each bead is cut to, per channel. at least 9 px
   peak threshold
   fourpi.threshold
0.2A bead's peak, as a fraction of the brightest's: lower finds dimmer beads. 0.01 to 1
   isolation
   fourpi.min_distance_px
0 pxBeads closer than this are both left out; 0: the box.
   outlier factor
   fourpi.brightness_range
2.5Beads brighter or dimmer than the median by more than this factor are marked excluded (clusters, dim specks); 0: none.
   bead diameter
   fourpi.bead_diameter_nm
40 nmThe beads' size, taken out of the pupil model: its dyes, spread over its height, average the fringe; 0: point-like.
PSF model – The PSF model's choices, one section wherever a model is learnt – beads in one or two channels, in situ, 4Pi – and what uipsf's builder reads (uipsf.model.build): the pupil's order and magnitude, the blur. Each workflow keeps its own fields beside it (BeadSettings, InSituModelSettings), and the form hides what one does not read (model_shown).
      Zernike order
      fourpi.psf.zernike_order
autoThe highest radial order of the pupil's modes; auto: 6. 2 to 12
      pupil magnitude
      fourpi.psf.magnitude
minimal (cos θ^γ)Minimal: cos θ^γ, the ring beyond the critical angle and the NA, a few physical numbers; Zernike: every mode up to the order; symmetric: the rotationally symmetric ones; fixed: uniform, the apodisation only. Choices: minimal (cos θ^γ); Zernike; symmetric Zernike; fixed (apodisation)
      blur (more)
      fourpi.psf.blur
roundA Gaussian blur of the image beyond the pixel's own, learnt (round: one σ for x and y) or held at its value. Choices: free; round; fixed
      blur σ (more)
      fourpi.psf.blur_nm
20 nmThe blur beyond the pixel's: its start when learnt, its value when fixed.
      SAF damping (more)
      fourpi.psf.saf_damping
onMinimal magnitude: learn a damping of the supercritical-angle ring, the light beyond the critical angle; off: the ring of a point on the coverslip.
      learn NA (more)
      fourpi.psf.learn_na
offMinimal magnitude: learn the aperture's NA, an effective one at most 5 % above the objective's; off: the objective's NA as typed.
      learn sample index (more)
      fourpi.psf.learn_n_med
offLearn the sample's refractive index from the microscope's sample index, a diagnostic; off: as typed.
   vectorial (more)
   fourpi.vectorial
onThe pupil model follows each arm's dipole fields through the quarter-wave plates and the polarising split: keep it on. Off: uiPSF v1's scalar model, to compare with v1.
   magnitude modes (more)
   fourpi.magnitude_modes
autoA Zernike magnitude's modes, Noll indices comma-separated (4, 11); auto: as the PSF model's magnitude says (symmetric: every one with a scalar model); empty or none: a flat magnitude.
   same magnitude (more)
   fourpi.same_magnitude
onBoth objectives one magnitude shape (one γ), as twin objectives have; how much light each brings stays free.
   photons per frame (more)
   fourpi.photons_per_observation
onA bead's photon count free in every frame, as its light varies.
   model z range (more)
   fourpi.model_z_range_nm
600 nm+- this: the z range the saved model covers. at least 100 nm
   model z step (more)
   fourpi.model_dz_nm
20 nmThe saved model's z step. at least 5 nm

References