Automated serial rotation electron diffraction combined with cluster analysis: an efficient multi-crystal workflow for structure determination

Serial rotation electron diffraction enables fully automated screening and data acquisition on submicrometre-sized crystals using the continuous rotation method via combined image processing and control of the transmission electron microscopy hardware. A data processing pipeline revolving around hierarchical cluster analysis deals with the large multi-crystal data set for phase analysis and structure determination.

cameras. This gives substantial control to design and implement new methods, and lends itself well for software automation. We make use of the fact that the TEM can be switched from image mode to diffraction mode via software. Automated crystal screening is performed in image mode at low magnification, by translating the sample stage in a raster over a large area, whereas data collection and crystal tracking are performed in diffraction mode, making use of the electron beam deflectors and lenses. In this section, we lay out the steps to implement a fully automated method for multicrystal electron diffraction with no human supervision. In principle, no bias is introduced in terms of crystal shape for all the crystals on the grid, so the method is considered to be suitable for both purephase samples and multi-phase samples.

S1.1. Setup
The experiment is implemented on our JEOL JEM-2100-LaB 6 , equipped with a 512 × 512 Timepix hybrid pixel detector (55 × 55 µm pixel size, model QTPX-262k) from ASI. The basic setup for the automatic experiment is to use a small condenser lens aperture. On our TEM, the second smallest condenser lens (physical diameter 50 μm, resulting in an illumination area of 12 μm in diameter when the electron beam is fully spread) is used. In combination with a small spot size (large spot number, 4 or 5 on our microscope) this helps to reduce the intensity of the probe and minimize the convergence angle. In imaging mode, parallel beam illumination is used, but in diffraction mode, the beam brightness (CL3) is tuned to give a probe size of around 1 μm in diameter. The values of the CL3 lens and the corresponding diffraction focus (the intermediate lens, IL1) are recorded. The defocus value should be carefully chosen so that the size of beam in defocused diffraction mode is similar to that in image mode. TEM grid with continuous carbon film (CF400-Cu-UL grids from Electron Microscopy Sciences) is used to avoid any extra confusion for particle recognition algorithm.

S1.2. Deflector and stage calibrations
To track the crystal, the diffraction pattern is defocused at regular intervals. By analyzing the snapshots of the crystal in defocused images, tracking is achieved experimentally by changing the beam shift deflectors (CLA1 in a JEOL TEM), which need to be calibrated in both imaging and diffraction mode to map out the scale and relative angle between the deflector system and the detector coordinate system. To ensure the diffraction pattern is centered, the image shift deflectors are employed (IS1 and IS2 in a JEOL TEM). Because the diffraction patterns in both focused and defocused conditions need to be taken care of, calibrations for the image shift deflectors are done in both focused and defocused conditions, thus resulting in four additional calibration steps. The calibration methods follow the protocol suggested in a previous paper on SerialED (Smeets, Zou et al., 2018), where 25 points of deflector change (in a 5 by 5 grid) and the corresponding images were recorded. The affine transformation matrix describing the relation between the deflector values and pixel coordinates is defined as: where the scales s x and s y , and the rotation angle θ are obtained from a least-squares fitting between the deflector values (X and Y) and the corresponding pixel shifts in x and y direction as observed using cross correlation with a diffraction pattern taken at the central position. In total, five 2 by 2 matrices, 1 (IS1 in focused condition), 2 (IS2 in focused condition), 1 (IS1 in defocused condition), 2 (IS2 in defocused condition), and (CLA1 in focused condition), are obtained and used during the tracking procedure. Beam shift calibration ( ) in real space (i.e. MAG1 mode in a JEOL TEM at 2500) should also be performed.
The stage is calibrated to perform basic centering of interesting particles. The same optimization method is followed by taking a 5 by 5 grid of stage position change under the desired magnification (i.e. 2500), and using cross correlation to map the pixel coordinates to the corresponding stage translations ( ).

S1.3. Crystal screening and detection
For crystal screening and detection, we have adapted the algorithms developed previously (Smeets, Zou et al., 2018). In a SerialED experiment, the sample stage is translated in a raster over a large area (typically several hundreds of micrometres), and at each position of the stage, an image is taken at a low magnification (typically 2500). Crystals are then detected using a local threshold filter, and only isolated crystals are selected. Crystals that are within 1.2 µm from another crystal are discarded, and a centering step is introduced for crystals within 1.2 µm from the edge of the image frame (see Figure 1 & S1). Crystals at the edges are not ideal to work with, because it is unknown what is outside the frame. Therefore, the crystals are first brought to the center of the of the image by stage translation (via ). This also serves to minimize the adjustments to the beam position using the deflectors to stabilize the diffraction patterns.

