index#
Index scanning 3DXRD data: orientation populations per voxel, fitted to the data with the forward model.
The steps, in order (python -m anri.index runs them on an ImageD11 dataset):
ring_table()andring_profile(): the rings, and how wide they are in the data.histogram_pixels(): the sparse pixels binned once intoH[ring, eta, omega, row], and a row-summed lit map (lit_table()).choose_grid(),prune()andorientation_mlem(): an orientation grid over the fundamental zone (anri.crystal.orientation_grid()), first filtered by completeness with tolerances from the grid and the data (match_tolerances()), then kept by the likelihood ratio of a global, intensity-aware orientation fit.fit_occupancy(): sparse occupancy of the kept orientations per voxel by MLEM, every voxel fitted jointly.populations(): each voxel’s occupancy grouped into orientation populations with fractions and spreads.
Functions
|
Back-project a sinogram [omega, row] onto voxels at |
|
Back-project a histogram onto each voxel's candidates: |
|
Rows a voxel's beam profile reaches (odd): the voxel's half diagonal, half the flat top and 3 sigma each side. |
|
Voxels per block (a power of 2) so that one block's system entries for q orientations take ~budget_bytes. |
|
Pick each voxel's k best orientations by the first MLEM update from unit occupancy. |
|
Pick each voxel's k best orientations as |
|
Compute the MLEM ratio d / mu, with empty bins taken as censored. |
|
Choose the coarsest grid step whose chance completeness is at most max_chance. |
|
Sum a histogram's rows in groups of g: row k goes to k // g. |
|
Fraction of each orientation's valid predictions with a lit bin within its own tolerance box. |
|
Completeness of many orientations, in chunks. |
|
Poisson deviance of observed bins, plus 2 x (mu - censor) for empty bins the model predicts above |
|
Draw the sample's outline on an image; returns a function that gives the mask of what was drawn. |
|
Each histogram row's dty, per omega bin, less its nominal dty: where the beam really was. |
|
Fit sparse occupancies: candidates per voxel, then MLEM. |
|
Forward-project occupancies: |
|
Bin pixels into |
|
Stream pixels into one or more histograms in a single pass over the data. |
|
Candidates for fine voxels from a coarse fit: what the nearest coarse voxel and its 8 neighbours occupied. |
|
Summed-area table of a lit map, for counting lit bins in any box in constant time. |
|
Lorentz x polarisation factor of every prediction of some orientations (see |
|
Compute the matching tolerances in eta and omega of predictions of grid orientations. |
|
Fit occupancies by MLEM: |
|
Fit one occupancy per orientation to a row-summed histogram by MLEM, and score each orientation. |
|
Otsu's threshold of some values: the cut that best separates them into two classes. |
|
Pad voxel positions to a multiple of vb with voxels far outside the scan (they reach no rows). |
|
Compute (2theta, eta, omega) of pixel centres, seen from the lab origin (no parallax). |
|
Mask [ny, nx] of the pixels inside a polygon given by (x, y) = (column, row) vertices. |
|
Group each voxel's occupied candidate orientations into up to p populations. |
|
Predict (eta, omega) of every reflection of some orientations, with both omega solutions. |
|
Predictions of an orientation list for |
|
Keep the grid orientations whose completeness passes a threshold. |
|
Filter each projection (row of |
|
Reconstruct the whole sample from the indexer's histogram, for a mask (or to check y0). |
|
Measure the rings' offsets and half-widths from a sample of pixels (see |
|
List the reflections of a crystal's first rings, with their structure factors. |
|
Measure each ring's offset and half-width (degrees 2theta) from a 2theta profile. |
|
Entries of the system matrix: (cell index, weight) for voxels and predictions. |
|
Mask of the sample: the convex hull of the largest connected region above a threshold (default Otsu's). |
|
Sum pixel intensities in 2theta bins. |