next up previous contents index
Next: Fit Sub-Menu Up: Calibration Sub-menu Previous: Calibration Sub-Menu Commands

Subsections



 Spatial Distortion Correction in MADNES

The program MADNES written by A Messerschmidt and J W Pflugrath [20] performs on-line protein crystallography data collection and integration with auto-indexing and auto-orientation. It includes the possibility to account for detector spatial distortion. Often a spatial distortion calibration and correction system produced by David Thomas [34], or by Marty Stanton [30], is used to correct for the spatial distortion. It is now possible to use FIT2D to produce calibration files for MADNES. This may have certain advantages:

The version of MADNES must have had the following subroutines changed for ones which use the FIT2D method of correction:

lodspd Load spatial distortion interpolation
pxtomm Convert distorted pixel grid to ideal millimetre grid
mmtopx Convert ideal millimetre grid to distorted pixel grid

These subroutines can be made available by the author, although some care must be taken to ensure that the code corresponds to the detector read-out system and diffractometer geometry being used (some modification of the code to account for the different coordinate system is likely).

MADNES needs both a function to convert from the distorted detector pixel grid to an ideal detector coordinate, and a function to convert from an ideal detector coordinate system to the distorted detector pixel grid. FIT2D allows these two functions to be created as interpolation spline functions. Normally (by default) FIT2D creates a spline function to convert from the distorted (measured) pixel grid to an ideal grid, as a function of 2-D distorted pixel position. To be able to create an interpolation spline to convert from an ideal detector to a distorted grid detector the command INVERSE DISTORTED/IDEAL exists. This command toggles between the two definitions of the distortion. By using the INVERSE DISTORTED/IDEAL command once, followed by the FIT GRID PEAKS command a spline function is produced for the ideal to distorted grid function. When the OUTPUT SPATIAL FUNCTION command is used the file created has an extra first line if it is from an ideal to distorted grid. Thus, FIT2D and MADNES can recognise the correct files.

MADNES creates automatically the file names to be input containing the two spatial distortion functions, based on a base name plus fixed file extension. The required extension for the file containing the function from the distorted grid to the ideal grid is .d2i, and from the ideal grid to the distorted grid is .i2d. In addition to the two spatial distortion files MADNES needs to know the beam centre in pixel coordinates on the detector. This number is input according to the MADNES detector coordinate system53.

Image Format Conventions

The following is MADNES documentation describing the different image storage formats that it can handle.

The image DATA can be stored in many orders. MADNES needs to know the 
order that your images are stored.  When one looks at the image from a 
camera-man's viewpoint, that is from behind the detector towards the 
crystal, there are 8 possible orders, depending on the origin and the 
slow and fast directions of pixel order:

 +------------+     O-slow->-----+     +-----<-tsaf-O     +------------+
 |            |     |            |     |            |     |            |
 ^            |     f            |     |            s     |            ^
 |            |     a            |     |            l     |            |
 w            |     s            |     |            o     |            t
 o     1      |     t     2      |     |     3      w     |     4      s
 l            |     |            |     |            |     |            a
 s            |     V            |     |            V     |            f
 |            |     |            |     |            |     |            |
 O-fast->-----+     +------------+     +------------+     +-----<-wols-O

 +------------+     O-fast->-----+     +-----<-wols-O     +------------+
 |            |     |            |     |            |     |            |
 ^            |     s            |     |            f     |            ^
 |            |     l            |     |            a     |            |
 t            |     o            |     |            s     |            w
 s     5      |     w     6      |     |     7      t     |     8      o
 a            |     |            |     |            |     |            l
 f            |     V            |     |            V     |            s
 |            |     |            |     |            |     |            |
 O-slow->-----+     +------------+     +------------+     +-----<-tsaf-O

Simply for historical reasons, in these routines, 
in specifying the detector pixel coordinates:

The FAST direction is called Yms (i.e. is first dimension of a
Fortran array)
The SLOW direction is called Zms (i.e. is second dimension of a
Fortran array)

Now for the mm coordinate system.  For the same viewpoint as above, 
the X mm points down along the omega axis (vertical for most goniostats,
often horizontal for synchrotrons).  Z goes into the beam and Y makes a 
right-handed system. The origin of the mm coordinate system is the 
position of the primary beam on the detector, when the tilt (aka swing, 
aka theta) angle is zero.

       +-------------+
       |             |
       |             |
       |             |
       |             |
       | Y<-- o      |   Z into beam.
       |      |      |
       |      V      |
       |      X      |
       +-------------+

Example of Producing Calibration Files

The following is part of the log produced by FIT2D showing the sequence of commands used to produce the two calibration files suitable for use by MADNES. Here is it assumed that the base file name for the calibration files will be gridi20.

Main menu: ENTER COMMAND [INPUT DATA]: 
FILE FORMAT [FIT2D STANDARD FORMAT]:princeton
DATA FILE NAME [grid600.spe]:gridi20.spe
INFO: Size of image =  1242 *  1152
Main menu: ENTER COMMAND [IMAGE]:calibration
Calibration sub-menu: ENTER COMMAND [FIND PEAKS]:size
NUMBER OF PIXELS (Range: 50 to 5000) [200]:400
Calibration sub-menu: ENTER COMMAND [FIND PEAKS]: 
MAXIMUM PEAK SEARCH DISTANCE (PIXELS) (Range: 1 to 100) [3]: 
PEAK DETECTION RATIO (Range: 0.0 to .99000) [.10000]: 
PEAK STANDARD DEVIATION WIDTH (Range: 0.0 to 1.000E+05)
 [1.30000]: 
