## research papers

*GrainSpotter*: a fast and robust polycrystalline indexing algorithm

^{a}Department of Physics, Technical University of Denmark, Denmark^{*}Correspondence e-mail: ssch@fysik.dtu.dk

A new approach for indexing multigrain diffraction data is presented. It is based on the use of a monochromatic beam simultaneously illuminating all grains. By operating in sub-volumes of Rodrigues space, a powerful vertex-finding algorithm can be applied, with a running time that is compatible with online analysis. The resulting program, *GrainSpotter*, is sufficiently fast to enable online analysis during synchrotron sessions. The program applies outlier rejection schemes, leading to more robust and accurate data. By simulations it is shown that several thousand grains can be retrieved. A new method to derive partial symmetries, called pseudo-twins, is introduced. Uniquely, *GrainSpotter* includes an analysis of pseudo-twins, which is shown to be critical to avoid erroneous grains resulting from the indexing.

Keywords: three-dimensional X-ray diffraction microscopy; polycrystalline materials; indexing; synchrotron radiation.

### 1. Introduction

During the past decade, several X-ray-based methods have materialized for identifying and potentially mapping grains in three dimensions in polycrystals. We mention the micro-beam Laue diffraction scanning technique pioneered by Larsson *et al.* (2002), and the two monochromatic beam based diffraction imaging methods known as three-dimensional X-ray diffraction (3DXRD) microscopy (Poulsen *et al.*, 2001; Juul-Jensen *et al.*, 2006) and diffraction contrast tomography (Ludwig *et al.*, 2008, 2009).

In this article we focus on 3DXRD. Within materials science, this technique has found widespread applications for three-dimensional studies of dynamic phenomena such as nucleation (West *et al.*, 2009), recrystallization (Lauridsen *et al.*, 2000; Schmidt *et al.*, 2004), grain growth (Schmidt *et al.*, 2008), phase transformations (Offerman *et al.*, 2002), dislocation dynamics (Jakobsen *et al.*, 2006) and plastic deformation (Margulies *et al.*, 2001; Winther *et al.*, 2004). Within chemistry, pharmacy and even structural biology, 3DXRD and its extension TotalCryst (Sørensen, Schmidt *et al.*, 2012) have provided a way to achieve structural solution and on polycrystals (Schmidt *et al.*, 2003; Vaughan *et al.*, 2004).

A cornerstone in the analysis of multigrain data is a polycrystalline indexing program. In this article we present a new algorithm for indexing and an associated program, *GrainSpotter*. It is intended for use with a conventional diffraction setup employing a two-dimensional detector with a pixel size of the same order as, or larger than, the grain size. In this case, the diffraction signal comprises distinct diffraction spots positioned in the vicinity of the Debye–Scherrer rings typical of powder diffraction.

The program is one of several (Wright, 2006; Moscicki *et al.*, 2009; Benier *et al.*, 2011; Sharma *et al.*, 2012*b*) that have been introduced within the past few years to replace the original multi-indexing program *GRAINDEX* (Lauridsen *et al.*, 2001). The underlying algorithm differs in several aspects, such as the use of back projection *versus* forward projection, the use of Friedel pairs and the reliance on an initial assumption that all grains are positioned at the origin.

*GrainSpotter* has been conceived with the aim of being able to index typical 3DXRD data with ∼1000 grains sufficiently quickly that online analysis during synchrotron experiments becomes possible. Furthermore, the focus is on robustness with respect to incomplete data, for example, owing to small grains, grains rotating in and out of the beam *etc*. The basic approach of *GrainSpotter* is to identify grains by finding vertices in orientation space. As demonstrated below, this can be done using Boolean algebra and with a running time that goes as *O*(*N*), where *N* is the number of grains. Once grains have been identified, in a second step the position and orientation of each grain is optimized, and at the same time outliers in the associated set of reflections are removed. Again a fast algorithm is chosen for the fitting. For ultimate accuracy in terms of determining the position, orientation and in addition the strain tensor of each grain, the proposed procedure is to feed the output of *GrainSpotter* into the (slower) optimization program *FitAllB* (Oddershede *et al.*, 2010).

Below we first introduce a new hybrid representation of orientation space, which is required in order to linearize the space. Following a detailed description of the algorithm, simulations are used to verify the program and to test its limitations, in particular in terms of the number of simultaneously illuminated grains. As examples of real experiments where *GrainSpotter* has already been used, we mention multigrain studies of metals (West *et al.*, 2009; Oddershede *et al.*, 2010, 2011, 2012; Poulsen *et al.*, 2011; Beaudoin *et al.*, 2012), macromolecules (Paithankar *et al.*, 2011), minerals (Sørensen, Hakim *et al.*, 2012) and high-pressure science (Zhanga *et al.*, 2013).

