detectorcal.fit#
- detectorcal.fit.fit_pixel(volume, smoothed, cutoff, i)#
Least squares regression for a single pixel.
- Parameters
- volume: np.ndarray
The detector-response volume.
- smoothed: np.ndarray
The detector-response volume once Gaussian smoothed across xy.
- cutoff: scalar
Minimum value in smoothed image at which to include the value in the regression. This is chosen to elminate values that fall outside of the range of linear response.
- i: int
index of the pixel in flattened corrdinates (i.e., raveled along x-y plane).
- Returns
- pixel_fit: scalar
Linear coefficient for the pixel.
- i: int
index of the pixel in flattened corrdinates (i.e., raveled along x-y plane).
- detectorcal.fit.fit_response(volume, dark=None, save_path=None, sigma=50, mode='nearest', cval=0.0, truncate=4.0, cutoff=300, gpu=False, verbose=False)#
For each pixel in the detector, fit a linear model predicting the true artefact-free detector response to an X-ray beam. For this, a stack of images representing the detector’s response across beam intensities is required. Additionally, a dark current image can be used to correct the dark current for this volume. A Gaussian filter is used to smooth the volume, yielding estimate the true intensity profile of the X-ray beam. The standard deviation of the Gaussian kernel should be chosen to eliminate pixel-wise variations. For each pixel, least-squares regression is then used to determine a coefficient that can be used to map the
- Parameters
- volume: np.ndarray
Array containing the stack of detector responses.
- dark: None or np.ndarray
Default None. Array containing the dark current image or None.
- save_path: None or str
Default None. Path to which the fit coefficients should be saved. If None, the coefficients will not be saved to disk. Please save as a tiff, hdf5, or zarr.
- sigma: scalar
Default 50. Standard deviation of the Gaussian kernel to be used for smoothing
- mode: str
Default ‘nearest’. Determines how the input array is extended at the boarder.
- cval: scalar
Default 0.0. Value with which to pad edges when mode ‘constant’ is used.
- truncate: float
Default 4.0. truncate filter at this many standard deviations.
- gpu: bool
Default determined by whether GPU version is installed (with pip install detectorcal[gpu]). Will gpu acceleration be required (or possible)?
- verbose: bool
Default False. Should messages be printed to the console? Will print a link to dask dashboard - this allows you to watch the computation across the workers.
- cutoff: scalar
Default 300. Minimum value in smoothed image at which to include the value in the regression. This is chosen to elminate values that fall outside of the range of linear response. Value choice depends on data type and range (e.g., 300 for 12 bit image).
- Returns
- fit: np.ndarray
Coefficients for each pixel in the detector
References
- Croton, L.C., Ruben, G., Morgan, K.S., Paganin, D.M. and Kitchen, M.J.,
2019. Ring artifact suppression in X-ray computed tomography using a simple, pixel-wise response correction. Optics express, 27(10), pp.14231-14245.
- detectorcal.fit.gaussian_smooth(volume: dask.array.core.Array, sigma=50, mode='nearest', cval=0.0, truncate=4.0, gpu=False, verbose=True)#
Apply a 2D Gaussian filter to slices of a 3D volume using dask. Facilitates dask-mediated parallelisation and has optional GPU acceleration.
- Parameters
- volume: np.ndarray
Array containing a series of x-y planes that require smoothing stacked along z.
- sigma: scalar
Standard deviation of the Gaussian kernel to be used for smoothing
- mode: str
Determines how the input array is extended at the boarder. For options see: https://docs.scipy.org/doc/scipy/reference/generated/scipy.ndimage.gaussian_filter.html
- cval: scalar
Value with which to pad edges when mode ‘constant’ is used.
- truncate: float
truncate filter at this many standard deviations.
- gpu: bool
Will gpu acceleration be required (or possible)?
- verbose: bool
Should messages be printed to the console?
- Returns
- smoothed: np.ndarray
Smoothed version of the input volume.
- detectorcal.fit.parallel_fit(fit, volume, smoothed, cutoff)#
Apply linear regression to each pixel. This is done using a numba accelerated nested for loop.
- detectorcal.fit.sequential_fit(volume, smoothed, cutoff)#
Apply linear regression to pixels sequentially.
- detectorcal.fit.sequential_gauss(volume: numpy.ndarray, sigma=50, mode='nearest', cval=0.0, truncate=4.0)#
Apply Gaussian smoothing to image planes in sequence.