Effective Pattern Intensity Artifacts Treatment for Electron Diffractive Imaging

We present a method to treat spurious intensities in electron diffraction experiments. Coherent electron diffraction imaging requires proper data reduction before the application of phase retrieval algorithms. The presence of spurious intensities in the electron diffraction patterns makes the data reduction complicated and time consuming and jeopardizes the application of mathematical constraints to maximize the information that can be extracted from the experimental data. Here we show how the experimental diffraction patterns can be treated to remove the unwanted artifacts without corrupting the genuine intensities scattered by the specimen. The resulting diffraction patterns are suitable for the application of further processes and constraints aimed at deriving fundamental structural information by applying phase retrieval algorithms or other approaches capable of deriving quantitative atomic resolution information about the specimen structure.


Introduction
Transmission Electron Microscopy (TEM) is widely used to investigate the properties of matter at atomic resolution [1,2].The ultimate resolution of a TEM experiment is limited by the aberrations of the electron lenses that only recently have been successfully partially compensated, by using computer assisted magnetic multipole correctors, pushing the resolution of High Resolution TEM (HRTEM) experiments to about 50 pm, but not yet achieving the diffraction limit [3,4].Since the work of Scherzer in 1936 [5], the need to overcome the resolution limits has led to the development of new methods capable of retrieving the specimen properties at better resolution despite the aberrations.The invention of electron holography by Dennis Gabor, for example, was one of these attempts [6].In addition, the exit wave reconstruction method was developed for this purpose [7].Recently, coherent Electron Diffractive Imaging (EDI) has demonstrated the best performances in improving the resolution of TEM imaging experiments [8][9][10], achieving a resolution of 70 pm in non-aberration corrected equipment, and revealing fundamental material properties not detectable in the relevant HRTEM experiments [10].EDI is theoretically based on the sampling theorem of Shannon [11] and requires the acquisition of the diffraction pattern at least at the Nyquist's frequency [12].The phase of the scattered waves is recovered by using iterative Fast Fourier Transform (FFT) algorithms that relates information available in the object domain, where the knowledge about the object support from the standard HRTEM is applied, to that available in the Fourier domain, where the known data are the intensities measured in the diffraction experiment [13].On the other hand, the capability of retrieving the phase in EDI experiments also requires a not obvious data reduction before the phasing algorithm can be applied [14], requiring also the handling of the diffraction pattern that has to be properly scaled and accurately rotated to be combined with the FFT of the relevant HRTEM image [10].This latter process is necessary to make data acquired in the direct space and in the reciprocal space compatible in magnification and rotation.In general, the magnification and the rotation between data in direct and reciprocal spaces, even if acquired in sequence on the same specimen illuminated area, are different due to the different setup of the TEM lenses in the projection system used to conjugate the image plane or the back focal plane, respectively, of the objective lens to the detector [1].Furthermore, the diffraction pattern exhibits the presence of spurious intensities due to experimental limitations related to the shutter of the equipment, to the detector itself [15], and to the very high intensity of the direct beam and of some of the strongest diffracted beams [1].The presence of spurious intensities in the diffraction pattern jeopardizes the data reduction and makes this process extremely time consuming and skill dependent, practically hindering the diffusion of EDI as a method for the study of matter.Indeed, spurious intensities in some cases are comparable with the weakest genuine diffracted intensities, which are often those carrying information at the highest spatial resolution.The capability to correct the spurious intensities in the diffraction pattern, without corrupting the experimental diffracted weak peaks, opens the application of EDI to derive more accurate structural information.In general, the need of methods for the correction of the artifacts in the electron diffraction pattern is well known [15].So far the problem, to our knowledge, has been tackled by trying to improve the signal or reducing the noise of a specific experimental intensity, or sets of experimental intensities, and not also by removing the presence of spurious intensities, as we do in the present work, to improve the overall experimental data and hence enable the application of new methods of quantitative data treatment to the whole diffraction pattern.Here, we show how the spurious intensities in electron diffraction patterns can be treated on synthetic and experimental data without affecting the genuine diffracted intensities, enabling a reliable phase retrieval process.Furthermore, we show how the intensity artifacts' removal is also a prerequisite that enables us to further process the electron diffraction data, making it possible to extract structural information otherwise buried in the data corrupted by spurious signals.

Results: Correction of the Electron Diffraction Intensity Artifacts
The first step in the artifacts' removal is the understanding of their origin to design a procedure that is able to remove them without affecting the completeness of the information.From the experimental evidence, the artifacts can be divided in different classes: parasitic intensity stripes [16], irregularities in the background due to wrong online dark-count subtraction procedures, corrupted detector areas, extra counts due to cosmic rays, memory effects in the detector, etc.Each class needs a suitable procedure either to remove the artifacts from the acquired ED patterns or to compensate for the eventual lack of data.It is worthwhile to remark here that, even if in some cases the experimental data could be ameliorated by a new acquisition, i.e., the data could be acquired again with a better background subtraction, the acquisition time could be changed to reduce the parasitic stripes, the memory effects can be cancelled by exposing the detector to an even illumination, the detector could be replaced, etc..In other cases this could be not possible because the specimen area could have been damaged by the first acquisition, as is the case for radiation sensitive specimens [17], or because it could have been contaminated, etc.The procedures developed here aim to apply EDI not only to the academic case study of the best experiment made on the best ultra-thin TEM specimen but, more generally, to a standard EDI experiment from standard good quality experimental electron diffraction data available from standard good quality specimens.

Basic Procedures
Before starting any artifact removal procedure, two basic algorithms have been developed in order to prepare the raw data for the next steps: (1) a preliminary basic procedure for merging multiple ED acquisitions from the same region of interest and (2) a procedure for centering the direct beam of the diffraction pattern on the center of the relevant frame.

