detectorcal.correct#
- detectorcal.correct.correct_image(ct_volume, coefficients, dark=None, flat=None, save_path=None, use_dask=False, sigma=None, smooth_radius=50, mode='nearest', cval=0.0, truncate=4.0, gpu=False, verbose=False)#
Use coefficient array, dark correction, flat field correction, and (optionally) residual correction to correct rings in CT volume.
- Parameters
- ct_volume: np.ndarray or dask.array.Array
CT image volume to be corrected. Note that if a dask array is inputted, the use_dask flag will be inffered as True. (n, y, x)
- coefficients: ndarray like
Linear coefficients for the detector. (y, x)
- dark: ndarray like
Dark current image to be subtracted. (y, x)
- flat: ndarray like
Mean of the flat-field images aquired with the CT sequence. (y, x)
- sigma: None or scalar
Number of standard deviations
- save_path: None or str
Default None. Optional path to which to save output.Please save as a tiff, hdf5, or zarr. If the output is expected to be larger than RAM, please save as zarr or hdf5.
- use_dask: bool
Defaut False. Should dask be used to support computation? Dask manages memory to allow for computation on larger images. Only set this to True if the default option raises MemoryError.
- smooth_radius: int
Default 50. Determines degree of smoothing of flat-field (i.e., sigma for Gaussian kernel). Please use the same value as that used to fit the coefficients.
- mode: str
Default ‘nearest’. Mode used for padding the edges of the flat-field image duing Gaussian smoothing.
- cval: scalar
Default 0.0. Value with which to pad edges when above mode is equal to ‘constant’.
- truncate: scalar
Default 4.0. Gaussian filter output will be truncated at at this many standard deviations.
- gpu: bool
Default False unless gpu option installed. Can NVIDIA GPUs be used to accelerate this?
- verbose: bool
Default False. Should descriptive print outs be written to console.
- Returns
- corrected: np.array or da.array.Array
Coefficient-corrected CT volume.
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.correct.dask_assisted_correction(ct_volume, coefficients, dark=None, flat=None, sigma=None, smooth_radius=50, mode='nearest', cval=0.0, truncate=4.0, gpu=False, verbose=False)#
Correction using dask. This is executed in detectorcal.correct_image if the use_dask flag is set to True.Please only use this option if the CT volume is too big to correct using numpy only as dask will add overhead and increase compute time.
- Parameters
- ct_volume: ndarray like
CT image volume to be corrected. (n, y, x)
- coefficients: ndarray like
Linear coefficients for the detector. (y, x)
- dark: ndarray like
Dark current image to be subtracted. (y, x)
- flat: ndarray like
Mean of the flat-field images aquired with the CT sequence. (y, x)
- sigma: None or scalar
Number of standard deviations
- smooth_radius: int
Determines degree of smoothing of flat-field (i.e., sigma for Gaussian kernel). Please use the same value as that used to fit the coefficients.
- mode: str
Mode used for padding the edges of the flat-field image duing Gaussian smoothing.
- cval: scalar
Value with which to pad edges when above mode is equal to ‘constant’.
- truncate: scalar
Gaussian filter output will be truncated at at this many standard deviations.
- gpu: bool
Can NVIDIA GPUs be used to accelerate this?
- verbose: bool
Should descriptive print outs be written to console.
- Returns
- corrected: da.core.Array
Coefficient-corrected CT volume.
- detectorcal.correct.dask_free_correction(ct_vol, coeffs, dark, flat, sigma=None, smooth_radius=50, mode='nearest', cval=0.0, truncate=4.0, gpu=False, verbose=False)#
Numpy or cupy based correction. This is executed when detectorcal.correct_image is called with the use_dask set to False (as is default).
- Parameters
- ct_volume: ndarray like
CT image volume to be corrected. (n, y, x)
- coefficients: ndarray like
Linear coefficients for the detector. (y, x)
- dark: ndarray like
Dark current image to be subtracted. (y, x)
- flat: ndarray like
Mean of the flat-field images aquired with the CT sequence. (y, x)
- sigma: None or scalar
Number of standard deviations
- smooth_radius: int
Determines degree of smoothing of flat-field (i.e., sigma for Gaussian kernel). Please use the same value as that used to fit the coefficients.
- mode: str
Mode used for padding the edges of the flat-field image duing Gaussian smoothing.
- cval: scalar
Value with which to pad edges when above mode is equal to ‘constant’.
- truncate: scalar
Gaussian filter output will be truncated at at this many standard deviations.
- gpu: bool
Can NVIDIA GPUs be used to accelerate this?
- verbose: bool
Should descriptive print outs be written to console.
- Returns
- corrected: np.array
Coefficient-corrected CT volume.