The article also contains a section on pseudo-twins. Unexpectedly, the multigrain work has revealed that diffraction data are subject to an additional symmetry, which to our knowledge has not been considered in conventional crystallography. In analysing multigrain diffraction data of high-symmetry structures, we find it critical to discriminate against erroneous grains that may emerge because of this symmetry. *GrainSpotter* is unique in including such a discrimination. Below we define the pseudo-twin symmetry, explore its properties for various group symmetries and describe how the pseudo-twin analysis is incorporated into *GrainSpotter*.

The *GrainSpotter* source code is publicly available at http://sourceforge.net/apps/trac/fable/browser/GrainSpotter (Schmidt, 2007).

### 2. Geometry

#### 2.1. Experimental setup

The setup is the conventional setup for single-crystal diffraction using a monochromatic beam (see Fig. 1). We shall assume that the beam at all times fully illuminates the (polycrystalline) sample and that the diffracted beam is transmitted through the sample and acquired on a two-dimensional far-field detector.

During data acquisition a series of diffraction images covering an ω interval in steps of are recorded.

#### 2.2. Orientation space

Central to the algorithm presented here is the mathematical representation of orientation space. Conventionally, the choice is between Euler angles, Rodrigues vectors or quaternions (Kocks *et al.*, 2000). We argue that the superior solution is a hybrid of the two latter representations.

In Rodrigues space an orientation is represented as a three-dimensional vector, the Rodrigues vector

is the rotation axis and φ is the rotation angle around the rotation axis. Here orientation means the rotation that allows the transformation of the orthonormal basis representation (Cartesian coordinate system) of the that coincides with the sample reference system into the orthonormal basis representation of the of the grain. Each grain corresponds to a single orientation and therefore a single point in Rodrigues space. Let be a vector in the reference and the corresponding vector in the of the grain. The set of points in the Rodrigues space (orientations) that rotates onto is called the geodesic.

A crucial property of this space is that the geodesics are straight lines (Moraviec & Field, 1996). This line can be parameterized by a line (Moraviec & Field, 1996)

where the origin, , and the slope, , are given by

Neglecting the complication of crystal symmetry for the moment, it appears that the task of indexing corresponds to identifying vertices in Rodrigues space. More specifically, for each grain it is necessary to determine a common intersection point (orientation) of multiple geodesics.

The invariant volume in the Rodrigues space can be written as (Moraviec & Field, 1996)

*i.e.* being radially symmetric in φ. Hence, for small values of φ,

to first order in φ. Consequently, near the origin the Rodrigues space is approximately Euclidean. It is well known that powerful algorithms exist for finding vertices in three-dimensional Euclidian space. Unfortunately, the Rodrigues space rapidly become non-Euclidian with increasing distance to the origin, and for low-symmetry space groups the space is infinite. This implies that the Rodrigues formulation is not generally useful.

The *GrainSpotter* approach is to use quaternion space (which is finite) for general sampling in orientation space, but restrict the key elements in the algorithm to local searches around a certain fixed-point Rodrigues vector. By a simple rotation, the fixed point can be moved to the origin and the local search is then restricted to the Euclidean part of the orientation space, hereafter named the local Rodrigues space. This way the global orientation space, *i.e.* all space groups, can be accommodated by subdividing the global orientation space into a series of local Rodrigues spaces. This is the core principle of *GrainSpotter*. The local Rodrigues space may contain orientations of several grains in the sample. The algorithm for obtaining a fast identification of these vertices is outlined in the following.

### 3. Algorithm

*GrainSpotter* operates on a set of diffraction spots, (see Fig. 1). Initially, the set of reciprocal **G** vectors are calculated, assuming that all grains are located at the origin of the sample reference system, *i.e.*

[see equation (32) in Appendix *A*]. The output is a list of grains and associated properties: the orientations {*U*} (see Appendix *A*) and (optionally) centre-of-mass positions . After of the orientation and the position, has propagated into (see Fig. 1). Furthermore, for each grain, descriptors of the quality of indexing are provided, such as the completeness: the ratio between the observed number of reciprocal **G** vectors associated with a grain and the number expected. In the current version *GrainSpotter* assumes all grains to belong to the same phase, and furthermore the must be known *a priori*.