Multiple Acquisitions
To measure the diffraction intensity for EDI it would be helpful, even if not strictly necessary, to measure not only the intensity around the Bragg peaks but also in between the peaks [10,18] where the detector counts are orders of magnitude lower than in the most intense peaks.A long acquisition time, necessary to have data reliable in between the peaks would saturate the detector on the most intense peak.A way to overcome this inconvenience is to make multiple acquisitions.Each acquisition uses the entire available detector dynamic range to reliably measure the most intense peak.At the end, all of the diffraction patterns, which depending on the experiment could be some units or tens or hundreds, are summed together increasing the signal-to-noise-ratio (SNR) especially on the measurable weaker intensities, compatibly with the maximum dose that the sample can bear before eventual damage.Unfortunately the whole acquisition process is blind, and in comparing the first to the last acquisition we could detect some variations that could be due either to small changes in the electron lens currents, in the accelerating voltage, in the drift of the detector, and/or of the specimen and of the electron illumination [19].The first two variations would produce a small change in the size of the pattern or a small rotation, whereas the detector drift would produce a rigid shift of the whole pattern.The specimen or beam drifts could be more insidious.Indeed, if the experiment were performed on an isolated nano-particle, the drift would change the illuminated area.This is a slow process and eventually, after several diffraction measurements, each performed with an exposure of some milliseconds, the data could become no longer representative of the nano-particle under investigation.Furthermore, if the illuminated area is self-confined, as in the case of the Keyhole EDI (KEDI) experiment [18], it could be more difficult to detect the drift.Nevertheless, the pattern could change either in the diffracted intensity, if the new illuminated area is characterized by a local different thickness, or in the whole symmetry, if the new illuminated region has an orientation slightly different with respect to the primary beam direction.Hence, it is necessary to analyze each pattern of the series, cross-correlating it to the first pattern, to decide if it should be discarded or eventually summed to the others.To this aim, a procedure based on image co-registration applied to the set of electron diffraction patterns has been developed.The co-registration of images is the process of geometrically aligning two or more images to integrate or fuse corresponding pixels that represent the same objects [20].A co-registration procedure, based on a metric optimization (cross-correlation (CC) or root mean squared error (RMSE)), is applied to the series.If n is the number of the available patterns, the first acquired pattern, P r , is used as a reference, so the others are P i , with i = 1, . . ., n−1, and are transformed into its coordinate system.Iteratively each P i is shifted and/or rotated in the frame, by means of rigid or affine transformations, and the gray scale values of pixels are compared with the corresponding ones of P r ; then either the cross-correlation or the RMSE between the two patterns, used as a similarity measure, is evaluated.The iterations are stopped when the maximum correlation (minimum RMSE) between each P i and P r is reached.However, a preliminary selection of the patterns used for the co-registration procedure, which takes into account the eventual drift of the samples, is needed.For example, when the pattern has a different symmetry revealing a drift on a tilted area, it is automatically excluded from the averaging.This process is based on the comparison of the position of the most intense peak among the different patterns of the buffer and the observation of the symmetry conservation of the whole pattern.Only the patterns revealing the same whole symmetry are selected for averaging.The resultant intensity is calculated as the geometric mean of the intensities of the selected co-registered patterns.We used the geometric mean instead of the arithmetic mean for the specific features of the patterns to be averaged.In fact, in each acquisition the intensities in the peaks are practically the same, whereas a relatively large variation can occur between the Bragg peaks due to the noise.In the case of strong differences between the averaged numbers, the geometric mean value is always smaller than the arithmetic one.Thus, the effect of the geometric mean is to minimize the strong variations, and hence the noise, leaving the diffracted intensities practically unaltered.Figure 1 shows a comparison between a single acquisition of an ED pattern and the pattern after combining multiple acquisitions.As a result, in this example, the multiple-acquisition ED pattern has a SNR increment of about 40%.shows a comparison between a single acquisition of an ED pattern and the pattern after combining multiple acquisitions.As a result, in this example, the multiple-acquisition ED pattern has a SNR increment of about 40%.

Centering of the Diffraction Pattern
The knowledge of the direct beam position in the ED pattern is necessary for some artifact removal methods and for the application of any phasing algorithm [10].In an experimental diffraction pattern, the direct beam position could not correspond to the center of the frame.Hence, we have developed a procedure to evaluate the direct beam spot and to make it the center of the frame.The function is based on the identification of the direct beam by at least two Friedel's pairs, calculating the center of mass of each selected spot and finding the direct beam position as the relevant inversion symmetry center.Finally, the pattern is rigidly shifted to position the direct beam in the center of the diffraction frame.In most cases, if the diffraction pattern has been collected

Centering of the Diffraction Pattern
The knowledge of the direct beam position in the ED pattern is necessary for some artifact removal methods and for the application of any phasing algorithm [10].In an experimental diffraction pattern, the direct beam position could not correspond to the center of the frame.Hence, we have developed a procedure to evaluate the direct beam spot and to make it the center of the frame.The function is based on the identification of the direct beam by at least two Friedel's pairs, calculating the center of mass of each selected spot and finding the direct beam position as the relevant inversion symmetry center.Finally, the pattern is rigidly shifted to position the direct beam in the center of the diffraction frame.In most cases, if the diffraction pattern has been collected without the use of the beam stopper, as it occurs in the KEDI experiment [18], the direct spot corresponds to the most intense peak of the pattern.
In some cases, dynamical effects can generate diffraction peaks with intensities comparable with the direct peak, making insidious the identification of the direct spot position.It is hence convenient to acquire during the experiments a pattern in which the direct beam can be unambiguously determined and used for the ex-situ centering procedure.