NUMBER OF SUB-PIXELS (Range: 1 to 100) [9]:5
INFO: Starting peaks found O.K.
INFO: Starting peak is at position    492.29999   469.69998
INFO: Next first grid axis peak is at position    519.30005   470.29999
INFO: Next second grid axis peak is at position    492.50000   496.29999
PROGRESS REPORT FREQUENCY (PEAKS) (Range: 1 to 100000) [400]:100
 
INFO: Starting peak search, this takes some time for big grids

$\dots$

INFO: Found   1000  peaks
INFO: Number of peaks found =   1001
INFO: Number of grid peaks (X/Y) =     34    34 (    1156)
INFO: Time taken =    .21E+03 seconds
GRID SPACING (CENTRE TO CENTRE IN microns)
 (Range: 1.00000 to 1.000E+06) [2000.00]:5000
INFO: Average pixel size in X-direction =     162.6968 +-   2.7524 microns
INFO: Average pixel size in Y-direction =     162.6369 +-   2.6746 microns
INFO: Overall average pixel size =     162.6669 +-     2.6770 microns
INFO: RMS pixel size in X-direction =     158.8293
INFO: RMS pixel size in Y-direction =     159.0563
INFO: Average rotation based on rows =      .473566 +-   .1525 degrees
INFO: Average rotation based on columns =      .583813 +-   .1607 degrees
INFO: Average rotation (both rows and columns) =
INFO:      .528689 +-      .1643 degrees
IDEAL X-PIXEL SIZE (MICRONS) (Range: 1.000E-04 to 1.000E+06)
 [158.829]: 
IDEAL Y-PIXEL SIZE (MICRONS) (Range: 1.000E-04 to 1.000E+06)
 [159.056]: 
GRID ROTATION ANGLE (DEGREES)
 (Range: -360.0000000 to 360.0000000) [.528689305]: 
X-NUMBER OF IDEAL HOLE (Range: 1 to 34) [17]: 
Y-NUMBER OF IDEAL HOLE (Range: 1 to 34) [17]: 
Calibration sub-menu: ENTER COMMAND [DISPLAY DISTORTION]:fit
AVERAGE FIT DISCREPANCY (PIXELS)
 (Range: 1.000E-05 to 1000.00) [.10000]:.2
INFO: Fitting X-Distortion
INFO: X-Distortion Spline
INFO: Number of horizontal/ vertical true knot points =     6    5
INFO: Average position discrepancy =  1.99996E-01
INFO: Fitting Y-Distortion
INFO: Y-Distortion Spline
INFO: Number of horizontal/ vertical true knot points =     5    6
INFO: Average position discrepancy =  1.99989E-01
INFO: Worst case fit discrepancies  in pixels (spline value - measured)
INFO: Lowest X-distortion =   -.82921E+00 at grid position (X/Y)   32   6
INFO: Highest X-distortion =   .73063E+00 at grid position (X/Y)   27   2
INFO: Lowest Y-distortion =   -.11955E+01 at grid position (X/Y)   17  15
INFO: Highest Y-distortion =   .11901E+01 at grid position (X/Y)   16  18
Calibration sub-menu: ENTER COMMAND
 [OUTPUT SPATIAL FUNCTION]: 
Name of file for spatial distortion interpolation function
FILE NAME [spatial.dat]:gridi20.d2i

The spatial distortion function from the distorted grid to an ideal grid has now been defined and saved, so it remains to change the definition of the peak positions and distortion values with the INVERSE DISTORTED/IDEAL command and to fit a new spline function.

Calibration sub-menu: ENTER COMMAND [EXIT]:inverse
INFO: Distortion now defined from ideal grid to distorted grid
Calibration sub-menu: ENTER COMMAND [FIT GRID PEAKS]: 
AVERAGE FIT DISCREPANCY (PIXELS)
 (Range: 1.000E-05 to 1000.00) [.20000]: 
INFO: Fitting X-Distortion
INFO: X-Distortion Spline
INFO: Number of horizontal/ vertical true knot points =     7    5
INFO: Average position discrepancy =  2.00015E-01
INFO: Fitting Y-Distortion
INFO: Y-Distortion Spline
INFO: Number of horizontal/ vertical true knot points =     7    8
INFO: Average position discrepancy =  2.00044E-01
INFO: Worst case fit discrepancies  in pixels (spline value - measured)
INFO: Lowest X-distortion =   -.88624E+00 at grid position (X/Y)   33  22
INFO: Highest X-distortion =   .10403E+01 at grid position (X/Y)   33   9
INFO: Lowest Y-distortion =   -.87807E+00 at grid position (X/Y)   16  18
INFO: Highest Y-distortion =   .95938E+00 at grid position (X/Y)   17  15
Calibration sub-menu: ENTER COMMAND
 [OUTPUT SPATIAL FUNCTION]: 
Name of file for spatial distortion interpolation function
FILE NAME [gridi20.d2i]:gridi20.i2d
Calibration sub-menu: ENTER COMMAND [EXIT]:


next up previous contents index
Next: Fit Sub-Menu Up: Calibration Sub-menu Previous: Calibration Sub-Menu Commands
Andrew Hammersley
2004-01-09