As stated previously *GrainSpotter* subdivides the global orientation space into a series of local Rodrigues spaces. Within each subdivision vertices are located by using the initial set of the reciprocal **G** vectors . Only the geodesics from a small fraction of the reciprocal **G** vectors pass through the sub-volume. The subset of **G** vectors can be identified prior to the determination of the geodesics: see the description of fast vertex detection below. Afterwards, one geodesic is calculated for each of the selected **G** vectors. The user-specified size of the local Rodrigues space is given by . In order to stay in the Euclidian part of the Rodrigues space should be less than 15°. Consequently, when splitting up the local Rodrigues space into voxels, the density of orientations within each voxel is approximately constant. This property facilitates robust identification of vertices as the size of the voxels must be large enough to capture the deviation from the initial set to the real set of reciprocal **G** vectors . Outside the Euclidian part of the sub-volume the density of orientations in the voxels drops off. Hence, owing to the aforementioned deviation in the reciprocal **G** vectors, the geodesics will no longer cross within a voxel, making identification of vertices less robust. The user-defined parameters including the size of the voxels are discussed in §5.

Following the identification of vertices in a local Rodrigues space the orientations and (optionally) grain centre-of-mass positions are fitted using the reciprocal **G** vectors belonging to each vertex (see details in §§3.3 and 3.4).

A central part of *GrainSpotter* is fast vertex identification. For a given local Rodrigues space the following two steps are carried out:

(1) Identification of the subset of reciprocal **G** vectors in from which the corresponding geodesics pass through the local Rodrigues space. This is done without searching through the full list of reciprocal **G** vectors. The potential reciprocal **G** vectors must be in the neighbourhood of the predicted directions derived from the centre point in the local Rodrigues space, *U*_{centre}. During startup of *GrainSpotter*, a look-up table is constructed for , ensuring that for a given predicted direction, , all potential reciprocal **G** vectors are identified.

(2) Finding the vertices. These are obtained by mapping all geodesics into the local Rodrigues space, but for each voxel keeping track of the reciprocal **G** vectors that have already passed through this voxel. This way it is possible to group the reciprocal **G** vectors that belong to the same vertex without searching through the local Rodrigues space itself. This is a two-step selection procedure (see details in §§3.1 and 3.2). In the first selection step a grouping of reciprocal **G** vectors potentially belonging to the same vertex is made. The second selection step identifies the vertices and verifies the reciprocal **G** vectors belonging to different vertices. The complexity of this method scales with the number of reciprocal **G** vectors.

#### 3.1. First selection

The reciprocal **G** vectors with geodesics passing through the local Rodrigues space are labelled 1 to *N*_{g}. Next a four-dimensional data structure is built, with the first three dimensions being identical to the voxels in the local Rodrigues space. The fourth dimension comprises a list of the geodesics (lines) passing through each voxel. To save memory and increase speed the list is implemented as an array of unsigned integers (16 bits), as illustrated in Fig. 2. For each voxel hit by the *i*th geodesic a logical OR operation with a mask is carried out. This keeps track of the geodesics visiting this particular voxel.

In addition, the set of geodesics that the *i*th geodesic has crossed are also stored in a separate two-dimensional structure by making a logical OR operation with all the voxels that the geodesic passed through. This way, the *i*th **G** vector keeps track of the possible intersections of the *i*th geodesic with the previous *i*-1 geodesics.

#### 3.2. Second selection

The two-dimensional structure lists the possible intersections of geodesics. However, not all crossings of geodesics are bound (see Fig. 3). Consequently, a second selection is done. For each table entry the geodesics are mapped into the modified four-dimensional space, keeping track of the voxel with the maximum hits, giving a candidate orientation for further investigation. Only the last *N*_{g}-*N*_{min} table entries are processed, where *N*_{min} is a lower limit of measurements for a grain specified by the user. Note, for both the first and second selection, the vertices are obtained without searching through the whole local Rodrigues space, implying that all candidate grains have been identified with an *O*(*N*) complexity (2*N*_{g}-*N*_{min} geodesics are mapped in the combined selection).

#### 3.3. Fitting position and orientation

The orientation space (local Rodrigues space) and ^{1}

The position of the grain in the sample reference system is denoted by (see Fig. 1). Each ray is parametrized by the position of the diffraction spot in the sample reference system, , and the direction of the ray in the sample reference system, . More specifically, is obtained by minimizing the following expression:

where . Hence,

where

The case for orientations is completely equivalent. Equation (7) can be reused by replacing with the origin of the geodesics, , and with the direction of the geodesic, [see equation (3)].

#### 3.4. Fitting procedure and outlier removal

The set of collected **G** vectors may contain falsely assigned vectors, typically originating from other grains or caused by noisy data. The following outlier rejection procedure aims at removing these wrongly assigned measurements:

Following the minimization of equation (7), the quality or the agreement of the individual measurement *i* with the overall fit is evaluated by the estimator *f*_{i},

where is the contribution to from the *i*th measurement, *N* is the number of measurements in the fit and is a predefined maximal angle deviation, which is related to the measurement uncertainty and is specified by the user. Generally, the lower the value of *f*_{i} the better the quality or agreement of the overall fit for the *i*th measurement. Note that *f*_{i} consists of two factors. The factor punishes measurements with deviations larger than an absolute value specified by . The second factor, , punishes measurements that are larger than the mean contribution, *i.e.* a relative limit. Both factors taken together result in a good quality for a given measurement if the deviation is smaller than or if the deviation is smaller than the mean deviation (and potentially larger than ). Consequently, by keeping measurements with the outliers with deviations larger than expected and larger than the mean deviation for the whole fit are removed.

Removing outliers and fitting the orientation is an iterative procedure. For a given set of measurements an orientation estimate is obtained through equations (8) and (9). Afterwards measurements with

are removed. A new fit with the remaining measurement is done. The procedure is repeated until a stable solution is found or the number of remaining measurements goes below a user-specified minimum.

If the position is estimated as well, the procedure alternates between the orientation fit and the position fit. Following the position fit the directions of the **G** vectors are updated according to the new origin. No selection is made. Following the orientation fit the outlier filtering is done according to the procedure described above.

### 4. analysis

It is well known that crystal symmetry implies that orientations can be equivalent: that is they are associated with exactly the same **G** vectors. When analysing multigrain data, partial symmetries do also occur: in this case the orientations only share some **G** vectors [see *e.g.* work by Grimmer *et al.* (1974) on coincidence-site lattices for the cubic system]. As an example, the partial symmetries appearing for the first five *hkl* families for a face-centred cubic material are shown in Fig. 4. For a given orientation, 274 other orientations exist with a partial overlap of reflections – all within the fundamental zone (where there are no symmetry equivalents). We shall call these pseudo-twins. Out of a total of 112 **G** vectors, pseudo-twins with 34, 24, 16, ten, eight, six, four and two reflections occur. The ones with 34 reflections correspond to regular first-order twins.

Experience shows that for high-symmetry structures it is crucial to include an analysis of pseudo-twins in the polycrystalline indexing algorithm. For the above example, one may argue that a completeness threshold of 1/3 or higher would remove these. However, in real data **G** vectors may be wrongly assigned to grains owing to either closely positioned measurements on the same diffraction rings or closely positioned diffraction rings. In both cases, the completeness of the pseudo-twins may end up systematically higher. To overcome this problem, it is relevant for each orientation found to investigate the pseudo-twin orientation and see if these are associated with a higher completeness or better fits. Such an analysis is also helpful in cases where real occurs and in general for noisy data. In the following, a method to derive pseudo-twins for all space groups is presented.

To derive an algorithm for finding the pseudo-twin orientation for a given trial orientation, we start by considering a pair of theoretical scattering vectors in **G** vectors, and , *i.e.* . Following the convention of Busing & Levy (1967), the crystallographic orientation *U*, fulfilling and , can be expressed as

given by a product of two orthogonal matrices. The first column vector in is a unit vector along . The third column is a unit vector perpendicular to the plane spanned by and . The second column is a unit vector perpendicular to the first and third columns, *i.e.* in the plane spanned by and . Likewise with respect to .

Now consider a different pair of theoretical scattering vectors, , where , and . The orientation matrix that brings and is then given by

If *U* and *U*_{2} are equivalent orientations, then

for some generator *E*_{i} of the in question, where is the correspondence between the Cartesian *hkl* lattice and (see Appendix *A*). Rearranging equation (14),

we find that the measured **G** vectors, , have cancelled out. Consequently, equation (15) provides a general criterion for recovering the same orientation when switching pairs of theoretical reflections. In other words, the orientation that brings one pair of theoretical reflections onto another pair ( and ) must be a symmetry-equivalent operation. More specifically,