Parasitic Stripes Removal
ED patterns, in particular for EDI experiments, frequently show intensity stripes in correspondence of the most intense peaks.These stripes are a consequence of detector memory effects and blooming during the acquisition of the pattern and of the type of shutter used for its acquisition [21].The presence of stripes from the top to the bottom of the ED pattern, and some oblique stripes originating mainly from the direct beam can be observed (see Figure 2).In any case, even if the origin of these stripes is different, it is possible to develop a method capable of eliminating both artifacts.These kinds of artifacts are particularly evident when the exposure time is very short and the signal intensity in some part of the pattern is very low.This is a condition always encountered in EDI experiments.From the statistical analysis of several diffraction patterns, we noted that the stripe intensity is very often proportional to the one of the corresponding peak.The residual parasitic stripes, affecting the whole detector from top to bottom, are almost constant in intensity in the region above the relevant diffraction peak, whereas they decay exponentially in the region below the peak.Instead, the oblique stripes are almost constant in intensity starting from the center of the transmitted beam.Indeed, the origin of these stripes is multicomponent and it depends on several physical and instrumental reasons related to the sensitivity of the CCD array and to the high intensity in some of the diffracted spots.The first process to be considered is called smearing/blooming and it is caused by excess charge spilling over into vertical transfer register from a given pixel during the CCD readout [21].The behavior of this intensity is decreasing going from the position of the intense spot to the border of the diffraction pattern.Moreover, there are also other reasons for the formation of intensity stripes related to the way in which the beam is blanked before to align it with the electron optical axis of the instruments for its acquisition.In a normal acquisition of a diffraction pattern in our equipment, the beam is first blanked and then swiped electrically to its centre.This intensity partially overlaps to the stripes formed by the blooming effect; this is why the vertical stripes have an half component almost constant from the top up to the middle of the pattern, where the beam is swiped overlapping the blooming intensity; the stripes in the other half, from the centre to the bottom of the pattern, are decreasing, since only the presence of the smearing/blooming effect is present.To decrease the intensity in the vertical stripes, there is the option to delay the exposure of an amount of time after the centering of the beam, which can be chosen in the setup of the CCD camera, by blanking the beam before the exposure.On the other hand, this process introduces the oblique stripe of constant intensity visible in Figure 2a.Both the stripes can be successfully treated with the method proposed in the paper.It is worthwhile to remark that each spot generates a stripe but only the most intense ones affect an accurate measure of the diffracted intensities, as the stripes generated by low intensity peaks are buried in the background.Given the peculiar genesis of these parasitic stripes, due to a swipe of the pattern related to the shutter of the camera and to blooming, a new general method for their removal has been developed.The basic idea is that such stripes could be compared to those generated by the motion blur in photography.This effect is determined by a flaw of definition of an image due to either the camera shake or to the movement of the focused subjects during the exposure time.In general, a motion blur occurs when there is a relative motion between the camera and subject during exposure.Applying this idea to the measured ED patterns, we assumed that a relative motion between the pattern and the detector occurs during acquisition of the experimental data.Such a movement determines the possible presence of the parasitic vertical and oblique stripes.Higher intensity peaks generate higher intensity stripes.The motion blur model has been used to implement a deconvolution algorithm to remove stripe artifacts, leaving the diffraction peaks unchanged.The effectiveness of the approach has been first tested on synthetic data, and then applied on experimental data.
remove stripe artifacts, leaving the diffraction peaks unchanged.The effectiveness of the approach has been first tested on synthetic data, and then applied on experimental data.

Synthetic Data
At first, the validity of our approach has been checked on simulated data, generating a synthetic 512 × 512 diffraction pattern containing intensity stripes similar, in intensity and shape, to those experimentally observed (Figure 3).For the sake of simplicity, we generated five Gaussian peaks with different intensities affected by noise following a Poisson's distribution.The central peak has an intensity of about 10% higher than the other peaks, resembling the stripe usually generated by the transmitted beam in the experimental patterns.Moreover, we added a Gaussian background in correspondence of the peaks, in order to simulate both the diffuse scattering of an eventual amorphous surface layer and the inelastic scattering contribution of a real experimental ED pattern.The effect of the parasitic stripes has been simulated by a convolution between the ideal pattern and a Point Spread Function (PSF) as shown in Figure 3.

Synthetic Data
At first, the validity of our approach has been checked on simulated data, generating a synthetic 512 × 512 diffraction pattern containing intensity stripes similar, in intensity and shape, to those experimentally observed (Figure 3).For the sake of simplicity, we generated five Gaussian peaks with different intensities affected by noise following a Poisson's distribution.The central peak has an intensity of about 10% higher than the other peaks, resembling the stripe usually generated by the transmitted beam in the experimental patterns.Moreover, we added a Gaussian background in correspondence of the peaks, in order to simulate both the diffuse scattering of an eventual amorphous surface layer and the inelastic scattering contribution of a real experimental ED pattern.The effect of the parasitic stripes has been simulated by a convolution between the ideal pattern and a Point Spread Function (PSF) as shown in Figure 3. remove stripe artifacts, leaving the diffraction peaks unchanged.The effectiveness of the approach has been first tested on synthetic data, and then applied on experimental data.Vertical and oblique stripes are visible in correspondence of the most intense peaks.

