Analysis › Measure · version 1 · can run once per region · can follow the ROI
A circle fitted to the localizations, per layer: its centre, radius and
Fits a circle to the localizations: where its centre is, how large its radius is, how precisely both are known, and how well a circle describes them. It is for structures that are rings – nuclear pores, endocytic pits seen from above, ring-shaped assemblies – and for finding the centre of anything round.
It runs on the view, on the localizations in the drawn ROI (region of interest), and, because it is a measurement, also in every ROI of the ROI manager or every cluster as one of the per-region steps: a radius per pore, to histogram or to filter by. Centre ROIs moves each ROI onto the centre it finds.
Each visible layer (one picture of the localizations, with its own filter and colours) is fitted on its own, as the layer shows it: its filter, and merged blinks where it merges them. A circle needs at least 4 localizations (3 with a fixed radius); in a region with fewer the numbers are left empty.
The fit takes a few milliseconds, so the plugin offers a follow ROI tick: the circle is fitted again while the ROI is dragged.
1. A start. The fit starts at the median of the localizations, with the median distance from there as the radius. The median, not the mean, so a few stray localizations do not move the start.
2. The circle. The centre and the radius are then adjusted until the distances of the localizations from the circle are as small as they can be – in the sense of a soft least squares: a localization close to the circle counts with its squared distance, as in ordinary least squares, but one further than about outlier scale counts only with its distance. So the unspecific localizations inside and around a ring, which ordinary least squares would let pull the circle towards them, have little say. With a fixed radius, only the centre is moved, which holds even on a ring of which only an arc was labelled; it then starts from the free circle's centre, since from the median, on the arc, the circle mirrored onto the arc's outer side fits as well.

One simulated ring of 50 nm radius: each label blinks several times, so the localizations come in small groups. The fitted circle (black) with its centre lies on the true ring (dashed).
3. How precise, how good. From how the localizations scatter around the circle, and how many there are, the plugin estimates the error of the centre and of the radius: roughly the scatter divided by the square root of their number. How well a circle describes them is the root mean square distance of the localizations from it; where the table has the localization precision, also that distance in units of each localization's own precision (the reduced chi-square): about 1 for a ring thinner than the precision, more for a wider ring, or for something that is not a ring at all.

Fitted radius of each of the simulated rings, with its error bar; the truth is the red line. The error bars cover the truth about two times in three, as one standard deviation should.
The loss. For localizations at and a circle of centre
and radius
, the residual of each is its distance from the circle,
What is minimised is the soft-L1 loss , with
the outlier scale: quadratic for
, linear for
. It is minimised by Gauss-Newton with reweighting – each step a weighted least squares with weights
– for up to 30 steps, or until no parameter moves by more than 0.001 nm. This is the same fit the circle template of Segment regions uses for each candidate ring.
The errors are those of a weighted least-squares fit at its minimum: the covariance , with
the derivatives of the
by
,
and
,
the weights, and
,
the number of fitted parameters (3, or 2 with a fixed radius, whose error is then 0). On simulated rings they match the scatter of the fitted radius over repeats. For very few localizations, or a ring with only a short arc labelled, they are optimistic; so they are when the localizations of one blink, which lie together, count separately – on a layer that merges blinks each counts once.
Goodness of fit. rms_nm is , over all localizations, so the unspecific ones raise it.
chi2_red is with
each localization's precision (
xy_err_nm).
Background. The soft loss limits how far unspecific localizations pull, but does not remove them: localizations spread evenly over the ROI lie mostly outside a ring smaller than it and pull its radius outwards by a few nm when they are as many as a third of the ring's. The centre stays. Filter them out before (by precision, by merging blinks), or keep the ROI close around the ring.
The radius. A ring's localizations are spread around its true radius by their precision. The radius fitted is the distance of the ring of labels, plus a small bias of order (under 1 nm for 8 nm precision on a 50 nm ring); the centre has none.
| setting | default | what it does |
|---|---|---|
fixed radiusradius_nm | 0 nm | 0: the radius is fitted. Otherwise only the centre, on a circle of this radius. Fix it when the radius is known (a nuclear pore's) and the rings are sparse or only partly labelled: the centre is then much better determined. Leave it at 0 to measure the radius. |
outlier scale (more)scale_nm | 20 nm | Localizations further than about this from the circle count with their distance, not its square. About the width of the ring as it appears – its own width and the precision together, 10 to 30 nm. Much smaller and the fit sees only the localizations right on the circle; much larger and it becomes ordinary least squares, which background pulls. at least 0.1 nm |
_L2, and so on): n_locs, the centre x_nm, y_nm and the radius radius_nm, with their errors x_err_nm, y_err_nm, radius_err_nm, and rms_nm and chi2_red. In the ROI manager they are columns of the results table.A good fit has the circle through the middle of the ring, a radius error a small fraction of the radius, and a reduced chi-square not far above 1. A circle through a blob or a crescent fits too – every set of points has a best circle – but with a large rms_nm, a large chi-square and a radius that differs from ROI to ROI.
Ported from SMAP's evaluator circleFitter (Ries 2020), the part that fits a circle to the localizations.
implicitfit), which the localizations inside a ring pull towards the centre; here the geometric distance, with the soft-L1 loss.