### Data representation

At this stage, it is important to point out that the unconventional scan patterns used here induce a paradigm shift in how image data are considered. In a traditional scanning mode, the data are essentially stored as an array of intensities, which are assigned to elements within a 2D matrix. However, for more complicated scan patterns, it is also necessary to specify the (nominal) position where each data point was acquired. A simple interpolation algorithm (herein called reconstruction) is used to map each data point to an element of the displayed or printed image. Thus, rather than a simple list of intensities (*I*
_{
i
}), the data are better envisioned as a list of positions and intensities (*x*
_{
i
}, *y*
_{
i
}, *I*
_{
i
}).

In practice, we have begun to store the nominal positions in this manner. Of course, it is possible to just store the scan-generation algorithm, but the factor of 3 increases in storage requirements is largely irrelevant here. Moreover, if distortions are significant, the true probe position may be quite different from the nominal position. Scan distortion correction consists of constructing the map from nominal to ‘true’ probe positions. Thus, this paradigm also highlights the analogy to the usual post-processing distortion correction, where a per-pixel map of corrections is generated [2–4].

In this paper, every G-STEM data set contains a series of twenty frames each acquired with 0.2 s frame time and the maximum frequency of 2 MHz. The 400,000 data points in each frame were then reconstructed to form a 200 × 200 image. The twenty image frames were aligned using cross-correlation and averaged to increase the signal-to-noise ratio (SNR). The final images presented in the figures were further smoothened in the frequency domain using a Gaussian filter.

### Sawtooth scans

A typical STEM image acquired using the conventional raster scan path with a dwell time of 20 μs and 512 × 512 frame size is shown in Fig. 1a. Here, the brighter atom columns are Sr and the fainter columns are Ti. The drift distortion is evident as the angle between [\(1\bar{1}0\)] and [001] deviates from 90°. We start the G-STEM attempt from the simple sawtooth scan path that resembles conventional raster scan from left to right and top to bottom. Here, we use a simple version of this path such that the beam flies directly from the end of the last line to the start of the next line and continues to scan without any flyback time or line synchronization. The probe location (*x*
_{
i
}
*, y*
_{
i
}) as a function of time is shown in Fig. 1b. Here, (*x*
_{
i
}
*, y*
_{
i
}) scales to the voltages applied along the two directions. The **X**-axis (red) is defined as the horizontal direction, also known as the fast scan direction in the conventional STEM. The **Y**-axis (black) is defined as the vertical direction, also known as the slow scan direction. The scans for both the **X-** and **Y**-axes are sawtooth waves of appropriate frequencies. Practically, the amplitude of this wave is controlled by the microscope electronics and defines the magnification of the STEM image. To better illustrate the scan path, we also plot the beam locations in 2D, as shown in Fig. 1c. The black zigzagging line connecting the dots illustrates the scan path.

Figure 1d shows a processed G-STEM image acquired using a fast sawtooth scan with a frame time of 0.2 s and 20 frames as discussed earlier. Note that although we use the HAADF signal in this paper, it is possible to simultaneously acquire multiples signals, such as both bright- and dark-field signals. The image is significantly distorted at the left edge of the displayed region, although the rest of the image is relatively undistorted. This distortion is likely from the phase lag of the scan electronics responding to a sudden change of beam location. When the beam moves from the end of the last line to the start of the next line, the actual location will take some extra time to reach the nominal position. Therefore, one way to compensate for the lag is to add in some extra shifts or a delay time, as in a conventional cathode ray tube.

Conventionally, a ‘flyback’ delay at the start of each fast scan line is used to reduce such distortion. For a present state-of-the-art STEM, flyback delays of 10–1000 μs are typical. As a specific example, the Nion UltraSTEM 200 typically needs more than 500 μs to yield images without noticeable distortions. Thus, for a scan of 512 × 512 pixels at 1 µs/pixel, using this flyback delay would result in losing roughly half of the available imaging time. If a fast enough blanker is available, the beam could be blanked during the flyback; otherwise, there might also be additional unnecessary damage at the edges of the scan where the beam spends extra time. The distribution of the electron dose is an important topic that will recur later. Clearly, a method of eliminating the flyback delay would allow an increase in scanning rate and potentially reduce the beam damage.

Another method to reduce the distortion and lateral shift along slow scan direction is called line-synchronization, i.e., tying each line to the same part of the wave of the electrical supply. Such synchronization has the added advantage that the effects of mains interference should be similar for each scan line and each frame, facilitating its correction [18]. However, this method either requires a delay time at the start of each line or imposes additional restrictions on the per-pixel dwell time.

### Serpentine scans

