ce_criterion#

cbclib.bin.ce_criterion(ij: numpy.ndarray, p: numpy.ndarray, fidxs: numpy.ndarray, shape: Tuple[int, int], lines: Sequence[numpy.ndarray], dilation: float = 0.0, epsilon: float = 1e-12, profile: str = 'gauss', num_threads: int = 1)[source]#

Calculate the cross-entropy criterion between an experimental pattern p and simulated diffraction streaks lines.

Parameters
  • ij (numpy.ndarray) – Detector coordinates, where the measured pattern p is above zero.

  • p (numpy.ndarray) – Measured normalised intensities.

  • fidxs (numpy.ndarray) – Frame indices.

  • shape (Tuple[int, int]) – Shape of the detector pixel grid.

  • lines (Sequence[numpy.ndarray]) – Simulated diffraction streaks.

  • dilation (float) – Dilation radius in pixels used to rasterise simulated diffraction streaks lines.

  • epsilon (float) – Epsilon value used to calculated logarithm of simulated standart profiles.

Notes

The cross-entropy between the measured patterns \(i_n(\mathbf{x}_i)\) and the simulated streaks is given by:

\[\mathcal{L} = -\sum_{ni} i_n(\mathbf{x}_i) \log(\max(f^2_{hkl}, \epsilon)),\]

where \(f^2_{hkl}\) is a set of standard profile patterns calculated with the help of Bresenham’s algorithm.

Returns

Cross-entropy value.

Return type

float