Synthetic Data
At first, the validity of our approach has been checked on simulated data, generating a synthetic 512 × 512 diffraction pattern containing intensity stripes similar, in intensity and shape, to those experimentally observed (Figure 3).For the sake of simplicity, we generated five Gaussian peaks with different intensities affected by noise following a Poisson's distribution.The central peak has an intensity of about 10% higher than the other peaks, resembling the stripe usually generated by the transmitted beam in the experimental patterns.Moreover, we added a Gaussian background in correspondence of the peaks, in order to simulate both the diffuse scattering of an eventual amorphous surface layer and the inelastic scattering contribution of a real experimental ED pattern.The effect of the parasitic stripes has been simulated by a convolution between the ideal pattern and a Point Spread Function (PSF) as shown in Figure 3. Let I be the ideal ED pattern intensity and N be the noise, then the simulated ED pattern P can be written as: where "⊗" denotes the convolution product.The PSF has been estimated by fitting the vertical intensity profile corresponding to the most intense spot [22].Let us define this value as PSF es (estimated), and PSF id (ideal), the latter being the PSF that enables the better intensity stripe removal.In order to obtain the ideal ED pattern I, the Lucy-Richardson (LR) deconvolution algorithm [23,24] has been applied on P. Nevertheless, the stripe artifacts have not been completely removed, but only partially reduced in intensity even by increasing the number of LR algorithm iterations.We found that this lack of efficiency is due to an incorrect estimation of the whole PSF from the simulated pattern P.
The simulations show that PSF id is obtained from PSF es corrected by a multiplicative factor k (with k ≥ 1) (Figure 4): where i is the pixel coordinate along the vertical axis and m is the pixel vertical coordinate of the peak (see Figure 4).This multiplicative factor k is necessary because of the lack of knowledge of the intensity of the PSF in correspondence of the spot in the simulated pattern P, where the PSF intensity is convolved with the intensity of the spot.The suitable k factor is retrieved iteratively starting from k = 1 and increasing its value of one unit at each iteration after the comparison between the PSF id and PSF es .We used the cross-correlation (CC) as the error metric to compare the two PSFs: while CC increases, the k value is changed; when CC reaches the maximum, the increase of the k value is stopped.With this procedure, we correctly estimated the PSF and, after a relatively small number of LR iterations (generally 10 is enough), the ideal pattern I has been properly retrieved, as shown in Figure 5.These are the spot intensities before adding the intensity stripes, demonstrating how on the synthetic data the procedure is capable of removing the parasitic stripes leaving the signal in the spots unaltered.Let I be the ideal ED pattern intensity and N be the noise, then the simulated ED pattern P can be written as: where "⊗" denotes the convolution product.The PSF has been estimated by fitting the vertical intensity profile corresponding to the most intense spot [22].Let us define this value as PSFes (estimated), and PSFid (ideal), the latter being the PSF that enables the better intensity stripe removal.
In order to obtain the ideal ED pattern I, the Lucy-Richardson (LR) deconvolution algorithm [23,24] has been applied on P. Nevertheless, the stripe artifacts have not been completely removed, but only partially reduced in intensity even by increasing the number of LR algorithm iterations.We found that this lack of efficiency is due to an incorrect estimation of the whole PSF from the simulated pattern P.
The simulations show that PSFid is obtained from PSFes corrected by a multiplicative factor k (with k ≥ 1) (Figure 4): where i is the pixel coordinate along the vertical axis and m is the pixel vertical coordinate of the peak (see Figure 4).This multiplicative factor k is necessary because of the lack of knowledge of the intensity of the PSF in correspondence of the spot in the simulated pattern P, where the PSF intensity is convolved with the intensity of the spot.The suitable k factor is retrieved iteratively starting from k = 1 and increasing its value of one unit at each iteration after the comparison between the PSFid and PSFes.We used the cross-correlation (CC) as the error metric to compare the two PSFs: while CC increases, the k value is changed; when CC reaches the maximum, the increase of the k value is stopped.With this procedure, we correctly estimated the PSF and, after a relatively small number of LR iterations (generally 10 is enough), the ideal pattern I has been properly retrieved, as shown in Figure 5.These are the spot intensities before adding the intensity stripes, demonstrating how on the synthetic data the procedure is capable of removing the parasitic stripes leaving the signal in the spots unaltered.

Examples on Experimental Data
We named the procedure for the correction of the parasitic stripe intensities on the experimental pattern as Stripe Removal.It is based on the following main steps: i.
shifting of the ED pattern to the center of the reference frame (see Section 2.1.2);ii.
selection and masking of the diffraction peaks to preserve their intensities; iii.
LR deconvolution procedure with a fixed or variable number of iterations.
To estimate the shape of the PSF to be used for deconvolution, both for the vertical and oblique stripes, it is mandatory to center the pattern.We estimated different PSFs, one for the vertical stripes and another for the oblique stripes.The evaluation was done by considering the stripe profile associated to the most intense peak and assuming a uniform motion blur (same stripe profile) for all the other diffraction peaks of the same kind.Different from the synthetic case, where the ideal PSF is known, here the LR algorithm is applied iteratively by increasing the k value at each run until the stripe intensities are minimized.Iterations stop by monitoring a Figure of Merit (FoM), which is defined as the standard deviation of the strongest artifact intensity signal.In image processing, the standard deviation measures how much variation exists from the mean.A low standard deviation indicates that the data tend to be very close to the mean, for example for a low noise level.Any structure of the image increases the standard deviation.Therefore, a spurious signal, such as an intensity stripe over the background, will cause a larger standard deviation with respect to the value corresponding only to the presence of the noise.Thus, minimizing the local image standard deviation (FoM), where the intensities are affected by the presence of structured artifacts, is the way to verify if they have been removed.To this aim, we selected an area on the more intense artifact stripe, far from the diffraction peaks, to evaluate the artifact intensity with respect to the surrounding background.Since the artifact is one-dimensional, in order to define the area where the image standard deviation is evaluated, it is sufficient to calculate the FoM on a linear region about five times larger than the transversal size of the most intense stripe.Nevertheless, to reduce the noise influence on the calculated FoM value, it can be considered a rectangular area with a horizontal size as above and a vertical size of about 10 pixels.We assume that when the artifact is partially or completely removed, the FoM is at a minimum, meaning that the artifact has been reduced to an intensity comparable with that of the background.Figure 6 shows some examples of the results obtained by the Stripe Removal procedure on the experimental data: the acquired ED patterns are reported on the left panels and the restored patterns on the right panels.In order to highlight the