An obvious improvement over the sawtooth scan to avoid a flyback delay is to perform a ‘serpentine’ scan, alternately moving the probe from left to right on one scan line and then right to left on the next, using what is sometimes called a triangle wave. A serpentine scan is shown in Fig. 2a, b, where the **X-** and **Y-** directions are the same as in Fig. 1b. Double serpentine scans (i.e., performing a second scan after rotating the slow-scan axis by 90°) can also be implemented.

Figure 2c shows the result of such a serpentine scan. Unfortunately, these scans initially appear worse than the conventional scan at high scan speeds, because the distortions are different for the leftwards and rightwards trajectories. For display purposes, it is best to separate out these two paths. Notably, unwarping this distortion might present an easier problem to solve than the regular sawtooth wave, because the triangle wave provides two images of the same area with different distortions. To a reasonable level of approximation, we might, therefore, expect the distortions to be similar, but reversed. Thus, a digital correction of serpentine scans could be a promising route for further development.

The obvious lesson from the serpentine scans is that the sharp changes in direction at the edges of the scan contribute significantly to the distortions. There is a clear difference in the acceleration of the probe between the abrupt changes at the end of each scan line as compared with the rest of the pixels. The relevance should be obvious in scanning tunneling microscopy (STM), in which the moving probe/stage has mass, but is perhaps a little surprising in STEM where the ‘probe’ does not really correspond to a physical object. However, it seems clear that there is a non-ideal response of the ‘true’ probe movement to the ‘nominal’ probe positions. The cause of this lag is inductance in the scan coils and other current-flow limitations, which limit how fast the scan can be changed, in an analogous way as to how inertia can limit mechanical movement. One route to address this problem would be with faster electronics or rapid electrostatic deflectors. However, such new hardware would introduce other complications and, thus, scan paths without sharp changes in acceleration merit further investigation.

### Spiral scans

We now focus on smooth curves that can fill the 2D space without crossing themselves. The distortions can hopefully be reduced due to the relatively smooth acceleration. Spiral curves are natural solutions to this problem. The mathematical study of spirals has a long and interesting history, dating back thousands of years [19]. In this paper, we focus on spirals with coordinates (*x*, *y*) as a function of time *t* defined by:

$$x = t^{a} { \cos }\left( {\omega t^{b} } \right),\;y = t^{a} { \sin }\left( {\omega t^{b} } \right)$$

(1)

where *ω* is the scanning frequency, and *a* and *b* are parameters to control the shape of the spirals. The scanning frequency *ω* can be adjusted to change the sampling rate. The spiral can go both inward and outward. As the drift distortion is different but correlated for inward and outward scans, this is a promising way to decouple drift distortion from the scan distortion, which will be considered in more detail in the future work.

Here, we explore the physical properties of the spiral curves, as they are closely related to the quality of STEM images reconstructed from those scan paths. We begin with the velocity \(\vec{v}\), which basically determines the distance between adjacent sampling points. For each point on the spiral, \(\vec{v}\) is the first derivative of Eq. (1), with a magnitude:

$$\left| {\vec{v}} \right| = t^{a - 1} \sqrt {a^{2} + \omega^{2} b^{2} t^{2b} } \approx \omega bt^{a + b - 1}$$

(2)

The term *a*
^{2} inside the square root can usually be neglected for large *ωt*
^{b}. We can see that when *a* + *b* = 1 the velocity magnitude is approximately constant for all the points on the spiral. If *a* + *b* > 1, the beam moves faster as it moves away from the center.

The angular velocity magnitude Ω is defined by:

$$\varOmega = \frac{{\left| {\vec{v}} \right|}}{r} = \frac{{\omega bt^{a + b - 1} }}{{t^{a} }} = \omega bt^{b - 1}$$

(3)

Here, we assume that the velocity \(\vec{v}\) is perpendicular to \(\vec{r}\) = (*x, y*), which is a reasonable approximation: The angle between \(\vec{v}\) and \(\vec{r}\) can be calculated as *θ* = *arc*cos(*a*/(*ωbt*
^{b})). As *t* increases, cos(*θ*) approaches zero and *θ* approaches 90°. Equation 3 tells us that the angular velocity is approximately constant if *b* = 1.

Another potentially interesting feature of the spiral curves is the sampling density. To ensure uniform sampling, the dose should ideally be the same across the whole area. For a first approximation, we consider how the spiral sweeping area *A* increases as a function of time *t*,

$$\frac{dA}{dt} = \frac{{d\left( {\pi \left( {t^{a} } \right)^{2} } \right)}}{dt} = 2a\pi t^{2a - 1}$$

(4)

For *a* = 0.5, the area increases linearly with time. For *a* < 0.5, the increase slows down over time, resulting in more dose at the edges, while for *a* > 0.5, the center is exposed to more electron dose. Now, with the understanding of physical properties of the spiral scans, we investigate the behavior for spiral curves with different *a* and *b* parameters.

