The focus of this work is the analysis of atomic resolution STEM-images of perovskite oxides. As mentioned earlier, these materials are in the form of ABO\(_3\). The A-site is a larger cation like strontium or lanthanum, the smaller B-site is typically a transition metal like manganese or titanium, and the O is oxygen. A-site cations are usually the heaviest element in the structure, the B-site cations the second heaviest, and oxygen the lightest. The heterostructures studied were La\(_{0.7}\)Sr\(_{0.3}\)MnO\(_3\) (LSMO) on LaFeO\(_3\) (LFO) on (111)-oriented Nb-doped STO and LSMO on (111)-oriented Nb-doped STO. TEM samples were prepared as thin sections perpendicular to the [1\(\overline{1}\)0]-direction of the STO. Deposition [35, 36] of the films and the preparation of the TEM specimens [37] are described in more detail elsewhere.

An example of a typical STEM image is shown in Fig. 1 (top left). The first aim of the method is to extract the position and shape for all the different atomic columns in these kinds of images. Second, we want to find the relations between the different atomic columns. In essence, the process of fitting one sublattice can be summed up in three steps: (i) Find the positions of all the atomic columns you want to examine. (ii) Refine the positions using center of mass until they are close enough for the 2-D Gaussian fitting to work robustly. (iii) Fit the atomic columns using a 2-D elliptical Gaussian function \(I(x,y)\). This is defined by the following:

$$\begin{aligned} I(x,y)&= I_0 + A\exp {\left( -\left( a(x-x_0)^2-2b(x-x_0) (y-y_0)+c(y-y_0)^2\right) \right) } \nonumber \\ a&= \frac{\cos ^2{\theta }}{2\sigma ^2_x}+\frac{\sin ^2 {\theta }}{2\sigma ^2_y}\nonumber \\ b&= -\frac{\sin {2\theta }}{4\sigma ^2_x}+\frac{\sin {2\theta }}{4\sigma ^2_y}\nonumber \\ c&= \frac{\sin ^2{\theta }}{2\sigma ^2_x}+\frac{\cos ^2 {\theta }}{2\sigma ^2_y} \end{aligned}$$

(1)

where \({I}_0\) is the background, *A* the amplitude, \({x}_0, {y}_0\) the center positions, \(\sigma _x, \sigma _y\) the standard deviations, and \(\theta\) the rotation. The background \(I_0\) is set to the minimum intensity value of the region around the atomic column. This way of setting the background value is easy and robust. However, it has some drawbacks in that a single pixel with low value due to some kind of artefact can lead to the background varying greatly between the different atomic columns. One way of improving this is by having the background as a parameter while fitting the 2-D Gaussians; however, this reduces the robustness as the chance of poor fitting increases. Therefore, in this work, the simpler minimum value method was used, as it worked well in practice. More advanced forms of background subtraction will be implemented in Atomap in the future.

Additional sublattices are found by having *a priori* crystallographic knowledge on where they are located in relation to the first sublattice, as explained below.

### Initial positions and refinements

To exemplify this, we show the procedure to find the positions of all sublattices in an STO crystal projected along the [1\(\overline{1}\)0]-direction. While this demonstrates the use of this method on a specific crystal structure along a specific projection, the software should work for any kind of atomic structure or projection, as long as the atomic columns are clearly resolved. Comments on how to adapt this for other structures and projections are outlined in "Adapting for other structures and projections".

#### A-cations

First, the original ADF image (Fig. 1, top left) is filtered. This involves doing a local averaging, where a Gaussian convolution of the image is made and subtracted from the original image. Next, 1-D PCA [38] denoises the modified image to reduce random noise. The outcome is a filtered ADF image with smaller intensity variations and less noise. The A-cations in the filtered ADF image are located using a peak finding method which finds the most intense local features, where each feature has to be separated by a minimum distance. This filtered ADF image is only used for the initial peak finding, all subsequent position refinement is done using the original, unfiltered, ADF image.

Next, these initial A-cation positions are refined using the original ADF image. This is done by finding the center of mass for a circular area centered at the current position with a radius of 40% of the distance to the closest A-cation neighbor. The result of this refinement is shown in the “A-cation positions” image in Fig. 1. These A-cation positions are used as the initial values for fitting 2-D Gaussians to every A-cation atomic column in the original ADF image.

The refined positions of the A-cations are the input parameters to further study the average 2-D atomic arrangement of the structure. For each A-cation, the distance and direction to the ten nearest neighbors are calculated. Next, using a similar peak finding process as explained earlier, all the repeating nearest neighbors are found. The “Nearest neighbor statistics” to the bottom left in Fig. 1 shows the real space nearest neighbor distance and direction, which gives information similar to an FFT: the average 2-D arrangement of atoms in a small repeating unit of this specific projection of the 3-D crystal structure. Using different planes visible in the image (i.e., perpendicular to the beam direction), atom columns which belong to the same atom planes are grouped. These atom planes are defined in the software by the vector perpendicular to the trace of the plane in the image. Thus, the atom planes shown in Fig. 1 (bottom left) are the (110) atom planes. The traces of these atom planes run in the [001]-direction.

