T3: Correcting for background and geometry (CLI)¶
In practice, recorded phase data is often subject to a non-linear background phase due to limitations of the measuring setup. Furthermore, the measured objects (e.g. cells, beads, liquid droplets) might be positioned too close to each other or the imaged region. DryMass offers several ways of dealing with the resulting artifacts. This tutorial uses polyacrylamide (PAA) bead measurements that were artificially altered to simulate the following cases:
- A constant offset in the phase background.
- A linear tilt in the phase background along one coordinate axis.
- A linear tilt in the phase background along both coordinate axes.
- A quadratic phase distortion along one axis and a phase tilt along the other axis.
- Quadratic phase distortions along both coordinate axes.
- Two beads that are close to each other.
- All of the above.
- A bead that is cut at the image border.
Please note that these are designed examples, i.e. the methods described here to fix these artifacts might not always work and their combination might not work for heterogeneous samples.
For this tutorial, you need:
Take a glimpse at the data¶
For this tutorial, the downloaded zip archive has to be extracted prior to the analysis. The extracted archive contains a readme file and the experimental data QLSR_PAA_beads_modified.h5 in the qpimage file format. DryMass can extract all relevant metadata from this file format (in contrast to the file formats used in tutorials 1 and 2), such that no manual intervention is required when running dm_analyze_sphere:
Please open the output folder (QLSR_PAA_beads_modified.h5_dm) and take a look at the file sensor_roi_images.tif. You can see the different artifacts discussed above (offset, tilt, etc.). In the file sphere_edge_projection_images.tif, you see that the default background correction strategy works for the offset and tilt artifacts, but fails when the background phase has quadratic components. Furthermore, notice that for the last three measurements no regions of interest (ROIs) were detected with the default parameters. As a result, these three measurements are not represented in sphere_edge_projection_images.tif. These issues are discussed and resolved in the following.
Select 2nd order polynomial background correction¶
A simple tilt-based background correction does not work for the measurements with the quadratic background. Setting the background correction to a second order polynomial resolves this issue. In the configuration file drymass.cfg (located in the output folder), edit the [bg] section:
[bg] phase profile = poly2o
Now the background is sufficiently flat for the first five ROIs.
Include beads that are close to each other¶
DryMass automatically removes ROIs that are close to each other, as this might have a negative effect on the subsequent analysis steps. To include these beads, we lift this restriction by modifying the [roi] section:
[roi] exclude overlap px = 0
In sensor_roi_images.tif, you can see that the ROIs of the beads are now included in the analysis. However, in sphere_edge_projection_images.tif you observe that the second bead seems to have a negative effect on the background correction. To resolve this issue, we set a binary threshold in the original ROI above which no data is used for background correction. Since it is difficult to set such a threshold manually, we use one of the threshold filters implemented in scikit-image that works well for this example: triangle
[bg] phase binary threshold = triangle
Now we have established a robust background correction pipeline that includes all but one bead.
Include beads at the border of the sensor image¶
By default, all ROIs that are within ten pixels of the border of the sensor image are removed from the analysis. We can include all ROIs by setting this distance to zero:
[roi] dist border px = 0
The bead in the final measurement is now included in the analysis, yielding values for refractive index and radius.
Exact determination of radius and refractive index¶
At this point, the tutorial is already complete in the sense that all cases given in the introduction have been covered. However, the residuals of the sphere model are still large, which can be attributed to the default analysis method of dm_analyze_sphere: The edge-detection algorithm, as implemented in DryMass, causes an underestimation of the beads radii and thus an overestimation of the refractive index. To retrieve more reliable results, we modify the [sphere] section to use the systematically-corrected Rytov approximation (see [MSG+18]):
[sphere] method = image model = rytov-sc
In addition to the previously achieved flat phase background for each ROI, this approach minimizes phase residuals and results in more accurate values for refractive index and size of the PAA beads.