corrct.processing.pre

Pre-processing routines.

@author: Nicola VIGANÒ, Computational Imaging group, CWI, The Netherlands, and ESRF - The European Synchrotron, Grenoble, France

Module Contents

Functions

pad_sinogram

Pad the sinogram.

apply_flat_field

Apply flat field.

apply_minus_log

Apply -log.

rotate_proj_stack

Rotate the projection stack.

shift_proj_stack

Shift each projection in a stack of projections, by projection dependent shifts.

bin_imgs

Bin a stack of images.

background_from_margin

Compute background of the projection data, from the margins of the projections.

destripe_wlf_vwu

Remove stripes from sinogram, using the Wavelet-Fourier method.

compute_eigen_flats

Compute the eigen flats of a stack of transmission images.

Data

eps

API

corrct.processing.pre.eps

None

corrct.processing.pre.pad_sinogram(sinogram: numpy.typing.NDArray, width: Union[int, collections.abc.Sequence[int], numpy.typing.NDArray], pad_axis: int = -1, mode: str = 'edge', **kwds) numpy.typing.NDArray[source]

Pad the sinogram.

Parameters

sinogram : NDArray The sinogram to pad. width : Union[int, Sequence[int]] The width of the padding. Normally, it should either be an int or a tuple(int, int). pad_axis : int, optional The axis to pad. The default is -1. mode : str, optional The padding type (from numpy.pad). The default is “edge”. **kwds : The numpy.pad arguments.

Returns

NDArray The padded sinogram.

corrct.processing.pre.apply_flat_field(projs_wvu: numpy.typing.NDArray, flats_wvu: numpy.typing.NDArray, darks_wvu: Optional[numpy.typing.NDArray] = None, crop: Union[numpy.typing.NDArray, collections.abc.Sequence[int], None] = None, cap_intensity: Optional[float] = None, dtype: numpy.typing.DTypeLike = np.float32) numpy.typing.NDArray[source]

Apply flat field.

Parameters

projs : NDArray Projections. flats : NDArray Flat fields. darks : Optional[NDArray], optional Dark noise. The default is None. crop : Optional[Sequence[int]], optional Crop region. The default is None. cap_intensity: float | None, optional Cap the intensity to a given value. The default is None. dtype : DTypeLike, optional Data type of the processed data. The default is np.float32.

Returns

NDArray Flat-field corrected and linearized projections.

corrct.processing.pre.apply_minus_log(projs: numpy.typing.NDArray, lower_limit: float = -np.inf) numpy.typing.NDArray[source]

Apply -log.

Parameters

projs : NDArray Projections.

Returns

NDArray Linearized projections.

corrct.processing.pre.rotate_proj_stack(data_vwu: numpy.typing.NDArray, rot_angle_deg: float) numpy.typing.NDArray[source]

Rotate the projection stack.

Parameters

data_vwu : NDArray The projection stack, with dimensions [v, w, u] (vertical, omega / sample rotation, horizontal). rot_angle_deg : float The rotation angle in degrees.

Returns

NDArray The rotated projection stack.

corrct.processing.pre.shift_proj_stack(data_vwu: numpy.typing.NDArray, shifts: numpy.typing.NDArray, use_fft: bool = False) numpy.typing.NDArray[source]

Shift each projection in a stack of projections, by projection dependent shifts.

Parameters

data_vwu : NDArray The projection stack shifts : NDArray The shifts use_fft : bool, optional Whether to use fft shift or not, by default False

Returns

NDArray The shifted stack

corrct.processing.pre.bin_imgs(imgs: numpy.typing.NDArray, binning: Union[int, float], axes: collections.abc.Sequence[int] = (-2, -1), auto_crop: bool = False, verbose: bool = True) numpy.typing.NDArray[source]

Bin a stack of images.

Parameters

imgs : NDArray The stack of images. binning : int | float The binning factor. auto_crop : bool, optional Whether to automatically crop the images to match, by default False verbose : bool, optional Whether to print the image shapes, by default True

Returns

NDArray The binned images

corrct.processing.pre.background_from_margin(data_vwu: numpy.typing.NDArray, margin: Union[int, collections.abc.Sequence[int], numpy.typing.NDArray[numpy.integer]] = 4, poly_order: int = 0, plot: bool = False) numpy.typing.NDArray[source]

Compute background of the projection data, from the margins of the projections.

Parameters

data_vwu : NDArray The projection data in the format [V]WU. margin : int | Sequence[int] | NDArray[np.integer], optional The size of the margin, by default 4 poly_order : int, optional The order of the interpolation polynomial, by default 0

Returns

NDArray The computed background.

Raises

NotImplementedError Different margins per line are not supported, at the moment. ValueError In case the margins ar larger than the image size in U.

corrct.processing.pre.destripe_wlf_vwu(data: numpy.typing.NDArray, sigma: float = 0.005, level: int = 1, wavelet: str = 'bior2.2', angle_axis: int = -2, other_axes: Union[collections.abc.Sequence[int], numpy.typing.NDArray, None] = None) numpy.typing.NDArray[source]

Remove stripes from sinogram, using the Wavelet-Fourier method.

Parameters

data : NDArray The data to de-stripe sigma : float, optional Fourier space filter coefficient, by default 0.005 level : int, optional The wavelet level to use, by default 1 wavelet : str, optional The type of wavelet to use, by default “bior2.2” angle_axis : int, optional The axis of the Fourier transform, by default -2 other_axes : Union[Sequence[int], NDArray, None], optional The axes of the wavelet decomposition, by default None

Returns

NDArray The de-striped data.

corrct.processing.pre.compute_eigen_flats(trans_wvu: numpy.typing.NDArray, flats_wvu: Optional[numpy.typing.NDArray] = None, darks_wvu: Optional[numpy.typing.NDArray] = None, ndim: int = 2, plot: bool = False) tuple[numpy.typing.NDArray, numpy.typing.NDArray][source]

Compute the eigen flats of a stack of transmission images.

Parameters

trans : NDArray The stack of transmission images. flats : NDArray The flats without sample. darks : NDArray The darks. ndim : int, optional The number of dimensions of the images, by default 2 plot : bool, optional Whether to plot the results, by default False

Returns

Tuple[NDArray, NDArray] The decomposition of the transmissions of the sample and the flats.