#### B-cations

Fitting Gaussians to the B-cations is more challenging, due to the A-cations being more intense. To get robust fitting of the B-cations, the intensity from the A-cations is removed from the original ADF image before starting the B-cation fitting. This is done by subtracting the 2-D Gaussians fitted to the A-cations. The original ADF image with the A-cations subtracted is shown in the top center of Fig. 1. This leaves the B-cations as the most intense feature in the ADF image.

The initial positions of the B-cation atomic columns are placed between each A-cation pair in the (110) atom planes. This is shown for one A-cation atom plane in Fig. 1 (bottom left), with the B-cation initial positions marked with red circles.

With the initial B-cation positions and the ADF image with the A-cations removed, the B-cation positions are refined using center of mass the same way as for the A-cations. The refined positions are used as the initial values when doing Gaussian fitting for the B-cations. The 2-D repeating units and atomic planes for the B-cations are constructed in the same way as for the A-cations. This process is shown in the middle column of Fig. 1, where the resulting B-cation (001) atom planes are shown.

#### Oxygen

The rightmost column in Fig. 1 shows how the oxygen positions are determined. The oxygen initial positions are placed between each pair of B-cations in the (001) atom planes, shown with the blue circles in the lower center image in Fig. 1. In ADF imaging, the oxygen is much less intense compared to the heavier A and B cations, so ABF imaging is utilized. Such an image is shown to the top right in Fig. 1 (original ABF), which has been acquired simultaneously with the ADF image. In the ABF image, the oxygen is visible, but still the least intense of the atomic columns. Using the initial A and B cation positions from the ADF image, 2-D Gaussians are fitted to the A and B cations in the ABF image and subtracted. The image contrast is further inverted, to create a modified ABF image where the oxygen columns are the most intense features in the image. Using this modified ABF image and the initial oxygen positions, the positions are refined using the center of mass, further refined using 2-D Gaussians, 2-D repeating units found, and the atomic planes constructed.

The end result gives the location of all the atom columns in the image, as shown to the lower right in Fig. 1.

### Finding distances between atomic columns

Having an accurate position for all the atomic columns is the first step toward making measurements of distances between columns or interplanar spacings. Having already grouped the atom columns into atomic planes, it is trivial to find the spacings in the (001)- and (110)-planes. The distances between neighboring atomic columns in the (001)-planes correspond to the (110) interplanar spacing as these are orthogonal (Fig. 2a). Similarly, the interplanar distances for the (110)-planes are found using the distances between the atomic columns in the (001)-planes. The case is less straightforward for (111)-planes, as neighboring atomic columns (of the same cation type) along the orthogonal (11\(\overline{2}\))-plane will be three monolayers apart. The interplanar spacing is the distance between one monolayer and its neighbor. To find this, a line is interpolated through the atomic columns in a (111)-plane. From an atomic column in the neighboring (111)-plane, the shortest distance from the atomic column to this line is found. This is the (111) interplanar spacing at this point, as shown to the bottom right in Fig. 2a. Repeating this for every atomic column and its neighbor atom plane gives a 2-D map of the monolayer distances.

In the perovskites, a common structural change is unit cell doubling along a specific direction as a result of oxygen octahedral tilting [20]. Depending on the tilt pattern, this will result in the oxygen columns shifting. An example of this is shown in Fig. 2b, where there is an obvious oxygen superstructure along the black line signified by alternating distances between the oxygen columns in the [001]-direction. One useful way of quantifying this is finding how much the oxygen atom deviates from the centrosymmetric position in a cubic perovskite structure. This displacement, *D*, is found by determining the distance from an atom to the next (*N*) and the previous (*P*) atoms in the atom plane, and divide the difference (*N*−*P*) by 4. This gives the distance the oxygen atom deviates from a centrosymmetric position, and is shown in the inset in Fig. 2b. For a cubic perovskite structure *D* is 0, while for bulk LFO D is 0.39 Å.

### Atomic column shape

Having fitted every atomic column with an elliptical 2-D Gaussian (Eq. 1) where the rotation of the major axis from the vertical is one of the fit parameters (i.e., the direction of the \(\sigma _{x,y}\) can change), one can extract information about the shape of the atomic column. This shape can reveal information about the structure parallel to the electron beam [19], and, in some materials, the position of light elements using the shape of the heavier atomic columns [13]. With the six parameters defined in Eq. 1, one can use the \(\sigma _x\) and \(\sigma _y\) to calculate the ellipticity for the atomic column which is a measure of how elongated the atomic column is. We define the ellipticity (\(\epsilon\)) as follows:

