Crystal hit finding
Crystal hit finding
Serial Crystallography hit finding:
Save all frames with more than n Bragg peaks
1) detector corrections
Usually the default settings work pretty well and are enough to get started.
For best results pay attention to the following:
1.Use a recent dark calibration. At least one per shift is recommended
2.Decide whether to use common mode correction. It works well if all cspad modules have unbonded pixels. If they do not, it produces bad results. Look at a few powder patterns to see whether there is strange subtraction occurring.
3.Use a recent geometry. Hit finding is normally not very sensitive to a perfect geometry, unlike crystal indexing. However, radial background subtraction is sensitive to geometry, and can be quite so in the presence of concentric ‘powder rings’ from ice or other polycrystalline sample in the beam. SAXS/WAXS traces also benefit from use of a refined geometry so that radial averages are averaged across the same scattering angles. Accurate geometry files are best obtained using the results of crystal indexing. Geometry refinement is extensively discussed on the CrystFEL web pages.
4.Use a recent bad pixel mask. New bad pixel masks need to be created each time the detector is rebuilt, and sometimes after it is damaged. A good idea to check they make sense (bad pixels are zeroed and ignored)
5.Check for regions to be excluded from analysis and include in the peakmask. For example:
- Regions shadowed by shroud, beamstop, or other equipment as in the above picture
- Regions containing jet streaks
- Powder rings from substrates or ice
Exclusion regions can change whenever the detector is moved, injector changed, or shift to shift. Look for suspicious regions (shadows, jet positions) in the powder pattern for each run (View-->powder).
Forgetting to exclude these regions from analysis (a) leads to false peaks, and (b) will pollute your indexing results with false reflection measurements when CrystFEL tries to integrate reflections predicted to be in these regions.
See the Detector Corrections page for more details.
2) Optimise peak finding
Accurately finding Bragg peaks is essential for both crystal hit finding and obtaining a high indexing rate. Effort spent on peak finding inevitably pays off in the end.
Too few peaks and both the hit rate (fewer peaks) and indexing rate drops (too few peaks to find lattice orientations). Too many false peaks and the hit rate becomes artificially high (counting lots of “peaks” which are not really peaks) and the indexing rate drops (false peaks confuse indexing algorithms so that they can’t determine the orientation of the crystal lattice).
The following recipes work in most cases.
-snr8pix2.ini (peak = two connected pixels above 8 sigma threshold, good for bright sharp peaks)
-snr6pix3.ini (peak = three connected pixels above 6 sigma threshold, better for weaker but fatter peaks)
-snr4pix4.ini (peak = four connected pixels above 4 sigma threshold, for very weak and fat peaks)
(from /reg/g/cfel/cheetah/template/cheetah/process)
3) Peakfinder 8
Peakfinder8 has been found to be fairly robust for SFX peak finding and operates as follows:
1)Compute the radial average and standard deviation over regions not excluded from analysis. This produces two arrays mean(r) and stddev(r) which are a function of radius from beam centre. The threshold as a function of radius becomes thresh(r) = mean(r) + SNR * stddev(r), where SNR is the input threshold hitfinderMinSNR.
2)Loop over the above calculation five times, each time excluding pixels above thresh(r) from the radial average calculation. This serves to reject outliers such as Bragg peaks and jet regions from the average calculation (the idea being to calculate mean(r) and stddev(r) only in background regions). Five loops is rather arbitrary but we found it works well.
3)Recalculate thresh(r) = mean(r) + SNR * stddev(r) and apply a minimum ADC criterion of hitfinderADC so that thresh(r) = MAX(thresh(r), hitfinderADC). Remember for the next step.
4)Loop over each logical detector module (ASIC, or similar). Within each module search for regions of n or more connected pixels above thresh(r). A potential peak is a region satisfying this criterion.
Detail: it is actually hitfinderMinPixCount < n < hitfinderMaxPixCount to enable really large peaks to be excluded, and remember threshold has a floor at hitfinderADC so that thresh(r) = MAX(thresh(r), hitfinderADC). For Pilatus you will want to change hitfinderADC =1 or 2 whereas for the cspad in high gain mode usually 100 or so works well.
5)Integrate each potential peak to find the ‘centre of mass’ and maximum ADC value. Compute local background using three-ring approach, and check that the peak really does satisfy the stated minimum signal to noise ratio. This cross-check is to avoid false peaks in noisier regions.
Detail: Three-ring radius found automatically but can be set using hitfinderLocalBgRadius.
6)Return list of found leaks satisfying local background check.
Note: Coordinate of each pixel is at it’s measurement centre (not the corner).
7)Optional: Exclude peaks that are too close together (hitfinderMinPeakSeparation), keeping only the brighter of peaks that are too close together.
8)Hits are frames with more than hitfinderNpeaks found peaks after all the above steps.
The key parameters to change are:
hitfinderMinSNR (signal-to-noise required to count as a pixel that is a part of a peak)
hitfinderMinPixCount (number of connected pixels above hitfinderMinSNR required to constitute a peak)
hitfinderNpeaks (number of peaks to count as a hit)
Less frequently adjusted but also useful are:
hitfinderADC (minimum ADC value for the threshold, applied over the entire image)
hitfinderMinRes (inner radius of peak search, in pixels)
hitfinderMaxRes (outer radius of peak search, in pixels)
peakmask (a user-defined pixel mask identifying regions of the image to exclude from peak searching)
The following are two good starting points which usually find something:
For small, intense peaks that illuminate few pixels:
hitfinderMinSNR=8
hitfinderMinPixCount=2
For slightly larger, less intense peaks the following values typically work better
hitfinderMinSNR=6
hitfinderMinPixCount=3
Each sample is different, and there is no substitute for looking at the peak finding performance and adjusting values to suit your data. Inspect hits found using the “View Hits” button, then select “Crystals-->Default crystal display settings” to circle the peaks found by Cheetah. This will immediately give some idea of whether many peaks are being missed, or whether most found peaks are in fact junk. The definition of what constitutes a peak, where to search and number of peaks to count as a hit can be adjusted accordingly.
Tweak values according to intuition - there is unfortunately no substitute for using your brain and intelligence.
Note that peaks found by Cheetah can be used for indexing by CrystFEL. Reliably selecting peaks at the hit finding stage benefits both indexing rate as well as accurate hit finding.
Source code:: source/libcheetah/src/peakfinder8.cpp
int peakfinder8(tPeakList *peaklist, float *data, char *mask, float *pix_r, long asic_nx, long asic_ny, long nasics_x, long nasics_y, float ADCthresh, float hitfinderMinSNR, long hitfinderMinPixCount, long hitfinderMaxPixCount, long hitfinderLocalBGRadius) {.....}
4) maximum and minimum radius limits
Maximum and minimum radii for peak finding (or any hit finding) can be set using
hitfinderMinRes (inner radius of peak search, in pixels)
hitfinderMaxRes (outer radius of peak search, in pixels)
Advantage:
-Makes it very easy to focus on the low resolution region where the brightest Bragg peaks are found.
-Quick and easy
Dangers:
-No peaks are found outside of this region, by definition
-CrystFEL compares locations of found and predicted peaks to determine the per-pattern resolution cutoff. Thus hitfinderMaxRes, by definition, sets an upper limit on the crystal resolution estimated by CrystFEL. This may affect your peak integration and final resolution. Used too freely it may even limit the resolution of your whole data set. Be warned.
-Additional peaks may help fine refinement of crystal orientation
-peakograms become useless above outside of set limits.