For a given *W*_{j}, can be calculated using equation (16). Pseudo-twin orientations are characterized by matching only a fraction of the true measurements. For each candidate orientation, *U*_{c}, found in the indexing procedure the true orientation is given by the orientation in the list

that maximizes the completeness estimator, *i.e.* the fraction of measurements found with respect to the number of measurements expected.

### 5. Simulations

To verify the indexing procedure, Monte Carlo simulations were performed. The sample was assumed to be a 500 × 500 × 500 µm Al polycrystal comprising *N* grains of random orientation. At 50 keV X-ray energy, exposures were made on a perfectly aligned distortion-free two-dimensional detector with 50 µm pixels, placed at a distance of 20 cm from the sample. The simulated data covered a rotation range of 180° in steps of 0.25° and included only the five *hkl* families with the highest *d* spacings.

The associated diffraction peaks are assumed to be ideal intensity spikes in the detector images; in other words the issue of spot broadening is neglected. On the other hand, experimental errors in the centre-of-mass (CMS) positions of the spots were included by adding Gaussian noise to the three angles defining the **G** vector: , and ω (see Fig. 1). The spreads were = 0.025°, = 0.05° and = 0.125°. The resulting distribution of the internal angular deviation between the **G** vector and the predicted direction resembles the observed distribution when indexing real data.^{2}

Simulations with up to 3000 grains were conducted, where in all cases all grains were retrieved and no erroneous grains were found. *GrainSpotter* was run with the following user-defined parameters: = 0.05°, = 0.1°, = 0.2° and = 3. These quantities have multiple functionalities. At startup each **G** vector will be associated with the set of (*h**k**l*) families for which . As stated previously, the outlier removal procedure is also based on the uncertainties with in equation (10). The size of the voxels in the local Rodrigues space is given by a conservative estimate: . The user-specified size of the local Rodrigues space was , yielding voxels along each dimension for °. Equivalently, ° corresponds to . A total of 100 000 random trials were selected for the search. Shown in Fig. 5 is the computing time for grains using one thread (*i.e.* a single core) on a 2.7 GHz Intel i7 processor and the corresponding purity, defined as the grain average of the ratio between the number of correct reflections associated by *GrainSpotter* and the number of simulated spots for the grain. It is evident that the running time is approximately linear in the number of grains (∼ 10^{-4}*N*^{2}+10^{-1}*N*) for °, and the result of less than 4 min for extracting 1000 grains complies well with the aspiration to perform indexing online during synchrotron experiments. The resulting purity of above 99% even at *N* = 1000 is also encouraging. When the size of the local Rodrigues space is enlarged, an enhancement in performance speed is seen for the case ° in Fig. 5. This is due to the higher rate of grains indexed per trial. However, in terms of complexity the *N*^{2} term has become more pronounced (∼10^{-4}*N*^{2}+10^{-2}*N*).

In Fig. 6 the corresponding histograms for the error in CMS position and orientation components for the case of *N* = 3000 are shown. The error on the position in *x* and *y* is 15 µm and that for *z* is 9 µm. Whereas errors on *x* and *y* are similar, the error on *z* is smaller because the *z* axis is parallel to the rotation axis ω. To index all grains *GrainSpotter* was run several times, saving the unassigned **G** vectors for the following indexing step. Starting with (2°/2) at each step, looser cuts were applied compared to the previous step. The whole process took 50 min on one core. The purity was 97.4%.

### 6. Discussion

Evidently the simulations represent an idealized situation. In actual experiments phenomena such as grain mosaicity, stress and sample texture will affect performance. A particular concern is the grain size distribution, which in many cases implies that the number of grains visible decreases strongly with decreasing *d* spacing. Discussions of these effects and suggestions for how to handle them can be found elsewhere (*e.g.* Schmidt *et al.*, 2003; Poulsen, 2004). For a systematic discussion on error propagation in relation to multigrain indexing the reader is referred to the work by Benier *et al.* (2011) and Sharma *et al.* (2012*b*).

Recently several other approaches have been proposed for polycrystalline indexing. We mention the following:

(1) The ImageD11 indexing algorithm is based on sorting of reflections in a combinatorial approach (Wright, 2006): All pairs of **G** vectors are created and the internal angle is compared with a set of theoretical angles. If a mutually consistent subset is found containing a minimum number of pairs it is stored as a grain. This is a simple and effective algorithm and is believed to go as *O*(*N*^{2}), with *N* being the number of reflections.