Examples on Experimental Data
We named the procedure for the correction of the parasitic stripe intensities on the experimental pattern as Stripe Removal.It is based on the following main steps: i.
shifting of the ED pattern to the center of the reference frame (see Section 2.1.2);ii.
selection and masking of the diffraction peaks to preserve their intensities; iii.
LR deconvolution procedure with a fixed or variable number of iterations.
To estimate the shape of the PSF to be used for deconvolution, both for the vertical and oblique stripes, it is mandatory to center the pattern.We estimated different PSFs, one for the vertical stripes and another for the oblique stripes.The evaluation was done by considering the stripe profile associated to the most intense peak and assuming a uniform motion blur (same stripe profile) for all the other diffraction peaks of the same kind.Different from the synthetic case, where the ideal PSF is known, here the LR algorithm is applied iteratively by increasing the k value at each run until the stripe intensities are minimized.Iterations stop by monitoring a Figure of Merit (FoM), which is defined as the standard deviation of the strongest artifact intensity signal.In image processing, the standard deviation measures how much variation exists from the mean.A low standard deviation indicates that the data tend to be very close to the mean, for example for a low noise level.Any structure of the image increases the standard deviation.Therefore, a spurious signal, such as an intensity stripe over the background, will cause a larger standard deviation with respect to the value corresponding only to the presence of the noise.Thus, minimizing the local image standard deviation (FoM), where the intensities are affected by the presence of structured artifacts, is the way to verify if they have been removed.To this aim, we selected an area on the more intense artifact stripe, far from the diffraction peaks, to evaluate the artifact intensity with respect to the surrounding background.Since the artifact is one-dimensional, in order to define the area where the image standard deviation is evaluated, it is sufficient to calculate the FoM on a linear region about five times larger than the transversal size of the most intense stripe.Nevertheless, to reduce the noise influence on the calculated FoM value, it can be considered a rectangular area with a horizontal size as above and a vertical size of about 10 pixels.We assume that when the artifact is partially or completely removed, the FoM is at a minimum, meaning that the artifact has been reduced to an intensity comparable with that of the background.Figure 6 Crystals 2017, 7, 186 9 of 16 shows some examples of the results obtained by the Stripe Removal procedure on the experimental data: the acquired ED patterns are reported on the left panels and the restored patterns on the right panels.In order to highlight the artifact visibility, a logarithmic contrast window has been used.The profiles in the insets of Figure 6 highlight that, before the application of the Stripe Removal algorithm, the low-signal diffracted peaks are almost hidden by the intensity stripes, whereas they are completely restored after the procedure.Our tests indicate that the Stripe Removal procedure is conservative, as we did not observe any alteration of the peak shape on the most intense peaks.In order to evaluate the performance of the Stripe Removal procedure, we used the SNR, defined as SNR = CNR√Npix, where Npix is the number of pixels belonging to the artifact and CNR (Contrast to Noise Ratio [25,26]) is  Our tests indicate that the Stripe Removal procedure is conservative, as we did not observe any alteration of the peak shape on the most intense peaks.In order to evaluate the performance of the Stripe Removal procedure, we used the SNR, defined as SNR = CNR √ N pix , where N pix is the number of pixels belonging to the artifact and CNR (Contrast to Noise Ratio [25,26]) is Here <I ob > and <I bk > (σ ob and σ bk ) are the mean intensity (standard deviation) values of the artifact signal and of the background, respectively.To check if the artifact is still visible after restoration, we applied the Rose criterion [27] SNR > 4, choosing an area of N pix = 900 containing the artifact signal.After the restoration, the Rose criterion was never satisfied, meaning that the artifact is no longer visible and is indistinguishable from the background.Eventual residual artifacts are still visible only in very high-contrast display conditions.An example of the outcome of the Stripe Removal procedure is shown in Figure 7a.The plot shows a comparison between the intensity of the artifacts before (blue line) and after the restoring procedure (red dotted line).This plot demonstrates that after the application of the algorithm, the stripe artifact is almost fully removed.Moreover, in Figure 7b we have compared the shape and the intensity of the most intense peak of the pattern of Figure 6c with that of the pattern of Figure 6d.Let us note that after the restoration, the peak shape is unchanged but, as an effect of the deconvolution, the intensity is increased, as shown in the zoom of the plot on the bottom left of Figure 7.This means that the algorithm also increases the overall SNR of the pattern, leaving the original shape of the peaks unchanged.
Crystals 2017, 7, 186 10 of 16 After the restoration, the Rose criterion was never satisfied, meaning that the artifact is no longer visible and is indistinguishable from the background.Eventual residual artifacts are still visible only in very high-contrast display conditions.An example of the outcome of the Stripe Removal procedure is shown in Figure 7a.The plot shows a comparison between the intensity of the artifacts before (blue line) and after the restoring procedure (red dotted line).This plot demonstrates that after the application of the algorithm, the stripe artifact is almost fully removed.Moreover, in Figure 7b we have compared the shape and the intensity of the most intense peak of the pattern of Figure 6c with that of the pattern of Figure 6d.Let us note that after the restoration, the peak shape is unchanged but, as an effect of the deconvolution, the intensity is increased, as shown in the zoom of the plot on the bottom left of Figure 7.This means that the algorithm also increases the overall SNR of the pattern, leaving the original shape of the peaks unchanged.

Irregular Background Compensation
In some experimental patterns, we observed that an incorrect on-line dark-current subtraction produces an inhomogeneous diffraction pattern background.This kind of artifact has been removed using a set of functions named Background Restoration.The procedure is summarized as follows: i.
Evaluates the background intensity on the border of the pattern, in an area free from diffracted spots; ii.
Determines the presence of eventual structures indicating an anomaly in the background and extracts a function describing the structure of these anomalies; iii.
Applies a correction to compensate either irregularities or intensity spikes in the background.
The procedure corrects the background anisotropy without influencing the diffraction peak intensities.In fact, although the background compensation is applied to the whole pattern, the impact on the peaks is negligible, as shown in Figure 8.An example of a pattern affected by an

Irregular Background Compensation
In some experimental patterns, we observed that an incorrect on-line dark-current subtraction produces an inhomogeneous diffraction pattern background.This kind of artifact has been removed using a set of functions named Background Restoration.The procedure is summarized as follows: i.
Evaluates the background intensity on the border of the pattern, in an area free from diffracted spots; ii.
Determines the presence of eventual structures indicating an anomaly in the background and extracts a function describing the structure of these anomalies; iii.
Applies a correction to compensate either irregularities or intensity spikes in the background.
The procedure corrects the background anisotropy without influencing the diffraction peak intensities.In fact, although the background compensation is applied to the whole pattern, the impact on the peaks is negligible, as shown in Figure 8.An example of a pattern affected by an irregular background is reported here (horizontal bands in Figure 8a,c).The pattern area marked by the white square has been zoomed in on Figure 8c for ease of visibility.In order to highlight the eventual inhomogeneities, we used a very narrow contrast window in logarithmic scale.Figure 8b and the corresponding zoomed area in Figure 8d show that the Background Restoration procedure leaves peaks unchanged, while the background has been almost fully restored.