S1.4. Automatic Z height adjustment
Setting the correct height of the crystal, as defined by Z, minimizes the movement of the crystal during rotation. To automate the height adjustment, an empirical feedback method is used, based on the assumption that the height is already reasonably close to the best value (i.e. up to 10 μm away).
This assumption is usually valid in a sense that the operator performs the routine TEM alignment before starting the automated experiment. Empirically, at the correct Z height, the crystal position (as defined by its pixel coordinates, x and y) should be invariant of the tilt angle. There are a few ways of adjusting the height automatically. We tried the method described in a previous paper (Koster et al., 1992), but it did not work as perfectly as expected. This is because the method requires calculating the displacement of the image over a certain rotation angle (i.e. 10°). Since we set a global rotation speed (0.86°/s) before the experiment and this cannot be changed during the experiment, the whole Z height adjustment process takes very long time since at least 5 points (thus 5 times 10° rotation) need to be sampled. With the existence of backlash in z direction, the accuracy of the outcome is also not satisfactory.
Instead, the software sends a command for the goniometer to tilt to a certain degree (a rotation range of 15° is typically used). Every 2 degrees, an image is recorded and compared to the previous image by calculating the difference in positions of the same particle in both images. From how much the position has changed, a decision of Z height change of 1 μm is made. Z height is adjusted in the way that the movement of the particle is minimized. We are able to achieve similar accuracy for the eucentric height, while the process is much less time-consuming. The height adjustment is made periodically (typically every 10 steps during raster scan) and contributes to improvement of the overall rotation ranges.

S1.5. Crystal rotation and data collection
Stage rotation is also controlled through software. Once a crystal has been identified and centered, the beam is focused on a crystal (with the pre-defined probe size), and the TEM is switched to diffraction mode. When the rotation is initiated, data collection starts with a delay of 0.1 s to avoid any existing backlash and goniometer acceleration in the tilting direction. Backlash may introduce inaccurate readout of the rotation angle, as well as a sudden crystal movement at the very beginning of rotation.
Diffraction data are collected typically with an exposure time of 0.5 s. As described in a previous paper (Cichocka et al., 2018), the diffraction patterns are defocused at regular intervals (defined as a defocusing frequency f defocus , typically every 10 th frame), and an image is taken with a short exposure (typically 0.01 s) to check the crystal position.
Automatic rotation is realized by making use of a tool (Goniotool on a JEOL microscope) that allows us to override the stepping frequency of the motors in the goniometer. In its default state, through the API, the goniometer always rotates at its full speed (~12°/s) to the targeted angle. By reducing the stepping frequency from 12 kHz to 1 kHz (the lowest allowed value), rotation speed can be reduced to 0.86°/s, which is quite suitable for cRED data collection. Slower rotation also decelerates the crystal movement during rotation, which provides certain tolerance for tracking the crystal.
Because the rotation can only operate at a set speed, we take a pragmatic approach to always initiate stage rotation from the current tilt angle ( Figure S5). If the current angle is negative, the target tilt angle is set to 70°, whereas if the rotation is positive, the target angle is set to -70°. Rotation can be interrupted at any time through the JEOLCOM API. This happens when the deflectors hit their limits, or if the crystal moves out of the electron beam.