$$\begin{aligned} \epsilon = {\left\{ \begin{array}{ll} \frac{\sigma _x}{\sigma _y}, \quad \text {if } \sigma _x > \sigma _y\\ \frac{\sigma _y}{\sigma _x}, \quad \text {if } \sigma _y > \sigma _x\\ \end{array}\right. } \end{aligned}$$

(2)

giving an \(\epsilon\) which is always greater or equal to 1. An \(\epsilon\) of 1 would be a perfectly circular atomic column, while \(\epsilon =2\) is an atomic column where one side is twice as long as the other side.

Similarly, one can use \(\theta\) to find the direction of the ellipticity. We define this direction as \(\rho,\)

$$\begin{aligned} \rho = {\left\{ \begin{array}{ll} \theta , \quad &\text {if } \sigma _x > \sigma _y\\ \theta +\frac{\pi }{2}, \quad &\text {if } \sigma _y > \sigma _x\\ \end{array}\right. } \end{aligned}$$

(3)

which means that \(\rho\) will be the angle between the positive x-axis and the longest \(\sigma\). In addition, \(\rho\) will always be between 0 and \(\pi\) due to the symmetry of the 2-D Gaussian.

### The software implementation

This program is implemented in the Python (3.x) programming language, and both the source code and instructions on how to install it is available at http://atomap.org. It relies heavily on the fitting and modelling routines implemented in HyperSpy [39]. Currently, the program is optimized for analysing STEM-images of perovskite oxide materials projected along a \(\langle110\rangle\) direction. However, it is trivial to adapt it for any structure as discussed below in "Adapting for other structures and projections". Extending the code should be easy, and requests for both new features and assistance in adapting for other structures are welcome on the issue tracker (linked from http://atomap.org/) or by e-mail to the corresponding author. The software and source code are distributed under the free and open source GNU General Public License v3.0.

The program is sorted into several classes: **atom_position**, **atom_plane**, **sublattice**, and **atom_lattice**. **atom_position** is the position of a single atomic column, and contains variables like position, \(\sigma\), \(\theta\), and other information about the shape of the atomic column. **atom_plane** contains all the **atom_positions** which belong to the same atomic plane. **sublattice** contains all the **atom_positions** and **atom_planes** belonging to the same sublattice, like the A-cations in Fig. 1. **atom_lattice** contains all the **sublattices**, so in Fig. 1, this would include the A-cations, B-cations, and oxygen sublattices. The **atom_lattice** class can be saved and loaded, saving all the **atom_position** parameters.

One current limitation is that the whole image given to the program must have a similar crystal structure. For example, a perovskite heterostructure shown in Figs. 4, 5, and 6 works fine, due to the structures being sufficiently similar. A perovskite oxide film grown on Si would, however, not work. Similarly, if there are any amorphous parts in the image, local bright features could be identified as atomic positions by the peak finding function. One simple solution is to crop the images, so only the same crystal structure is within the image given to the program. This could probably be automated, which would allow for automatic determination of regions with different structures. For example, in an aluminum alloy, one would be able to automatically figure out which regions are aluminum matrix and which are precipitates.

When fitting a single sublattice, the fitting is done on individual atomic column using a single 2D Gaussian. One obvious improvement would be to make a model containing all the atomic columns, and fitting them all simultaneously. While this is more computationally demanding, it could reduce the effects from neighboring atomic columns and, therefore, increase the accuracy of the fitting. The amount of improvement would be related to the degree of overlap between the atomic columns. With a very large separation between the atomic columns, this improvement would be zero or very small. With a very small separation, this improvement would be substantial. Quantifying the limits of fitting a single atomic column vs. including the neighboring atomic columns is interesting, but outside the scope of this work as the separation between the atomic columns was sufficiently large.

Atomap implements a version of this by removing the most intense sublattice before fitting the less intense sublattices. This is equivalent to having a model where the most intense atomic columns are fitted first, then locked, and afterwards fitting the second most intense atomic columns. Fitting 2D Gaussians to all atomic columns in a data set simultaneously will be experimented with in Atomap in the near future, using the aforementioned process to find reasonable initial values first.

### Adapting for other structures and projections

The first step in using the program is finding a value for the smallest atomic separation for the first sublattice. It is important to find a good value for this variable, as having either too many or too few atoms in the first sublattice will lead to the wrong repeating unit being identified. This then results in incorrect identification of the sublattice. In the example, discussed in "Initial positions and refinements", this value is half the separation between the A-cations in the [1\(\overline{1}\)0]-direction. The projected (110) spacing is 2.76 Å for STO. However, half the value (1.38 Å) did not work very well, which is caused by the scanning distortions and sample drift during image acquisition. By trial and error, a value slightly less than half the smallest separation was found to work reliably. For the STO in Fig. 1: approximately 1.3 Å. This value is used for the atom column separation in the peak finding function. For only fitting a single sublattice, this will be enough for the program to work.

Finding a second sublattice requires some *a priori* knowledge. For a perovskite oxide in the [1\(\overline{1}\)0]-projection (Fig. 1), one would specify that the atoms in the second sublattice are found between the atom columns in the (110)-atomic planes for the first sublattice.

These procedures are documented on the webpage (http://atomap.org/).