Analysis › After fit · version 1
What a fitter runs once its last frame is in – astigmatic z, drift correction, colours, a chain – on the open localizations.
A fit is rarely the end. An astigmatic fit wants its widths turned into z, almost every acquisition wants the drift taken out, and a two-colour fit wants each localization given its colour. None of that can be done while the frames are still coming in: a drift curve is measured across the whole acquisition, and the colours are told apart by a histogram of the whole sample.
So every fitter has a section after the fit, folded at the foot of its form, whose title says which steps are on. Once the last frame is fitted, the fitter runs these steps over the whole table, and only then saves the file. The file on disk is then the finished table, not a raw fit somebody has to remember to correct.
This plugin is the same section on its own: the same settings, run on the localizations that are open. You rarely open it by itself. Inside every fitter's after the fit there is a button, Run these now, which runs it on the open localizations without fitting again. Use it when a step was not ticked during the fit, or to try other settings. It is one step of the undo and one line of the history, under the name After the fit.
The steps, in this order. Each one is a plugin of its own, with that plugin's settings, so a fit that finishes itself and a table finished by hand give the same numbers:
Only what applies is shown. Each step appears only where the fit can give it what it needs. Assign colours appears only in the two-colour fitters (Gaussian 2D 2C, Spline 3D 2C). Astigmatic z appears only in Gaussian 2D, and only while its elliptical is ticked. 4Pi z appears only in Spline 4Pi. Overlay channels appears only in a one-colour fitter whose channels reads two channels. A step's settings appear below it only while the step is on: tick assign colours and colour assignment appears; choose COMET and only COMET drift is shown.
What the table cannot take is passed over. When this plugin runs on the open localizations, it looks at the table rather than at a fitter. Colours need two channels' photons (photons_ch0 and photons_ch1, or MINFLUX's dcr). Astigmatic z needs sigma_x_nm and sigma_y_nm. 4Pi z needs phase_rad and phase_err_rad. The overlay needs camera_channel, which a fit on two channels writes. A step whose attributes are missing is skipped without a word, so the default assign colours does nothing to a one-colour table.
A step that fails is a line in the output. These steps run after a fit that may have taken twenty minutes. A colour histogram with one peak, or a drift estimate on too few localizations, must not cost that fit. So a step that fails says why in the output, the steps after it still run, and the table is saved.
Inside a fitter the steps run on the table as the fit made it, with every localization and no filter. The drift steps merge blinks as the Render tab's merge blinks does, for the distance and dark frames they leave on auto. Each step that changed the table goes into the file's history with the settings it used. The streamed file is written once more with the finished table when any step changed it.
From the button, the steps get the session's localizations: all of them, every file, whatever the layers show. Drift is estimated per file, as when RCC or COMET is run on its own.
A chain is read from its file each time it runs, so a chain saved a moment ago is the one that runs. It runs with the values saved in the file. A chain with a fitting step in it is refused, because it would open the movie and fit it again. The other steps still run.
| setting | default | what it does |
|---|---|---|
astigmatic zastigmatic_z | off | Z from the widths of the elliptical Gaussian, before any drift correction so that it can correct z (Analysis/After fit/Astigmatic z). The calibration under z calibration is the one Astigmatic z uses: a file from the PSF calibration window, method elliptical Gaussian, or curves typed in. Saving such a calibration in that window puts it here, in Gaussian 2D, with elliptical and astigmatic z ticked. |
| z calibration | ||
calibrationastigmatic.calibration | from a file | A file from the PSF calibration window (elliptical Gaussian), or the curves typed. Choices: from a file; typed |
fileastigmatic.path | – | An astigmatic z calibration (.h5). |
| curves – One curve per axis, s(z) = s0 sqrt(1 + u^2 + A u^3 + B u^4), u = (z - focus) / depth. | ||
width xastigmatic.typed.sigma_x_nm | 130 nm | s0: the narrowest the spot gets in x. at least 1 nm |
focus xastigmatic.typed.focus_x_nm | 300 nm | The z where x is narrowest; z = 0 is the round spot. |
depth xastigmatic.typed.depth_x_nm | 400 nm | How far from its focus the x width has grown by sqrt(2). at least 1 nm |
width yastigmatic.typed.sigma_y_nm | 130 nm | s0: the narrowest the spot gets in y. at least 1 nm |
focus yastigmatic.typed.focus_y_nm | -300 nm | The z where y is narrowest. |
depth yastigmatic.typed.depth_y_nm | 400 nm | How far from its focus the y width has grown by sqrt(2). at least 1 nm |
A x (more)astigmatic.typed.a_x | 0 | Huang's cubic term in x. |
B x (more)astigmatic.typed.b_x | 0 | Huang's quartic term in x. |
A y (more)astigmatic.typed.a_y | 0 | Huang's cubic term in y. |
B y (more)astigmatic.typed.b_y | 0 | Huang's quartic term in y. |
z rangeastigmatic.typed.z_range_nm | 800 nm | +- this: where the curves are trusted. at least 10 nm |
z scaleastigmatic.z_scale | 1 | True z per apparent z: about 0.7-0.8 for an oil objective imaging in water, 1 for none. at least 0.01 |
4Pi zfourpi_z | on | Z from the interference phase of a 4Pi fit, unwrapped by its envelope z (Analysis/After fit/4Pi z). On by default, and shown only after a 4Pi fit, where it is the step that gives z its precision. Its settings, under 4Pi phase, are those of 4Pi z; the fit keeps the phase's slope with the table, so as fitted needs no file. |
| 4Pi phase | ||
calibrationfourpi.slope | as fitted | The phase's slope in z: kept with the table by the 4Pi fit, or read from a 4Pi model file. Choices: as fitted; from a model file |
modelfourpi.path | – | A 4Pi model (.h5): this program's or uiPSF v1's. |
time windowfourpi.window_frames | 1000 frames | The cavity's phase is measured over this many frames. at least 10 frames |
smoothingfourpi.smoothing | 1 windows | Average each window with its neighbours, this many in all. at least 1 windows |
refine periodfourpi.refine_period | off | Find the fringe period that the data agree with best. |
z scale (more)fourpi.z_scale | 1 | True z per apparent z: 1 when sample and immersion index match. at least 0.01 |
overlay channelsoverlay | off | Move the second half of a two-channel fit onto the first, by beads; channel is the half (Analysis/After fit/Overlay channels). Off by default. Inside a fitter, the beads are fitted with that fitter's camera settings and in its channel arrangement, so the overlay's own channels part is not shown there. With keep the registration on, the beads are fitted and registered once and the result is used again by every fit that names the same beads, until a bead file changes. |
| channel overlay | ||
transformation fromoverlay_channels.source | transformation file | A saved registration, beads already fitted as two channels, or bead movies to fit. Choices: transformation file; fitted beads; bead movies |
fileoverlay_channels.path | – | A _2ct.h5 (Calibrate transform, or this plugin's), or a dual-colour bead calibration. |
fitted beadsoverlay_channels.beads_table | – | Bead localizations fitted with channels > read: two channels. |
bead moviesoverlay_channels.beads | – | A folder of bead movies, or one movie's path; beads seen in both halves. |
| bead fit – How the bead movies are fitted: Gaussian 2D, two channels, the sample's camera. | ||
cutoffoverlay_channels.bead_fit.cutoff | 1.7 | The detection threshold, in units of the filtered frame's noise (the fitters' dynamic cutoff). at least 0.1 |
at mostoverlay_channels.bead_fit.max_frames | auto | Frames fitted per bead movie; auto: all. at least 1 frames |
| channels – Where a split chip's two channels lie: the microscope's entry, or chosen by hand. | ||
layoutoverlay_channels.channels.layout | the microscope's | How 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 channeloverlay_channels.channels.main_channel | the microscope's | The 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)overlay_channels.channels.split_position | auto | The 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. | ||
transformationoverlay_channels.registration.model | projective (8 coefficients) | Projective extrapolates gracefully; the polynomial describes a distorted field far better where the pairs reach, and is refused when they do not reach far enough. Choices: projective (8 coefficients); polynomial, order 3 (20) |
vote bin (more)overlay_channels.registration.vote_bin_px | 2 px | The bin of the histogram of pair vectors the offset is voted in. at least 0.1 px |
vote smoothing (more)overlay_channels.registration.vote_smooth_px | 4 px | The width of the difference-of-Gaussians filter the vote is scored with. at least 0.1 px |
coarse matchingoverlay_channels.registration.coarse_tolerance_px | 20 px | First pass; must cover the rotation between the channels – 3 degrees over 512 px is 27 px. at least 0.1 px |
fine matchingoverlay_channels.registration.fine_tolerance_px | 1 px | Second pass over clean matches only, which is where the accuracy comes from; 0 skips it. |
adapt fine matching (more)overlay_channels.registration.adapt_fine_tolerance | on | Widen the fine matching to what the coarse fit misses its own pairs by, when those pairs are clean. |
minimum pairs (more)overlay_channels.registration.min_pairs | 20 | Fewer pairs than this and the registration refuses. at least 4 |
pairs used in the fit (more)overlay_channels.registration.max_pairs | 20000 | At most this many pairs, drawn at random, go into each fit. at least 4 |
outlier threshold (more)overlay_channels.registration.reprojection_threshold_px | 1 px | The robust (RANSAC) fit's inlier radius, at least; it widens with the matching tolerance. at least 0.01 px |
dx/dy limit (more)overlay_channels.registration.transform_axis_limit_px | 0.5 px | The largest |dx| or |dy| a pair may keep after the first fit, at least; it widens with the matching tolerance. at least 0.01 px |
keep the registrationoverlay_channels.save | on | Write it beside the beads as <name>_2ct.h5 and use it again while the beads and these settings are unchanged. |
drift correctiondrift | none | Estimate the drift from the finished table and subtract it from every localization. Off by default: it is minutes of work on a dataset it cannot see beforehand. Their pages, RCC and COMET, say which to choose. The settings under RCC drift and COMET drift are theirs. COMET's question before a long run is not asked after a fit: choosing it is the agreement. With z in the table, both correct z as well, unless their correct z says otherwise. Choices: none; RCC; COMET |
| RCC drift – How finely to bin, render and search. | ||
time windowsrcc.n_timepoints | 20 | How many windows the acquisition is cut into: more follow faster drift, fewer are less noisy. at least 2 |
pixel sizercc.pixelsize_nm | 15 nm | The pixel of the images that are correlated; about the localization precision. at least 1 nm |
z bin (more)rcc.z_pixelsize_nm | 5 nm | The bin width of the z histograms. at least 0.1 nm |
max driftrcc.max_drift_nm | 500 nm | The largest drift between any two windows that can be found. at least 1 nm |
peak fit half-width (more)rcc.fit_window | 3 px | The patch the correlation peak is fitted over, for its sub-pixel position. at least 1 px |
max image size (more)rcc.max_pixels | 2048 px | A wider field of view is folded back onto itself, to keep the correlation fast. at least 64 px |
correct zrcc.use_z | auto | Auto: if the table has z. |
merge blinksrcc.group | on | Merge the localizations of one blink into one before measuring. |
within (more)rcc.group_dx_nm | auto | How close localizations in consecutive frames must be to be one blink; auto: the session's merge settings. |
dark frames (more)rcc.group_dt | auto | How many dark frames a blink may skip; auto: the session's merge settings. |
tile (more)rcc.tile_nm | 200 nm | The axial pass correlates z histograms in tiles of the field of view this size. at least 1 nm |
tile y (more)rcc.tile_y_nm | auto | Auto: square tiles. at least 1 nm |
max axial drift (more)rcc.axial_max_drift_nm | 200 nm | How far from zero the axial correlation peak is looked for. at least 1 nm |
skip zero shift (more)rcc.exclude_zero_lag | on | Leave the zero-shift sample out of the axial peak search. |
error barrcc.split_half | on | Estimate again from each half of the field and show both: how far they differ is twice the curve's noise. |
reference (more)rcc.reference | as estimated | The frame the drift is zero at; first or last frame for consecutive files. Choices: as estimated; first frame; last frame |
| COMET drift – COMET parameters. The defaults suit a typical SMLM movie. | ||
window unit (more)comet.segmentation_mode | frames | What window size counts; time-window fit only. Choices: frames; localizations; windows |
window sizecomet.segmentation_var | 500 | Frames or localizations per time window, or the number of windows; time-window fit only. at least 1 |
max driftcomet.max_drift_nm | 300 nm | The largest drift expected; also the radius within which localizations are paired. at least 1 nm |
target sigmacomet.target_sigma_nm | 30 nm | The finest width of the overlap Gaussian, where refinement stops. at least 0.1 nm |
initial sigma (more)comet.initial_sigma_nm | auto | The width the refinement starts from; auto: a third of max drift. |
smoothing (more)comet.boxcar_width | 1 windows | Running mean over this many windows between refinement steps; 1 is none; time-window fit only. 1 to 1000 windows |
interpolation (more)comet.interpolation | cubic | The curve from the window estimates to every frame; time-window fit only. Choices: cubic; catmull-rom |
max locs / window (more)comet.max_locs_per_segment | auto | A random subset of at most this many per window; auto: all; time-window fit only. at least 1 |
ftol (more)comet.optimizer_ftol | 1e-07 | Relative change of the cost at which the optimizer stops. |
approximate kernel (more)comet.approximate_kernel | on | Skip pairs more than 6 sigma apart; the spline fit always does. |
ftol coarse (more)comet.optimizer_ftol_coarse | auto | Ftol for the steps above the target sigma; auto: ftol; time-window fit only. |
quality control (more)comet.quality_control | off | Discard time windows whose fit does not beat no correction; needs fit spline off. |
min lift (more)comet.min_lift | 0 | How much a window's fit must improve its overlap over no correction to be kept. |
merge blinkscomet.group | on | Merge the localizations of one blink into one before estimating. |
within (more)comet.group_dx_nm | auto | How close localizations in consecutive frames must be to be merged; auto: the session's merge settings. |
dark frames (more)comet.group_dt | auto | How many dark frames a blink may skip; auto: the session's merge settings. |
two stage (more)comet.two_stage | off | A grouped pass, then an ungrouped one within fine radius. |
fine radius (more)comet.two_stage_radius_nm | 30 nm | The max drift of the second, ungrouped pass. |
RCC first (more)comet.rcc_prepass | off | Correlate rendered time windows to take out the bulk of the drift, then run COMET over a small max drift. |
RCC windows (more)comet.rcc_prepass_windows | 10 | The time windows RCC correlates. at least 2 |
RCC max drift (more)comet.rcc_prepass_max_drift_nm | auto | Auto: RCC's own default. |
fit splinecomet.spline | on | Fit the drift as a smooth curve in time rather than one value per time window. |
knot spacingcomet.spline_knot_frames | 2000 frames | Frames between the spline's coefficients. at least 10 frames |
spline penalty (more)comet.spline_penalty | 0 | Extra penalty on the curve's bending; 0 is none. |
transformationcomet.transformation | shift | What changes over time besides the position; spline fit only. Choices: shift; xy scale; xy scale + rotation; xy affine; xy affine + z scale; 3D affine |
transformation knots (more)comet.transformation_knot_frames | auto | Frames between the transformation's spline coefficients; auto: the knot spacing. at least 10 frames |
transformation penalty (more)comet.transformation_penalty | 0 | Pulls the transformation towards none where the data say little; 0 is none. |
correct zcomet.use_z | auto | Auto: if the table has z. |
precision weightscomet.precision_weights | on | Widen each pair's Gaussian by the two localizations' precisions, so imprecise ones count less; needs xy_err_nm, and z_err_nm for z. |
z width (more)comet.sigma_z_factor | 1 x lateral | The overlap Gaussian's width in z as a multiple of its lateral width; 1 is one width for all axes. 0.1 to 20 x lateral |
error barcomet.split_half | on | Estimate again from each half of the field and show both: how far they differ is twice the curve's noise. |
reference (more)comet.reference | as estimated | The frame the drift is zero at; first or last frame for consecutive files. Choices: as estimated; first frame; last frame |
assign coloursassign_colors | on | Split the localizations by their photon ratio and write channel (Analysis/After fit/Assign colours). On by default: in a two-colour fit it is seconds, and it is what the fit was for. To change the rule afterwards, change colour assignment and press Run these now. |
| colour assignment | ||
methodcolors.mode | split at the minima | A cut in r, or a posterior per localization. Choices: split at the minima; probabilistic |
colourscolors.colors | 2 | How many species the histogram of r holds. 1 to 6 |
exclusion drcolors.exclusion | 0.05 | Minima: leave this much of r on either side of a boundary unassigned. |
sigmacolors.tolerance | 3 | Probabilistic: a colour is given only within this many sigma of its expected split, the sigma being that localization's own photon statistics plus any extra spread. 0: assign to the nearest colour however far away. |
keep the tailscolors.keep_tails | off | Probabilistic: apply the sigma test only between the outermost colours, so a localization more extreme than the first or the last mode is kept rather than refused. |
allowed crosstalkcolors.crosstalk | 0.05 | Probabilistic: refuse what is too close to call as well – the largest expected fraction of wrongly assigned localizations. Narrow beside the sigma test, and what matters where two colours overlap. 1e-06 to 0.5 |
extra spreadcolors.spread | 0 | Probabilistic: a species' own width in r, added in quadrature to the shot noise, for a dye whose splitting ratio varies across the field or between molecules. 0: shot noise alone (the summary prints what the modes suggest). |
use fitted errorscolors.use_errors | on | Take the photon errors from the fit where the table has them; otherwise sqrt(photons). |
use abundances (more)colors.use_prior | on | Probabilistic: weight each species by how much of the sample sits under its mode. |
minimum photons (more)colors.min_photons | 0 | Localizations with fewer photons in total are ignored and left unassigned. |
intensity LUT (more)colors.cmap | viridis | The colour map of the intensity plot's 2D histogram. Choices: viridis; cividis; turbo; magma; inferno; Greys; Greys_r |
histogram bins (more)colors.bins | 200 | How many bins the histogram of r has over its whole range, -1 to 1. 10 to 2000 |
smoothing (more)colors.smoothing | 2 bins | The histogram is smoothed by this much before its maxima are looked for; it also sets how far apart two modes must be. |
expected r (more)colors.expected | auto | The species' ratios, comma separated ("-0.65, 0.96"), measured on single-label samples or computed from the spectra. auto: the histogram's own maxima. |
channel 1 attribute (more)colors.channel1 | auto | Auto: photons_ch0, or the first pair of per-channel attributes in the table. |
channel 2 attribute (more)colors.channel2 | auto | The attribute r counts negative; name both attributes or neither. |
then chainchain | – | A saved chain run last, on the finished table; empty: none. Leave it empty for none. Its settings are edited in the chain's own panel and saved to its file. |
The table with what the steps wrote: z_nm and z_err_nm from Astigmatic z or 4Pi z (with fringe_probability), the second half moved and channel written by the overlay, positions moved by the drift correction, channel from Assign colours, and whatever the chain added. The output lists one line per step: what it found, that it failed and why, or nothing for a step that was not run. Each step's figures (the drift curve, the colour histogram, the widths against z) open with the result, each named after its step.