Image quality

Analysis › Measure · version 1

Map where each layer's localizations disagree with a widefield image of the same field (SQUIRREL's error map, with RSE and RSP) and where the picture resolves what (the local FRC); written to the localizations, as image layers or as TIFFs, and ranked by QnR across layers.

What it does

A super-resolved picture can look sharp and still be wrong. A structure can be missing because it was not labelled, not detected or filtered away. Two filaments close together can be drawn as one. A molecule localized hundreds of times can make a bright clump that is not in the sample. None of this shows in a resolution number.

This plugin draws two maps of where the picture can be trusted, one of each per visible layer of localizations:

The two answer different questions. The error map asks is it there?, the FRC map how finely is it resolved?. A region can be well resolved and wrong, or right and blurred.

With two or more layers – two filter settings, two fitters, before and after a correction – QnR ranks them by both at once, as eSRRF does (Laine et al. 2023).

What it needs. For the error map, a widefield image of the same field in the session: a TIFF opened with File > Open, or the average of the camera frames a fit keeps with its localizations (chosen by reference). It must lie where the localizations lie, give or take max shift. For the FRC map, a frame attribute and at least per tile at least localizations in a tile.

It measures each visible layer as it is shown: its filter and the drawn ROI. It reads single localizations, never merged blinks. The FRC needs that, because it splits the acquisition in time. The error map counts what was localized, which is what the widefield image saw.

How it works

1. The localizations on the widefield image's pixels. The localizations are counted on a grid finer by times finer than the reference's pixels. The reference itself is left as it is: nothing is interpolated.

2. Blurred and scaled. The counts are blurred by a Gaussian of width , the blur. Each block of fine pixels is then summed into the reference pixel it lies in, which is what a camera does with light. The result is scaled, : turns counts into the camera's brightness, and is the background. , and are those that make the two pictures agree best.

3. The shift. The widefield image and the localizations rarely lie exactly on each other. With find shift the offset between them is found by cross-correlation, the localizations are moved by it, and the search repeats until no shift is left.

4. The map. The error map is the difference, pixel by pixel. It is bright where the widefield image shows something the localizations do not, and where the localizations show something the widefield image does not. signed keeps the sign: negative is missing, positive is added.

Left: the widefield image. Middle: the localizations blurred and scaled to it. Right: the error map. A patch of the structure was taken out of the localizations (bright, right), and a clump of 400 localizations of one point was added (bright, lower left); the rest is noise.

5. Two numbers. The RSE (resolution-scaled error) is the root mean square of the map, in the widefield image's units. The RSP (resolution-scaled Pearson) is the correlation of the two pictures, from -1 to 1. Read the RSP to compare datasets: it does not depend on how bright the image is. Read the map to find where they disagree.

6. The local FRC map. With local FRC map the field is cut into squares of tile size, and the FRC of Localization Precision is measured in each square on its own: the same split in time, the same rendering, the same 1/7 threshold. A tile needs per tile at least localizations for a value. A tile with fewer, or whose curve never falls through 1/7, has none and is drawn grey. The spread over the FRC splits is each tile's error bar.

A field whose left half was localized with a precision of 6 nm and its right half with 24 nm. Left: the map, tiles of 2 µm; the two halves are told apart at once. Right: each tile's resolution against the FRC of its own half measured as one field (dashed).

7. QnR. With QnR of the layers, each layer's FRC resolution is measured over its whole field. It is turned into a rank between 0 and 1 within the layers compared: the best becomes 0.925, the worst 0.075. QnR is the harmonic mean of that rank and the RSP. A layer scores high only if it is both faithful and sharp.

In detail

The fit. For a given , the best and are a straight-line fit of the reference against the blurred counts , solved exactly:

Only is searched: by Brent's method between 0 and 5 reference pixels, minimising

over the compared pixels. A that ends on the bound of 5 pixels is reported: the two pictures then agree best when everything is blurred away, which usually means they are not of the same field. The blur is done in Fourier space, once per shift, which makes each tried one multiplication.

Which pixels. The compared pixels are those of the reference that the localizations cover: their bounding box, cut to the image. A widefield image larger than the localizations' field would otherwise count everything outside it as missed structure. The fine grid reaches 21 reference pixels beyond them, and the shift's reach beyond that, so that localizations just outside still blur into the edge. Nothing is cropped.

The shift is the peak of the cross-correlation of the blurred picture with the reference, refined below a pixel by a quadratic fit (as in Register layers). The localizations are moved by it and pictured again, up to 4 times, until the correlation finds less than a hundredth of a pixel. The quadratic fit pulls towards whole pixels; at a residual near zero that pull is gone.

The localizations, not the rendering. The picture compared is a histogram of the positions, never what the window renders. The window's contrast and saturation would break the straight line between counts and brightness. Any blur a renderer adds is a Gaussian the fitted takes up anyway.

Drift. The localizations are compared as the table holds them. A widefield image taken before the acquisition matches a drift curve that is zero at the first frame; one taken after it, the last frame. A constant offset is the shift, found anyway. The average of the raw frames that a fit keeps is smeared by whatever drifted during the acquisition. The fitted takes that up only in part, so the map then shows drift too.

