short communications
Computer-assisted area detector masking
aDepartment of Chemical Engineering, University of South Carolina, Columbia, SC 29208, USA
*Correspondence e-mail: cjwright4242@gmail.com
Area detectors have become the predominant type of detector for the rapid acquisition of X-ray diffraction, small-angle scattering and total scattering. These detectors record the scattering for a large area, giving each shot good statistical significance to the resulting scattered intensity I(Q) pattern. However, many of these detectors have pixel level defects, which cause error in the resulting one-dimensional patterns. In this work, new software to automatically find and mask these dead pixels and other defects is presented. This algorithm is benchmarked with both ideal simulated and experimental datasets.
Keywords: masking; area detector; Python.
1. Introduction
In recent years, X-ray powder diffraction and X-ray total scattering techniques have been used to perform rapid in situ measurements at synchrotron radiation sources. This requires use of large two-dimensional area detectors with fast frame rates. Two-dimensional area detectors are especially important for atomic pair distribution function (PDF) analysis and other techniques which require large (Q-space) and good statistics at large Q (Chupas et al., 2003). However, these detectors can have defects including dead/hot scintillators and pixels. In areas of low incident intensity these defects can cause data to become unreliable and thus unusable. In most azimuthal integration software, including Fit2D and pyFAI, these dead pixels are removed by masking the bad regions (Hammersley et al., 1996; Kieffer & Karkoulis, 2013). These masks are usually produced manually or using an intensity threshold. In manual masking, each pixel is painstakingly examined for deviation from the proper value. While threshold masking is automatic, it has a tendency of removing large regions of data or missing the bad regions completely.
Voltolini et al. (2013) and Vamvakeros et al. (2015) have also addressed this masking issue in the context of X-ray diffraction tomography. Voltolini et al.'s work uses a combination of thresholding and mask dilation. However, it seems that large areas of pixels are replaced during the masking, even when some are not needing removal. The work by Vamvakeros et al. performs a two-dimensional integration before applying various statistical filters, including standard deviation trimmed mean. While the use of the two-dimensional integration is similar to the method presented here, the two-dimensional integration step, which usually requires a split pixel method, can cause unwanted covariances in the integrated data (Yang et al., 2014).
We present a solution to this problem in the form of an automated mask writing program. This program will take advantage of the inherent azimuthal symmetry of powder X-ray scattering to mask statistically significant outliers.
2. Methodology
In this method we have applied the automatic masking procedure to two-dimensional diffraction images which contain powder diffraction rings known as Debye–Scherrer rings (Billinge & Egami, 2012). The masking algorithm relies on measuring statistically significant outliers.
2.1. Algorithm design
To properly mask the detector the image must first be binned to its appropriate rings. To avoid issues of pixel size in Q space the binning is done in the detector radial space, with the resolution of each ring set to the diagonal of a single pixel. While this creates some issues with highly tilted detectors, most detector setups will be masked properly, as shown in the experimental benchmarking section. Once the bins are formed, the image is integrated twice, obtaining the mean value and standard deviation of each ring. Finally, each pixel that is α standard deviations away from the mean is masked. Note that the threshold α can be a function of distance from the point of incidence.
2.2. Test cases
To study the effectiveness of the masking we ran the algorithm against both simulated and experimental data. The simulated data test cases can be found in the supporting information.
Figs. 1 and 2 show experimental X-ray scattering recorded at beamline 11-ID-B at the Advanced Photon Source (APS) using a Perkin Elmer area detector for Pr2NiO4 at 50°C and a glass capillary, respectively. The wavelength was 0.143 Å−1, the sample-to-detector distance was 25 cm and the images were recorded using QXRD software (Jennings, 2015). pyFAI was used to calibrate the detector, based on a CeO2 standard. Each image was corrected for and a beam polarization of 0.95 using pyFAI. Masks were computed for each image after the polarization correction. The Pr2NiO4 and glass images were acquired by summing 250 0.2 s exposures and 20 5 s exposures, respectively. Both masks were made with a threshold of two times the standard deviation. The integrations were performed using pyFAI with 1450 bins.
As previously shown with the simulated data, the beamstop holder is masked to very low Q values and the dead/hot pixels are properly removed. Unlike the simulated data, the experimental data also have streaks of dead pixels, which have also been properly removed. Proper data pre-processing, including and polarization corrections, were found to be extremely important as these corrections helped to reduce the standard deviation of each ring, allowing for more bad pixels to be caught. Each dataset shows the removal of the `high-Q kink' via masking. While the exact origin of the `kink' is unknown, it may be due to a combination of the shadow from the beamstop holder and the edge defects in the detector. It is also important to note that the low-scattering glass-based mask captures more of the low-Q beamstop while there are missing rings in the medium-scattering Pr2NiO4 mask. This may be due to a combination of the sharpness of the Pr2NiO4 peaks and the detector tilt. Since the masking algorithm is not able to account for the detector tilt it can put pixels from two close, but distinct, rings in the same bin. This binning issue causes a higher standard deviation, since two proximal pixels could have very different values if one is on the Bragg peak and the other is not, allowing the beamstop pixels to slip under the threshold. This effect is less of a problem with the glass sample, where the changes in the intensity are more gradual, thus the error of putting two pixels in the same bin is smaller. This could potentially be remedied by using Q resolution binning which is corrected for detector tilt.
3. Conclusion
Overall, this work is a significant advancement in data processing for two-dimensional area detectors developing a robust and simple algorithm for masking. These advancements were tested against a series of both computationally and experimentally derived datasets. Most importantly, the masking and integration of the experimental datasets showed that proper masking can result in the removal of the high-Q `kink' which had previously limited the extent of X-ray scattering which could be used for PDF analysis. Future work in this area may include the development of a tilt-corrected Q binning algorithm and examining different mathematical categorization of outliers. This work will not only help in advancing the most demanded in situ and high-throughput powder diffraction measurements but also provide reliable data from samples in complex environments.
This software is currently available on GitHub in the XPD workflow repository: https://github.com/CJ-Wright/xpd_workflow. This software will also be added to the more general scikit-beam repository in the near future: https://github.com/scikit-beam/scikit-beam.
Supporting information
Additional test cases for the masking algorithm. DOI: https://doi.org/10.1107/S1600577517000157/fv5059sup1.pdf
Acknowledgements
The authors would like to thank the APS 11-ID-B team for helping with the data collection, the NSLS-II DAMA group for help with the software design, Dr Sanjit Ghose for his insights and thorough edits, James McClintock for working on the second iteration of this software, and Emir Dogdibegovic for providing the experimental sample. This material is based upon work supported under the National Science Foundation IGERT Grant No. 1250052 and USC Presidential Fellows Program.
References
Billinge, S. J. L. & Egami, T. (2012). Underneath the Bragg Peaks: Structural Analysis of Complex Materials, 2nd ed. Amsterdam: Elsevier. Google Scholar
Chupas, P. J., Qiu, X., Hanson, J. C., Lee, P. L., Grey, C. P. & Billinge, S. J. L. (2003). J. Appl. Cryst. 36, 1342–1347. Web of Science CrossRef CAS IUCr Journals Google Scholar
Hammersley, A. P., Svensson, S. O., Hanfland, M., Fitch, A. N. & Hausermann, D. (1996). High. Press. Res. 14, 235–248. CrossRef Web of Science Google Scholar
Jennings, G. (2015). QXRD – Readout Software for Flat Panel X-ray Detectors, https://qxrd.sourceforge.net/. Google Scholar
Kieffer, J. & Karkoulis, D. (2013). J. Phys. Conf. Ser. 425, 202012. CrossRef Google Scholar
Vamvakeros, A., Jacques, S. D. M., Di Michiel, M., Middelkoop, V., Egan, C. K., Cernik, R. J. & Beale, A. M. (2015). J. Appl. Cryst. 48, 1943–1955. Web of Science CrossRef CAS IUCr Journals Google Scholar
Voltolini, M., Dalconi, M. C., Artioli, G., Parisatto, M., Valentini, L., Russo, V., Bonnin, A. & Tucoulou, R. (2013). J. Appl. Cryst. 46, 142–152. Web of Science CrossRef CAS IUCr Journals Google Scholar
Yang, X., Juhás, P. & Billinge, S. J. L. (2014). J. Appl. Cryst. 47, 1273–1283. Web of Science CrossRef CAS IUCr Journals Google Scholar
© International Union of Crystallography. Prior permission is not required to reproduce short quotations, tables and figures from this article, provided the original authors and source are cited. For more information, click here.