Corrupted Detector Areas Correction
The presence of damaged areas in the detector is a common problem that can occur so that the manufacturer usually provide a specific tool to identify the damaged area and to compensate the lack of information in a specific pixel by, for example, replacing the pixel value with the average value of the surrounding pixels.Nevertheless, the presence of temporary accidental malfunctions of some detector areas have been observed.If the corrupted area does not affect the diffracted peaks, it is useful to correct the pattern by properly removing the damaged areas.The procedure is based on the replacement of the relevant pixels with random intensity values extracted in a reference area where the background is regular.The function, named Damaged Pixels Restoration, corrects the

Corrupted Detector Areas Correction
The presence of damaged areas in the detector is a common problem that can occur so that the manufacturer usually provide a specific tool to identify the damaged area and to compensate the lack of information in a specific pixel by, for example, replacing the pixel value with the average value of the surrounding pixels.Nevertheless, the presence of temporary accidental malfunctions of some detector areas have been observed.If the corrupted area does not affect the diffracted peaks, it is useful to correct the pattern by properly removing the damaged areas.The procedure is based on the replacement of the relevant pixels with random intensity values extracted in a reference area where the background is regular.The function, named Damaged Pixels Restoration, corrects the measured ED pattern in a few steps: i.
Selection of the background zone to be used as a reference for the restoration; ii.
Identification of the corrupted dark zone; iii.
Replacement of each pixel of the corrupted area with pixels randomly chosen from the reference background zone.
The selection of the reference background aims to measure a background zone close to the region where the intensity defect is located and to replace the pixels within the deficiency area with pixels randomly chosen within the reference region.A safe identification of the defected zone can be performed selecting a point inside the corrupted area, that represents the "seed" point, and performing a segmentation procedure by means of the Region Growing Algorithm [28] to identify the whole corrupted area.The Damaged Pixels Restoration procedure operates only in the background zone without affecting the genuine peaks that have to be previously masked (see Section 2.2.2).In Figure 9 an example of the application of the Damaged Pixels Restoration procedure to a pattern with an extended CCD-detector dead area is reported.It is worth mentioning that this method alone cannot recover an experimental intensity falling in the damaged area.performed selecting a point inside the corrupted area, that represents the "seed" point, and performing a segmentation procedure by means of the Region Growing Algorithm [28] to identify the whole corrupted area.The Damaged Pixels Restoration procedure operates only in the background zone without affecting the genuine peaks that have to be previously masked (see Section 2.2.2).In Figure 9 an example of the application of the Damaged Pixels Restoration procedure to a pattern with an extended CCD-detector dead area is reported.It is worth mentioning that this method alone cannot recover an experimental intensity falling in the damaged area.

Spikes Removal
The experimental ED pattern could present some hot or stuck defects, visible as spikes of high intensity, or dark areas, with respect to the neighborhood intensity values.Generally, spikes are tiny spots that are very sharp in a background region, also due to cosmic rays, with a shape completely different from that of genuine diffraction peaks.Nevertheless, in order to be sure that spikes are not diffraction peaks, it is convenient to scan the pattern in the region and check the spike shape before applying any removal function.These artifacts could strongly condition the phasing algorithms, because they could be recognized and treated as diffracted signals.We have developed a procedure, named the Spikes Removal Function, similar to the Damaged Pixels Restoration, which removes this kind of artifact.The procedure is based on the selection of a small area containing the artifact, and replacing all the intensities belonging to the anomalous spikes with other values randomly extracted from the rest of the selected area.The anomalous spikes are identified by applying the Grubbs' test for the outliers [29], assuming a normal distribution of the intensities of the selected area.As a result, the spikes are completely removed, as can be seen in Figure 10 where two zoomed areas of an ED

Spikes Removal
The experimental ED pattern could present some hot or stuck defects, visible as spikes of high intensity, or dark areas, with respect to the neighborhood intensity values.Generally, spikes are tiny spots that are very sharp in a background region, also due to cosmic rays, with a shape completely different from that of genuine diffraction peaks.Nevertheless, in order to be sure that spikes are not diffraction peaks, it is convenient to scan the pattern in the region and check the spike shape before applying any removal function.These artifacts could strongly condition the phasing algorithms, because they could be recognized and treated as diffracted signals.We have developed a procedure, named the Spikes Removal Function, similar to the Damaged Pixels Restoration, which removes this kind of artifact.The procedure is based on the selection of a small area containing the artifact, and replacing all the intensities belonging to the anomalous spikes with other values randomly extracted from the rest of the selected area.The anomalous spikes are identified by applying the Grubbs' test for the outliers [29], assuming a normal distribution of the intensities of the selected area.As a result, the spikes are completely removed, as can be seen in Figure 10 where two zoomed areas of an ED pattern are shown before (on the left panels) and after (on the right panels) the Spikes Removal Function application.The electron diffraction patterns after the treatment of spurious intensities become an optimized starting point for approaches aimed at maximizing the information achievable from an electron diffraction experiment.The kinematical approximation is seldom valid in TEM experiments due to the strong interactions between the primary high-energy beam and the specimen [1].This makes complicated, or even impossible, the use of several crystallographic methods developed for the X-rays, in the case of experiments with electrons [30].In the case of EDI experiments, the need to minimize the multiple scattering requires the use of extremely thin TEM specimens for reliable quantitative experiments, as the relationship between the diffracted intensities and the atomic structure factors are not very simple in the presence of multiple scattering typical of TEM experiments [8][9][10].The need for extremely thin specimens for EDI is a reason that limits the application of this methodology despite its capability to image the structure of the matter at atomic resolution.Indeed in a recent paper [31] it has been demonstrated that, if the electron diffraction