(2) Ludwig *et al.* (2009) suggested an approach based on Friedel pairs, through the use of a near-field detector and rotation of the sample by 360°. This is an effective solution for extended specimens and has been used for a number of grain mapping experiments. As an example, 1008 grains were indexed simultaneously in an experimental data set on β-Ti. In terms of speed, the algorithm again is believed to go as *O*(*N*^{2}).

(3) Moscicki *et al.* (2009) developed an algorithm based on Friedel pairs and far-field data, which was verified on nine grains.

(4) Benier *et al.* (2011) operated on far-field data and proposed a back-projecting algorithm with some similarity to *GrainSpotter*. The focus is here in particular on strain analysis. In short, for selected diffraction spots, a search for candidate grains is performed along the associated geodesic (also known as a fibre). The software was successfully demonstrated on an aggregate of 819 grains.

(5) Sharma *et al.* (2012*b*), operating also on far-field data, put the emphasis on large data sets and introduced an indexing formalism that simultaneously exploits the constraints in both direct and orientation space. They demonstrated the software on a simulated data set with 3000 grains.

Without round-robin tests it is not possible to conclude on relative performance, but it appears that none of the algorithms can be labelled as universally ideal, and they also tend to be motivated, at least in part, by different performance criteria. Nevertheless, *GrainSpotter* is to my knowledge the first indexing routine to be used for online data analysis.

The *GrainSpotter* algorithm can be generalized in several ways:

(i) *Grainspotter* works on segmented data, *i.e.* data where the diffraction spots have been harvested in the diffraction images. To ensure that the total throughput is high, the focus so far has been based on segmentation *via* thresholding and the use of connected components (pixel connectivity search, where detector pixels are grouped into spots) type algorithms. However, *Grainspotter* is directly compatible with any segmentation scheme, such as watersheding, relevant in cases where spot overlap is a concern (Kenesei, 2010; Sharma *et al.*, 2012*a*).

(ii) It is possible to offset the centre of origin in the code. By repeating *Grainspotter* with several origins and picking the best grains from the set of resulting outputs, one can extend the use of *GrainSpotter* in the direction of large *N* and extended samples.

(iii) *GrainSpotter* is well adapted to perform indexing also in cases of unknown space groups, of interest in particular in geoscience and chemistry. Work on this topic will be reported elsewhere.

(iv) *GrainSpotter* is easy to parallelize, as the computation of candidate grains for local Rodrigues spaces can be performed independently.

A *e.g.* when the sample is partly illuminated by the beam (grains moving in and out of the beam), or if the active area of the detector is not taken fully into account (partly illuminated diffraction rings, dead areas *etc.*). In these cases the completeness estimator may be lower than expected for the best However, by carefully examining the set of (*h**k**l*)s matched against data one can determine if the orientation is ambiguous or true, as certain combinations of (*h**k**l*)s uniquely determine the orientation. For complete data sets the classical way of requiring a high value of the completeness estimator, as an alternative to the pseudo-twin analysis, is also available as a user-defined option in *GrainSpotter*.

### APPENDIX A

### Forward projection

In the following we derive equations for determining the directions of the diffraction vector in the sample reference system given a grain with orientation *U* and a lattice plane (*h*,*k*,*l*). Generally, each **G** vector gives rise to two directions in the sample reference system, which will be shown in the following. The emphasis is on a formulation that leads to efficient programming. In addition, previous work on establishing the geometry of the forward projection (Poulsen, 2004) is generalized.

Poulsen (2004) gives the diffraction equation as

Here is the scattering vector () in the laboratory system of reflection *i*, *d*_{i} is the spacing between the planes in the atomic lattice for the *i*th reflection, is a right-hand rotation, , round the *z* axis for the *i*th reflection,

and is the correspondence between the Cartesian *hkl* lattice,

and

where and are the lattice parameters in direct and reciprocal space.

In the following we generalize equation (18) by introducing the generalized rotation matrix ,

where and are known right-handed rotations around the *x* and *y* axis, thus accommodating all possible directions of the rotation axis. Furthermore, the length of the scattering vector is changed to , where λ is the wavelength of the monochromatic beam. The scattering vector in the sample system, the reciprocal vector , is defined by

Expressing as a function of and η we have

Since is independent of ,

where

The solutions are given by

The solution can easily be verified by substituting and and solving for . Consequently, we can determine the direction of the diffraction vector in real space, ,

where is the first column vector of . Note that . For each reciprocal vector there exist (up to) two

