# Autocloud

With the advent of position sensitive detectors in X-ray and neutron diffraction the problem arises how integrated reflection intensities may be extratcted from the collected volumes of data. Typically a series of frames is measured while rotating the crystal under investigation in omega. Autocloud implements a novel approach for the extraction of reflection intensities from such data. Other currently used integration packages use a UB-matrix to predict the position of a reflection on the detector and then integrate the intensity in a box around the predicted position. In contrast autocloud tries to determine reflection positions and intensities directly from the data. In order to do so a template matching algorithm is used. One advantage of this approach is that crystals with magnetic or incommensurate structures can be easily analysed. Typically packages for intensity integration do not have facilities for predicting such reflections. The other advantage is ease of use. Data analysis with autocloud requires only two steps: Integration followed by indexing.

## Running Autocloud

The syntax is:

    autocloud options datafile

The following options are known:

-a val
  Selects the algorithm to use. The following algorithms are currently supported:
  max
    perform only a local maximum search
  template
    Perform template matching. This is the default.
  cross
    Perform template matching using the cross correlation function.
-b AAxBBxCC
  For the evaluation of the initial template a preliminary box size is needed. This can be specified through this option. Three values separated by the character 'x' are required, one for each dimension in the order x, y, z.
-d val
  After the correlation of the data volume with the template another maximum search is started in order to locate the reflections. In order to suppress spurious peaks, a minimum steepness of the candidate peak can be set with the -d option.
-e val
  Some systems store frames a single files. With the -e option the end file number of the frame files can be set.
-m val
  When the maximum search only option is set a, a threshold is required for suppressing spurious peaks. This threshold can be set with the -m option.
-o file
  Redirects output to the file name specified. By default all output is written to stdout.
-s val
  Some systems store frames a single files. With the -s option the start file number of the frame files can be set.
-t type
  This option sets the type of the data file. Currently understood are:
  sxd
    For NeXus data from SXD at ISIS.
  trics
    For NeXus data files from TRICS, SINQ
  debug
    An internal format used during software testing.
-v val
  Increases the verbosity of the output.

## The Autocloud Algorithm

The autocloud algorithm has the following steps:

1. Location of strong peaks for template evaluation.
2. Background Subtraction.
3. Evaluation of a template for volume matching.
4. Correlation of the template with the data volume.
5. Location of maxima in the correlated data.
6. Integration of the reflections found.

### Location of Strong Peaks for Template Evaluation

This is basically a local maximum detection scheme. A local maxima must be the strongest intensity within a 7 by 7 by 7 volume. All maxima smaller then 10% of the largest maximum found are discarded.

### Background Subtraction

Background subtraction is done with essentially the same algorithm XDS uses. For each x, y coordinate in the frame values are summed along the third dimension. Points belonging to a local maimum are excluded. The background for this x,y coordinate is then the average of the values summed. The data volume is then corrected for the background with these values. This works well as long as the assumption holds that the background varies mostly across the detector and not much with the third dimension.

### Template Evaluation

The template to be used for template matching later on is calculated by summing all local maxima first. Then the limits of the reflection are calculated for each scanline using the Lehmann-Larsen algorithm. The reflection thus found is scaled to a value of 1 and used as the template.

### Template Matching

For the actual correlation of the template with the data two variantes can be used: Normal simple correlation or cross correlation.

### Peak Detection

This is again a local maximum detection within a 7 by 7 by 7 box. Another criterium for the supression of wrong identifications is a minimum steepness. This means that the candidate local maximum must at least be higher by a certain amount (the steepness) then the points at the border of its 7 by 7 by 7 box.

### Peak Integration

A scale factor is calculated for each candidate reflection between the data and the template. The intensity is derived from this scale factor and the standard deviation is calculated as the squared difference between the scaled template and the data. This scheme is the same as learnt profile fitting as described by Ford for the 1- and 2d cases.