#### Archimedean spiral

The first type of spiral we consider is an ‘Archimedean’ spiral with *a* = 1 and *b* = 1:

$$x = t{ \cos }\left( {\omega t} \right),\;y = t{ \sin }\left( {\omega t} \right)$$

(5)

The beam scan path Fig. 3a shows that the magnitude of *x* and *y* slowly increase without any sharp turns and the frequency of the sinusoids remains constant. Taking coordinates from Fig. 3a, we can form the outward scan trajectory, as shown in the left part of Fig. 3b. The inward scan shown in the right part is constructed by reversing of the scan path and also the y-direction. Two typical reconstructed images using Archimedean inward and outward spirals are shown in Fig. 3c. Note that the resulting STEM images do not display any obvious non-linear distortion. This is attributed to the constant frequencies (and constant angular velocity) for *b* = 1. Both inward and outward images are rotated at the same angle with respect to the sawtooth scan images in Fig. 1d. The distortion is likely from the scan lag which is related to the angular velocity. As the spiral scan direction is clockwise for both the inward and outward scans, the distortion is the same for both images.

The main problem with an Archimedean scan is the sampling density. This can be seen simply by recognizing that the number of points scanned in time *t* will be proportional to *t*, while the area scanned is approximately proportional to the square of the time, as *t*
^{2}. Thus, the sampling density and dose at the sample will vary with position in the image. This is also evident from the corrupted regions close to the edge of the reconstructed images due to very sparse sampling in those areas. Also, due to very dense sampling in the center, the beam dose there will be much larger than the average, resulting in extra beam damage. Clearly, if uniform sampling distribution is desired, Eq. 4 reveals that we should investigate solutions with *a* = 0.5.

#### Fermat spiral

Here, we use a different spiral with *a* = 0.5 and *b* = 1 to give both uniform sampling and constant angular velocity:

$$x = \sqrt t { \cos }\left( {\omega t} \right),\;y = \sqrt t { \sin }\left( {\omega t} \right)$$

(6)

This spiral has been known as Fermat spiral, which has the more general form *r*
^{2} = *ωt*. Since the square root has two solutions (positive and negative), a natural approach is to use one part as the outward scan and the other as the inward scan. Figure 4a shows how *x* and *y* change as a function of time for the outward scan part. Figure 4b shows the scan path for both outward and inward scans. Note that the end point (A) of the outward scan and the starting point (B) of the inward scan are at opposite sides. Therefore, a smooth wave was added to move the probe from A and B for a smooth transition between outward scan and inward scan. The outward and inward scan paths move clockwise and counter clockwise, respectively. The two reconstructed STEM images are shown in Fig. 4c. Again, the distortion seems to be purely linear due to constant angular velocity. The rotation distortions are opposite as expected from different spiral rotation directions. However, the image quality is not uniform; the edge area is noticeably more blurred than the center area. This non-uniformity is attributed to the anisotropic sample spacing. Near the center area, the spacing between adjacent points along the tangent direction is much shorter than the spacing along radial directions. For the edge area, the spacing along the radial direction is much longer than along the tangential direction. Therefore, despite the nominally uniform areal distribution, the actual sampling is still not ideal.

#### Constant linear velocity spiral

We seek a spiral that retains the constant sampling density, but where the distance between samples is isotropic. The solution is known as a constant linear velocity spiral. From the previous discussion on the physical properties of spirals, the two parameters should satisfy *a* = 0.5 and *a* + *b* = 1. The spiral equation is thus:

$$x = \sqrt t { \cos }\left( {\omega \sqrt t } \right),\;y = \sqrt t { \sin }\left( {\omega \sqrt t } \right)$$

(7)

This spiral has both constant sampling density (dose distribution) and, evenly, isotropic spaced points. A similar scan path was proposed for atomic force microscopy (AFM) [20]. The scan path is shown in Fig. 5a. Examples of the sampling trajectories for both outward and inward scans are shown in Fig. 5b, where we can see that the data points are evenly distributed along both tangential and radial directions.

Experimental images with the constant velocity spiral are shown in Fig. 5c. The outward and inward parts of the scan are displayed separately. Significant distortions are apparent at the center of the images where the scan frequency is changing the fastest. The two images have opposite rotation distortion directions in the center, which result from different spiral rotation directions. Therefore, the drawback of this spiral is that the angular frequency changes. Since the distortions depend on frequency, the disadvantage is that the distortions are non-uniform across a single frame. Another way to look at this problem is that to keep a constant linear velocity, the angular velocity has to be large near the center and smaller at the edges. Thus, the angular distortion changes with angular velocity, which results in much more severe distortions at the center.