vectors, . Also note that can be expressed in terms of the reciprocal vector, , without reference to , and .Note that the formalism presented here also facilitates an indexing procedure when recording data using multiple rotation axes.

### Acknowledgements

The author wishes to thank Henning Friis Poulsen for discussions during the preparation of the manuscript.

### References

Beaudoin, A. J., Obstalecki, M., Storer, R., Tayon, W., Mach, J., Kenesei, P. & Lienert, U. (2012). *Model. Simul. Mater. Sci. Eng.* **20**, 024006. Web of Science CrossRef

Benier, J. V., Barton, N. R., Lienert, U. & Miller, M. P. (2011). *J. Strain Anal. Eng. Des.* **46**, 527–547.

Busing, W. R. & Levy, H. A. (1967). *Acta Cryst.* **22**, 457–464. CrossRef IUCr Journals Web of Science

Coles, S. (2001). *An Introduction to Statistical Modeling of Extreme Values.* London: Springer-Verlag.

Grimmer, H., Bollmann, W. & Warrington, D. H. (1974). *Acta Cryst.* A**30**, 197–207. CrossRef IUCr Journals Web of Science

Grosse-Kunstleve, R. W. (1994). *SgInfo – Space Group Info*, http://cci.lbl.gov/sginfo/ .

Jakobsen, B., Poulsen, H. F., Lienert, U., Almer, J., Shastri, S. D., Sorensen, H. O., Gundlach, C. & Pantleon, W. (2006). *Science*, **312**, 889–892. Web of Science CrossRef PubMed CAS

Juul Jensen, D., Lauridsen, E. M., Margulies, L., Poulsen, H. F., Schmidt, S., Sorensen, H. O. & Vaughen, G. B. M. (2006). *Mater. Today*, **9**, 18–25.

Kenesei, P. (2010). *DIGIgrain*, http://sourceforge.net/apps/trac/digigrain/ .

Kocks, U. F., Tome, C. N., Wenk, H.-R. & Mecking, H. (2000). *Texture and Anisotropy: Preferred Orientations in Polycrystals and Their Effect on Materials Properties.* Cambridge University Press.

Larson, B. C., Yang, W., Ice, G. E., Budai, J. D. & Tischler, J. Z. (2002). *Nature*, **415**, 887–890. Web of Science CrossRef PubMed CAS

Lauridsen, E. M., Jensen, D. J., Poulsen, H. F. & Lienert, U. (2000). *Scr. Mater.* **43**, 561–566. Web of Science CrossRef CAS

Lauridsen, E. M., Schmidt, S., Suter, R. M. & Poulsen, H. F. (2001). *J. Appl. Cryst.* **34**, 744–750. Web of Science CrossRef CAS IUCr Journals

Ludwig, W., Herbig, M., Buffire, J. Y., Ludwig, W., Reischig, P., King, A., Johnson, G., King, A., Johnson, G., Marrow, T. J. & Lauridsen, E. M. (2009). *Rev. Sci. Instrum.* **80**, 033905. Web of Science CrossRef PubMed

Ludwig, W., Schmidt, S., Lauridsen, E. M. & Poulsen, H. F. (2008). *J. Appl. Cryst.* **41**, 302–309. Web of Science CrossRef CAS IUCr Journals

Margulies, L., Winther, G. & Poulsen, H. F. (2001). *Science*, **291**, 2392–2394. Web of Science CrossRef PubMed CAS

Moraviec, A. & Field, D. P. (1996). *Philos. Mag. A*, **73**, 1113–1130.

Moscicki, M., Kenesei, P., Wright, J., Pinto, H., Lippmann, T., Borbely, A. & Pyzalla, A. R. (2009). *Mater. Sci. Eng. A*, **524**, 64–68. Web of Science CrossRef

Oddershede, J., Camin, S., Schmidt, S., Mikkelsen, L. P., Sørensen, H. O., Lienert, U., Poulsen, H. F. & Reimers, W. (2012). *Acta Mater.* **60**, 3570–3580. Web of Science CrossRef CAS

Oddershede, J., Schmidt, S., Poulsen, H. F., Margulies, M., Wight, J., Moscickic, M., Reimers, W. & Winther, G. (2011). *Mater. Charact.* **62**, 651–660. Web of Science CrossRef CAS

Oddershede, J., Schmidt, S., Poulsen, H. F., Sørensen, H. O., Wright, J. & Reimers, W. (2010). *J. Appl. Cryst.* **43**, 539–549. Web of Science CrossRef CAS IUCr Journals

