4.3 Atomic force microscopy
4.3.4 Distortion correction algorithm
Atomic force microscopy is often used to track the evolution of a system with time or through the variation of an external parameter. These types of mea-surements requiring sequential AFM images have been used to study a wide variety of systems such as collagen self-assembly , nano-encapsulation processes for drug delivery , effects of drugs on mechanics and struc-ture of bacteria , magneto-electric couplings in multiferroic materials [142,143], and electromechanical effects in graphene . In ferroelectric materials, sequential measurements were used to track the evolution of ferro-electric domains [113,145,146] and to study the conduction at domain walls under increasing electric field [56, 57]. In these sequential measurements, significant further insight can sometimes be gained by directly correlating individual nanoscale features across time or changing external parameters, which requires tracking features across the sequentially acquired images.
In this respect, atomic force microscopy suffers from drawbacks related to the piezoelectric actuators used to control the tip position with respect to the sample. AFM images can be formed from either the left-to-right (trace) or right-to-left (retrace) branches of the raster scanning pattern. Due to piezoelectric hysteresis effects, images formed from the trace and retrace sections will exhibit relative distortions which are usually maximal at the
4.3 Atomic force microscopy
middle of the image.
Moreover, fast movements of the tip require fast changes in the voltage applied to the scanner. In these conditions, the scanner moves fast for most of the distance, then much slower for the remainder. This second slow step is called scanner creep and leads to further distortion in AFM images.
Furthermore, temperature changes or gradients are an additional source of distortions, called thermal drift.
Hardware solutions exist to minimise these phenomena. Atomic force microscopes can be enclosed in thermally insulated or temperature-controlled casings to reduce thermal drift. In so-called closed-loop systems, the position of the column can be measured externally, typically through capacitive sen-sors, in order to correct for the aforementioned effects in real time. However, closed loop systems are sometimes difficult to implement or financially out of reach. In these cases, various software solutions have been developed.
Real-time corrections can be performed with the drawback of requiring complex calibration routines [147,148]. Relative corrections of distortions can also be performed after image acquisition [149,150] using topography information to extract a mapping between subsequent images.
An algorithm using a similar approach as the latter has been developed in the Paruch group . The correction of relative distortion between two AFM scans within a series is performed in the following steps and illustrated in figure4.20:
1. Within the series of AFM images, a reference scan is chosen by the user.
2. Matching points and their respective coordinates in the topography signals are found automatically between the reference (xr,i, yr,i) and the target scan (xt,i,yt,i).
3. The coordinates of the matching points are used to generate a polyno-mial transform that maps the target topography onto the reference.
4. The transform is applied to all scan channels in the target scan.
The algorithm uses methods implemented in the OpenCV Python library for computer vision. The feature detection can be performed by the SIFT , SURF  or ORB  methods while the matching is performed by the FLANN  algorithm. The computation of the transformation and corrected target coordinate map are performed using functions implemented in the Scikit-image transformations and Scipy ndimage libraries, respectively.
A demonstration of the algorithm is shown in figure4.21. The first and last scans in a series of 21 PFM scans are used to demonstrate the viability of the algorithm. Figure4.21(a,d) shows the topographies of the first and last scans respectively. Slight shifts and distortions are present between the
Figure 4.20:Distortion correction algorithm work flow (a) The reference and target images are loaded. (b) Matching points in the topography and their respective positions are found automatically. (c-e) The coordinate transform required to map the target topography onto the reference is computed and applied to all channels in the target scan. From 
Figure 4.21:Use case of the distortion correction algorithm on the first and last scans in a series of 21 images taken consecutively.(a) Topography of the first scan, used as a reference. (b) Uncorrected topography of the last scan showing slight shifts and distortions with respect to the reference. (b) Map of height differences between the uncorrected last scan and reference showing inhomogeneous differences due to the relative distortions. (e) Height difference map between the last corrected scan and reference. The differences are now much smoother. (c) Corrected topography of the last scan showing that the image had to be compressed in order to match the reference.
(f) Histograms of the maps shown in (b) in blue and (e) in red. The histogram of corrected height differences is much narrower indicating that the correction was effective.
two scans. A map of the pixel by pixel difference between the scans is shown in figure4.21(b). The first topography is used as a reference to correct the last scan in the series and the resulting corrected topography is shown in figure 4.21(c). The white areas on the left and bottom indicate where the image had to be compressed in order to fit the topography and show that the last scan is not only shifted with respect to the reference but also slightly distorted. Figure 4.21(e) shows the difference between the corrected last
4.3 Atomic force microscopy
Figure 4.22: Phase images corresponding to (a) the reference and (d) the last scan in the series of consecutive PFM images shown in figure4.21. (b) The phase difference map between the last uncorrected scan and reference show the mismatch between the two images, while the differences between the corrected last scan and reference are much smoother. (c) Domain wall positions extracted by binarising the phase signals of the reference (blue) and uncorrected (red) PFM scans showing large shifts. (f) The domain wall positions of the corrected scan show an almost perfect overlap with the reference.
scan and the reference. The map of differences is now much smoother. This can also be seen in the histogram of differences between the reference and uncorrected scan in blue and corrected scan in green. The distribution in the latter is much narrower highlighting the effectiveness of the correction.
The same warping was used to correct the PFM phase signal. Figure 4.22shows the reference and uncorrected PFM phases, as well as differences between the reference and uncorrected and corrected phases.4.22(c,d) show the extracted domain wall position of the reference scan in blue. The un-corrected domain wall position shown in panel (c) shows strong shifts and distortions, while the corrected domain wall position is almost perfectly overlapping the domain wall position in the first scan in the series.
This algorithm was used to correct for distortions between sequential AFM measurements presented in chapters 5and7.
Crackling at the nanoscale
As discussed in chapter 4, previous studies of crackling noise in ferroelec-tric materials lack spatial information and do not distinguish between the creep and depinning regimes of interface velocity. Theoretical work 
suggests that in disordered elastic systems theory, which has been successful at describing the static and dynamic properties of ferroelectric domain walls, avalanches cluster in space and time in the creep regime, while in the depin-ning regime, individual avalanches appear to be uncorrelated. Experimental [156,157] and theoretical  studies of propagating crack fronts, which are well modelled by elastic interfaces in disordered media with long-range interactions, have shown that close to but above the depinning force, global avalanches are formed by local disconnected clusters, whose aspect ratio depends on the roughness exponent of the crack. The size distributions of both the global and local avalanches follow power law behaviours, albeit with different exponents related byτcluster= 2τglobal−1. These results point to the importance of distinguishing between the creep and depinning regimes when studying crackling and show that spatial information about individual jerky events provides further insight into the systems under study.
In this chapter, crackling behaviour is studied in two ferroelectric thin films of Pb(Zr0.2Ti0.8)O3 using PFM to investigate the distribution of the jerky event sizes with nanoscale spatial resolution.