Bragg Spot Finder (BSF): a new machine-learning-aided approach to deal with spot finding for rapidly filtering diffraction pattern images

Jianxiang Dong, Zhaozheng Yin, Dale F. Kreitler, H. J. Bernstein, Jean JakoncicJournal of Applied Crystallography 2024 · DOI

TL;DR

This paper introduces Bragg Spot Finder (BSF), a novel machine-learning-based approach for identifying diffraction spots in X-ray crystallography images. BSF significantly improves the detection of weak and diffuse spots, overcoming limitations of existing methods and keeping pace with faster synchrotron beamlines, which is crucial for determining complex protein structures.

What Problem Does This Paper Address?

Macromolecular crystallography (MX) is vital for understanding protein structures, which in turn aids in drug design. The process involves collecting X-ray diffraction images from protein crystals. "Spotfinders" are essential tools that identify diffraction spots within these images, serving as the primary data for structure determination. However, recent advancements in synchrotron X-ray sources have led to faster data collection rates, outpacing the capabilities of current spotfinder software. This bottleneck means that weak or diffuse spots, often found in challenging crystal samples or when using microbeams, can be missed. This can lead to incomplete datasets, requiring more synchrotron time and hindering the discovery of crucial protein structures. The paper aims to bridge this gap by developing a more sensitive and faster spotfinder.

Methods

The core of the Bragg Spot Finder (BSF) is a U-Net architecture, a type of convolutional neural network well-suited for image segmentation. The process involves several key stages:

  • Data Pre-processing: Raw diffraction images (in .cbf format) are converted to grayscale. Due to memory constraints and image size, images are split into smaller patches (512x512 pixels) for processing.
  • U-Net Segmentation: The U-Net model, with its encoder-decoder structure and skip connections, is trained to segment image patches, distinguishing between foreground spots and background. The output is a probabilistic map indicating the likelihood of each pixel belonging to a spot.
  • Post-processing: This is a crucial multi-step process to refine the raw U-Net output:
  • Image Reconstruction: Patches are stitched back together to form the complete image.
  • Large Spot Splitting: A watershed algorithm is used to split large detected regions into smaller individual spots. Spots smaller than a defined threshold are then removed.
  • Ice Ring Removal (IRSR): Artifacts caused by ice rings (common in cryogenic crystallography) are identified and removed. This involves calculating ice ring positions and masking out predicted spots within a certain proximity.
  • Tilted Detector Calibration (TDC): To improve the accuracy of ice ring removal, a calibration step accounts for the detector's orientation, ensuring more precise identification of ice ring artifacts.

Datasets

The paper introduces a new benchmark dataset called the Bragg Spot Detection (BSD) dataset.

  • BSD Dataset: This dataset comprises 304 high-resolution diffraction images collected from the AMX beamline at the National Synchrotron Light Source II. It contains over 66,000 manually annotated Bragg spots. The dataset was split into training (245 images) and testing (59 images) sets. The ground truth annotations were generated by expert crystallographers using the ADXV viewer, with careful manual inspection and correction.

Key Insights and Ideas

  • Machine Learning for Spot Finding: The paper demonstrates that a U-Net architecture, a powerful tool in computer vision, can be effectively adapted for the challenging task of Bragg spot detection in crystallography.
  • The Importance of Post-processing: Raw output from deep learning models often requires significant refinement. The multi-stage post-processing pipeline, particularly the ice ring removal and tilted detector calibration, is critical for improving accuracy and reducing false positives.
  • Weak Spots are Key: The motivation for BSF stems from the need to detect weak and diffuse spots, which are often missed by traditional methods but are vital for solving complex structures or working with challenging crystals.
  • Bridging the Speed Gap: The development of BSF is driven by the need to match the increasing speed of X-ray detectors, enabling real-time analysis and more efficient use of synchrotron facilities.

Key Results

  • Performance Comparison: BSF achieved comparable or better results than two popular spotfinder software packages, Dozor and DIALS, on the BSD benchmark dataset.
  • High Recall: BSF demonstrated a higher recall rate (correctly identifying more spots) than both Dozor and DIALS, indicating its superior sensitivity for detecting weak reflections.
  • Accuracy: In spot-level comparisons, BSF showed significantly higher performance than DIALS across all metrics and outperformed Dozor in F1 score and recall. Image-level metrics also favored BSF.
  • Ablation Study: The paper's ablation studies confirmed the effectiveness of individual components:
  • The radius used for generating ground truth masks impacts performance, with a radius of 10 pixels found to be optimal.
  • The combination of large-spot splitting (LSS), ice ring spot removal (IRSR), and tilted detector calibration (TDC) provided the best overall performance, with TDC significantly improving IRSR accuracy.

Limitations and Future Work

  • Precision vs. Recall: While BSF excels in recall, its precision is noted to be slightly lower than Dozor, meaning it can sometimes misclassify artifacts as spots. This is partly attributed to data-driven artifacts like ice rings and potential inaccuracies in the ground truth labeling.
  • Speed: Although BSF is designed to be faster, its current speed of four images per second is still not sufficient to keep pace with the fastest real-time data collection rates.
  • Future Directions:
    • Improved Backbones: Exploring other deep learning architectures like DepLab and ResUNet.
  • Enhanced Post-processing: Incorporating more expert knowledge into post-processing to further reduce false positives.
  • Speed Optimization: Investigating teacher-student frameworks and knowledge distillation to create faster and lighter neural networks.
  • Indexing Integration: Using predicted reflection coordinates to attempt indexing and improve heat map generation for optimal data collection.

Summary updated

Abstract

Macromolecular crystallography contributes significantly to understanding diseases and, more importantly, how to treat them by providing atomic resolution 3D structures of proteins. This is achieved by collecting X-ray diffraction images of protein crystals from important biological pathways. Spotfinders are used to detect the presence of crystals with usable data, and the spots from such crystals are the primary data used to solve the relevant structures. Having fast and accurate spot finding is essential, but recent advances in synchrotron beamlines used to generate X-ray diffraction images have brought us to the limits of what the best existing spotfinders can do. This bottleneck must be removed so spotfinder software can keep pace with the X-ray beamline hardware improvements and be able to see the weak or diffuse spots required to solve the most challenging problems encountered when working with diffraction images. In this paper, we first present Bragg Spot Detection (BSD), a large benchmark Bragg spot image dataset that contains 304 images with more than 66 000 spots. We then discuss the open source extensible U-Net-based spotfinder Bragg Spot Finder (BSF), with image pre-processing, a U-Net segmentation backbone, and post-processing that includes artifact removal and watershed segmentation. Finally, we perform experiments on the BSD benchmark and obtain results that are (in terms of accuracy) comparable to or better than those obtained with two popular spotfinder software packages (<i>Dozor</i> and <i>DIALS</i>), demonstrating that this is an appropriate framework to support future extensions and improvements.
BibTeX
@article{dong2024bragg,
  author = {Jianxiang Dong and Zhaozheng Yin and Dale F. Kreitler and H. J. Bernstein and Jean Jakoncic},
  title = {{Bragg Spot Finder (BSF): a new machine-learning-aided approach to deal with spot finding for rapidly filtering diffraction pattern images}},
  journal = {Journal of Applied Crystallography},
  year = {2024},
  doi = {10.1107/s1600576724002450},
}
Figure