Discussion
The electron diffraction patterns after the treatment of spurious intensities become an optimized starting point for approaches aimed at maximizing the information achievable from an electron diffraction experiment.The kinematical approximation is seldom valid in TEM experiments due to the strong interactions between the primary high-energy beam and the specimen [1].This makes complicated, or even impossible, the use of several crystallographic methods developed for the X-rays, in the case of experiments with electrons [30].In the case of EDI experiments, the need to minimize the multiple scattering requires the use of extremely thin TEM specimens for reliable quantitative experiments, as the relationship between the diffracted intensities and the atomic structure factors are not very simple in the presence of multiple scattering typical of TEM experiments [8][9][10].The need for extremely thin specimens for EDI is a reason that limits the application of this methodology despite its capability to image the structure of the matter at atomic resolution.Indeed in a recent paper [31] it has been demonstrated that, if the electron diffraction patterns are free of spurious intensities, it is possible to compensate the dynamical effects by proper constraints based on further information on the specimen chemistry, which can be obtained by energy dispersive X-ray spectroscopy during the same experimental TEM session.In fact, after the treatment of the dynamical effects, the projected potential of the specimen can be quantitatively measured at the atomic resolution by the deconvolution of the autocorrelation function of the experimental diffraction pattern [31].The determination of the specimen atomic projected-potential enables us to distinguish between crystal atomic columns with different compositions and, for example in the case of the SrTiO 3 specimen oriented with the (001) plane perpendicular to the direction of the primary electron beam, enables us to distinguish the atomic column containing Sr, or Ti+O, or only O, gathering fundamental information regarding the properties of the specimen.Also in the case of the KEDI experiments, a proper treatment of the spurious intensities in the electron diffraction patterns and a new phasing algorithm enabled us to retrieve, for the first time, the image of the atomic projected potential at a resolution of 65 pm starting from completely random phases [32].Moreover, X-ray diffraction patterns could also be affected by several artifacts, which could benefit from some of the methods presented here.As an example, the deconvolution of the source spread function can be very useful to ameliorate the X-ray diffraction patterns as shown in [33].It can be envisaged that other methods based on the measurement of the electron diffraction intensities will benefit from the results of a proper treatment of the experimental results for spurious intensities.

Conclusions
EDI recently demonstrated its capability to image the structure of matter at atomic resolution, overcoming the limitation of HRTEM due to electron lens aberrations.Nevertheless, EDI requires a time consuming data reduction that obliges the direct intervention of skilled scientists to handle and process the data to obtain a proper set of diffracted intensities on which phase retrieval algorithms can be efficiently and safely applied.Our attempts to apply methods to derive the specimen projected potential by deconvolution of the autocorrelation function of the dynamical electron diffraction pattern and for data reduction of EDI experiments indicate that the eventual presence of spurious counts of the detector, due to various experimental origins, could produce unreliable results [18].Here we developed an approach to treat the experimental intensity artifacts making the diffraction pattern suitable for further quantification and phase retrieval.The results shown here indicate that the intensity artifacts can be treated in a reliable way without affecting the integrity of the diffraction data.The diffraction data free from spurious intensity, even if acquired on a relatively thick standard TEM specimen, are indeed the effective starting point to apply further methods for the quantification of the properties of the specimen at atomic resolution.This enabled us to develop and demonstrate [31] new methods to manage the dynamical effects, always present in TEM experiments on standard specimen thicknesses, and to quantitatively derive the atomic projected potentials even in the case of atoms of light elements in the crystal matrix of heavy elements [31].The diffraction data of a KEDI experiment, free from spurious intensities, were also used to image, for the first time and by using new phasing algorithms, the structure of a specimen starting from random phases [32].We believe that the methods used here to treat the spurious diffracted intensities are helpful for all the methods based on electron diffraction.For example, it could open new opportunities to apply many approaches already developed in X-ray crystallography to electron diffraction experiments, in analogy with what was demonstrated by De Caro et al. [31].As a result, new fields of application for quantitative electron diffraction could be opened.There are cases in which the methods so far developed cannot be used in the present form.For example: experimental intensities falling in the damaged areas of the detector cannot be recovered by the damaged pixel restoration; and continuous diffraction patterns, where the genuine interference pattern is superimposed to the artifacts, could not be restored by the procedures in the present form.The intensity treatments developed here are suitable to be performed automatically by computer algorithms and we are now working to develop a computer program that is capable of handling the experimental electron diffraction data and to apply proper algorithms, based on the methods presented here and on their further development, to treat spurious electron diffraction intensities.This is the subject of our forthcoming work.

Figure 1 .
Figure 1.(a) Electron Diffraction ED pattern of SrTiO3 [001] single acquisition; (b) ED pattern after the combination of multiple acquisitions.Three patterns have been selected, matched, and merged together, using the method described in the text; (c) Comparison between two line profiles: blue for the single acquisition in (a), red for the merged ED patterns in (b).The two profiles have been rescaled with respect to the maximum peak value.The red line shows an increase of the signal-to-noise ratio SNR of about 40%.

Figure 1 .
Figure 1.(a) Electron Diffraction ED pattern of SrTiO 3 [001] single acquisition; (b) ED pattern after the combination of multiple acquisitions.Three patterns have been selected, matched, and merged together, using the method described in the text; (c) Comparison between two line profiles: blue for the single acquisition in (a), red for the merged ED patterns in (b).The two profiles have been rescaled with respect to the maximum peak value.The red line shows an increase of the signal-to-noise ratio SNR of about 40%.

Figure 2 .
Figure 2. Parasitic diffracted electron artifacts in an ED pattern of Si [112] (a) and SrTiO3 [001] (b).Vertical and oblique stripes are visible in correspondence of the most intense peaks.

Figure 2 .
Figure 2. Parasitic diffracted electron artifacts in an ED pattern of Si [112] (a) and SrTiO3 [001] (b).Vertical and oblique stripes are visible in correspondence of the most intense peaks.

Figure 2 .
Figure 2. Parasitic diffracted electron artifacts in an ED pattern of Si [112] (a) and SrTiO3 [001] (b).Vertical and oblique stripes are visible in correspondence of the most intense peaks.

