pyextal.LucyRichardson¶
Attributes¶
Functions¶
|
Calculates the signal-dependent noise. |
|
Calculates the Detective Quantum Efficiency (DQE). |
|
Calculates the 2D chi-squared value. |
|
Performs a 2D convolution using FFT. |
|
Performs a 2D convolution in real space. |
|
Performs Lucy-Richardson deconvolution. |
Module Contents¶
- pyextal.LucyRichardson.sgnoise(img, m, g, A, delta, varB)¶
Calculates the signal-dependent noise.
- Parameters:
img (np.ndarray) – The input image.
m (float) – Mixing factor.
g (float) – Gain.
A (float) – A parameter related to Fano noise and conversion gain.
delta (float) – Squared percentage error in the gain image.
varB (float) – Variance of the background.
- Returns:
The calculated signal-dependent noise.
- Return type:
np.ndarray
- pyextal.LucyRichardson.DQE(img, varB, delta, A)¶
Calculates the Detective Quantum Efficiency (DQE).
- Parameters:
img (np.ndarray) – The input image.
varB (float) – Variance of the background.
delta (float) – Squared percentage error in the gain image.
A (float) – A parameter related to Fano noise and conversion gain.
- Returns:
The calculated DQE.
- Return type:
np.ndarray
- pyextal.LucyRichardson.chisq2d(exp, convolved, bval, m, g, A, delta, varB)¶
Calculates the 2D chi-squared value.
- Parameters:
exp (np.ndarray) – The experimental data.
convolved (np.ndarray) – The convolved model.
bval (np.ndarray) – The background values.
m (float) – Mixing factor.
g (float) – Gain.
A (float) – A parameter related to Fano noise and conversion gain.
delta (float) – Squared percentage error in the gain image.
varB (float) – Variance of the background.
- Returns:
The calculated chi-squared value.
- Return type:
float
- pyextal.LucyRichardson.convolved2d(img, mtf)¶
Performs a 2D convolution using FFT.
mtfis taken to be already in the Fourier domain and to have the same shape asimg— this is whatpyextal.larbed.LARBEDCalibration.calculate_mtf()produces.- Parameters:
img (np.ndarray) – The input image.
mtf (np.ndarray) – The modulation transfer function, in the Fourier domain.
- Returns:
The convolved image.
- Return type:
np.ndarray
- pyextal.LucyRichardson.convolved2d_real(img, mtf)¶
Performs a 2D convolution in real space.
mtfis taken to be a real-space kernel. This is the convolution used by the standalone PyLARBED package and is kept so that results produced with it can be reproduced exactly; see themodeargument oflucy_Richardson().- Parameters:
img (np.ndarray) – The input image.
mtf (np.ndarray) – The modulation transfer function, as a real-space kernel.
- Returns:
The convolved image, cropped to the shape of
img.- Return type:
np.ndarray
- pyextal.LucyRichardson._CONVOLUTIONS¶
- pyextal.LucyRichardson.lucy_Richardson(dp, mtf, background, niter, varB=0, delta=0, A=1, g=1, m=1, mode='fourier')¶
Performs Lucy-Richardson deconvolution.
- Parameters:
dp (np.ndarray) – The diffraction pattern.
mtf (np.ndarray) – The modulation transfer function. Interpreted as a Fourier-domain array when
mode='fourier'and as a real-space kernel whenmode='real'.background (np.ndarray) – The background of the diffraction pattern.
niter (int) – The number of iterations.
varB (float, optional) – Variance of the background. Defaults to 0.
delta (float, optional) – The squared percentage error in the gain image. Defaults to 0.
A (float, optional) – A parameter related to Fano noise and conversion gain, given by \(1 + F + \frac{1}{mG}\). Defaults to 1.
g (float, optional) – The gain. Defaults to 1.
m (float, optional) – The mixing factor. Defaults to 1.
mode (str, optional) –
'fourier'to convolve via FFT,'real'to convolve in real space. Defaults to'fourier'.
- Returns:
The deconvolved image.
- Return type:
np.ndarray
- Raises:
ValueError – If
modeis not'fourier'or'real'.