Offerman, S. E., van Dijk, N. H., Sietsma, J., Grigull, S., Lauridsen, E. M., Margulies, L., Poulsen, H. F., Rekveldt, M. T. & van der Zwaag, S. (2002). *Science*, **298**, 1003–1005. Web of Science CrossRef PubMed CAS

Paithankar, K. S., Sørensen, H. O., Wright, J. P., Schmidt, S., Poulsen, H. F. & Garman, E. F. (2011). *Acta Cryst.* D**67**, 608–618. Web of Science CrossRef CAS IUCr Journals

Poulsen, H. F. (2004). *Three-Dimensional X-ray Diffraction Microscopy. Mapping Polycrystals and Their Dynamics*, Tracts in Modern Physics, Vol. 205. Berlin: Springer-Verlag.

Poulsen, H. F., Nielsen, S. F., Lauridsen, E. M., Schmidt, S., Suter, R. M., Lienert, U., Margulies, L., Lorentzen, T. & Juul Jensen, D. (2001). *J. Appl. Cryst.* **34**, 751–756. Web of Science CrossRef CAS IUCr Journals

Poulsen, S. O., Lauridsen, E. M., Lyckegaard, A., Oddershede, J., Gundlach, C., Curfs, C. & Juul Jensen, D. (2011). *Scr. Mater.* **64**, 1003–1006. Web of Science CrossRef CAS

Schmidt, S. (2007). *GrainSpotter*, http://sourceforge.net/apps/trac/fable/browser/GrainSpotter .

Schmidt, S., Nielsen, S. F., Gundlach, C., Margulies, L., Huang, X. & Jensen, D. J. (2004). *Science*, **305**, 229–232. Web of Science CrossRef PubMed CAS

Schmidt, S., Olsen, U. L., Poulsen, H. F., Sørensen, H. O., Lauridsen, E. M., Margulies, L., Maurice, C. & Juul Jensen, D. (2008). *Scr. Mater.* **59**, 491–494. Web of Science CrossRef CAS

Schmidt, S., Poulsen, H. F. & Vaughan, G. B. M. (2003). *J. Appl. Cryst.* **36**, 326–332. Web of Science CrossRef CAS IUCr Journals

Sharma, H., Huizenga, R. M. & Offerman, S. E. (2012*a*). *J. Appl. Cryst.* **45**, 693–704. Web of Science CrossRef CAS IUCr Journals

Sharma, H., Huizenga, R. M. & Offerman, S. E. (2012*b*). *J. Appl. Cryst.* **45**, 705–718. Web of Science CrossRef CAS IUCr Journals

Sørensen, H. O., Hakim, S. S., Pedersen, S., Christiansen, B. C., Balogh, Z., Hem, C. P., Pasarin, S., Schmidt, S., Olsen, U. L., Oddershede, J. C. F., Feidenhansĺ, R. & Stipp, S. L. S. (2012). *Can. Mineral.* **50**, 501–509.

Sørensen, H. O., Schmidt, S., Wright, J. P., Vaughan, G. B. M., Techert, S., Garman, E. F., Oddershede, J., Davaasambuu, J., Paithankar, K. S., Gundlach, C. & Poulsen, H. F. (2012). *Z. Kristallogr.* **227**, 63–78.

Vaughan, G. B. M., Schmidt, S. & Poulsen, H. F. (2004). *Z. Kristallogr.* **219**, 813–825. Web of Science CSD CrossRef CAS

West, S. S., Schmidt, S., Sørensen, H. O., Winther, G., Poulsen, H. F., Margulies, L., Gundlach, C. & Juul Jensen, D. (2009). *Scr. Mater.* **61**, 875–878. Web of Science CrossRef CAS

Winther, G., Margulies, L., Schmidt, S. & Poulsen, H. F. (2004). *Acta Mater.* **52**, 2863–2872. Web of Science CrossRef CAS

Wright, J. P. (2006). *ImageD11*, http://sourceforge.net/apps/trac/fable/wiki/imaged11 .

Zhanga, L., Meng, Y., Dera, P., Wenge, Y., Wendy, L. M. & Mao, H.-K. (2013). *Proc. Natl Acad. Sci. USA*, **110**, 6292–6295. Web of Science PubMed

© International Union of Crystallography. Prior permission is not required to reproduce short quotations, tables and figures from this article, provided the original authors and source are cited. For more information, click here.