Figure 3 .
Figure 3. Simulated ED pattern with vertical stripe artifacts.

Figure 3 .
Figure 3. Simulated ED pattern with vertical stripe artifacts.

Figure 4 .
Figure 4. (a) Normalized PSFid used to generate artifacts in the simulation (blue line) and PSFes estimated from the simulated pattern (red dotted line); (b) PSFid (blue line) and PSFes (red dotted line) with correct k scale factor, retrieved iteratively.The plots are in logarithmic scale on the vertical axis in order to better observe the behavior of the PSFs.

Figure 4 .
Figure 4. (a) Normalized PSF id used to generate artifacts in the simulation (blue line) and PSF es estimated from the simulated pattern (red dotted line); (b) PSF id (blue line) and PSF es (red dotted line) with correct k scale factor, retrieved iteratively.The plots are in logarithmic scale on the vertical axis in order to better observe the behavior of the PSFs.

Figure 5 .
Figure 5. Simulated ED pattern after stripes removal.The intensities in the spots are the same as the pattern before adding the parasitic stripes.

Figure 5 .
Figure 5. Simulated ED pattern after stripes removal.The intensities in the spots are the same as the pattern before adding the parasitic stripes.
a logarithmic contrast window has been used.The profiles in the insets of Figure6highlight that, before the application of the Stripe Removal algorithm, the low-signal diffracted peaks are almost hidden by the intensity stripes, whereas they are completely restored after the procedure.

Figure 6 .
Figure 6.(a) Experimental ED patterns of SrTiO3 with some parasitic stripes pointed by red arrows ; (b) the pattern of SrTiO3 after application of the Stripe Removal procedure.(c) Si experimental ED pattern with some parasitic stripes pointed out by red arrows; (d) the pattern of Si after application of the Stripe Removal procedure.The inset (a1) shows a comparison between two line profiles of the marked areas of the pattern: the blue line corresponds just to the artifacts signal; the red line corresponds to both low-intensity diffracted peaks and artifacts.The inset (b1) shows the comparison between the same line profiles after the Stripe Removal procedure.The same comparison is shown in the insets (c1,d1) for the Si sample, where a low-signal peak has been selected.

3 )
Here <Iob> and <Ibk> (σob and σbk) are the mean intensity (standard deviation) values of the artifact signal and of the background, respectively.To check if the artifact is still visible after restoration, we applied the Rose criterion[27] SNR > 4, choosing an area of Npix = 900 containing the artifact signal.

Figure 6 .
Figure 6.(a) Experimental ED patterns of SrTiO 3 with some parasitic stripes pointed by red arrows ; (b) the pattern of SrTiO 3 after application of the Stripe Removal procedure.(c) Si experimental ED pattern with some parasitic stripes pointed out by red arrows; (d) the pattern of Si after application of the Stripe Removal procedure.The inset (a 1 ) shows a comparison between two line profiles of the marked areas of the pattern: the blue line corresponds just to the artifacts signal; the red line corresponds to both low-intensity diffracted peaks and artifacts.The inset (b 1 ) shows the comparison between the same line profiles after the Stripe Removal procedure.The same comparison is shown in the insets (c 1 ,d 1 ) for the Si sample, where a low-signal peak has been selected.

Figure 7 .
Figure 7.Comparison between the profiles of the patterns in Figure 6c,d.(a) Shows the significant reduction of the artifact signal (blue line) after Stripe Removal (red dotted line).(b) Shows a comparison between the line profiles on the peak position before (blue line) and after (red dotted line) the application of the Stripe Removal procedure.The inset on the left (lower panel) is a zoom on the peak showing an increase of its intensity as an effect of the deconvolution.The positions of the line profiles are marked in Figure 6.

Figure 7 .
Figure 7.Comparison between the profiles of the patterns in Figure 6c,d.(a) Shows the significant reduction of the artifact signal (blue line) after Stripe Removal (red dotted line).(b) Shows a comparison between the line profiles on the peak position before (blue line) and after (red dotted line) the application of the Stripe Removal procedure.The inset on the left (lower panel) is a zoom on the peak showing an increase of its intensity as an effect of the deconvolution.The positions of the line profiles are marked in Figure 6.

Crystals 2017, 7 , 186 11 of 16 Figure 8 .
Figure 8.(a) Diffraction pattern of Si showing the irregular background; (b) the same pattern after the Background Restoration procedure.The areas marked by the white squares are zoomed on the bottom panels to better visualize the background features before (c) and after (d) the application of the algorithm.Red arrows point out some horizontal bands for the reader's convenience.

Figure 8 .
Figure 8.(a) Diffraction pattern of Si showing the irregular background; (b) the same pattern after the Background Restoration procedure.The areas marked by the white squares are zoomed on the bottom panels to better visualize the background features before (c) and after (d) the application of the algorithm.Red arrows point out some horizontal bands for the reader's convenience.

Figure 9 .
Figure 9. (a) Diffraction pattern of TiO2: the red arrow point to the detector dead zone; (b) the pattern after Restoration Damaged Pixels procedure application.

Figure 9 .
Figure 9. (a) Diffraction pattern of TiO 2 : the red arrow point to the detector dead zone; (b) the pattern after Restoration Damaged Pixels procedure application.

Crystals 2017, 7 , 186 13 of 16 Figure 10 .
Figure 10.Examples of spikes removal.The figures are zoomed sections of ED patterns for ease of visibility.(a) The red arrow points a spike; (b) Effect of the application of the spike removal function on the area pointed in (a).(c) The red arrow points another kind of spike; (d) Effect of the application of the spike removal function on the area pointed in (c)

Figure 10 .
Figure 10.Examples of spikes removal.The figures are zoomed sections of ED patterns for ease of visibility.(a) The red arrow points a spike; (b) Effect of the application of the spike removal function on the area pointed in (a).(c) The red arrow points another kind of spike; (d) Effect of the application of the spike removal function on the area pointed in (c)