23.6.2. CrystalMatch software for plate imaging¶
23.6.2.1. Background¶
Data collections within wells are marked in SynchWeb prior to the plate being loaded onto the beamline endstation, using an image taken by the Formulatrix’s imager (see An overview of VMXi). These images must be compared to images taken on the beamline using the OAV to determine the location of the data collection so the scan can be described (see Overview section of Data Collection).
To perform this task, GDA uses the CrystalMatch software developed and maintained by the Controls group, the code for which can be found on GitHub at CrystalMatch.
23.6.2.2. Overview¶
There are three problems solved by the CrystalMatch software.
Creation of an extended-focus image from an image z-stack, centred around the most in focus image.
Matching of an extended-focus image against the reference Formulatrix image (providing the transform for the given points against the reference image).
Determination of the most in focus image for each provided point (pixel location), to align the sample in the rotation axis.
Each of these problems represents an issue that was once tackled by different systems (z-stacking, image matching, and auto-focusing) and can now be solved with a single run of CrystalMatch.
23.6.2.3. Usage in GDA¶
GDA provides CrystalMatch with the following inputs:
The reference image from the Formulatrix.
A directory containing the z-stack - images from the OAV taken at varying sample_z positions.
The pixel:pixel scale between the Formulatrix image and the OAV images.
The pixel positions marked on the Formulatrix image by the user, representing data collection locations (a single pixel for a rotation, two pixels for the top-left and bottom-right corners of a grid).
Directories for outputs and logging.
Given this input, CrystalMatch will:
Determine the most-in-focus image.
Create an extended-focus image using the surrounding 12 (configurable) images.
Determine the best-focus image for each point in the provided point list out of the images used for the extended focus.
Determine a global transformation between the Formulatrix image and the extended-focus image.
Apply the transformation to the provided point list.
Return the location of the extended focus image, the global transform applied, the transformed positions and their z-level in JSON format.
23.6.2.4. Limitations¶
Feature Tracking
CrystalMatch currently only applies the global transformation when returning the transformed positions; it makes no attempt to track movement of individual features (for instance, caused by individual drift of crystals). It is hoped that this feature will one day be developed, and GDA use the positions output by CrystalMatch, rather than applying the transformations itself, in anticipation.
Focusing
The initial focusing step is a global focus and has a chance to prefer features far removed from the samples, such as dirt on the back of the plate, or the edges of the well. This is rare, and so long as the focus position is not too far from the actual z-position of samples, not usually a problem.
More problematic is the determination of the focus-position for individual samples. For each point, a small region is used to compare across the z-stack images. Neighbouring crystals may get caught within that region and could cause the focus to drift, fine precipitate may cause a preference for a different z-location, or the selected region may be such that no obvious detail is found to focus on (possibly on very large crystals).
This is significant as this step is used to determine the z position for the sample stages, and move the sample into the rotation axis. An error here makes it likely the sample will drift in and out of the beam during rotation.
Refraction
An unfortunate feature of physics is that X-Rays and Visible Light refract differently, due to the large difference in wavelengths.
A minor error in apparent focus position due to the plastic of the plate can be accounted for by a fixed offset when preparing for the scan, but refractive errors due to the drop itself cannot be so easily corrected for. Errors in the x-y plane so far appear minor, only being noticeable at the edges of the drop (due to the increased angle, from the drop’s curvature) and only being significant for the very smallest of crystals.
Errors along the z axis are more problematic, frequently causing the sample to move out of the beam during rotation datasets, reducing the range data is collected in from 60 degrees to as little as 20, or even 10 degrees in the worst cases.