The FRC map's tiles. A tile is a square of the whole field's FRC pixel (a fifth of its resolution), rounded up to a size the Fourier transform is fast at, so the tile is a little larger than tile size asks; the run says how large. The grid starts at the lowest x and y of the layer's localizations. Each tile is tapered at its edges as the whole field is (a Tukey window over the outer eighth of each side), so the map is a map of regions, not of single structures. With smooth the value written to a localization is interpolated linearly between the centres of the measured tiles around it; a localization whose own tile has no value stays NaN.

QnR's rank is eSRRF's logistic: with and the best and worst resolution of the layers,

with and such that and , and

It is a rank, not a measure: the same layer scores differently against other layers. With layers of equal resolution every rank is 0.5.

Differences from the publications. SQUIRREL (and its Python port in NanoPyx) magnifies the widefield image to the super-resolved pixels by interpolation and compares there. Interpolation smooths the reference's noise and so shrinks the error; here the comparison is on the reference's own pixels. SQUIRREL searched , and together by a particle swarm; here and are solved exactly and only is searched. SQUIRREL registers by shifting images and crops the edges; here the localizations are moved, so nothing is cropped. SQUIRREL's FRC map splits an image stack into odd and even frames; here the halves are blocks of frames, so a blink stays in one half. eSRRF's QnR ranks a sweep of reconstruction parameters; here it ranks layers.

Parameters

settingdefaultwhat it does
error map (SQUIRREL)
error_map
onThe localizations against a widefield image of the same field: what is missing or added.
error map
   reference
   squirrel.reference
–The widefield image of the same field; auto: the one an image layer shows, else the first image.

The widefield image must be of the same field and the same focus. The average of the raw frames is the convenient choice for a fit: it is always there, on the same pixels, but it is smeared by any drift during the acquisition. A separate widefield image taken just before the acquisition shows the sample unbleached and at one place.

   blur
   squirrel.sigma_nm
autoThe Gaussian that takes the localizations to the widefield resolution; auto: fitted.

Leave it on auto. Set it to the PSF's width (from a bead calibration) to compare datasets at the same blur. A fitted blur much larger than the PSF means the localizations are spread more than the optics would: drift, a reference out of focus, or a different field.

   find shift
   squirrel.register
onThe offset between the localizations and the reference, found and taken out.

Off only when the two are known to lie on each other to a few nanometres – a widefield image computed from the same camera frames, say.

   signed
   squirrel.signed
offAlso the map with its sign: positive where the localizations show more than the reference.

The absolute map shows where; the signed one shows which way. Negative is structure the localizations miss, positive is structure they add.

   max shift (more)
   squirrel.max_shift_nm
1000 nmThe farthest the shift is looked for. at least 1 nm
   finer by (more)
   squirrel.magnification
4The localizations are counted on pixels this much finer than the reference's.

4 is enough: the counts' own pixel then adds a blur of about 7 nm on 100 nm camera pixels, which the fitted takes up. More costs time and memory and changes nothing visible.

1 to 10
local FRC map
frc_map
offThe FRC resolution of each tile of the field: where the picture is good and where not.
local FRC map
   tile size
   frc_local.tile_um
2 µmThe side of the squares the FRC is measured in.

Choose it so that most tiles hold a few thousand localizations: smaller tiles show more detail, but more of them are grey and the rest noisier. Between 1 and 5 µm suits most dSTORM and PAINT data.

0.2 to 50 µm
   per tile at least
   frc_local.min_locs
1000Localizations a tile needs for a value; fewer is NaN.

Below about 1000 a curve crosses 1/7 by chance; raise it if the map is speckled by single tiles far from their neighbours.

at least 100
   smooth
   frc_local.smooth
offThe attribute interpolated between the tile centres, not constant in a tile.

For a picture coloured by the attribute; leave it off to keep the measured value of each tile.

   FRC blocks (more)
   frc_local.blocks
20The acquisition is cut into this many stretches of frames before the two halves are dealt. at least 2
   FRC splits (more)
   frc_local.repeats
5The curves of this many random deals are averaged; their spread is the error bar. 1 to 50
QnR of the layers
qnr
offTwo or more layers ranked by fidelity and resolution together (eSRRF); needs the error map.

Compare layers of the same field only: QnR ranks them against each other.

write to localizations
write_column
onEach map's value on the localizations it was measured on, NaN elsewhere.

Off, the table is left alone and the run only measures.

add image layers
image_layer
onEach map as an image layer over the localizations.
save as TIFF
save_tiff
offEach map as a 32-bit TIFF beside the localization file.

Each map is a 32-bit TIFF beside the localization file, named after it, the map and the layer; ImageJ reads its pixel size, and File > Open puts it back where it was. Save image layer saves any image layer the same way.

Output

The text has a line per map and layer:

Besides the text:

Reading the error map. A good map is noise: a speckle without structure, and an RSP close to 1. Structure in the map is structure the two pictures disagree on. A line or patch of negative error is missing from the localizations: look at the filter, the detection threshold, the labelling. A bright spot of positive error is added: repeated localizations of one molecule, or a fluorescent speck that blinks. An error that follows every edge means the blur does not fit: a reference out of focus, or one taken through different optics. The map cannot see errors below the widefield image's resolution; two filaments 50 nm apart drawn as one look the same as two drawn as two.

Reading the FRC map. A good map is even over the structure, with values close to the whole-field FRC. A patch much worse than its neighbours is a region the picture does not resolve as well: look there for drift that was not corrected, a focus that wandered, or labelling that is sparser. A tile's curve is noisier than the whole field's, so read differences between regions larger than the tiles' error bars, not single tiles.

References