S1.6. Automatic crystal tracking
The crystal tracking is an essential function for collecting rotation data with high tilt ranges. The defocusing method gives the possibility of chasing the crystal dynamically and tracking the crystal by shifting the electron beam via the beam shift deflectors ( Figure S2). The use of the stage position to track the crystal is not preferred for two reasons. First, mechanical backlash makes it difficult to achieve precise positioning of the stage, especially with frequent translations in the sub-micrometer range, and second, mechanical movement is quite slow. We have tested the piezo-stage to control the stage position, and although it is much more precise, it is even slower and the translation is limited to ± 200 nm. In comparison, repositioning the beam via the deflector system is very precise and almost instantaneous.
First, the pixel coordinates of the crystal and the center of the primary beam should be determined.
Here we did assume that the transformation matrix of beam shift in image mode on the detector is the same as that in defocused diffraction mode, which turned out to be valid as long as the defocus value is correctly chosen during the setup step.
On our microscope, the goniometer system is generally more stable at low tilt angles (i.e. in the range of ± 40°). Therefore, by starting at higher angles that mark the beginning of a rotation experiment, the movement is exaggerated and more frequent tracking of the crystal position may be needed. Part of this can be attributed to the goniometer design, which makes a conical movement during rotation (i.e. the crystal 'swings' around the rotation axis). This prevents eucentric tilting, because the crystal cannot be centered on the rotation axis if it is off the "eucentric height". To get around this, a dynamic tracking algorithm is implemented in the data collection routine. For every focused diffraction pattern, the scale of an image (total intensity over the pixels) is calculated using Equation (s3). Two criteria are employed to verify whether the crystal is still in the electron beam. First, the scale S DP (defined as the total intensity) of every (focused) diffraction pattern is evaluated as: where i and j are the dimensions of the image. If the scale between two subsequent frames changes by more than a threshold value (i.e. ( ) (0) < 0.85, where n is the frame number), this is an indication of the crystal moving out of the beam. In an attempt to prevent this, the defocus frequency is increased to 2, to more frequently apply deflector shifts to track the crystal back with the beam (so-called "robust tracking"). A second criterion is defined as the variance of the defocused diffraction pattern: where ̅ is the average intensity value over the squared image in Figure 2b. Similarly, robust tracking feature is activated when 2 ( ) 2 (0) < 0.5, where n is the frame number. The feature is deactivated after five attempts by resetting S DP (0) and σ 2 defocus (0) values to the current ones, since in some cases the rotated sample causes permanent change of the scale or variance. When the crystal moves out of the beam completely (

S1.7. Descan
Whenever a beam shift ΔBS (ΔBS x , ΔBS y ) is applied, the centers of both the focused and defocused diffraction patterns are also shifted. From the calibration we know that the effect of beam shift on the diffraction pattern pixel shift would be • . The effect on the defocused diffraction pattern pixel shift (ΔDD = (ΔDD x , ΔDD y )) is calculated on-the-fly every time when applying defocus, which is the difference of the pixel positions of the two beam centers in the defocused images in Figure 2a.
A combination of the image shift deflectors (ΔIS1 = (ΔIS1 x , ΔIS1 y ) and ΔIS2 = (ΔIS2 x , ΔIS2 y )) are used to ensure the position of the primary beam is stable, which is an assumption made for data processing in XDS and DIALS. Table S1 Data quality indicators for the cRED data collected on ZSM-5 and indexed in Laue group mmm. A default resolution cut-off of 0.8 Å is used globally for all the data sets. This led to various kinds of data statistics which can be seen in the table. A low I/σ(I) value or CC 1/2 value (usually with high R meas ) suggests that the actual resolution of the data set is lower than 0.8 Å; a low CC 1/2 value can also indicate that rotation range for this particular data set is low, leading to too few indexed reflections to get a statistically significant estimate of CC 1/2 values.

Figure S1
Flowcharts for the multi-crystal data acquisition. (a) Automatic crystal finding in a serial manner. If a suitable, isolated crystal is found, the function for cRED data collection is activated. (b) Automated cRED data collection procedure. Steps performed in focused diffraction condition are shown in purple, while those in defocused condition are shown in green. In the focused condition, the image scale (S DP ) is checked, and in the defocused condition, the image variance (σ2 defocus ) is checked.
If the change (see Eq. s3 & s4) in either parameter is larger than the threshold value, robust tracking (abbreviated as RT in the figure) is activated by setting the defocus frequency to 2. Th1, th2, and th3 are the three threshold numbers set for deciding whether the crystal has moved (partially) out of the electron beam. Typical numbers used are: th1 = 0.15, th2 = 0.5 and th3 = 0.8.

Figure S3
Reflection-based clustering for PCN-416 experiment. The magenta cluster, consisting of 12 single data sets, possessed the best data statistics in terms of data completeness and / value, and thus was used for structure determination and refinement. is that, among all the indexed data sets, 7 data sets could be successfully indexed by both unit cells.
This can be due to the fact that we left the indexing successfully rate to be default (25%) in XDS. By looking at (d), a lot of the data sets are actually far from each other; when we made the cutoff of CC(I)'s to be 92.5% and 88.8% for PST-20 and ZSM-25 as shown in the figures, the circled data sets (No. 22 in b and No. 11 in c) are actually the same data set. We had to decide ourselves that since this data seemed to be more correlated to PST-20 from the dendrogram, it is assigned as a PST-20 data set. Finally ZSM-25 was cut at a lower distance to exclude dataset #11.